Linux下搭建即时通讯聊天服务Tigase 实战详解

闲话不说,先总结下我在部署的过程中遇到的问题以及官方打包的程序中存在的问题:

官方文档存在的问题:

1、官方安装文档没有说明要在部署的服务器上安装mysql或者其他你要使用的数据库的环境,而是简单的说要安装相应的驱动

2、官方文档中提供的版本(tigase-server-7.0.1)中其mysql驱动jar包有不兼容的问题,进而导致tigase服务器安装不成功。

我在安装过程中遇到的问题:

1、安装mysql相关环境,我在这默认装了:yum install mysql 
2、修改tigase/etc/init.properties中 —virt-host = ip 
3、增加启动时的内存设置 防止内存溢出!!

一、准备

linux版本

<pre name="code" class="csharp">[root@iZ235okehetZ tigase]# uname -a 
Linux iZ235okehetZ 2.6.32-431.23.3.el6.x86_64 #1 SMP Thu Jul 31 17:20:51 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux


内核

<pre name="code" class="csharp">[root@iZ235okehetZ tigase]# cat /proc/version 
Linux version 2.6.32-431.23.3.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Thu Jul 31 17:20:51 UTC 2014




java jdk 

[root@iZ235okehetZ tigase]# java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)



jdk的安装路径为:/usr/java/jdk1.7.0_71  安装tigase的时候需要设置jdk的路径,jre不能满足tigase的运行需要。

tigase server 版本

tigase-server-7.0.1

下载地址:https://projects.tigase.org/projects/tigase-server/files
在这里我用的是jar安装形式。tigase-server-7.0.1-b3809.jar

准备好你要将tigase安装到的目录,我这里是:/mnt/xmpp_service/service 在安装的过程中需要设置。

mysql数据库

版本:5.5.18.1 并准备一个有对此数据路有完全管理权限的账号和密码我这里是root  和rootpwd

以上,准备工作完毕。

二、Tigase Server 安装

1、run the jar file

[root@iZ235okehetZ tigase]# ll
total 60776
-rwxrwxrwx 1 root root 62168336 Mar 24 17:11 tigase-server-7.0.1-b3809.jar
[root@iZ235okehetZ tigase]# <strong><span style="color:#ff0000;">java -jar tigase-server-7.0.1-b3809.jar -console


2、Initial Screen

On this screen you will find server version info which will be useful if you would to suggest something to Tigase developers.
输入命令后会显示一些tigase相关信息,直接 preess 1 and ENTER 就ok

Welcome to the installation of Tigase XMPP (Jabber) Server 7.0.1-b3809!
 - Artur Hefczyc <[email protected]>
 - Bartosz Ma?kowski <[email protected]>
 - Wojciech Kapcia <[email protected]>
 - Andrzej W贸jcik <[email protected]>
 - Wojciech Czubaszek <[email protected]>
 - Eric Dziewa <[email protected]>
 - Jacek Predki <[email protected]>
 - Piotr Kontek
 - Alexander Gnauck
 - Tomasz Sterna
 - Mateusz Fio?ka
 - David Pache
 - Peter Sandstr枚m
 - Yonas Yanfa
The homepage is at: http://www.tigase.org/
press 1 to continue, 2 to quit, 3 to redisplay



3、JDK Selection

  输入你安装jdk的目录
The installed application needs a JDK. A java runtime environment (JRE) will be not sufficient.
Enter path: /usr/java/jdk1.7.0_71



4、Actions Selection

Choose whether you want to configure the server in addition to install it.
选择你好配置的选项
*** Select what you want to do next:
On this panel you can specify whether you want to install only or configure already installed server or to do both. If you are just installing a server on your machine it is a good idea to do both steps.

-------------------

The wizards you want to execute
Installation of the Tigase Server
[on, off]
on
Configuration of the Tigase Server
[on, off]
on

-------------------


5、Installer Info

之后会显示安装的相关信息,直接选择1 就ok

Please note!
While the Tigase server is quite stable and well tested application the installer itself is a new addition. Take precautions especially if you upgrade the server from earlier version. Backup old server files and the database.

If you notice any problems please report them to address: [email protected]
press 1 to continue, 2 to quit, 3 to redisplay


6、Server Info

If you don’t know what exactly is Tigase server, you can find some basic introduction on this screen.
之后会显示一些关于tigase的相关基本信息
技术分享

一直回车,直到出现下一个选项

7、Server License

This is a licence that you have to agree to use Tigase server. Please read it carefully. Take note, that in this manual only part is shown in order to decrease guide length.
主要是一些许可证相关信息
技术分享

