1. 程式人生 > >64位 CentOS 6.2 安裝erlang及rabbitmq Server

64位 CentOS 6.2 安裝erlang及rabbitmq Server

CentOS 6.2 64bit 安裝erlang及RabbitMQ Server

1、作業系統環境(CentOS 6.2 64bit)

[root@leekwen ~]# cat /etc/issue
CentOS release 6.2 (Final)
Kernel \r on an \m
[root@leekwen ~]# 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@leekwen ~]# yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel


3、匯入erlang源,並安裝erlang

[root@leekwen ~]# rpm --import http://binaries.erlang-solutions.com/debian/erlang_solutions.asc
[root@leekwen ~]# wget -O /etc/yum.repos.d/erlang_solutions.repo  http://binaries.erlang-solutions.com/rpm/centos/erlang_solutions.repo
--2014-04-09 22:29:49--  http://binaries.erlang-solutions.com/rpm/centos/erlang_solutions.repo
Resolving binaries.erlang-solutions.com... 46.235.224.136
Connecting to binaries.erlang-solutions.com|46.235.224.136|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://packages.erlang-solutions.com//rpm/centos/erlang_solutions.repo [following]
--2014-04-09 22:29:56--  http://packages.erlang-solutions.com//rpm/centos/erlang_solutions.repo
Resolving packages.erlang-solutions.com... 31.172.186.53
Connecting to packages.erlang-solutions.com|31.172.186.53|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 245
Saving to: /etc/yum.repos.d/erlang_solutions.repo

100%[=================================================================================>] 245         --.-K/s   in 0s

2014-04-09 22:30:09 (34.0 MB/s) - /etc/yum.repos.d/erlang_solutions.repo
[root@leekwen ~]# wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Resolving tree.repoforge.org... 78.46.17.228
Connecting to tree.repoforge.org|78.46.17.228|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm [following]
--2014-04-09 22:30:54--  http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Resolving apt.sw.be... 193.1.193.67
Connecting to apt.sw.be|193.1.193.67|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12700 (12K) [application/x-redhat-package-manager]
Saving to: rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

100%[=================================================================================>] 12,700      4.80K/s   in 2.6s

2014-04-09 22:31:07 (4.80 KB/s) - rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

如果上述地址丟失,可以用下面這個地址:
http://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

[root@leekwen ~]# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
[root@leekwen ~]# rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm
[root@leekwen ~]# yum update
[root@leekwen ~]# yum update --skip-broken
[root@leekwen ~]# yum install erlang

4、測試erlang環境

[root@leekwen ~]# 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
^C[root@leekwen ~]#


5、下載並安裝rabbitmq-server

[root@leekwen ~]# wget -c http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.0/rabbitmq-server-3.3.0-1.noarch.rpm
--2014-04-10 16:44:24--  
http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.0/rabbitmq-server-3.3.0-1.noarch.rpm
Resolving www.rabbitmq.com... 192.240.153.117
Connecting to www.rabbitmq.com|192.240.153.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3869384 (3.7M) [application/x-redhat-package-manager]
Saving to: “rabbitmq-server-3.3.0-1.noarch.rpm”

100%[======================================>] 3,869,384   11.9K/s   in 5m 37s

2014-04-10 16:50:10 (11.2 KB/s) - “rabbitmq-server-3.3.0-1.noarch.rpm” saved [3869384/3869384]

[root@leekwen ~]#  yum install rabbitmq-server-3.3.0-1.noarch.rpm
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * rpmforge: ftp.riken.jp
 * updates: centos.ustc.edu.cn
Setting up Install Process
Examining rabbitmq-server-3.3.0-1.noarch.rpm: rabbitmq-server-3.3.0-1.noarch
Marking rabbitmq-server-3.3.0-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package rabbitmq-server.noarch 0:3.3.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package           Arch     Version     Repository                         Size
================================================================================
Installing:
 rabbitmq-server   noarch   3.3.0-1     /rabbitmq-server-3.3.0-1.noarch   4.3 M

Transaction Summary
================================================================================
Install       1 Package(s)

