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版本

[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


內核

[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 版本

下載地址:https://projects.tigase.org/projects/tigase-server/files
在這裏我用的是jar安裝形式。tigase-server-7.0.1

準備好你要將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]# 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
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章