最近在实施酒店中央预订(CRS)项目,为了及时将网上预订订单情况通知成员酒店相关人员,决定架设一台内部局域网即时通讯(IM)服务器。首先想到的服务器软件就是开源的Jabberd,这个可是老字号了,应该不会差。可是昨晚安装Jabberd2(Ver2.2.4)时,在编译时老是提示我GnuSASL的版本没有符合(0.2.27 or higher)的要求(可是我已分安装了GnuSASL0.2.29、0.2.28和0.2.27,还是同样结果),一直无法完成编译,折腾到凌晨1点多以后,决定放弃,所以在网上一Google后,就找到Openfire+Spark,相比之下,Openfire的安装真是太简单,将下载的文件上传到服务器,参照官方文档,不到十分钟就安装成功(真可惜在Jabberd2上浪费太多时间了,害我今天上班困得要命),下面是经过整理的安装记录。
0、准备工作:下载相关软件
1、Clone一台Linux Server(Oracle Enterprise Linux Release 5 Update2);
2、用WinSCP将Mysql及openfire安装软件上传至服务器(我安装服务器时没有安装Mysql所需的Per DBI,所以同时也从Linux安装盘找到perl-DBI-1.52-1.fc6.i386.rpm一并传上);
3、安装Mysql
[root@im ~]# rpm -ivh MySQL-server-community-5.0.67-0.rhel5.i386.rpm error: Failed dependencies: perl(DBI) is needed by MySQL-server-community-5.0.67-0.rhel5.i386 [root@im ~]# rpm -ivh perl-DBI-1.52-1.fc6.i386.rpm warning: perl-DBI-1.52-1.fc6.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159 Preparing… ########################################### [100%] 1:perl-DBI ########################################### [100%] [root@im ~]# rpm -ivh MySQL-server-community-5.0.67-0.rhel5.i386.rpm Preparing… ########################################### [100%] 1:MySQL-server-community ########################################### [100%] PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password ‘new-password’ /usr/bin/mysqladmin -u root -h im.abc.com password ‘new-password’
Alternatively you can run: /usr/bin/mysql_secure_installation
which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com Starting MySQL..[ OK ] Giving mysqld 2 seconds to start [root@im ~]# rpm -ivh MySQL-client-community-5.0.67-0.rhel5.i386.rpm Preparing… ########################################### [100%] 1:MySQL-client-community ########################################### [100%] [root@im ~]#
|
4、修改Mysql用户root密码并确认数据库已装好;
[root@im ~]# /usr/bin/mysqladmin -u root password ‘abc’ [root@im ~]# mysql -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 4 Server version: 5.0.67-community MySQL Community Edition (GPL)
Type ‘help;’ or ‘/h’ for help. Type ‘/c’ to clear the buffer.
mysql> show databases; +——————–+ | Database | +——————–+ | information_schema | | mysql | | test | +——————–+ 3 rows in set (0.00 sec)
mysql>
|
5、首先参考官方的安装文档安装Openfire,非常简单,就几个步骤。首先安装Openfile 的RPM包,系统文件将被自动安装至/opt/openfire目录
[root@im ~]# rpm -ivh openfire-3.6.1-1.i386.rpm Preparing… ########################################### [100%] 1:openfire ########################################### [100%] [root@im ~]# ll /opt/openfire/ total 180 drwxr-xr-x 2 daemon daemon 4096 Nov 21 18:41 bin -rw-r–r– 1 daemon daemon 117797 Nov 15 04:11 changelog.html drwxr-xr-x 2 daemon daemon 4096 Nov 21 18:41 conf drwxr-xr-x 4 daemon daemon 4096 Nov 21 18:41 documentation drwxr-xr-x 4 daemon daemon 4096 Nov 21 18:41 jre drwxr-xr-x 2 daemon daemon 4096 Nov 21 18:41 lib -rw-r–r– 1 daemon daemon 18329 Nov 15 04:11 LICENSE.html drwxr-xr-x 2 daemon daemon 4096 Nov 15 04:11 logs drwxr-xr-x 3 daemon daemon 4096 Nov 21 18:41 plugins -rw-r–r– 1 daemon daemon 5477 Nov 15 04:11 README.html drwxr-xr-x 6 daemon daemon 4096 Nov 21 18:41 resources [root@im ~]#
|
6、创建数据库,并导入相应库表结构,并将该数据库的权限赋给openfiredbo,我不喜欢应用程序直接用root连接数据。
[root@im ~]# mysqladmin create openfire -h localhost -u root -p Enter password: [root@im ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 8 Server version: 5.0.67-community MySQL Community Edition (GPL)
Type ‘help;’ or ‘/h’ for help. Type ‘/c’ to clear the buffer.
mysql> show databases; +——————–+ | Database | +——————–+ | information_schema | | mysql | | openfire | | test | +——————–+ 4 rows in set (0.01 sec)
mysql> exit Bye
[root@im database]# cd /opt/openfire/resources/database
[root@im database]# cat openfire_mysql.sql | mysql openfire -p Enter password: [root@im database]# mysql openfire -p Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 14 Server version: 5.0.67-community MySQL Community Edition (GPL)
Type ‘help;’ or ‘/h’ for help. Type ‘/c’ to clear the buffer.
mysql> select * from ofUser; +———-+—————+——————-+—————+——————-+————–+——————+ | username | plainPassword | encryptedPassword | name | email | creationDate | modificationDate | +———-+—————+——————-+—————+——————-+————–+——————+ | admin | admin | NULL | Administrator | admin@example.com | 0 | 0 | +———-+—————+——————-+—————+——————-+————–+——————+ 1 row in set (0.00 sec)
mysql> GRANT all ON openfire.* to openfiredbo@localhost IDENTIFIED by ‘abc’; Query OK, 0 rows affected (0.00 sec)
|
7、调整系统分配给JVM的最大内存,原来默认的64MB是不够的。
[root@im database]# vi /etc/sysconfig/openfire
|
将#OPENFIRE_OPTS=”-Xmx1024m”的注释去除
8、启动Openfire
[root@im conf]# /etc/init.d/openfire start Starting openfire: [root@im conf]#
|
9、打开浏览器,用http://服务器地址:9090.进行配置。
配置很简单,照屏幕提示去做即可。
需要注意的时,我的后端数据库用的是Mysql,根据官方文档提示,在连接URL后面加上:?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8以更好支持UTF-8。