1、安裝erlang 語言環境html
安裝依賴文件node
#yum -y installncurses-devel python
yum -y install gcc gcc-c++linux
yum -y install zlib zlib-devel xmltoc++
安裝python ,能夠執行python –V查詢是否安裝,通常系統自帶已安裝。git
進入http://www.erlang.org/download.html選擇源文件下載web
wgethttp://www.erlang.org/download/ otp_src_17.1.tar.gzspring
tar zxvf otp_src_17.1.tar.gzshell
cd otp_src_17.1vim
閱讀HOTO/INSTALL.md文件
#./configure
#make && make install
安裝完成之後,執行erl看是否能打開eshell,用’halt().’退出,注意後面的點號,那是erlang的結束符。
[root@localhostsrc]# erl
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [async-threads:10] [hipe][kernel-poll:false]
EshellV6.1 (abort with ^G)
2> 9+3.
12
3> halt().
2、安裝RabbitMQ
進入http://www.rabbitmq.com/download.html選擇最新的源碼包
#wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.4/rabbitmq-server-3.3.4.tar.gz
#tar zxvfrabbitmq-server-3.3.4.tar.gz
mkdir /usr/rabbitmq
#cdrabbitmq-server-3.3.4
#makeTARGET_DIR=/usr/rabbitmq SBIN_DIR=/usr/rabbitmq/sbin MAN_DIR=/usr/rabbitmq/man DOC_INSTALL_DIR=/usr/rabbitmq/doc
#makeTARGET_DIR=/usr/rabbitmq SBIN_DIR=/usr/rabbitmq/sbin MAN_DIR=/usr/rabbitmq/manDOC_INSTALL_DIR=/usr/rabbitmq/doc install
3、啓動rabbitmq-server
運行rabbitmq:
#/usr/rabbitmq/sbin/rabbitmq-server start&
(或者#/usr/rabbitmq/sbin/rabbitmq-server -detached)
須要在/etc/hosts 中添加
127.0.0.1 localhost主機名
四、安裝web插件管理界面—必須安裝web插件,不然沒法啓用15672端口和進行web頁面登陸
#cd /usr/rabbitmq/sbin
#mkdir /etc/rabbitmq/ --默認插件是安裝到此目錄,因此必須建立
#./rabbitmq-plugins enablerabbitmq_management
五、好了,到這裏rabbitmq已經配置好了,能夠啓動了:
#./rabbitmq-server start&
我運行的時候報錯了,ERROR: epmd errorfor host "springzoo": timeout (timed out)
更改下/etc/hosts:
127.0.0.1 localhost springzoo
::1 localhost springzoo
# ps aux | grep rabbitmq //查看端口,默認就是5672
netstat -tnlp | grep 5672
tcp 0 00.0.0.0:15672 0.0.0.0:* LISTEN 30435/beam.smp
tcp 0 00.0.0.0:55672 0.0.0.0:* LISTEN 30435/beam.smp
tcp 0 0:::5672 :::* LISTEN 30435/beam.smp
若是看到下面的信息就代表已經啓動成功了:
運行以下的命令,增長用戶admin,密碼admin
[root@localhost sbin]# ./rabbitmqctl add_user admin admin
Creating user "admin" ...
...done.
[root@localhost sbin]# ./rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...
...done.
[root@localhost sbin]# ./rabbitmqctl list_users
Listing users ...
admin [administrator]
guest [administrator]
...done.
最後關閉防火牆咱們就能夠在瀏覽器上輸入http://127.0.0.1:15672/登陸管理界面了(因爲端口號過大,若是沒法經過防火牆,那必須關閉防火牆)
使用登陸的名戶名和密碼默認都算admin,登陸後的頁面以下:
查看rabbitmq狀態:
#/usr/rabbitmq/sbin/rabbitmqctl status
關閉rabbitmq:
#/usr/rabbitmq/sbin/rabbitmqctl stop
6、查看RabbitMQ服務啓動的狀態,並開啓RabbitMQ的相應管理插件
[root@localhostsbin]# ./rabbitmqctl status
Status of node rabbit@localhost ...
[{pid,35112},
{running_applications,[{rabbit,"RabbitMQ","3.3.4"},
{os_mon,"CPO CXC 138 46","2.2.15"},
{xmerl,"XML parser","1.3.7"},
{mnesia,"MNESIA CXC 138 12","4.12.1"},
{sasl,"SASL CXC 138 11","2.4"},
{stdlib,"ERTS CXC 138 10","2.1"},
{kernel,"ERTS CXC 138 10","3.0.1"}]},
{os,{unix,linux}},
{erlang_version,"Erlang/OTP 17 [erts-6.1] [source] [64-bit][async-threads:30] [hipe] [kernel-poll:true]\n"},
{memory,[{total,35218336},
{connection_procs,2728},
{queue_procs,5456},
{plugins,0},
{other_proc,13339072},
{mnesia,57552},
{mgmt_db,0},
{msg_index,33968},
{other_ets,708832},
{binary,30112},
{code,16881166},
{atom,654217},
{other_system,3505233}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,769332019},
{disk_free_limit,50000000},
{disk_free,45550653440},
{file_descriptors,[{total_limit,924},
{total_used,3},
{sockets_limit,829},
{sockets_used,1}]},
{processes,[{limit,1048576},{used,124}]},
{run_queue,0},
{uptime,2182}]
...done.
[root@localhost sbin]# ./rabbitmq-plugins list
[ ]amqp_client 3.3.4
[ ]cowboy 0.5.0-rmq3.3.4-git4b93c2d
[ ]eldap 3.3.4-gite309de4
[ ]mochiweb 2.7.0-rmq3.3.4-git680dba8
[ ]rabbitmq_amqp1_0 3.3.4
[ ] rabbitmq_auth_backend_ldap 3.3.4
[ ] rabbitmq_auth_mechanism_ssl 3.3.4
[ ] rabbitmq_consistent_hash_exchange 3.3.4
[ ]rabbitmq_federation 3.3.4
[ ] rabbitmq_federation_management 3.3.4
[ ]rabbitmq_management 3.3.4
[ ] rabbitmq_management_agent 3.3.4
[ ] rabbitmq_management_visualiser 3.3.4
[ ]rabbitmq_mqtt 3.3.4
[ ]rabbitmq_shovel 3.3.4
[ ] rabbitmq_shovel_management 3.3.4
[ ] rabbitmq_stomp 3.3.4
[ ]rabbitmq_test 3.3.4
[ ]rabbitmq_tracing 3.3.4
[ ]rabbitmq_web_dispatch 3.3.4
[ ]rabbitmq_web_stomp 3.3.4
[ ] rabbitmq_web_stomp_examples 3.3.4
[ ] sockjs 0.3.4-rmq3.3.4-git3132eb9
[ ]webmachine 1.10.3-rmq3.3.4-gite9359c7
[root@localhost sbin]#
配置開機啓動
vi /etc/rc.d/rc.local
添加
/usr/rabbitmq/sbin/rabbitmq-server start &
在另外一臺服務器上安裝rabbit時,遇到問題
/bin/sh: nc: 未找到命令
/bin/sh: zip: 未找到命令
這會致使有部分文件沒法編譯生成,因此必須先安裝這兩個命令
yum -y install zip nc unzip
遇到的問題
1.解壓rabbit安裝包後,須要新建一個目錄,與make命令中制定的文件目錄一致,可是不要直接指定爲rabbit解壓目錄,不然會出現$home$/sbin目錄爲空的狀況。
2.服務器重啓後啓動common等須要鏈接到rabbitmq的服務,發現啓動報錯,沒法啓動,
3.執行還原命令rabbitmqctlreset時報錯:
Error:mnesia_unexpectedly_running
須要執行的是:
[root@HK-210209127027 ~]# rabbitmqctlstop_app
[root@HK-210209127027 ~]# rabbitmqctlreset
[root@HK-210209127027 ~]# rabbitmqctlcluster root@HK-210209127027
經常使用命令:
查看全部隊列信息
# rabbitmqctllist_queues
關閉應用
# rabbitmqctlstop_app
啓動應用,和上述關閉命令配合使用,達到清空隊列的目的
# rabbitmqctlstart_app
清除全部隊列
# rabbitmqctl reset
更多用法及參數,能夠執行以下命令查看
# rabbitmqctl
(1)首先關閉rabbitmq: rabbitmqctl stop_app
(2)還原: rabbitmqctl reset
(3)啓動: rabbitmqctl start_app
(4)添加用戶: rabbitmqctl add_user root root
(5)設置權限:rabbitmqctl set_permissions -p / root".*" ".*" ".*"
(6)查看用戶: rabbitmqctl list_users
在單機上實現rabbitmq多實例操做:
須要修改的配置文件爲:
#vim /etc/rabbitmq/rabbitmq.config
[
{rabbit,
[
{tcp_listeners, [5672]},
{tcp_listeners,[{"127.0.0.1", 5673},{"::1", 5673}]}
]
},
{rabbitmq_management,
[
{listener, [{port, 15673},
{ip, "0.0.0.0"},
{ssl, false}
]}
]}
].
修改完成後,,若是要開啓多個實例,參照如下修改配置文件的端口,而後用下面的命令執行便可(注意應同時修改RABBITMQ_NODE_PORT的端口號):
RABBITMQ_NODE_PORT=5673RABBITMQ_NODENAME=rab /usr/rabbitmq/sbin/rabbitmq-server –detached &
以上步驟是開啓了5673端口的一個rabbitmq實例,若是再開啓一個實例,那麼再修改配置文件:
#vim /etc/rabbitmq/rabbitmq.config
[
{rabbit,
[
{tcp_listeners, [5672]}
%%{tcp_listeners, [5672]},
%%{tcp_listeners,[{"127.0.0.1", 5672},{"::1", 5672}]}
%%{tcp_listeners,[{"127.0.0.1", 5672},{"::1", 5672}]}
]
}
%%{rabbitmq_management,
%%[
%%{listener, [{port, 15673},
%% {ip, "0.0.0.0"},
%% {ssl, false}
%%]}
%%]}
].
保存退出,
執行命令:/usr/rabbitmq/sbin/rabbitmq-serverstart &便可啓動默認端口爲5672的服務。
若是須要恢復默認的啓動方式:
# /usr/rabbitmq/sbin/rabbitmq-server start &
則對應的配置文件爲:
#vim /etc/rabbitmq/rabbitmq.config
[
{rabbit,
[
{tcp_listeners, [5672]},
{tcp_listeners,[{"127.0.0.1", 5672},{"::1", 5672}]}
]
}
%%{rabbitmq_management,
%%[
%%{listener, [{port, 15673},
%% {ip, "0.0.0.0"},
%% {ssl, false}
%%]}
%%]}
].