RabbitMQ 单机安装-CentOS
官网查看RabbitMQ和对应的Erlang版本
-
进入 RabbitMQ 官网 ,点击 顶上的 Get Started
-
点击Download + Installation
-
点击左侧的Erlang Versions 查看对应版本
根据自己需要安装的RabbitMQ版本,找到需要Erlang的版本。
下载
根据需要安装RabbitMQ的机器进行选择安装指南:
下载 二进制文件:
安装Erlang
安装Erlang
安装RabbitMQ
解压添加环境变量
#解压
[root@localhost: local]#tar xvf rabbitmq-server-generic-unix-3.7.15.tar.xz
#随后移动至/usr/local/下 改名rabbitmq:
[root@localhost: local]#cp -r rabbitmq_server-3.7.15/ /usr/local/rabbitmq
#添加到环境变量去
[root@localhost: local]#echo 'export PATH=$PATH:/usr/local/rabbitmq/sbin' >> /etc/profile
[root@localhost: local]#source /etc/profile
开启RabbitMQ后台管理
#启动后台管理
[root@VM-0-9-centos sbin]#rabbitmq-plugins enable rabbitmq_management
账号:guest 密码:guest
RabbitMQ相关命令
插件管理
开启某个插件:rabbitmq-plugins enable xxx
关闭某个插件:rabbitmq-plugins disable xxx
列出插件及状态:rabbitmq-plugins list
注意:修改插件后,需要重启RabbitMQ服务后生效。
用户相关
默认网页guest用户是不允许访问的,需要增加一个用户修改一下权限,代码如下:
查看用户列表:rabbitmqctl list_users
添加用户:rabbitmqctl add_user admin admin
添加权限:rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
修改用户角色:rabbitmqctl set_user_tags admin administrator
修改用户密码:rabbitmqctl change_password username 'newpasswd'
服务启动相关
启动服务:rabbitmq-server -detached
重启服务:rabbitmq-server restart
关闭服务:rabbitmqctl stop
查看状态:rabbitmqctl status
遇到问题及解决办法
启动rabbitmq,提示ERROR: node with name “rabbit” already running on “localhost”
[root@VM_0_9_centos: ~]#rabbitmq-server
ERROR: node with name "rabbit" already running on "localhost"
[root@VM_0_9_centos: ~]#ps aux|grep epmd
wangyizhe 949 0.0 0.0 2461372 256 ?? S 二04下午 0:00.99 /usr/local/Cellar/erlang/19.0.2/lib/erlang/erts-8.0.2/bin/epmd -daemon
wangyizhe 14871 0.0 0.0 2424600 432 s001 R+ 4:12下午 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn epmd
[root@VM_0_9_centos: ~]#ps aux|grep erl
wangyizhe 4519 0.7 0.4 4134296 29636 s000 S 二05下午 12:43.67 /usr/local/Cellar/erlang/19.0.2/lib/erlang/erts-8.0.2/bin/beam.smp -W w -A 64 -P 1048576 -t 5000000 -stbt db -K true -B i -- -root /usr/local/Cellar/erlang/19.0.2/lib/erlang -progname erl -- -home /Users/wangyizhe -- -pa /usr/local/Cellar/rabbitmq/3.6.4/ebin -noshell -noinput -s rabbit boot -sname rabbit@localhost -boot /usr/local/opt/erlang/lib/erlang/bin/start_clean -kernel inet_default_connect_options [{nodelay,true}] -rabbit tcp_listeners [{"127.0.0.1",5672}] -sasl errlog_type error -sasl sasl_error_logger false -rabbit error_logger {file,"/usr/local/var/log/rabbitmq/rabbit@localhost.log"} -rabbit sasl_error_logger {file,"/usr/local/var/log/rabbitmq/rabbit@localhost-sasl.log"} -rabbit enabled_plugins_file "/usr/local/etc/rabbitmq/enabled_plugins" -rabbit plugins_dir "/usr/local/Cellar/rabbitmq/3.6.4/plugins" -rabbit plugins_expand_dir "/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost-plugins-expand" -os_mon start_cpu_sup false -os_mon start_disksup false -os_mon start_memsup false -mnesia dir "/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost" -kernel inet_dist_listen_min 25672 -kernel inet_dist_listen_max 25672
wangyizhe 4532 0.0 0.0 2434824 464 ?? Ss 二05下午 0:12.77 erl_child_setup 256
wangyizhe 949 0.0 0.0 2461372 256 ?? S 二04下午 0:00.99 /usr/local/Cellar/erlang/19.0.2/lib/erlang/erts-8.0.2/bin/epmd -daemon
wangyizhe 14897 0.0 0.0 2424600 472 s001 R+ 4:12下午 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn erl
[root@VM_0_9_centos: ~]#kill -9 4519
[root@VM_0_9_centos: ~]#rabbitmq-server
RabbitMQ 3.6.4. Copyright (C) 2007-2016 Pivotal Software, Inc.
## ## Licensed under the MPL. See http://www.rabbitmq.com/
## ##
########## Logs: /usr/local/var/log/rabbitmq/rabbit@localhost.log
###### ## /usr/local/var/log/rabbitmq/rabbit@localhost-sasl.log
##########
Starting broker...
completed with 10 plugins.
启动服务出现:ERROR: distribution port 25672 in use by rabbit@VM-0-9-centos
ERROR: distribution port 25672 in use by rabbit@VM-0-9-centos
# 解决方法
netstat -lnp | grep 25672
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 2668/beam.smp
[root@VM-0-9-centos apps]# kill -9 2668
[root@VM-0-9-centos apps]# rabbitmq-server –detached