centos安装单机rabbitmq

下载安装erlang

yum install -y epel-release

yum install -y erlang

wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm

rpm -Uvh erlang-solutions-1.0-1.noarch.rpm

yum install -y socat

安装RabbitMQ

sudo rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc

wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm # 下载RabbitMQ安装包

sudo yum install rabbitmq-server-3.6.6-1.el7.noarch.rpm

RabbitMQ的基本操作 启动 添加用户

默认使用端口有两个 567215672

# 查看hostname
hostname


vim /etc/rabbitmq/rabbitmq-env.conf
NODENAME=rabbit@[hostname] # 更改hostname
NODE_IP_ADDRESS=127.0.0.1

# 运行RabbitMQ

/sbin/rabbitmq-server
$ sudo chkconfig rabbitmq-server on  # 添加开机启动RabbitMQ服务
$ sudo /sbin/service rabbitmq-server start # 启动服务
$ sudo /sbin/service rabbitmq-server status # 查看服务状态
$ sudo /sbin/service rabbitmq-server stop # 停止服务


# 查看当前所有用户
$ sudo rabbitmqctl list_users

# 查看默认guest用户的权限
$ sudo rabbitmqctl list_user_permissions guest

# 由于RabbitMQ默认的账号用户名和密码都是guest。为了安全起见, 先删掉默认用户
$ sudo rabbitmqctl delete_user guest

# 添加新用户
$ sudo rabbitmqctl add_user username password

# 设置用户tag
$ sudo rabbitmqctl set_user_tags username administrator

# 赋予用户默认vhost的全部操作权限
$ sudo rabbitmqctl set_permissions -p / username ".*" ".*" ".*"

# 查看用户的权限
$ sudo rabbitmqctl list_user_permissions username

查看日志

erlang故障排除

erl -sname test

node().

net_adm:names().

net_adm:ping('rabbite@master'). # 确认连上rabbite节点

rpc:call('rabbite@master',erlang,system_info,[process_count]) # 获得该节点erlang进程数

rpc:call('rabbite@master',mnesia,info,[])

# 退出执行

q().

启动Rabbit web manager

sudo rabbitmq-plugins enable rabbitmq_management

# 内部测试 外网需要打开防火墙 默认用户名guest密码guest 只支持localhost登录 远程登录需要添加账户
curl http://localhost:15672
添加账户

添加延迟队列exchange插件
插件列表
https://dl.bintray.com/rabbitmq/community-plugins/

cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.6/plugins

wget https://dl.bintray.com/rabbitmq/community-plugins/rabbitmq_delayed_message_exchange-0.0.1.ez

rabbitmq-plugins enable rabbitmq_delayed_message_exchange

配置RabbitMQ
下载配置模板
官网解释

cd /etc/rabbitmq/

wget https://raw.githubusercontent.com/rabbitmq/rabbitmq-server/master/docs/rabbitmq.conf.example

cp rabbitmq.conf.example rabbitmq.conf

vim rabbitmq.conf
# 开启远程访问
{loopback_users, ["username"]}

sudo /sbin/service rabbitmq-server restart

相关链接

rabbitmq官网:http://www.rabbitmq.com/install-rpm.html

erlang官网: https://www.erlang-solutions.com/resources/download.html

RabbitMQ文档 https://www.rabbitmq.com/documentation.html

RabbitMQ服务端配置 https://www.rabbitmq.com/admin-guide.html

rabbitmqctl手册 https://www.rabbitmq.com/rabbitmqctl.8.html

RabbitMQ web界面操作的命令行工具 https://www.rabbitmq.com/management-cli.html

网易开源镜像站 http://mirrors.163.com/

centos镜像使用 http://mirrors.163.com/.help/centos.html

本文总阅读量