CentOS下 RabbitMQ安裝配置:
阿新 • • 發佈:2017-10-30
net mini rtu 配置 list /var/ 解析 .rpm -a
CentOS RabbitMQ rpm 安裝方法:
系統環境:CentOS6
IP地址:10.100.62.41
1.erlang安裝:
erlang下載地址: http://www.rabbitmq.com/releases/erlang/ [root@v05-apppre-rabbitmq ~]# cd /opt/ytd_src/ [root@v05-apppre-rabbitmq ytd_src]# wget http://www.rabbitmq.com/releases/erlang/erlang-18.2-1.el6.x86_64.rpm --2017-10-30 07:30:33-- http://www.rabbitmq.com/releases/erlang/erlang-18.2-1.el6.x86_64.rpm 正在解析主機 www.rabbitmq.com (www.rabbitmq.com)... 104.20.62.197, 104.20.63.197, 2400:cb00:2048:1::6814:3fc5, ... 正在連接 www.rabbitmq.com (www.rabbitmq.com)|104.20.62.197|:80... 已連接。 已發出 HTTP 請求,正在等待回應... 200 OK 長度:18354700 (18M) [application/x-redhat-package-manager] 正在保存至: “erlang-18.2-1.el6.x86_64.rpm” 100%[===============================================================================>] 18,354,700 134KB/s 用時 3m 41s 2017-10-30 07:34:16 (81.0 KB/s) - 已保存 “erlang-18.2-1.el6.x86_64.rpm” [18354700/18354700]) [root@v05-apppre-rabbitmq ytd_src]# ll 總用量 17928 -rw-r--r-- 1 root root 18354700 1月 3 2016 erlang-18.2-1.el6.x86_64.rpm [root@v05-apppre-rabbitmq ytd_src]# rpm -ivh erlang-18.2-1.el6.x86_64.rpm 準備中... ################################# [100%] 正在升級/安裝... 1:erlang-18.2-1.el6 ################################# [100%] [root@v05-apppre-rabbitmq ytd_src]# erlang版本地址: wget –no-cache http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo -O /etc/yum.repos.d/convirt.repo yum makecache yum install socat
2.rabbitMQ安裝:
下載地址:https://dl.bintray.com/rabbitmq/rabbitmq-server-rpm/ [root@v05-apppre-rabbitmq ytd_src]# wget https://dl.bintray.com/rabbitmq/rabbitmq-server-rpm/rabbitmq-server-3.6.12-1.el6.noarch.rpm --2017-10-30 07:42:07-- https://dl.bintray.com/rabbitmq/rabbitmq-server-rpm/rabbitmq-server-3.6.12-1.el6.noarch.rpm 正在解析主機 dl.bintray.com (dl.bintray.com)... 35.161.20.85, 52.34.155.241 正在連接 dl.bintray.com (dl.bintray.com)|35.161.20.85|:443... 已連接。 ...... 已發出 HTTP 請求,正在等待回應... 200 OK 長度:4964260 (4.7M) [application/x-rpm] 正在保存至: “rabbitmq-server-3.6.12-1.el6.noarch.rpm” 100%[===============================================================================>] 4,964,260 1.54MB/s 用時 3.1s 2017-10-30 07:42:14 (1.54 MB/s) - 已保存 “rabbitmq-server-3.6.12-1.el6.noarch.rpm” [4964260/4964260]) [root@v05-apppre-rabbitmq ytd_src]# ll 總用量 22776 -rw-r--r-- 1 root root 18354700 1月 3 2016 erlang-18.2-1.el6.x86_64.rpm -rw-r--r-- 1 root root 4964260 9月 21 03:34 rabbitmq-server-3.6.12-1.el6.noarch.rpm [root@v05-apppre-rabbitmq ytd_src]# rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc [root@v05-apppre-rabbitmq ytd_src]# rpm -ivh rabbitmq-server-3.6.12-1.el6.noarch.rpm 錯誤:依賴檢測失敗: socat 被 rabbitmq-server-3.6.12-1.el6.noarch 需要 解決報錯: [root@v05-apppre-rabbitmq ytd_src]# wget –no-cache http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo -O /etc/yum.repos.d/convirt.repo [root@v05-apppre-rabbitmq ytd_src]# yum makecache -y [root@v05-apppre-rabbitmq ytd_src]# yum install socat -y [root@v05-apppre-rabbitmq ytd_src]# rpm -ivh rabbitmq-server-3.6.12-1.el6.noarch.rpm 準備中... ################################# [100%] 正在升級/安裝... 1:rabbitmq-server-3.6.12-1.el6 ################################# [100%]
3.安裝管理插件:
[root@v05-apppre-rabbitmq ytd_src]# rabbitmq-plugins enable rabbitmq_management
4.啟動服務:
[root@v05-apppre-rabbitmq ytd_src]# service rabbitmq-server start Starting rabbitmq-server (via systemctl): [ 確定 ]
5.瀏覽器訪問:
http://10.100.62.41:15672
用系統默認的guest賬號 結果登錄失敗 可能權限的問題吧,果斷創建一個用戶.
添加用戶: [root@v05-apppre-rabbitmq ytd_src]# rabbitmqctl add_user admin 123456 Creating user "admin" [root@v05-apppre-rabbitmq ytd_src]# rabbitmqctl set_user_tags admin administrator Setting tags for user "admin" to [administrator] [root@v05-apppre-rabbitmq ytd_src]#
6.重啟服務:
[root@v05-apppre-rabbitmq ytd_src]# service rabbitmq-server restart
至此MQ單機版就已經安裝完成了.
解決/etc/rabbitmq/rabbitmq.config (not found)問題:
Config file /etc/rabbitmq/rabbitmq.config (not found) Database directory /var/lib/rabbitmq/mnesia/rabbit@localhost Log file /var/log/rabbitmq/[email protected] SASL log file /var/log/rabbitmq/[email protected] 新建一個文件:/etc/rabbitmq/rabbitmq.config,輸入一下配置內容: [{rabbit, [{loopback_users, []}]}].
由於機器有限,就打算在測試環境給搭建個單機集群版的MQ。
單機集群版配置:
查看第一個節點的狀態,(就是默認的單機版狀態)
[root@v05-apppre-rabbitmq ~]# rabbitmqctl status Status of node ‘rabbit@v05-apppre-rabbitmq‘ [{pid,1957}, {running_applications, 我們看到默認啟動的是rabbit@v05-apppre-rabbitmq
1.啟動第一個節點(即是單機MQ)
RABBITMQ_NODE_PORT=5672 RABBITMQ_NODENAME=rabbit@v05-apppre-rabbitmq rabbitmq-server #由於這個MQ前面已經啟動,在這裏再啟動時可能會報已經啟動的錯誤,暫且不理.
2.啟動第二個節點:
RABBITMQ_NODE_PORT=5673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}] -rabbitmq_stomp tcp_listeners [61614] -rabbitmq_mqtt tcp_listeners [1884]" RABBITMQ_NODENAME=rabbit-01@v05-apppre-rabbitmq rabbitmq-server -detached [root@v05-apppre-rabbitmq ~]# rabbitmqctl status -n rabbit-01@v05-apppre-rabbitmq Status of node ‘rabbit-01@v05-apppre-rabbitmq‘ [{pid,17574}, ......
3.啟動第三個節點:
RABBITMQ_NODE_PORT=5674 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15674}] -rabbitmq_stomp tcp_listeners [61615] -rabbitmq_mqtt tcp_listeners [18845]" RABBITMQ_NODENAME=rabbit-02@v05-apppre-rabbitmq rabbitmq-server -detached [root@v05-apppre-rabbitmq ~]# rabbitmqctl status -n rabbit-02@v05-apppre-rabbitmq Status of node ‘rabbit-02@v05-apppre-rabbitmq‘ [{pid,19076}, ......
集群操作:
節點二(rabbit-01@v05-apppre-rabbitmq)添加到集群:
停止第二個節點的應用程序: [root@v05-apppre-rabbitmq ~]# rabbitmqctl -n rabbit-01@v05-apppre-rabbitmq stop_app Stopping rabbit application on node ‘rabbit-01@v05-apppre-rabbitmq‘ 重新設置第二個節點的元數據和狀態為清空狀態 [root@v05-apppre-rabbitmq ~]# rabbitmqctl -n rabbit-01@v05-apppre-rabbitmq reset Resetting node ‘rabbit-01@v05-apppre-rabbitmq‘ [root@v05-apppre-rabbitmq ~]# 將rabbit-01@v05-apppre-rabbitmq節點加入rabbit@v05-apppre-rabbitmq集群節點中 [root@v05-apppre-rabbitmq ~]# rabbitmqctl -n rabbit-01@v05-apppre-rabbitmq join_cluster rabbit@v05-apppre-rabbitmq Clustering node ‘rabbit-01@v05-apppre-rabbitmq‘ with ‘rabbit@v05-apppre-rabbitmq‘ [root@v05-apppre-rabbitmq ~]# 重新啟動rabbit-01@v05-apppre-rabbitmq節點 [root@v05-apppre-rabbitmq ~]# rabbitmqctl -n rabbit-01@v05-apppre-rabbitmq start_app Starting node ‘rabbit-01@v05-apppre-rabbitmq‘
節點三添加到集群:
[root@v05-apppre-rabbitmq ~]# rabbitmqctl -n rabbit-02@v05-apppre-rabbitmq stop_app Stopping rabbit application on node ‘rabbit-02@v05-apppre-rabbitmq‘ [root@v05-apppre-rabbitmq ~]# rabbitmqctl -n rabbit-02@v05-apppre-rabbitmq reset Resetting node ‘rabbit-02@v05-apppre-rabbitmq‘ [root@v05-apppre-rabbitmq ~]# rabbitmqctl -n rabbit-02@v05-apppre-rabbitmq join_cluster rabbit@v05-apppre-rabbitmq Clustering node ‘rabbit-02@v05-apppre-rabbitmq‘ with ‘rabbit@v05-apppre-rabbitmq‘ [root@v05-apppre-rabbitmq ~]# [root@v05-apppre-rabbitmq ~]# rabbitmqctl -n rabbit-02@v05-apppre-rabbitmq start_app Starting node ‘rabbit-02@v05-apppre-rabbitmq‘ [root@v05-apppre-rabbitmq ~]#
查看集群狀態:
[root@v05-apppre-rabbitmq ~]# rabbitmqctl cluster_status -n rabbit@v05-apppre-rabbitmq Cluster status of node ‘rabbit@v05-apppre-rabbitmq‘ [{nodes,[{disc,[‘rabbit-01@v05-apppre-rabbitmq‘, ‘rabbit-02@v05-apppre-rabbitmq‘, ‘rabbit@v05-apppre-rabbitmq‘]}]}, {running_nodes,[‘rabbit-02@v05-apppre-rabbitmq‘, ‘rabbit-01@v05-apppre-rabbitmq‘, ‘rabbit@v05-apppre-rabbitmq‘]}, {cluster_name,<<"rabbit@v05-apppre-rabbitmq">>}, {partitions,[]}, {alarms,[{‘rabbit-02@v05-apppre-rabbitmq‘,[]}, {‘rabbit-01@v05-apppre-rabbitmq‘,[]}, {‘rabbit@v05-apppre-rabbitmq‘,[]}]}] [root@v05-apppre-rabbitmq ~]#
參考文檔:http://www.cnblogs.com/wanglan/p/7662471.html
http://blog.csdn.net/Java_HuiLong/article/details/73718714
CentOS下 RabbitMQ安裝配置: