第一台机器:
课前准备工作:
[root@rsync_inotify_server~]# mkdir -p /data/software
[root@rsync_inotify_server ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:F4:20:F8
inet addr:172.18.11.230 Bcast:172.18.11.255 Mask:255.255.255.0
[root@rsync_inotify_server ~]# hostname
rsync_inotify_server
[root@rsync_inotify_server ~]# cat /etc/hosts
127.0.0.1 rsync_inotify_server localhost localhost.localdomain localhost4localhost4.localdomain4
::1 localhost localhost.localdomainlocalhost6 localhost6.localdomain6
172.18.11.230 rsync_inotify_server
172.18.11.240 rsync_inotify_client
[root@rsync_inotify_server~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=rsync_inotify_server
第一步:安装erlang
[root@rsync_inotify_server~]# cd /data/software
[root@rsync_inotify_serversoftware]# ls
otp_src_R16B03-1.tar.gz rabbitmq-server-generic-unix-2.7.1.tar.gz
Python-2.7.3.tar.bz2 simplejson-3.4.1.tar.gz
[root@rsync_inotify_serversoftware]# tar -zxf otp_src_R16B03-1.tar.gz
[root@rsync_inotify_serversoftware]# cd otp_src_R16B03-1
[root@rsync_inotify_serverotp_src_R16B03-1]# ./configure
#此时报错:configure:error: No curses library functions found
configure: error: /bin/sh'/usr/local/src/otp_src_R16B03-1/erts/configure' failed for erts
#解决方法如下:
# yum -y install ncurses-devel
[root@rsync_inotify_serverotp_src_R16B03-1]# make
[root@rsync_inotify_serverotp_src_R16B03-1]# sudo make install
第二步:检查python版本
[root@rsync_inotify_serversoftware]# pwd
/data/software
如果Python版本低,编译simplejson时会报错 python -V 查看版本
安装至少2.7版本
[root@rsync_inotify_serversoftware]# tar xjvf Python-2.7.3.tar.bz2
[root@rsync_inotify_serversoftware]# cd Python-2.7.3
[root@rsync_inotify_serverPython-2.7.3]# ./configure
[root@rsync_inotify_serverPython-2.7.3]# make
[root@rsync_inotify_serverPython-2.7.3]# make install
第三步:安装simplejson
[root@rsync_inotify_serversoftware]# pwd
/data/software
[root@rsync_inotify_serversoftware]# tar xvzf simplejson-3.4.1.tar.gz
[root@rsync_inotify_serversoftware]# cd simplejson-3.4.1
[root@rsync_inotify_serversimplejson-3.4.1]# python setup.py install
第四步: 安装rabbitmq
[root@rsync_inotify_serversoftware]# pwd
/data/software
[root@rsync_inotify_server software]# tar zxvf rabbitmq-server-generic-unix-2.7.1.tar.gz-C /opt
[root@rsync_inotify_server software]#cd /opt
[root@rsync_inotify_server opt]# ln -srabbitmq_server-2.7.1 rabbitmq
修改/etc/profile,添加环境变量export PATH=$PATH:/opt/rabbitmq/sbin:
[root@rsync_inotify_server opt]# vim/etc/profile
使生效:source /etc/profile
启用管理方式(用网页方式管理MQ):
[root@rsync_inotify_serverrabbitmq]# cd /opt/rabbitmq/sbin/
[root@rsync_inotify_serversbin]# pwd
/opt/rabbitmq/sbin
第二台机器:
课前准备工作:
[root@rsync_inotify_client ~]#ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:46:E8:75
inet addr:172.18.11.240 Bcast:172.18.11.255 Mask:255.255.255.0
[root@rsync_inotify_client~]# hostname
rsync_inotify_client
[root@rsync_inotify_client ~]# cat /etc/hosts
127.0.0.1 rsync_inotify_client localhost localhost.localdomain localhost4localhost4.localdomain4
::1 localhost localhost.localdomainlocalhost6 localhost6.localdomain6
172.18.11.230 rsync_inotify_server
172.18.11.240 rsync_inotify_client
[root@rsync_inotify_client~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=rsync_inotify_client
第一步:安装erlang
[root@rsync_inotify_server~]# cd /data/software
[root@rsync_inotify_serversoftware]# ls
otp_src_R16B03-1.tar.gz rabbitmq-server-generic-unix-2.7.1.tar.gz
Python-2.7.3.tar.bz2 simplejson-3.4.1.tar.gz
[root@rsync_inotify_serversoftware]# tar -zxf otp_src_R16B03-1.tar.gz
[root@rsync_inotify_serversoftware]# cd otp_src_R16B03-1
[root@rsync_inotify_serverotp_src_R16B03-1]# ./configure
[root@rsync_inotify_serverotp_src_R16B03-1]# make
[root@rsync_inotify_serverotp_src_R16B03-1]# sudo make install
第二步:检查python版本
[root@rsync_inotify_serversoftware]# pwd
/data/software
如果Python版本低,编译simplejson时会报错 python -V 查看版本
安装至少2.7版本
[root@rsync_inotify_serversoftware]# tar xjvf Python-2.7.3.tar.bz2
[root@rsync_inotify_serversoftware]# cd Python-2.7.3
[root@rsync_inotify_serverPython-2.7.3]# ./configure
[root@rsync_inotify_serverPython-2.7.3]# make
[root@rsync_inotify_serverPython-2.7.3]# make install
第三步:安装simplejson
[root@rsync_inotify_serversoftware]# pwd
/data/software
[root@rsync_inotify_serversoftware]# tar xvzf simplejson-3.4.1.tar.gz
[root@rsync_inotify_serversoftware]# cd simplejson-3.4.1
[root@rsync_inotify_serversimplejson-3.4.1]# python setup.py install
第四步: 安装rabbitmq
[root@rsync_inotify_serversoftware]# pwd
/data/software
[root@rsync_inotify_server software]# tar zxvfrabbitmq-server-generic-unix-2.7.1.tar.gz -C /opt
[root@rsync_inotify_server software]#cd /opt
[root@rsync_inotify_server opt]# ln -srabbitmq_server-2.7.1 rabbitmq
修改/etc/profile,添加环境变量export PATH=$PATH:/opt/rabbitmq/sbin:
[root@rsync_inotify_serveropt]# vim /etc/profile
使生效:source /etc/profile
接下来rabbitmq安装完成之后作如下操作:
[root@rsync_inotify_client sbin]# pwd
/opt/rabbitmq/sbin
启用维护插件:rabbitmq-plugins enablerabbitmq_management
此处报错:
Error:{cannot_write_enabled_plugins_file,"/etc/rabbitmq/enabled_plugins",
enoent}
解决方法:
[root@rabbitmq_cluster_1sbin]# mkdir /etc/rabbitmq
启用管理方式(用网页方式管理MQ):
[root@rsync_inotify_serverrabbitmq]# cd /opt/rabbitmq/sbin/
------------------------------------------------------------------------------------------------------------------
[root@rsync_inotify_serversbin]# pwd
/opt/rabbitmq/sbin
接着重启服务:
重启rabbitMQ服务,关闭服务命令如下:
[root@rsync_inotify_serversbin]# rabbitmqctl stop
Stopping andhalting node rabbit@rsync_inotify_server ...
[os_mon] cpusupervisor port (cpu_sup): Erlang has closed
...done.
再运行启动命令:
[root@rsync_inotify_serversbin]# rabbitmq-server &
注:rabbitmq默认启动端口:55672
- ----- ---------- ----- ---- --
配置rabbitmq集群:
在配置集群之前,要保证每天机器要启动rabbitmq。
一共是两台机器配置集群,我就在第二台机器上(在第一台也一样)进行rabbitmq配置集群的相关操作:
[root@rabbitmq_slavesbin]# pwd
/opt/rabbitmq/sbin
[root@rabbitmq_slave sbin]# rabbitmqctl stop_app
[root@rabbitmq_slave sbin]# rabbitmqctl reset
[root@rabbitmq_slave sbin]# rabbitmqctl cluster rabbit@rabbitmq_master
[root@rabbitmq_slave sbin]# rabbitmqctl start_app
#到此,rabbitmq集群配置结束。
接下来开始查看集群是否配置成功:
第一台机器:
[root@rabbitmq_master sbin]#rabbitmqctl cluster_status
Cluster status of node rabbit@rabbitmq_master...
[{nodes,[{disc,[rabbit@rabbitmq_master]},{ram,[rabbit@rabbitmq_slave]}]},
{running_nodes,[rabbit@rabbitmq_slave,rabbit@rabbitmq_master]}]
...done.
第二台机器:
[root@rabbitmq_slave sbin]#rabbitmqctl cluster_status
Cluster status of node rabbit@rabbitmq_slave...
[{nodes,[{disc,[rabbit@rabbitmq_master]},{ram,[rabbit@rabbitmq_slave]}]},
{running_nodes,[rabbit@rabbitmq_master,rabbit@rabbitmq_slave]}]
...done.
查看集群状态显示rabbitmq集群配置成功!