本文记录一次在CentOS上安装RabbitMQ的步骤,因为RabbitMQ需要使用Erlang,所以先安装Erlang,再安装RabbitMQ~
Erlang和RabbitMQ的版本信息
Erlang版本
otp_src_17.5.tar.gz
RabbitMQ版本
rabbitmq-server-generic-unix-3.5.3.tar.gz
安装包下载地址:https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.3/rabbitmq-server-generic-unix-3.5.3.tar.gz
安装Erlang
下载Erlang安装包
使用wget命令下载安装包,如:
wget http://erlang.org/download/otp_src_17.5.tar.gz
root@dev03 srv]# wget http://erlang.org/download/otp_src_17.5.tar.gz --2017-03-28 14:05:15-- http://erlang.org/download/otp_src_17.5.tar.gz Resolving erlang.org... 192.121.151.106 Connecting to erlang.org|192.121.151.106|:80... Failed: Connection timed out. Retrying. --2017-03-28 14:05:23-- (try: 2) http://erlang.org/download/otp_src_17.5.tar.gz Connecting to erlang.org|192.121.151.106|:80... connected. HTTP request sent,awaiting response... 200 OK Length: 67242289 (64M) [application/x-tar] Saving to: “otp_src_17.5.tar.gz” 100%[====================================================================================================================================================================================================================================>] 67,242,289 220K/s in 4m 59s 2017-03-28 14:10:23 (220 KB/s) - “otp_src_17.5.tar.gz” saved [67242289/67242289] [root@dev03 srv]#
解压
使用tar -zvxf命令解压,如:
tar -zvxf otp_src_17.5.tar.gz
[root@dev03 srv]# tar -zvxf otp_src_17.5.tar.gz ... ... otp_src_17.5/system/doc/reference_manual/expressions.xml otp_src_17.5/system/doc/reference_manual/data_types.xml otp_src_17.5/system/doc/reference_manual/patterns.xml otp_src_17.5/system/doc/reference_manual/distributed.xml otp_src_17.5/system/doc/reference_manual/book.xml otp_src_17.5/system/doc/reference_manual/macros.xml otp_src_17.5/system/doc/reference_manual/processes.xml otp_src_17.5/system/doc/reference_manual/part.xml otp_src_17.5/system/doc/reference_manual/xmlfiles.mk otp_src_17.5/system/doc/system_architecture_intro/ otp_src_17.5/system/doc/system_architecture_intro/Makefile otp_src_17.5/system/doc/system_architecture_intro/sys_arch_intro.xml otp_src_17.5/system/doc/system_architecture_intro/warning.gif otp_src_17.5/system/doc/system_architecture_intro/note.gif otp_src_17.5/system/doc/system_architecture_intro/book.xml otp_src_17.5/system/doc/system_architecture_intro/part.xml otp_src_17.5/system/doc/system_architecture_intro/xmlfiles.mk otp_src_17.5/system/README otp_src_17.5/system/COPYRIGHT otp_src_17.5/HOWTO/ otp_src_17.5/HOWTO/OTP-PATCH-APPLY.md otp_src_17.5/HOWTO/BOOTSTRAP.md otp_src_17.5/HOWTO/INSTALL.md otp_src_17.5/HOWTO/INSTALL-ANDROID.md otp_src_17.5/HOWTO/DTRACE.md otp_src_17.5/HOWTO/INSTALL-WIN32.md otp_src_17.5/HOWTO/BENCHMARKS.md otp_src_17.5/HOWTO/SYSTEMTAP.md otp_src_17.5/HOWTO/INSTALL-CROSS.md otp_src_17.5/HOWTO/TESTING.md otp_src_17.5/HOWTO/MARKDOWN.md otp_src_17.5/OTP_VERSION otp_src_17.5/proposed_updates.json otp_src_17.5/erl-build-tool-vars.sh otp_src_17.5/otp_build otp_src_17.5/bin/ otp_src_17.5/Makefile.in otp_src_17.5/configure [root@dev03 srv]#
configure
进入解压缩后的otp_src_17.5目录,
[root@dev03 srv]# cd otp_src_17.5 [root@dev03 otp_src_17.5]#
然后执行./configure命令
[root@dev03 otp_src_17.5]# ./configure Ignoring the --cache-file argument since it can cause the system to be erroneously configured Disabling caching checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for gcc... no checking for cc... no checking for cc... no checking for cl... no configure: error: no acceptable C compiler found in $PATH See `config.log' for more details. [root@dev03 otp_src_17.5]#
出现问题~~
[root@dev03 otp_src_17.5]# yum install make ncurses-devel gcc gcc-c++ ... ... [root@dev03 otp_src_17.5]# yum install unixODBC unixODBC-devel openssl openssl-devel
如
[root@dev03 otp_src_17.5]# yum install make ncurses-devel gcc gcc-c++ Loaded plugins: fastestmirror Setting up Install Process Loading mirror speeds from cached hostfile Package 1:make-3.81-20.el6.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package gcc.x86_64 0:4.4.7-16.el6 will be installed --> Processing Dependency: libgomp = 4.4.7-16.el6 for package: gcc-4.4.7-16.el6.x86_64 --> Processing Dependency: cpp = 4.4.7-16.el6 for package: gcc-4.4.7-16.el6.x86_64 --> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-16.el6.x86_64 --> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-16.el6.x86_64 --> Processing Dependency: libgomp.so.1()(64bit) for package: gcc-4.4.7-16.el6.x86_64 ---> Package gcc-c++.x86_64 0:4.4.7-16.el6 will be installed --> Processing Dependency: libstdc++-devel = 4.4.7-16.el6 for package: gcc-c++-4.4.7-16.el6.x86_64 --> Processing Dependency: libmpfr.so.1()(64bit) for package: gcc-c++-4.4.7-16.el6.x86_64 ---> Package ncurses-devel.x86_64 0:5.7-4.20090207.el6 will be installed --> Running transaction check ---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed --> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64 --> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64 ---> Package cpp.x86_64 0:4.4.7-16.el6 will be installed ---> Package glibc-devel.x86_64 0:2.12-1.166.el6 will be installed --> Processing Dependency: glibc-headers = 2.12-1.166.el6 for package: glibc-devel-2.12-1.166.el6.x86_64 --> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.166.el6.x86_64 ---> Package libgomp.x86_64 0:4.4.7-16.el6 will be installed ---> Package libstdc++-devel.x86_64 0:4.4.7-16.el6 will be installed ---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed --> Running transaction check ---> Package glibc-headers.x86_64 0:2.12-1.166.el6 will be installed --> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.166.el6.x86_64 --> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.166.el6.x86_64 ---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed --> Running transaction check ---> Package kernel-headers.x86_64 0:2.6.32-573.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================================================================================== Package Arch Version Repository Size ============================================================================================================================================================================================================================================================================== Installing: gcc x86_64 4.4.7-16.el6 ISO 10 M gcc-c++ x86_64 4.4.7-16.el6 ISO 4.7 M ncurses-devel x86_64 5.7-4.20090207.el6 ISO 641 k Installing for dependencies: cloog-ppl x86_64 0.15.7-1.2.el6 ISO 93 k cpp x86_64 4.4.7-16.el6 ISO 3.7 M glibc-devel x86_64 2.12-1.166.el6 ISO 985 k glibc-headers x86_64 2.12-1.166.el6 ISO 614 k kernel-headers x86_64 2.6.32-573.el6 ISO 3.9 M libgomp x86_64 4.4.7-16.el6 ISO 134 k libstdc++-devel x86_64 4.4.7-16.el6 ISO 1.6 M mpfr x86_64 2.4.1-6.el6 ISO 157 k ppl x86_64 0.10.2-11.el6 ISO 1.3 M Transaction Summary ============================================================================================================================================================================================================================================================================== Install 12 Package(s) Total download size: 28 M Installed size: 61 M Is this ok [y/N]: Is this ok [y/N]: y Downloading Packages: (1/12): kernel-headers-2.6.32-573.el6.x86_64.rpm | 3.9 MB 00:00 (2/12): ncurses-devel-5.7-4.20090207.el6.x86_64.rpm | 641 kB 00:00 (3/12): gcc-c++-4.4.7-16.el6.x86_64.rpm | 4.7 MB 00:00 (4/12): gcc-4.4.7-16.el6.x86_64.rpm | 10 MB 00:00 (5/12): libgomp-4.4.7-16.el6.x86_64.rpm | 134 kB 00:00 (6/12): mpfr-2.4.1-6.el6.x86_64.rpm | 157 kB 00:00 (7/12): glibc-headers-2.12-1.166.el6.x86_64.rpm | 614 kB 00:00 (8/12): cpp-4.4.7-16.el6.x86_64.rpm | 3.7 MB 00:00 (9/12): libstdc++-devel-4.4.7-16.el6.x86_64.rpm | 1.6 MB 00:00 (10/12): ppl-0.10.2-11.el6.x86_64.rpm | 1.3 MB 00:00 (11/12): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93 kB 00:00 (12/12): glibc-devel-2.12-1.166.el6.x86_64.rpm | 985 kB 00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 47 MB/s | 28 MB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : mpfr-2.4.1-6.el6.x86_64 1/12 Installing : cpp-4.4.7-16.el6.x86_64 2/12 Installing : ppl-0.10.2-11.el6.x86_64 3/12 Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 4/12 Installing : libstdc++-devel-4.4.7-16.el6.x86_64 5/12 Installing : libgomp-4.4.7-16.el6.x86_64 6/12 Installing : kernel-headers-2.6.32-573.el6.x86_64 7/12 Installing : glibc-headers-2.12-1.166.el6.x86_64 8/12 Installing : glibc-devel-2.12-1.166.el6.x86_64 9/12 Installing : gcc-4.4.7-16.el6.x86_64 10/12 Installing : gcc-c++-4.4.7-16.el6.x86_64 11/12 Installing : ncurses-devel-5.7-4.20090207.el6.x86_64 12/12 Verifying : kernel-headers-2.6.32-573.el6.x86_64 1/12 Verifying : ncurses-devel-5.7-4.20090207.el6.x86_64 2/12 Verifying : gcc-c++-4.4.7-16.el6.x86_64 3/12 Verifying : gcc-4.4.7-16.el6.x86_64 4/12 Verifying : libgomp-4.4.7-16.el6.x86_64 5/12 Verifying : mpfr-2.4.1-6.el6.x86_64 6/12 Verifying : glibc-headers-2.12-1.166.el6.x86_64 7/12 Verifying : cpp-4.4.7-16.el6.x86_64 8/12 Verifying : libstdc++-devel-4.4.7-16.el6.x86_64 9/12 Verifying : ppl-0.10.2-11.el6.x86_64 10/12 Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 11/12 Verifying : glibc-devel-2.12-1.166.el6.x86_64 12/12 Installed: gcc.x86_64 0:4.4.7-16.el6 gcc-c++.x86_64 0:4.4.7-16.el6 ncurses-devel.x86_64 0:5.7-4.20090207.el6 Dependency Installed: cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-16.el6 glibc-devel.x86_64 0:2.12-1.166.el6 glibc-headers.x86_64 0:2.12-1.166.el6 kernel-headers.x86_64 0:2.6.32-573.el6 libgomp.x86_64 0:4.4.7-16.el6 libstdc++-devel.x86_64 0:4.4.7-16.el6 mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6 Complete! [root@dev03 otp_src_17.5]#
然后再次执行./configure命令~
make & make install
root@dev03 otp_src_17.5]# make & make install [1] 5836 MAKE depend MAKE emulator make[1]: Entering directory `/srv/otp_src_17.5/erts' make[1]: Entering directory `/srv/otp_src_17.5/erts/emulator' MAKE generate make[2]: Entering directory `/srv/otp_src_17.5/erts/emulator' MAKE opt make[3]: Entering directory `/srv/otp_src_17.5/erts/emulator' M4 x86_64-unknown-linux-gnu/opt/smp/hipe_x86_asm.h make[2]: Entering directory `/srv/otp_src_17.5/erts/emulator' GEN x86_64-unknown-linux-gnu/gen_git_version.mk M4 x86_64-unknown-linux-gnu/opt/smp/hipe_amd64_asm.h M4 x86_64-unknown-linux-gnu/opt/smp/hipe_sparc_asm.h M4 x86_64-unknown-linux-gnu/opt/smp/hipe_ppc_asm.h M4 x86_64-unknown-linux-gnu/opt/plain/hipe_x86_asm.h M4 x86_64-unknown-linux-gnu/opt/smp/hipe_arm_asm.h M4 x86_64-unknown-linux-gnu/opt/plain/hipe_amd64_asm.h M4 x86_64-unknown-linux-gnu/opt/plain/hipe_sparc_asm.h M4 x86_64-unknown-linux-gnu/opt/plain/hipe_ppc_asm.h M4 x86_64-unknown-linux-gnu/opt/plain/hipe_arm_asm.h GEN x86_64-unknown-linux-gnu/opt/plain/erl_alloc_types.h GEN x86_64-unknown-linux-gnu/opt/smp/erl_alloc_types.h GEN x86_64-unknown-linux-gnu/opt/plain/OPCODES-GENERATED GEN x86_64-unknown-linux-gnu/opt/smp/OPCODES-GENERATED ... ... make[3]: Leaving directory `/srv/otp_src_17.5/lib/ose' === Leaving application ose make[2]: Leaving directory `/srv/otp_src_17.5/lib/ose' make[1]: Leaving directory `/srv/otp_src_17.5/lib' (cd "/usr/local/lib/erlang" \ && ./Install -minimal "/usr/local/lib/erlang") /usr/bin/install -c -m 644 "/srv/otp_src_17.5/OTP_VERSION" "/usr/local/lib/erlang/releases/17" cd /usr/local/bin rm -f erl rm -f erlc rm -f epmd rm -f run_erl rm -f to_erl rm -f dialyzer rm -f typer rm -f escript rm -f ct_run ln -s ../lib/erlang/bin/erl erl ln -s ../lib/erlang/bin/erlc erlc ln -s ../lib/erlang/bin/epmd epmd ln -s ../lib/erlang/bin/run_erl run_erl ln -s ../lib/erlang/bin/to_erl to_erl ln -s ../lib/erlang/bin/dialyzer dialyzer ln -s ../lib/erlang/bin/typer typer ln -s ../lib/erlang/bin/escript escript ln -s ../lib/erlang/bin/ct_run ct_run [root@dev03 otp_src_17.5]#
验证Erlang安装
使用erl -version来查看Erlang安装~
[root@dev03 otp_src_17.5]# erl -version Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 6.4 [root@dev03 otp_src_17.5]#
安装RabbitMQ
下载RabbitMQ安装包
使用wget的方式下载~ 如
[root@dev03 srv]# wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.3/rabbitmq-server-generic-unix-3.5.3.tar.gz
详细信息~
[root@dev03 srv]# wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.3/rabbitmq-server-generic-unix-3.5.3.tar.gz --2017-03-28 17:10:38-- https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.3/rabbitmq-server-generic-unix-3.5.3.tar.gz Resolving www.rabbitmq.com... 192.240.153.117 Connecting to www.rabbitmq.com|192.240.153.117|:443... connected. HTTP request sent,awaiting response... 200 OK Length: 4182821 (4.0M) [application/x-gzip] Saving to: “rabbitmq-server-generic-unix-3.5.3.tar.gz” 100%[====================================================================================================================================================================================================================================>] 4,182,821 89.3K/s in 83s 2017-03-28 17:12:02 (49.2 KB/s) - “rabbitmq-server-generic-unix-3.5.3.tar.gz” saved [4182821/4182821] [root@dev03 srv]#
解压、重命名
使用tar -zvxf 解压缩~如:
tar -zvxf rabbitmq-server-generic-unix-3.5.3.tar.gz
重命名 rabbitmq_server-3.5.3目录名字为rabbitmq,
mv rabbitmq_server-3.5.3 rabbitmq
[root@dev03 srv]# tar -zvxf rabbitmq-server-generic-unix-3.5.3.tar.gz ... ... [root@dev03 srv]# mv rabbitmq_server-3.5.3 rabbitmq [root@dev03 srv]# cd rabbitmq [root@dev03 rabbitmq]# ll total 164 drwxr-xr-x 2 1024 1024 12288 May 22 2015 ebin drwxr-xr-x 3 1024 1024 4096 May 22 2015 etc drwxr-xr-x 2 1024 1024 4096 May 22 2015 include -rw-r--r-- 1 1024 1024 93 May 22 2015 INSTALL -rw-r--r-- 1 1024 1024 29347 May 22 2015 LICENSE -rw-r--r-- 1 1024 1024 11358 May 22 2015 LICENSE-APACHE2-ExplorerCanvas -rw-r--r-- 1 1024 1024 10175 May 22 2015 LICENSE-Apache-Basho -rw-r--r-- 1 1024 1024 10851 May 22 2015 LICENSE-APL2-Stomp-Websocket -rw-r--r-- 1 1024 1024 1206 May 22 2015 LICENSE-BSD-base64js -rw-r--r-- 1 1024 1024 1304 May 22 2015 LICENSE-BSD-glMatrix -rw-r--r-- 1 1024 1024 1087 May 22 2015 LICENSE-MIT-EJS10 -rw-r--r-- 1 1024 1024 1066 May 22 2015 LICENSE-MIT-eldap -rw-r--r-- 1 1024 1024 1069 May 22 2015 LICENSE-MIT-Flot -rw-r--r-- 1 1024 1024 1075 May 22 2015 LICENSE-MIT-jQuery164 -rw-r--r-- 1 1024 1024 1087 May 22 2015 LICENSE-MIT-Mochi -rw-r--r-- 1 1024 1024 1076 May 22 2015 LICENSE-MIT-Sammy060 -rw-r--r-- 1 1024 1024 24897 May 22 2015 LICENSE-MPL-RabbitMQ drwxr-xr-x 2 1024 1024 4096 May 22 2015 plugins drwxr-xr-x 2 1024 1024 4096 May 22 2015 sbin drwxr-xr-x 3 1024 1024 4096 May 22 2015 share [root@dev03 rabbitmq]#
配置RabbitMQ环境变量
为了方便,在path中添加rabbitMQ的sbin路径到path中~
打开vim /etc/profile,在最后面添加内容export PATH=$PATH:/srv/rabbitmq/sbin/
[root@dev03 rabbitmq]# vim /etc/profile
然后使用soucre /etc/profile使配置生效~
[root@dev03 rabbitmq]# source /etc/profile
开启管理插件
使用rabbitmq-plugins enable rabbitmq_management开启管理插件~ 如:
[root@dev03 rabbitmq]# rabbitmq-plugins enable rabbitmq_management The following plugins have been enabled: mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent rabbitmq_management Applying plugin configuration to rabbit@dev03... Failed. * Could not contact node rabbit@dev03. Changes will take effect at broker restart. * Options: --online - fail if broker cannot be contacted. --offline - do not try to contact broker. [root@dev03 rabbitmq]#
创建用户
创建一个账户 admin并设置权限~
[root@dev03 rabbitmq]# rabbitmqctl add_user admin admin Creating user "admin" ... [root@dev03 rabbitmq]# rabbitmqctl set_user_tags admin administrator Setting tags for user "admin" to [administrator] ... [root@dev03 rabbitmq]# rabbitmqctl set_permissions -p / admin ".*" ".*" ".*" Setting permissions for user "admin" in vhost "/" ... [root@dev03 rabbitmq]#
启动RabbitMQ服务
使用rabbitmq-server start命令启动RabbitMQ服务~
[root@dev03 rabbitmq]# rabbitmq-server start RabbitMQ 3.5.3. Copyright (C) 2007-2014 GoPivotal,Inc. ## ## Licensed under the MPL. See http://www.rabbitmq.com/ ## ## ########## Logs: /srv/rabbitmq/sbin/../var/log/rabbitmq/rabbit@dev03.log ###### ## /srv/rabbitmq/sbin/../var/log/rabbitmq/rabbit@dev03-sasl.log ########## Starting broker... completed with 6 plugins.
查看状态
[使用rabbitmqctl status查看服务状态~ 如:
[root@dev03 ~]# rabbitmqctl status Status of node rabbit@dev03 ... [{pid,1427},{running_applications,[{rabbitmq_management,"RabbitMQ Management Console","3.5.3"},{rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher",{webmachine,"webmachine","1.10.3-rmq3.5.3-gite9359c7"},{mochiweb,"MochiMedia Web Server","2.7.0-rmq3.5.3-git680dba8"},{rabbitmq_management_agent,"RabbitMQ Management Agent",{rabbit,"RabbitMQ",{os_mon,"CPO CXC 138 46","2.3.1"},{inets,"INETS CXC 138 49","5.10.6"},{mnesia,"MNESIA CXC 138 12","4.12.5"},{amqp_client,"RabbitMQ AMQP Client",{xmerl,"XML parser","1.3.7"},{sasl,"SASL CXC 138 11","2.4.1"},{stdlib,"ERTS CXC 138 10","2.4"},{kernel,"3.2"}]},{os,{unix,linux}},{erlang_version,"Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:2:2] [async-threads:30] [hipe] [kernel-poll:true]\n"},{memory,[{total,83447000},{connection_readers,0},{connection_writers,{connection_channels,{connection_other,5616},{queue_procs,2808},{queue_slave_procs,{plugins,610152},{other_proc,13572680},60728},{mgmt_db,227192},{msg_index,47200},{other_ets,1101600},{binary,136808},{code,20156426},{atom,711569},{other_system,46814221}]},{alarms,[]},{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},{vm_memory_high_watermark,0.4},{vm_memory_limit,1606685491},{disk_free_limit,50000000},{disk_free,20716195840},{file_descriptors,[{total_limit,511900},{total_used,3},{sockets_limit,460708},{sockets_used,1}]},{processes,[{limit,1048576},{used,178}]},{run_queue,{uptime,4789}] [root@dev03 ~]#
验证
打开浏览器,输入http://<IP_ADDRESS>:15672/ 访问RabbitMQ管理界面~ 如
使用admin账户登录
至此,RabbitMQ安装成功~
原文链接:https://www.f2er.com/centos/378180.html