第一臺機器:node
課前準備工做:python
[root@rsync_inotify_server~]# mkdir -p /data/softwarejson
[root@rsync_inotify_server ~]# ifconfig vim
eth0 Link encap:Ethernet HWaddr 00:0C:29:F4:20:F8 app
inet addr:172.18.11.230 Bcast:172.18.11.255 Mask:255.255.255.0dom
[root@rsync_inotify_server ~]# hostnameide
rsync_inotify_serverspa
[root@rsync_inotify_server ~]# cat /etc/hosts插件
127.0.0.1 rsync_inotify_server localhost localhost.localdomain localhost4localhost4.localdomain4unix
::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集羣配置成功!