标签:
CentOS 6.2 64bit 安装erlang及RabbitMQ Server
1、操作系统环境(CentOS 6.2 64bit)
1 [root@HAproxy ~]# cat /etc/issue 2 3 CentOS release 6.2 (Final) 4 Kernel \r on an \m 5 [root@HAproxy ~]# cat /proc/cpuinfo |grep "clflush size" 6 clflush size : 64 7 clflush size : 64 8 clflush size : 64 9 clflush size : 64 10 clflush size : 64 11 clflush size : 64 12 clflush size : 64 13 clflush size : 64
2、安装erlang依赖的基本环境
[root@HAproxy ~]# yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
3、导入erlang源,并安装erlang
1 [root@HAproxy ~]# rpm --import http://binaries.erlang-solutions.com/debian/erlang_solutions.asc 2 3 [root@HAproxy ~]# wget -O /etc/yum.repos.d/erlang_solutions.repo http://binaries.erlang-solutions.com/rpm/centos/erlang_solutions.repo 4 5 --2014-04-09 22:29:49-- http://binaries.erlang-solutions.com/rpm/centos/erlang_solutions.repo 6 7 Resolving binaries.erlang-solutions.com... 46.235.224.136 8 9 Connecting to binaries.erlang-solutions.com|46.235.224.136|:80... connected. 10 11 HTTP request sent, awaiting response... 301 Moved Permanently 12 13 Location: http://packages.erlang-solutions.com//rpm/centos/erlang_solutions.repo [following] 14 15 --2014-04-09 22:29:56-- http://packages.erlang-solutions.com//rpm/centos/erlang_solutions.repo 16 17 Resolving packages.erlang-solutions.com... 31.172.186.53 18 19 Connecting to packages.erlang-solutions.com|31.172.186.53|:80... connected. 20 21 HTTP request sent, awaiting response... 200 OK 22 23 Length: 245 24 25 Saving to: /etc/yum.repos.d/erlang_solutions.repo 26 27 28 100%[=================================================================================>] 245 --.-K/s in 0s 29 30 31 2014-04-09 22:30:09 (34.0 MB/s) - /etc/yum.repos.d/erlang_solutions.repo 32 33 [root@HAproxy ~]# wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm 34 35 Resolving tree.repoforge.org... 78.46.17.228 36 37 Connecting to tree.repoforge.org|78.46.17.228|:80... connected. 38 39 HTTP request sent, awaiting response... 301 Moved Permanently 40 41 Location: http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm [following] 42 43 --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 44 45 Resolving apt.sw.be... 193.1.193.67 46 47 Connecting to apt.sw.be|193.1.193.67|:80... connected. 48 49 HTTP request sent, awaiting response... 200 OK 50 51 Length: 12700 (12K) [application/x-redhat-package-manager] 52 53 Saving to: rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm 54 55 56 57 100%[=================================================================================>] 12,700 4.80K/s in 2.6s 58 59 60 61 2014-04-09 22:31:07 (4.80 KB/s) - rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm 62 63 64 65 [root@HAproxy ~]# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt 66 67 [root@HAproxy ~]# rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm 68 69 [root@HAproxy ~]# yum update 70 71 [root@HAproxy ~]# yum update --skip-broken 72 73 [root@HAproxy ~]# yum install erlang
4、测试erlang环境
1 [root@HAproxy ~]# erl 2 Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:8:8] [async-threads:10] [kernel-poll:false] 3 4 Eshell V5.10.4 (abort with ^G) 5 1> A=12. 6 12 7 2> A. 8 12 9 3> 10 BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded 11 (v)ersion (k)ill (D)b-tables (d)istribution 12 [root@HAproxy ~]#
5、下载并安装rabbitmq-server
1 [root@HAproxy ~]# wget -c http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.0/rabbitmq-server-3.3.0-1.noarch.rpm 2 --2014-04-10 16:44:24-- 3 http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.0/rabbitmq-server-3.3.0-1.noarch.rpm 4 Resolving www.rabbitmq.com... 192.240.153.117 5 Connecting to www.rabbitmq.com|192.240.153.117|:80... connected. 6 HTTP request sent, awaiting response... 200 OK 7 Length: 3869384 (3.7M) [application/x-redhat-package-manager] 8 Saving to: “rabbitmq-server-3.3.0-1.noarch.rpm” 9 10 100%[======================================>] 3,869,384 11.9K/s in 5m 37s 11 12 2014-04-10 16:50:10 (11.2 KB/s) - “rabbitmq-server-3.3.0-1.noarch.rpm” saved [3869384/3869384] 13 14 [root@HAproxy ~]# yum install rabbitmq-server-3.3.0-1.noarch.rpm 15 Loaded plugins: fastestmirror, security 16 Loading mirror speeds from cached hostfile 17 * base: centos.ustc.edu.cn 18 * extras: centos.ustc.edu.cn 19 * rpmforge: ftp.riken.jp 20 * updates: centos.ustc.edu.cn 21 Setting up Install Process 22 Examining rabbitmq-server-3.3.0-1.noarch.rpm: rabbitmq-server-3.3.0-1.noarch 23 Marking rabbitmq-server-3.3.0-1.noarch.rpm to be installed 24 Resolving Dependencies 25 --> Running transaction check 26 ---> Package rabbitmq-server.noarch 0:3.3.0-1 will be installed 27 --> Finished Dependency Resolution 28 29 Dependencies Resolved 30 31 ================================================================================ 32 Package Arch Version Repository Size 33 ================================================================================ 34 Installing: 35 rabbitmq-server noarch 3.3.0-1 /rabbitmq-server-3.3.0-1.noarch 4.3 M 36 37 Transaction Summary 38 ================================================================================ 39 Install 1 Package(s) 40 41 Total size: 4.3 M 42 Installed size: 4.3 M 43 Is this ok [y/N]: y 44 Downloading Packages: 45 Running rpm_check_debug 46 Running Transaction Test 47 Transaction Test Succeeded 48 Running Transaction 49 Installing : rabbitmq-server-3.3.0-1.noarch 1/1 50 51 Installed: 52 rabbitmq-server.noarch 0:3.3.0-1 53 54 Complete!
6、启动rabbitmq-server
1 [root@HAproxy ~]# /etc/init.d/rabbitmq-server start 2 Starting rabbitmq-server: 3 FAILED - check /var/log/rabbitmq/startup_{log, _err} 4 rabbitmq-server. 5 [root@HAproxy ~]# cat /var/log/rabbitmq/startup_err 6 [root@HAproxy ~]# cat /var/log/rabbitmq/startup_log 7 ERROR: epmd error for host HAproxy: address (cannot connect to host/port) 8 [root@HAproxy ~]# hostname 9 HAproxy 10 [root@HAproxy ~]# vi /etc/sysconfig/network 11 NETWORKING=yes 12 HOSTNAME=HAproxy13 [root@HAproxy ~]# cat /etc/hosts 14 127.0.0.1 localhost 15 127.0.0.1 HAproxy 16 ::1 localhost
7、以上操作排除了因为主机名不同导致RabbitMQ-Server启动报错的问题,请修改主机名(参见上述步骤),再次启动RabbitMQ-Server
1 [root@HAproxy ~]# /etc/init.d/rabbitmq-server restart 2 Restarting rabbitmq-server: RabbitMQ is not running 3 FAILED - check /var/log/rabbitmq/startup_{log, _err} 4 rabbitmq-server.
8、结果同样报错,查看错误的日志:
1 [root@HAproxy ~]# cat /var/log/rabbitmq/startup_log 2 RabbitMQ 3.3.0. Copyright (C) 2007-2013 GoPivotal, Inc. 3 ## ## Licensed under the MPL. See http://www.rabbitmq.com/ 4 ## ## 5 ########## Logs: /var/log/rabbitmq/rabbit@HAproxy.log 6 ###### ## /var/log/rabbitmq/rabbit@HAproxy-sasl.log 7 ########## 8 Starting broker... 9 10 BOOT FAILED 11 =========== 12 13 Error description: 14 {case_clause, 15 {error, 16 {{shutdown, 17 {failed_to_start_child,tcp_listener, 18 {cannot_listen,{0,0,0,0,0,0,0,0},5672,eaddrinuse}}}, 19 {child,undefined,‘rabbit_tcp_listener_sup_:::5672‘, 20 {tcp_listener_sup,start_link, 21 [{0,0,0,0,0,0,0,0}, 22 5672, 23 [inet6,binary, 24 {packet,raw}, 25 {reuseaddr,true}, 26 {backlog,128}, 27 {nodelay,true}, 28 {linger,{true,0}}, 29 {exit_on_close,false}], 30 {rabbit_networking,tcp_listener_started,[amqp]}, 31 {rabbit_networking,tcp_listener_stopped,[amqp]}, 32 {rabbit_networking,start_client,[]}, 33 "TCP Listener"]}, 34 transient,infinity,supervisor, 35 [tcp_listener_sup]}}}} 36 37 Log files (may contain more information): 38 /var/log/rabbitmq/rabbit@HAproxy.log 39 /var/log/rabbitmq/rabbit@HAproxy-sasl.log 40 41 Stack trace: 42 [{rabbit_networking,start_listener0,4,[]}, 43 {rabbit_networking,‘-start_listener/4-lc$^0/1-0-‘,4,[]}, 44 {rabbit_networking,start_listener,4,[]}, 45 {rabbit_networking,‘-boot_tcp/0-lc$^0/1-0-‘,1,[]}, 46 {rabbit_networking,boot_tcp,0,[]}, 47 {rabbit_networking,boot,0,[]}, 48 {rabbit,‘-run_boot_step/1-lc$^1/1-1-‘,1,[]}, 49 {rabbit,run_boot_step,1,[]}] 50 51 52 53 BOOT FAILED 54 =========== 55 56 Error description: 57 {could_not_start,rabbit, 58 {bad_return, 59 {{rabbit,start,[normal,[]]}, 60 {‘EXIT‘, 61 {rabbit,failure_during_boot, 62 {case_clause, 63 {error, 64 {{shutdown, 65 {failed_to_start_child,tcp_listener, 66 {cannot_listen,{0,0,0,0,0,0,0,0},5672,eaddrinuse}}}, 67 {child,undefined,‘rabbit_tcp_listener_sup_:::5672‘, 68 {tcp_listener_sup,start_link, 69 [{0,0,0,0,0,0,0,0}, 70 5672, 71 [inet6,binary, 72 {packet,raw}, 73 {reuseaddr,true}, 74 {backlog,128}, 75 {nodelay,true}, 76 {linger,{true,0}}, 77 {exit_on_close,false}], 78 {rabbit_networking,tcp_listener_started,[amqp]}, 79 {rabbit_networking,tcp_listener_stopped,[amqp]}, 80 {rabbit_networking,start_client,[]}, 81 "TCP Listener"]}, 82 transient,infinity,supervisor, 83 [tcp_listener_sup]}}}}}}}}} 84 85 Log files (may contain more information): 86 /var/log/rabbitmq/rabbit@HAproxy.log 87 /var/log/rabbitmq/rabbit@HAproxy-sasl.log 88 89 {"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]}}}}}}}}}}} 90 tail: /var/log/rabbitmq/startup_log: file truncated [FAILED] 91 92 93 [root@HAproxy ~]# cat /var/log/rabbitmq/startup_err 94 95 Crash dump was written to: erl_crash.dump 96 init terminating in do_boot ()
9、出现如上的错误,可能是因为5672端口已经被占用的原因。
查看5672端口的情况,如果有进程占用此端口,请将它关闭后,重新启动RabbitMQ-Server;
1 [root@HAproxy ~]# netstat -atn |grep 5672 2 tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN 3 [root@HAproxy ~]# lsof -i:5672 4 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 5 qpidd 1901 qpidd 10u IPv4 13941 0t0 TCP *:amqp (LISTEN) 6 [root@HAproxy ~]# chkconfig qpidd off 7 [root@HAproxy ~]# netstat -atn |grep 5672 8 tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN 9 [root@HAproxy ~]# chkconfig qpidd --list 10 qpidd 0:off 1:off 2:off 3:off 4:off 5:off 6:off 11 [root@HAproxy ~]# /etc/init.d/qpidd stop 12 Stopping Qpid AMQP daemon: [ OK ] 13 [root@HAproxy ~]# netstat -atn |grep 5672 14 tcp 0 0 127.0.0.1:25672 127.0.0.1:60925 TIME_WAIT 15 [root@HAproxy ~]# lsof -i:5672 16 [root@HAproxy ~]# /etc/init.d/rabbitmq-server start 17 Starting rabbitmq-server: SUCCESS 18 rabbitmq-server.
10、查看RabbitMQ服务启动的状态,并开启RabbitMQ的相应管理插件:
1 [root@HAproxy ~]# rabbitmqctl status 2 Status of node rabbit@HAproxy ... 3 [{pid,716}, 4 {running_applications,[{rabbit,"RabbitMQ","3.3.0"}, 5 {os_mon,"CPO CXC 138 46","2.2.14"}, 6 {mnesia,"MNESIA CXC 138 12","4.11"}, 7 {xmerl,"XML parser","1.3.5"}, 8 {sasl,"SASL CXC 138 11","2.3.4"}, 9 {stdlib,"ERTS CXC 138 10","1.19.4"}, 10 {kernel,"ERTS CXC 138 10","2.16.4"}]}, 11 {os,{unix,linux}}, 12 {erlang_version,"Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:8:8] [async-threads:30] [kernel-poll:true]\n"}, 13 {memory,[{total,36436456}, 14 {connection_procs,2704}, 15 {queue_procs,5408}, 16 {plugins,0}, 17 {other_proc,13704576}, 18 {mnesia,60240}, 19 {mgmt_db,0}, 20 {msg_index,24368}, 21 {other_ets,789624}, 22 {binary,13672}, 23 {code,16399491}, 24 {atom,594537}, 25 {other_system,4841836}]}, 26 {alarms,[]}, 27 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]}, 28 {vm_memory_high_watermark,0.4}, 29 {vm_memory_limit,6690450636}, 30 {disk_free_limit,50000000}, 31 {disk_free,47402364928}, 32 {file_descriptors,[{total_limit,924}, 33 {total_used,3}, 34 {sockets_limit,829}, 35 {sockets_used,1}]}, 36 {processes,[{limit,1048576},{used,131}]}, 37 {run_queue,0}, 38 {uptime,83}] 39 ...done. 40 41 [root@HAproxy ~]# netstat -atn |grep 5672 42 tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 43 tcp 0 0 :::5672 :::* LISTEN 44 [root@HAproxy ~]# lsof -i:5672 45 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 46 beam.smp 716 rabbitmq 15u IPv6 1948888 0t0 TCP *:amqp (LISTEN) 47 [root@HAproxy ~]# rabbitmq-plugins list 48 [ ] amqp_client 3.3.0 49 [ ] cowboy 0.5.0-rmq3.3.0-git4b93c2d 50 [ ] eldap 3.3.0-gite309de4 51 [ ] mochiweb 2.7.0-rmq3.3.0-git680dba8 52 [ ] rabbitmq_amqp1_0 3.3.0 53 [ ] rabbitmq_auth_backend_ldap 3.3.0 54 [ ] rabbitmq_auth_mechanism_ssl 3.3.0 55 [ ] rabbitmq_consistent_hash_exchange 3.3.0 56 [ ] rabbitmq_federation 3.3.0 57 [ ] rabbitmq_federation_management 3.3.0 58 [ ] rabbitmq_management 3.3.0 59 [ ] rabbitmq_management_agent 3.3.0 60 [ ] rabbitmq_management_visualiser 3.3.0 61 [ ] rabbitmq_mqtt 3.3.0 62 [ ] rabbitmq_shovel 3.3.0 63 [ ] rabbitmq_shovel_management 3.3.0 64 [ ] rabbitmq_stomp 3.3.0 65 [ ] rabbitmq_tracing 3.3.0 66 [ ] rabbitmq_web_dispatch 3.3.0 67 [ ] rabbitmq_web_stomp 3.3.0 68 [ ] rabbitmq_web_stomp_examples 3.3.0 69 [ ] sockjs 0.3.4-rmq3.3.0-git3132eb9 70 [ ] webmachine 1.10.3-rmq3.3.0-gite9359c7 71 [root@HAproxy ~]# rabbitmq-plugins enable rabbitmq_management 72 The following plugins have been enabled: 73 mochiweb 74 webmachine 75 rabbitmq_web_dispatch 76 amqp_client 77 rabbitmq_management_agent 78 rabbitmq_management 79 Plugin configuration has changed. Restart RabbitMQ for changes to take effect. 80 [root@HAproxy ~]# rabbitmq-plugins enable mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_m anagement_agent rabbitmq_management 81 Plugin configuration unchanged. 82 [root@HAproxy ~]# rabbitmq-plugins list 83 [E] amqp_client 3.3.0 84 [ ] cowboy 0.5.0-rmq3.3.0-git4b93c2d 85 [ ] eldap 3.3.0-gite309de4 86 [E] mochiweb 2.7.0-rmq3.3.0-git680dba8 87 [ ] rabbitmq_amqp1_0 3.3.0 88 [ ] rabbitmq_auth_backend_ldap 3.3.0 89 [ ] rabbitmq_auth_mechanism_ssl 3.3.0 90 [ ] rabbitmq_consistent_hash_exchange 3.3.0 91 [ ] rabbitmq_federation 3.3.0 92 [ ] rabbitmq_federation_management 3.3.0 93 [E] rabbitmq_management 3.3.0 94 [E] rabbitmq_management_agent 3.3.0 95 [ ] rabbitmq_management_visualiser 3.3.0 96 [ ] rabbitmq_mqtt 3.3.0 97 [ ] rabbitmq_shovel 3.3.0 98 [ ] rabbitmq_shovel_management 3.3.0 99 [ ] rabbitmq_stomp 3.3.0 100 [ ] rabbitmq_tracing 3.3.0 101 [E] rabbitmq_web_dispatch 3.3.0 102 [ ] rabbitmq_web_stomp 3.3.0 103 [ ] rabbitmq_web_stomp_examples 3.3.0 104 [ ] sockjs 0.3.4-rmq3.3.0-git3132eb9 105 [E] webmachine 1.10.3-rmq3.3.0-gite9359c7 106 [root@HAproxy ~]# rabbitmq-plugins list 107 [E] amqp_client 3.3.0 108 [ ] cowboy 0.5.0-rmq3.3.0-git4b93c2d 109 [ ] eldap 3.3.0-gite309de4 110 [E] mochiweb 2.7.0-rmq3.3.0-git680dba8 111 [ ] rabbitmq_amqp1_0 3.3.0 112 [ ] rabbitmq_auth_backend_ldap 3.3.0 113 [ ] rabbitmq_auth_mechanism_ssl 3.3.0 114 [ ] rabbitmq_consistent_hash_exchange 3.3.0 115 [ ] rabbitmq_federation 3.3.0 116 [ ] rabbitmq_federation_management 3.3.0 117 [E] rabbitmq_management 3.3.0 118 [E] rabbitmq_management_agent 3.3.0 119 [ ] rabbitmq_management_visualiser 3.3.0 120 [ ] rabbitmq_mqtt 3.3.0 121 [ ] rabbitmq_shovel 3.3.0 122 [ ] rabbitmq_shovel_management 3.3.0 123 [ ] rabbitmq_stomp 3.3.0 124 [ ] rabbitmq_tracing 3.3.0 125 [E] rabbitmq_web_dispatch 3.3.0 126 [ ] rabbitmq_web_stomp 3.3.0 127 [ ] rabbitmq_web_stomp_examples 3.3.0 128 [ ] sockjs 0.3.4-rmq3.3.0-git3132eb9 129 [E] webmachine 1.10.3-rmq3.3.0-gite9359c7 130 [root@HAproxy ~]# netstat -atn |grep 5672 131 tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 132 tcp 0 0 :::5672 :::* LISTEN 133 [root@HAproxy ~]# netstat -atn |grep 15672 134 [root@HAproxy ~]# netstat -atn |grep 55672 135 [root@HAproxy ~]# /etc/init.d/rabbitmq-server restart 136 Restarting rabbitmq-server: SUCCESS 137 rabbitmq-server. 138 [root@HAproxy ~]# netstat -atn |grep 55672 139 [root@HAproxy ~]# netstat -atn |grep 5672 140 tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 141 tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 142 tcp 0 0 127.0.0.1:54463 127.0.0.1:25672 TIME_WAIT 143 tcp 0 0 127.0.0.1:60321 127.0.0.1:25672 TIME_WAIT 144 tcp 0 0 127.0.0.1:25672 127.0.0.1:56750 TIME_WAIT 145 tcp 0 0 :::5672 :::* LISTEN 146 147 就可以用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即可。
1 [root@HAproxy ~]# rabbitmqctl add_user admin admin 2 Creating user "admin" ... 3 ...done. 4 [root@HAproxy ~]# rabbitmqctl list_users 5 Listing users ... 6 admin [] 7 guest [administrator] 8 ...done. 9 [root@HAproxy ~]# rabbitmqctl set_user_tags admin administrator 10 Setting tags for user "admin" to [administrator] ... 11 ...done. 12 [root@HAproxy ~]# rabbitmqctl list_users 13 Listing users ... 14 admin [administrator] 15 guest [administrator] 16 ...done.
到此,配置完成
64位CentOS6.2安装erlang及rabbitmqServer
标签:
原文地址:http://www.cnblogs.com/nb-blog/p/5266712.html