首页  »   Erlang

64位 CentOS 6.2 装配erlang及rabbitmq Server

网友分享于:2013-07-14  浏览:0次
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

[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/rabbit@leekwen.log
  ######  ##        /var/log/rabbitmq/rabbit@leekwen-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@leekwen.log
   /var/log/rabbitmq/rabbit@leekwen-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@leekwen.log
   /var/log/rabbitmq/rabbit@leekwen-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@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.
到此,配置完成。

相关解决方案

最新解决方案