Total size: 4.3 M
Installed size: 4.3 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : rabbitmq-server-3.3.0-1.noarch                               1/1

Installed:
  rabbitmq-server.noarch 0:3.3.0-1

Complete!

6、啟動rabbitmq-server

[root@leekwen ~]# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server:
FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
[root@leekwen ~]# cat /var/log/rabbitmq/startup_err
[root@leekwen ~]# cat /var/log/rabbitmq/startup_log
ERROR: epmd error for host leekwen: address (cannot connect to host/port)
[root@leekwen ~]# hostname
leekwen
[root@leekwen ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=leekwen
[root@leekwen ~]# cat /etc/hosts
127.0.0.1       localhost
127.0.0.1       leekwen
::1             localhost


7、以上操作排除了因為主機名不同導致RabbitMQ-Server啟動報錯的問題,請修改主機名(參見上述步驟),再次啟動RabbitMQ-Server

[root@leekwen ~]# /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@leekwen ~]# 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/[email protected]
  ######  ##        /var/log/rabbitmq/[email protected]
  ##########
              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/[email protected]
   /var/log/rabbitmq/[email protected]

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/[email protected]
   /var/log/rabbitmq/[email protected]

{"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@leekwen ~]# 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@leekwen ~]# netstat -atn |grep 5672
tcp        0      0 0.0.0.0:5672                0.0.0.0:*                   LISTEN
[root@leekwen ~]# lsof -i:5672
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
qpidd   1901 qpidd   10u  IPv4  13941      0t0  TCP *:amqp (LISTEN)
[root@leekwen ~]# chkconfig qpidd off
[root@leekwen ~]# netstat -atn |grep 5672
tcp        0      0 0.0.0.0:5672                0.0.0.0:*                   LISTEN
[root@leekwen ~]# chkconfig qpidd --list
qpidd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@leekwen ~]# /etc/init.d/qpidd stop
Stopping Qpid AMQP daemon:                                 [  OK  ]
[root@leekwen ~]# netstat -atn |grep 5672
tcp        0      0 127.0.0.1:25672             127.0.0.1:60925             TIME_WAIT
[root@leekwen ~]# lsof -i:5672
[root@leekwen ~]# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server: SUCCESS
rabbitmq-server.


10、檢視RabbitMQ服務啟動的狀態,並開啟RabbitMQ的相應管理外掛:

[root@leekwen ~]# rabbitmqctl status
Status of node rabbit@leekwen ...
[{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@leekwen ~]# netstat -atn |grep 5672
tcp        0      0 0.0.0.0:25672               0.0.0.0:*                   LISTEN
tcp        0      0 :::5672                     :::*                        LISTEN
[root@leekwen ~]# 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@leekwen ~]# 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@leekwen ~]# 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@leekwen ~]# rabbitmq-plugins enable mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_m                                                             anagement_agent rabbitmq_management
Plugin configuration unchanged.
[root@leekwen ~]# 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@leekwen ~]# 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@leekwen ~]# netstat -atn |grep 5672
tcp        0      0 0.0.0.0:25672               0.0.0.0:*                   LISTEN
tcp        0      0 :::5672                     :::*                        LISTEN
[root@leekwen ~]# netstat -atn |grep 15672
[root@leekwen ~]# netstat -atn |grep 55672
[root@leekwen ~]# /etc/init.d/rabbitmq-server restart
Restarting rabbitmq-server: SUCCESS
rabbitmq-server.
[root@leekwen ~]# netstat -atn |grep 55672
[root@leekwen ~]# 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@leekwen ~]# rabbitmqctl add_user admin admin
Creating user "admin" ...
...done.
[root@leekwen ~]# rabbitmqctl list_users
Listing users ...
admin   []
guest   [administrator]
...done.
[root@leekwen ~]# rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...
...done.
[root@leekwen ~]# rabbitmqctl list_users
Listing users ...
admin   [administrator]
guest   [administrator]
...done.

到此,配置完成。

文章連結如下:

將32位的修改為64位的源就可以了。這裡不再贅述。。