CentOS 6.2 64bit 安装erlang及RabbitMQ Server
1、操作系统环境(CentOS 6.2 64bit)
[root@HAproxy ~]# cat /etc/issue CentOS release 6.2 (Final)
Kernel \r on an \m
[root@HAproxy ~]# cat /proc/cpuinfo |grep "clflush size"
clflush size : 64
clflush size : 64
clflush size : 64
clflush size : 64
clflush size : 64
clflush size : 64
clflush size : 64
clflush size : 64
2、安装erlang依赖的基本环境
[root@HAproxy ~]# yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
3、,并安装erlang
1、首先要先安装GCC GCC-C++ Openssl等以来模块:
yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
2、再安装ncurses模块
yum -y install ncurses-devel
yum install ncurses-devel
3、下载Erang源代码文件otp_src_R15B03-1.tar.gz文件,并对其付权限和解压文件:
chmod +x otp_src_R15B03-1.tar.gz
tar -xzvf otp_src_R15B03-1.tar.gz
mv otp_src_R15B03-1 erlang_R15B #重命名解压厚的文件
4、下面是安装erlang的重头戏,依次执行以下操作:
cd erlang_R15B/
./configure --prefix=/usr/local/erlang --with-ssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-javac //不用java编译,故去掉java避免错误
继续配置erlang软件安装环境
[root@localhost otp_src_17.1]# ./configure --prefix=/usr/local/erlang
...
checking for perl... no_perl
configure: error: Perl is required to generate v2 to v1 mib converter script
configure: error: /bin/sh '/root/software/otp_src_17.1/lib/snmp/./configure' failed for snmp/.
configure: error: /bin/sh '/root/software/otp_src_17.1/lib/configure' failed for lib
#如上,提示错误,解决方法:安装Perl
[root@localhost otp_src_17.1]# yum install perl
make && make install //编译后安装
5、配置erlang环境:
vi /etc/profile
export PATH=$PATH:/usr/local/erlang/bin
好了,现在erlang的已经配置好了,现在我们来看一下陪在结果:
# whereis erlang
erlang: /usr/local/erlang
4、测试erlang环境
[root@HAproxy ~]# erl
Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:8:8] [async-threads:10] [kernel-poll:false] Eshell V5.10.4 (abort with ^G)
1> A=12.
12
2> A.
12
3>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
[root@HAproxy ~]#
5、下载并安装rabbitmq-server
在CentOS上安装rabbitmq-server ***在 CentOS 6.4上安装python*** 注意啊,自己手动安装python2.7.5,不要动系统上面其他的版本 1,先安装GCC,用如下命令yum install gcc gcc-c++ yum install zlib yum install zlib-devel 2,下载python-2.7.5.tar.gz文件,修改文件权限chmode +x python-7.5.tar.gz 3,解压tar文件,tar -xzvf python-2.7.5.tar.gz 4,cd python-2.7.5 vim Python-2.7.5/Modules/Setup.dist ./configure --prefix=/usr/local/python27 --with-zlib=/usr/include make && make install 5、建立软连接,使系统默认的python指向python27 mv /usr/bin/python /usr/bin/python2.6.6.old ln -s /usr/local/bin/python27 /usr/bin/python 已经安装完成python的安装或升级的全部操作了,我们再来看一下现在的python的版本: # python -V Python 2.7.5 虽然现在python已经安装完成,但是使用yum命令会有问题 yum不能正常工作: 这是因为yum默认使用的python版本是2.6.6,到哪是现在的python版本是2.7.5,故会出现上述问题,只需要该一下yum的默认python配置版本就行了: #vi /usr/bin/yum 将文件头部的#!/usr/bin/python改为 #!/usr/bin/python2.6 ***在 CentOS 6.4上安装Erlang*** 在本节中,我们将来学习如何在CentOS 6.4上安装erlang,具体的Erlang版本是R16B02。 在安装之前,需要先要安装一些其他的软件,否则在安装中间会出现一些由于没有其依赖的软件模块而失败。 1、首先要先安装GCC GCC-C++ Openssl等以来模块: yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel 2、再安装ncurses模块 yum -y install ncurses-devel yum install ncurses-devel 3、下载Erang源代码文件文件,并对其付权限和解压文件: wget http://www.erlang.org/download/otp_src_R16B02.tar.gz chmod +x otp_src_R16B02.tar.gz tar -xzvf otp_src_R16B02.tar.gz mv otp_src_R16B02 erlang_R16B #重命名解压厚的文件 4、下面是安装erlang的重头戏,依次执行以下操作: cd erlang_R16B/ ./configure --prefix=/usr/local/erlang --with-ssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-javac //不用java编译,故去掉java避免错误 make && make install //编译后安装 5、配置erlang环境: vi /etc/profile ERL_HOME=/usr/local/erlang export PATH=$$PATH:$$ERL_HOME/bin 好了,现在erlang的已经配置好了,现在我们来测试一下是否安装成功,在控制台输入命令erl,如果在erlang shell里出现下图所示就说明安装成功了: 此处省略截图了... *** 在CentOS上安装rabbitmq-server-3.1.5 *** 在本节中我们来看一下如何在CentOS上安装RabbitMQ。我们使用的rabbitmq的版本是rabbitmq-server-3.1.5.tar.gz,CentOS的版本是CentOS 6.4。 在安装rabbitmq之前需要先安装python和erlang,这两部分的安装过程请参看在 CentOS 6.4上安装python和在 CentOS 6.4上安装Erlang,这里不再赘述。 安装rabbitmq的具体步骤如下: 1、下载rabbitmq-server-3.1.5.tar.gz文件,并解压之: #cd /usr/local #wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.1.5/rabbitmq-server-3.1.5.tar.gz #chmod +x rabbitmq-server-3.1.5.tar.gz #tar -xzvf rabbitmq-server-3.1.5.tar.gz 2、在编译rabbitmq源码之前先要安装其需要以来包: #yum -y install xmlto 否则会编译不通过: /bin/sh: line 1: xmlto: command not found 3、开始编译源代码: #cd rabbitmq-server-3.1.5 #make #make install TARGET_DIR=/opt/mq/rabbitmq SBIN_DIR=/opt/mq/rabbitmq/sbin MAN_DIR=/opt/mq/rabbitmq/man //将rabbitmq编译到/opt/mq/rabbitmq目录 4、安装web插件管理界面 #cd /opt/mq/rabbitmq/sbin #mkdir /etc/rabbitmq/
#rabbitmq-plugins enable rabbitmq_management 5、好了,到这里rabbitmq已经配置好了,可以启动了: #./rabbitmq-server start & 我运行的时候报错了,ERROR: epmd error for 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 0 0.0.0.0:15672 0.0.0.0:* LISTEN 30435/beam.smp tcp 0 0 0.0.0.0:55672 0.0.0.0:* LISTEN 30435/beam.smp tcp 0 0 :::5672 :::* LISTEN 30435/beam.smp 如果看到下面的信息就表明已经启动成功了: 省略截图.... 最好我们就可以在浏览器上输入http://127.0.0.1:15672/登录管理界面了 使用登录的名户名和密码默认都算guest,登录后的页面如下:
6、启动rabbitmq-server
[root@HAproxy ~]# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server:
FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
[root@HAproxy ~]# cat /var/log/rabbitmq/startup_err
[root@HAproxy ~]# cat /var/log/rabbitmq/startup_log
ERROR: epmd error for host HAproxy: address (cannot connect to host/port)
[root@HAproxy ~]# hostname
HAproxy
[root@HAproxy ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=HAproxy [root@HAproxy ~]# cat /etc/hosts
127.0.0.1 localhost
127.0.0.1 HAproxy
::1 localhost
7、以上操作排除了因为主机名不同导致RabbitMQ-Server启动报错的问题,请修改主机名(参见上述步骤),再次启动RabbitMQ-Server
[root@HAproxy ~]# /etc/init.d/rabbitmq-server restart
Restarting rabbitmq-server: RabbitMQ is not running
FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
8、结果同样报错,查看错误的日志:
[root@HAproxy ~]# cat /var/log/rabbitmq/startup_log
RabbitMQ 3.3.0. Copyright (C) 2007-2013 GoPivotal, Inc.
## ## Licensed under the MPL. See http://www.rabbitmq.com/
## ##
########## Logs: /var/log/rabbitmq/rabbit@HAproxy.log
###### ## /var/log/rabbitmq/rabbit@HAproxy-sasl.log
##########
Starting broker... BOOT FAILED
=========== Error description:
{case_clause,
{error,
{{shutdown,
{failed_to_start_child,tcp_listener,
{cannot_listen,{0,0,0,0,0,0,0,0},5672,eaddrinuse}}},
{child,undefined,'rabbit_tcp_listener_sup_:::5672',
{tcp_listener_sup,start_link,
[{0,0,0,0,0,0,0,0},
5672,
[inet6,binary,
{packet,raw},
{reuseaddr,true},
{backlog,128},
{nodelay,true},
{linger,{true,0}},
{exit_on_close,false}],
{rabbit_networking,tcp_listener_started,[amqp]},
{rabbit_networking,tcp_listener_stopped,[amqp]},
{rabbit_networking,start_client,[]},
"TCP Listener"]},
transient,infinity,supervisor,
[tcp_listener_sup]}}}} Log files (may contain more information):
/var/log/rabbitmq/rabbit@HAproxy.log
/var/log/rabbitmq/rabbit@HAproxy-sasl.log Stack trace:
[{rabbit_networking,start_listener0,4,[]},
{rabbit_networking,'-start_listener/4-lc$^0/1-0-',4,[]},
{rabbit_networking,start_listener,4,[]},
{rabbit_networking,'-boot_tcp/0-lc$^0/1-0-',1,[]},
{rabbit_networking,boot_tcp,0,[]},
{rabbit_networking,boot,0,[]},
{rabbit,'-run_boot_step/1-lc$^1/1-1-',1,[]},
{rabbit,run_boot_step,1,[]}] BOOT FAILED
=========== Error description:
{could_not_start,rabbit,
{bad_return,
{{rabbit,start,[normal,[]]},
{'EXIT',
{rabbit,failure_during_boot,
{case_clause,
{error,
{{shutdown,
{failed_to_start_child,tcp_listener,
{cannot_listen,{0,0,0,0,0,0,0,0},5672,eaddrinuse}}},
{child,undefined,'rabbit_tcp_listener_sup_:::5672',
{tcp_listener_sup,start_link,
[{0,0,0,0,0,0,0,0},
5672,
[inet6,binary,
{packet,raw},
{reuseaddr,true},
{backlog,128},
{nodelay,true},
{linger,{true,0}},
{exit_on_close,false}],
{rabbit_networking,tcp_listener_started,[amqp]},
{rabbit_networking,tcp_listener_stopped,[amqp]},
{rabbit_networking,start_client,[]},
"TCP Listener"]},
transient,infinity,supervisor,
[tcp_listener_sup]}}}}}}}}} Log files (may contain more information):
/var/log/rabbitmq/rabbit@HAproxy.log
/var/log/rabbitmq/rabbit@HAproxy-sasl.log {"init terminating in do_boot",{rabbit,failure_during_boot,{could_not_start,rabb use,{error,{{shutdown,{failed_to_start_child,tcp_listener,{cannot_listen,{0,0,0, stener_sup,start_link,[{0,0,0,0,0,0,0,0},5672,[inet6,binary,{packet,raw},{reusea networking,tcp_listener_started,[amqp]},{rabbit_networking,tcp_listener_stopped, or,[tcp_listener_sup]}}}}}}}}}}}
tail: /var/log/rabbitmq/startup_log: file truncated [FAILED] [root@HAproxy ~]# cat /var/log/rabbitmq/startup_err Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
9、出现如上的错误,可能是因为5672端口已经被占用的原因。
查看5672端口的情况,如果有进程占用此端口,请将它关闭后,重新启动RabbitMQ-Server;
[root@HAproxy ~]# netstat -atn |grep 5672
tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN
[root@HAproxy ~]# lsof -i:5672
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
qpidd 1901 qpidd 10u IPv4 13941 0t0 TCP *:amqp (LISTEN)
[root@HAproxy ~]# chkconfig qpidd off
[root@HAproxy ~]# netstat -atn |grep 5672
tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN
[root@HAproxy ~]# chkconfig qpidd --list
qpidd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@HAproxy ~]# /etc/init.d/qpidd stop
Stopping Qpid AMQP daemon: [ OK ]
[root@HAproxy ~]# netstat -atn |grep 5672
tcp 0 0 127.0.0.1:25672 127.0.0.1:60925 TIME_WAIT
[root@HAproxy ~]# lsof -i:5672
[root@HAproxy ~]# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server: SUCCESS
rabbitmq-server.
10、查看RabbitMQ服务启动的状态,并开启RabbitMQ的相应管理插件:
[root@HAproxy ~]# rabbitmqctl status
Status of node rabbit@HAproxy ...
[{pid,716},
{running_applications,[{rabbit,"RabbitMQ","3.3.0"},
{os_mon,"CPO CXC 138 46","2.2.14"},
{mnesia,"MNESIA CXC 138 12","4.11"},
{xmerl,"XML parser","1.3.5"},
{sasl,"SASL CXC 138 11","2.3.4"},
{stdlib,"ERTS CXC 138 10","1.19.4"},
{kernel,"ERTS CXC 138 10","2.16.4"}]},
{os,{unix,linux}},
{erlang_version,"Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:8:8] [async-threads:30] [kernel-poll:true]\n"},
{memory,[{total,36436456},
{connection_procs,2704},
{queue_procs,5408},
{plugins,0},
{other_proc,13704576},
{mnesia,60240},
{mgmt_db,0},
{msg_index,24368},
{other_ets,789624},
{binary,13672},
{code,16399491},
{atom,594537},
{other_system,4841836}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,6690450636},
{disk_free_limit,50000000},
{disk_free,47402364928},
{file_descriptors,[{total_limit,924},
{total_used,3},
{sockets_limit,829},
{sockets_used,1}]},
{processes,[{limit,1048576},{used,131}]},
{run_queue,0},
{uptime,83}]
...done. [root@HAproxy ~]# netstat -atn |grep 5672
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN
tcp 0 0 :::5672 :::* LISTEN
[root@HAproxy ~]# lsof -i:5672
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 716 rabbitmq 15u IPv6 1948888 0t0 TCP *:amqp (LISTEN)
[root@HAproxy ~]# rabbitmq-plugins list
[ ] amqp_client 3.3.0
[ ] cowboy 0.5.0-rmq3.3.0-git4b93c2d
[ ] eldap 3.3.0-gite309de4
[ ] mochiweb 2.7.0-rmq3.3.0-git680dba8
[ ] rabbitmq_amqp1_0 3.3.0
[ ] rabbitmq_auth_backend_ldap 3.3.0
[ ] rabbitmq_auth_mechanism_ssl 3.3.0
[ ] rabbitmq_consistent_hash_exchange 3.3.0
[ ] rabbitmq_federation 3.3.0
[ ] rabbitmq_federation_management 3.3.0
[ ] rabbitmq_management 3.3.0
[ ] rabbitmq_management_agent 3.3.0
[ ] rabbitmq_management_visualiser 3.3.0
[ ] rabbitmq_mqtt 3.3.0
[ ] rabbitmq_shovel 3.3.0
[ ] rabbitmq_shovel_management 3.3.0
[ ] rabbitmq_stomp 3.3.0
[ ] rabbitmq_tracing 3.3.0
[ ] rabbitmq_web_dispatch 3.3.0
[ ] rabbitmq_web_stomp 3.3.0
[ ] rabbitmq_web_stomp_examples 3.3.0
[ ] sockjs 0.3.4-rmq3.3.0-git3132eb9
[ ] webmachine 1.10.3-rmq3.3.0-gite9359c7
[root@HAproxy ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
mochiweb
webmachine
rabbitmq_web_dispatch
amqp_client
rabbitmq_management_agent
rabbitmq_management
Plugin configuration has changed. Restart RabbitMQ for changes to take effect.
[root@HAproxy ~]# rabbitmq-plugins enable mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_m anagement_agent rabbitmq_management
Plugin configuration unchanged.
[root@HAproxy ~]# rabbitmq-plugins list
[E] amqp_client 3.3.0
[ ] cowboy 0.5.0-rmq3.3.0-git4b93c2d
[ ] eldap 3.3.0-gite309de4
[E] mochiweb 2.7.0-rmq3.3.0-git680dba8
[ ] rabbitmq_amqp1_0 3.3.0
[ ] rabbitmq_auth_backend_ldap 3.3.0
[ ] rabbitmq_auth_mechanism_ssl 3.3.0
[ ] rabbitmq_consistent_hash_exchange 3.3.0
[ ] rabbitmq_federation 3.3.0
[ ] rabbitmq_federation_management 3.3.0
[E] rabbitmq_management 3.3.0
[E] rabbitmq_management_agent 3.3.0
[ ] rabbitmq_management_visualiser 3.3.0
[ ] rabbitmq_mqtt 3.3.0
[ ] rabbitmq_shovel 3.3.0
[ ] rabbitmq_shovel_management 3.3.0
[ ] rabbitmq_stomp 3.3.0
[ ] rabbitmq_tracing 3.3.0
[E] rabbitmq_web_dispatch 3.3.0
[ ] rabbitmq_web_stomp 3.3.0
[ ] rabbitmq_web_stomp_examples 3.3.0
[ ] sockjs 0.3.4-rmq3.3.0-git3132eb9
[E] webmachine 1.10.3-rmq3.3.0-gite9359c7
[root@HAproxy ~]# rabbitmq-plugins list
[E] amqp_client 3.3.0
[ ] cowboy 0.5.0-rmq3.3.0-git4b93c2d
[ ] eldap 3.3.0-gite309de4
[E] mochiweb 2.7.0-rmq3.3.0-git680dba8
[ ] rabbitmq_amqp1_0 3.3.0
[ ] rabbitmq_auth_backend_ldap 3.3.0
[ ] rabbitmq_auth_mechanism_ssl 3.3.0
[ ] rabbitmq_consistent_hash_exchange 3.3.0
[ ] rabbitmq_federation 3.3.0
[ ] rabbitmq_federation_management 3.3.0
[E] rabbitmq_management 3.3.0
[E] rabbitmq_management_agent 3.3.0
[ ] rabbitmq_management_visualiser 3.3.0
[ ] rabbitmq_mqtt 3.3.0
[ ] rabbitmq_shovel 3.3.0
[ ] rabbitmq_shovel_management 3.3.0
[ ] rabbitmq_stomp 3.3.0
[ ] rabbitmq_tracing 3.3.0
[E] rabbitmq_web_dispatch 3.3.0
[ ] rabbitmq_web_stomp 3.3.0
[ ] rabbitmq_web_stomp_examples 3.3.0
[ ] sockjs 0.3.4-rmq3.3.0-git3132eb9
[E] webmachine 1.10.3-rmq3.3.0-gite9359c7
[root@HAproxy ~]# netstat -atn |grep 5672
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN
tcp 0 0 :::5672 :::* LISTEN
[root@HAproxy ~]# netstat -atn |grep 15672
[root@HAproxy ~]# netstat -atn |grep 55672
[root@HAproxy ~]# /etc/init.d/rabbitmq-server restart
Restarting rabbitmq-server: SUCCESS
rabbitmq-server.
[root@HAproxy ~]# netstat -atn |grep 55672
[root@HAproxy ~]# netstat -atn |grep 5672
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:54463 127.0.0.1:25672 TIME_WAIT
tcp 0 0 127.0.0.1:60321 127.0.0.1:25672 TIME_WAIT
tcp 0 0 127.0.0.1:25672 127.0.0.1:56750 TIME_WAIT
tcp 0 0 :::5672 :::* LISTEN 就可以用guest,guest登陆http://192.168.1.101:15672端口了。
注意:如果此时你从端口15672或55672登陆不了,请关闭CentOS6.2的防火墙,再次登陆,
如果仍然出现无法登陆的想象,查看日志后,显示:
=ERROR REPORT==== 20-Apr-2014::00:55:15 ===
webmachine error: path="api/whoami"
"Unauthorized"
那么请运行如下的命令,增加用户admin,密码admin即可。
[root@HAproxy ~]# rabbitmqctl add_user admin admin
Creating user "admin" ...
...done.
[root@HAproxy ~]# rabbitmqctl list_users
Listing users ...
admin []
guest [administrator]
...done.
[root@HAproxy ~]# rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...
...done.
[root@HAproxy ~]# rabbitmqctl list_users
Listing users ...
admin [administrator]
guest [administrator]
...done.
到此,配置完成