#yum update
#yum -y remove java*
下载jdk-7u79-linux-x64.tar.gz到/tmp/下(路径随意)
进入/tmp/
将jdk-7u79-linux-x64.tar.gz解压到/usr/local/,并改名为jdk
#tar -zxvf jdk-7u79-linux-x64.tar.gz -C /usr/local
#mv jdk-7u79-linux-x64 jdk
配置环境变量
#vi /etc/profile
在profile文件末尾加入:
JAVA_HOME=/usr/local/jdk
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
保存退出,使/etc/profile里的配置立即生效
#source /etc/profile
#wget http://download.igniterealtime.org/openfire/openfire_3_10_2.tar.gz
将openfire_3_10_2.tar.gz解压到/usr/local/,并改名为openfire
#tar -zxvf openfire_3_10_2.tar.gz -C /usr/local
解压后/usr/local/下如果直接是openfire则无需重命名
#mv openfire_3_10_2 openfire
进入/usr/local/openfire/bin执行如下命令启动openfire
#./openfire start
为你需要的n个主机做同样的步骤
在配置openfire之前需要配置一下mysql数据库(mysql作为数据库服务器一般单独安装在另外一台主机上)
在MySQL中为openfire创建一个数据库(以用户名root登录,密码admin123456789)
mysql -uroot -padmin123456789
创建的数据库名称叫做”dbopenfire”,然后添加新的用户”test”并且密码设置为”123456”
mysql> CREATE DATABASE dbopenfire CHARACTER SET='utf8';
mysql> CREATE USER 'test'@'%' IDENTIFIED BY '123456';
mysql> GRANT ALL ON dbopenfire.* TO 'test'@'%';
mysql> FLUSH PRIVILEGES;
mysql> quit
openfire配置登录: http ://openfire服务器地址:9090/
首先进行语言配置
其次进行服务器设置
这里域统一设置为ubuntu(可以随意设置,但是所有的openfire必须一致,而且在用户登录时,username@host中的host就是这个域)
再进行数据库设置-标准连接
所有的openfire必须设置为同样的数据库。(这一步非常重要)
接下来选择初始设置
最后配置一下服务器的登录密码,默认用户名admin
(注意,因为所有的openfire服务器共享一个数据库,所有所有的openfire服务器的登录用户名和密码都一样)
进入openfire的安装目录 /usr/local/openfire
执行如下命令
./bin/openfire stop
进入openfire的安装目录 /usr/local/openfire/plugins
a) 删除已有插件hazelcast.jar和broadcast.jar
b) 删除插件目录 plugins/hazelcasr和plugins/broadcast
c) 将新的hazelcasr.jar和broadcast.jar插件复制到 plugins目录
切换到
/usr/local/openfire
执行
./bin/openfire start
重启之后登录网页管理页面在插件中就可以看到安装好的hazelcasr和broadcast插件
进入服务器管理中的集群
进入集群管理,在集群设置启用集群
启用之后就可看到集群了
hazelcast最新版3.5.2的配置有重要修改
官方给出的
With the multicast auto-discovery mechanism, Hazelcast allows cluster members to find each other using multicast communication. The cluster members do not need to know the concrete addresses of the other members, they just multicast to all the other members for listening. It depends on your environment if multicast is possible or allowed.
通过组播自动发现机制,hazelcast允许集群成员自动发现而不需要知道准确的地址。
通过这个机制,无需在对< tcp-ip>进行配置
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false"/>
<aws enabled="false"/>
</join>
如果需要手动配置集群成员的地址则需要关闭< multicast>
集群如下
主机 | 内网ip | 应用 |
---|---|---|
主机1 | 172.16.181.73 | openfire |
主机1 | 172.16.181.77 | openfire |
配置如下(openfire/plugins/hazelcast/classes/hazelcast-cache-config.xml)
<join>
<multicast enabled="false">
</multicast>
<tcp-ip enabled="true">
<member>172.16.181.73:5701</member>
<member>172.16.181.77:5701</member>
</tcp-ip>
<aws enabled="false"/>
</join>
如果按照之前版本的配置里面< tcp-ip>中的节点是< hostname>则会报错,服务器日志为:
org.jivesoftware.openfire.plugin.util.cache.ClusteredCacheFactory - Unable to start clustering - continuing in local mode
com.hazelcast.config.InvalidConfigurationException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'hostname'. One of '{"http://www.hazelcast.com/schema/config":required-member, "http://www.hazelcast.com/schema/config":member, "http://www.hazelcast.com/schema/config":interface, "http://www.hazelcast.com/schema/config":members, "http://www.hazelcast.com/schema/config":member-list}' is expected.
安装 Haproxy
yum install haproxy
配置 Haproxy
vi /etc/haproxy/haproxy.cfg
添加如下内容
listen openfirexmpp :15222
mode tcp
option log-health-checks
option redispatch
option tcplog
balance roundrobin
server p1 172.16.181.73:5222 check
server p2 172.16.181.77:5222 check
listen xmpp-openfirexmpp23 :15223
mode tcp
option log-health-checks
option redispatch
option tcplog
balance roundrobin
server p1 172.16.181.73:5223 check
server p2 172.16.181.77:5223 check
listen openfirehttp :17070
mode tcp
option log-health-checks
option redispatch
option tcplog
balance roundrobin
server p1 172.16.181.73:7070 check
server p2 172.16.181.77:7070 check
listen xmpp-7443 :17443
mode tcp
option log-health-checks
option redispatch
option tcplog
balance roundrobin
server p1 172.16.181.73:7443 check
server p2 172.16.181.77:7443 check
listen openfireadmin :19090
mode tcp
option log-health-checks
option redispatch
option tcplog
balance roundrobin
server p1 172.16.181.73:9090 check
server p2 172.16.181.77:9090 check
重启haproxy
service haproxy restart
测试
成功登陆