局域网通讯工具jabber的搭建和使用--服务器篇

前言

最近想找一个好用的LINUX局域网通讯工具,jabber的关注度比较高,所以搭建了一套试试效果。Jabber能让我们自己架即时通讯服务器,可以在Internet上应用,也可以在局域网中应用。搭建服务器端有几个现成的实现,ejabberd 和 jabberd。我在fedora 20中搭建,使用了jabberd

安装

在fedora中直接yum install jabberd即可

epel源中也有这个软件包。

数据库的配置

mysqladmin create jabberd2
mysql jabberd2 < /usr/share/jabberd/db-setup.mysql
(create user in mysql for jabberd2 database) 
mysql mysql -u root -p 
mysql> GRANT ALL PRIVILEGES ON jabberd2.* TO 'jabberd2'@'localhost' IDENTIFIED BY 'secret_pass' WITH GRANT OPTION;
mysql> flush privileges; 
关于第二步,我这里测试不通,打开

/usr/share/jabberd/db-setup.mysql  去掉create database的一行,就执行通过了

配置文件

1. Set hostname ID in c2s.xml

打开c2s.xml,找到下的

localhost.localdomain

修改为:

10.1.81.221

我这里使用了IP,替代域名,如果有域名则推荐使用域名

2. Set authreg module to use in c2s.xml

找到 ,修改为:

mysql


      
      localhost
      3306

      
      jabberd2

      
      jabberd2
      secret_pass

3. Set hostname ID in sm.xml

打开sm.xml,找到,修改为:

10.1.81.221

4. Set storage module to use in sm.xml

下修改:

mysql


localhost
3306


jabberd2


jabberd2
secret_pass

启动jabberd

[root@localhost jabberd]# systemctl start jabberd
[root@localhost jabberd]# systemctl status jabberd
jabberd.service - Jabber Server
   Loaded: loaded (/usr/lib/systemd/system/jabberd.service; disabled)
   Active: active (exited) since 三 2014-12-17 17:17:51 CST; 7s ago
  Process: 9323 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 9323 (code=exited, status=0/SUCCESS)

12月 17 17:17:51 localhost.localdomain systemd[1]: Started Jabber Server.

如果启动出现故障,可以查看日志

[root@localhost jabberd]# journalctl -f
.......
12月 17 17:20:33 localhost.localdomain jabberd/router[9469]: [s2s] set as default route
12月 17 17:20:33 localhost.localdomain jabberd/router[9469]: [s2s] online (bound to 127.0.0.1, port 43316)
12月 17 17:20:33 localhost.localdomain jabberd/router[9469]: [c2s] online (bound to 127.0.0.1, port 43315)
12月 17 17:20:33 localhost.localdomain jabberd/c2s[9470]: [0.0.0.0, port=5222] listening for connections
12月 17 17:20:33 localhost.localdomain jabberd/s2s[9471]: [0.0.0.0, port=5269] listening for connections
12月 17 17:20:33 localhost.localdomain jabberd/s2s[9471]: ready for connections
12月 17 17:20:33 localhost.localdomain jabberd/c2s[9470]: ready for connections
12月 17 17:20:34 localhost.localdomain jabberd/sm[9465]: attempting connection to router at 127.0.0.1, port=5347
12月 17 17:20:34 localhost.localdomain jabberd/router[9469]: [127.0.0.1, port=43317] connect
12月 17 17:20:34 localhost.localdomain jabberd/router[9469]: [127.0.0.1, port=43317] authenticated as jabberd@jabberd-router
12月 17 17:20:34 localhost.localdomain jabberd/sm[9465]: connection to router established
12月 17 17:20:34 localhost.localdomain jabberd/router[9469]: [sm] online (bound to 127.0.0.1, port 43317)
12月 17 17:20:34 localhost.localdomain jabberd/router[9469]: [10.1.81.221] online (bound to 127.0.0.1, port 43317)
12月 17 17:20:34 localhost.localdomain jabberd/sm[9465]: sm ready for sessions
12月 17 17:20:40 localhost.localdomain jabberd/c2s[9470]: [8] [10.1.82.0, port=52630] connect

直接存数据库的用户可能登录失败

1月 30 11:26:09 localhost.localdomain jabberd/c2s[2297]: [8] DIGEST-MD5 authentication succeeded: [email protected] 10.1.81.223:48700
1月 30 11:26:09 localhost.localdomain jabberd/c2s[2297]: [8] bound: [email protected]/f5c78745
1月 30 11:26:09 localhost.localdomain jabberd/sm[2292]: user not found and user.auto-create not enabled, can't start session: [email protected]

可以修改sm.xml的
    
       
即可。


参考:

https://github.com/jabberd2/jabberd2/wiki/InstallGuide-QuickStartGuideRPM

https://github.com/jabberd2/jabberd2/wiki/InstallGuide-BasicConfiguration

http://wiki.jabbercn.org/Jabberd2:%E5%AE%89%E8%A3%85%E5%92%8C%E7%AE%A1%E7%90%86%E6%8C%87%E5%8D%97#.E6.8F.90.E4.BE.9B.E5.92.8C.E9.85.8D.E7.BD.AEPostgreSQL

你可能感兴趣的:(工具)