1. 程式人生 > >centos 6.5 yum安裝rabbitMQ

centos 6.5 yum安裝rabbitMQ

1、檢視系統版本, 升級系統基本lib庫

[[email protected] ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)

[[email protected] ~]# yum install ncurses ncurses-base ncurses-devel ncurses-libs ncurses-static ncurses-term ocaml-curses ocaml-curses-devel openssl-devel zlib-devel

2、安裝erlang語言環境

下載erlang
[[email protected]

~]# wget https://github.com/rabbitmq/erlang-rpm/releases/download/v21.1.1/erlang-21.1.1-1.el6.x86_64.rpm

[[email protected] ~]# rpm -ivh erlang-21.1.1-1.el6.x86_64.rpm
warning: erlang-21.1.1-1.el6.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing... ########################################### [100%]
1:erlang ########################################### [100%]

 

3、下載rabbitmq

[[email protected] ~]# wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.9/rabbitmq-server-3.7.9-1.el6.noarch.rpm

[[email protected] ~]# rpm -ivh rabbitmq-server-3.7.9-1.el6.noarch.rpm
warning: rabbitmq-server-3.7.9-1.el6.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
error: Failed dependencies:
socat is needed by rabbitmq-server-3.7.9-1.el6.noarch

 

//報錯提示缺少socat 包支援

[[email protected] ~]# yum install socat
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.vpshosting.com.hk
* extras: mirror.vpshosting.com.hk
* updates: mirror.vpshosting.com.hk
Setting up Install Process
No package socat available.

 

此時會報錯沒有socat包或是找不到socat包,解決方法安裝centos的epel的擴充套件源

[[email protected] ~]# yum -y install epel-release

 

[[email protected] ~]# rpm -ivh rabbitmq-server-3.7.9-1.el6.noarch.rpm
warning: rabbitmq-server-3.7.9-1.el6.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing... ########################################### [100%]
1:rabbitmq-server ########################################### [100%]
[[email protected] ~]#

4、生產配置檔案

[[email protected] ~]# cp /usr/share/doc/rabbitmq-server-3.7.9/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config

// 可以自定修改埠,預設埠是5672和25672

5、啟動rabbitMQ

[[email protected] ~]# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server: SUCCESS
rabbitmq-server.
[[email protected] ~]# netstat -nlpt  //檢視是否有5672和25672埠

6、開啟管理頁面外掛

rabbitmq-plugins enable rabbitmq_management     //管理頁面預設埠是15672

[[email protected] ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to [email protected]
The following plugins have been enabled:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch

started 3 plugins.
[[email protected] ~]#

7、新增管理員賬號 
rabbitmqctl add_user rabbitadmin 123456

[[email protected] ~]# rabbitmqctl add_user rabbitadmin 123456
Adding user "rabbitadmin" ...

分配使用者標籤 
rabbitmqctl set_user_tags rabbitadmin administrator

[[email protected] ~]# rabbitmqctl set_user_tags rabbitadmin administrator
Setting tags for user "rabbitadmin" to [administrator] ...

建立和賦角色完成後檢視並確認

[[email protected] ~]# rabbitmqctl list_users
Listing users ...
user tags
rabbitadmin [administrator]
guest [administrator]

刪除guest帳號

[[email protected] ~]# rabbitmqctl delete_user guest
Deleting user "guest" ...
[[email protected] ~]# rabbitmqctl list_users
Listing users ...
user tags
rabbitadmin [administrator]

 

rabbitmqctl 詳細命令使用

[[email protected] ~]# rabbitmqctl --help

 

 登入rabbitmq管理介面

瀏覽器輸入地址:http://伺服器IP地址:15672/

使用者名稱密碼:rabbitadmin/123456