还是一路enter

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
1.  I accept the terms of this license agreement.
2.  I do not accept the terms of this license agreement.
Choose number (1-2): 1</span>
<span style="font-family:Courier New;">press 1 to continue, 2 to quit, 3 to redisplay
1


选择同一协议并继续

8、Server Location Selection

Enter where do you want the server to be installed. If you have administrator rights you can place it in a standard location where all your applications reside. If you don’t have write rights for this place, you can always install the server in your home directory.
输入你准备安装tigase服务的文件夹
这里是:/mnt/xmpp_service/service/tigase

Select target path [/mnt/xmpp_service/soft/tigase] 
/mnt/xmpp_service/service/tigase
press 1 to continue, 2 to quit, 3 to redisplay
1
------


9、Selection of Packs to be Installed

选择你要安装的选项
Select the packs you want to install:

1 => Base, The base files
2 => Unix Files, Files needed to run the server on Unix like systems
3 => [x] Docs, The documentation
4 => [x] Extras, Extras libraries, MUC, PubSub, STUN, Socks5, Message Archiving, ACS
5 => [x] Groovy scripting, Various Groovy scripts extending server functionality
6 => [x] Derby Database (DB included), Derby database (included) and JDBC driver
7 => [x] MySQL Database driver (DB not included), MySQL JDBC driver (MySQL has to be installed separately)
8 => [ ] PostgreSQL Database driver (DB not included), PostgreSQL JDBC driver (PostgreSQL has to be installed separately)
9 => [ ] SQL Server Database driver (DB not included), SQL Server JDBC driver (SQL Server has to be installed separately)
10 => [ ] MongoDB Database support (DB not included), Libraries need to use MongoDB from Tigase (includes driver)
11 => [x] OSGi dependencies, If you intend to run Tigase in OSGi mode you need additional libraries. Enabling this Pack will also setup configuration files to start Tigase XMPP server in OSGi mode.
12 => [x] HTTP API Component, Interface for the service administration, monitoring and exchange data between Tigase and external system
13 => [x] Sources, The server source files, tools and libraries sources are not included
r => Redisplay menu
d => Done

Choose action: d


显示你所选择的选项都安装成功:
press 1 to continue, 2 to quit, 3 to redisplay
1
[ Starting to unpack ]
[ Processing package: Base (1/10) ]
[ Processing package: Unix Files (2/10) ]
[ Processing package: Docs (3/10) ]
[ Processing package: Extras (4/10) ]
[ Processing package: Groovy scripting (5/10) ]
[ Processing package: Derby Database (DB included) (6/10) ]
[ Processing package: MySQL Database driver (DB not included) (7/10) ]
[ Processing package: OSGi dependencies (8/10) ]
[ Processing package: HTTP API Component (9/10) ]
[ Processing package: Sources (10/10) ]
[ Unpacking finished ]
*** Basic Tigase server configuration
On this panel you can specify basic configuration settings for the Tigase server.

Based on your selection here more configuration options might be presented later on. After the configuration is complete init.properties file will be created.



10、Basic Configuration

一些相关的基础配置

You can optionally restart the server at the end of the process if you like.
-------------------

0  [x] Default installation
1  [ ] Default plus extra components
2  [ ] Session Manager only
3  [ ] Network connectivity only
input selection:
0
Your XMPP (Jabber) domains [<strong>iZ235okehetZ</strong>] 

Server administrators [<strong>admin@iZ235okehetZ</strong>] 

Admin password [<strong>tigase</strong>] 

0  [x] Derby (built-in database)
1  [ ] MySQL
2  [ ] PostgreSQL
3  [ ] SQLServer
4  [ ] Other...
input selection:
1

-------------------



粗体部分都是默认,直接回车就ok,安装完成后可以用此管理账号和密码用测试客户端(spark等)进行登录。

11、Advanced Configuration

-------------------

Advanced configuration options
[on, off]
off
press 1 to continue, 2 to quit, 3 to redisplay
1
*** Database configuration:
You have selected MySQL database. This database needs additional configuration parameters. Please enter all required information.

-------------------



12、Database Configuration


根据提示,输入刚才我们准备好的数据库账号和密码,并输入连接数据库的地址等相关信息
技术分享

查看下面输出的日志,一切ok


All users added
Post installation actions  
Finalizing... completed OK
Loading socks5 component schema  
Loading socks5 schema...
Socks5 schema exists, skipping schema load
Loading PubSub component schema  
Loading PubSub schema...
PubSub schema exists, skipping schema load


Install was successeful
application installed on /mnt/xmpp_service/service/tigase
[ Console installation done ]



目前看起来一切都正常,安装成功。

13、启动以及fix bug

那行,那我们就启动一下试试:
在tigase的安装主目录下输入命令:

[root@iZ235okehetZ tigase]# ./scripts/tigase.sh start etc/tigase.conf 
Starting Tigase: 
Tigase running pid=19179
[root@iZ235okehetZ tigase]# nohup: redirecting stderr to stdout



然后我们查看日志

Mar 27, 2015 11:41:56 AM tigase.conf.ConfiguratorAbstract setProperties
Mar 27, 2015 11:41:58 AM tigase.db.jdbc.DataRepositoryImpl initRepository
SEVERE: null
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found by tigase-server [26]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1550)
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1988)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:274)
        at tigase.db.jdbc.DataRepositoryImpl.initRepository(DataRepositoryImpl.java:262)
        at tigase.db.RepositoryFactory.getDataRepository(RepositoryFactory.java:458)
        at tigase.db.jdbc.JDBCRepository.initRepository(JDBCRepository.java:575)
        at tigase.db.RepositoryFactory.getUserRepository(RepositoryFactory.java:660)
        at tigase.conf.ConfiguratorAbstract.addUserRepo(ConfiguratorAbstract.java:903)
        at tigase.conf.ConfiguratorAbstract.setProperties(ConfiguratorAbstract.java:832)
        at tigase.conf.ConfiguratorAbstract.setup(ConfiguratorAbstract.java:540)
        at tigase.conf.ConfiguratorAbstract.componentAdded(ConfiguratorAbstract.java:177)
        at tigase.conf.Configurator.componentAdded(Configurator.java:50)
        at tigase.conf.Configurator.componentAdded(Configurator.java:33)
        at tigase.server.AbstractComponentRegistrator.addComponent(AbstractComponentRegistrator.java:116)
        at tigase.server.MessageRouter.addRegistrator(MessageRouter.java:131)
        at tigase.server.MessageRouter.setConfig(MessageRouter.java:603)
        at tigase.server.XMPPServer.start(XMPPServer.java:142)
        at tigase.osgi.Activator.start(Activator.java:89)
        at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:2152)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2070)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1297)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
        at java.lang.Thread.run(Thread.java:745)



很不幸,报错,这个就是我前面说到的,tigase打包的的时候,数据库java驱动有问题,他们给的是mysql-connector-java.jar,这个jar包是有问题的,我换成了mysql-connector-java-5.1.18-bin.jar 问题解决。

另外我们需要做的:
1、修改--virt-hosts = your ip address  目录在etc/init.properties
2、安装mysql(可能不需要,但是由于时间原因,我没有验证,如果有博友验证了可以告诉我~~)yum install mysql
3、修改OSGI=false 
4、修改启动时分配的内存,防止发生内存泄漏
配置文件如下:

#osgiEnabled=(true|false)
#osgiEnabled=false
<strong>OSGI=false</strong>
ENC="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8"
DRV="-Djdbc.drivers=com.mysql.jdbc.Driver:org.postgresql.Driver:org.apache.derby.jdbc.EmbeddedDriver"
#GC="-XX:+UseBiasedLocking -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:ParallelCMSThreads=2 -XX:-ReduceInitialCardMarks"
#EX="-XX:+OptimizeStringConcat -XX:+DoEscapeAnalysis -XX:+UseNUMA"
#JMX_REMOTE_IP="-Djava.rmi.server.hostname=0.0.0.0"
JAVA_HOME="/usr/java/jdk1.7.0_71"
CLASSPATH=""
JAVA_OPTIONS="${GC} ${EX} ${ENC} ${DRV} ${JMX_REMOTE_IP} <strong>-server -Xms1000M -Xmx2000M -XX:PermSize=320m -XX:MaxPermSize=2560m -XX:MaxDirectMemorySize=1280m</strong> "
TIGASE_CONFIG="etc/tigase.xml"
TIGASE_OPTIONS=" --property-file etc/init.properties "


 做完这一些,然后重启服务!

查看日子,ok,没有任何报错!!

三、测试

用spark客户端进行测试


注册

技术分享
技术分享
技术分享

登录:

技术分享

技术分享
技术分享


技术分享

登录成功!

至此,tigase server 安装完毕。。。


原创文章,转载请注明出处:http://blog.csdn.net/jessonlv

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。