安装

1、下载解压

wget http://192.168.1.22:8090/download/attachments/2557088/rabbitmq-server-generic-unix-3.8.4.tar.xz?version=1&modificationDate=1590979700000&api=v2&download=true

tar xf rabbitmq-server-generic-unix-3.8.4.tar.xz -C /usr/local/rabbitmq/

2、配置环境变量

cat <<'EOF' >> /etc/profile

# rabbit mq
export PATH=$PATH:/usr/local/rabbitmq/sbin
EOF

source /etc/profile

启动

rabbitmq-server -detached #后台启动,监听5672端口

附加:常用操作

1、启动rabbitmq  
rabbitmq-server -detached #后台启动

2、查看服务状态
rabbitmqctl status

3、 停止RabbitMQ
rabbitmqctl stop

4、列出/启动插件
列出插件
rabbitmq-plugins list
启用插件
rabbitmq-plugins enable rabbitmq_management
默认端口15672,对外访问即:IP:15672,默认的账号密码是guest,但是该账号只能通过localhost登录

1)添加用户
rabbitmqctl add_user [username] [password]

2)添加权限
rabbitmqctl set_permissions -p "/" [username] ".*" ".*" ".*" # "/"即vhost

3)修改用户角色
rabbitmqctl set_user_tags [username] administrator

4)修改用户密码
rabbitmqctl change_password [username] [password] 

4)查看当前用户列表
rabbitmqctl list_users

5)删除用户  
rabbitmqctl delete_user [username]

MQ自启动

1、首先需要确保将你的erl 链接到/usr/bin/erl,需要执行

ln -s ${which erl} /usr/bin/erl

2、假设你是在Centos7中采用源码方式安装的RabbitMQ,且安装目录为/usr/local/rabbitmq,你需要执行(注意:以下服务中的user和Group非常重要,不能删除)

cat <<'EOF' >> /usr/lib/systemd/system/rabbitmq-server.service

[Unit] Description=RabbitMQ broker After=syslog.target network.target

[Service]

Type=notify

User=root Group=root WorkingDirectory=/usr/local/rabbitmq ExecStart=/usr/local/rabbitmq/sbin/rabbitmq-server ExecStop=/usr/local/rabbitmq/sbin/rabbitmqctl stop

[Install] WantedBy=multi-user.target

EOF

systemctl enable rabbitmq-serve 3、尝试重启服务器验证mq是否正常启动

Copyright © 运维知识库 all right reserved,powered by Gitbook文件修订时间: 2023-09-19 10:45:38

results matching ""

    No results matching ""