美文网首页
rabbitmq单节点搭建

rabbitmq单节点搭建

作者: su酥饼 | 来源:发表于2021-11-16 17:17 被阅读0次

rabbitmq 搭建

相关链接 https://www.cnblogs.com/huhongy/p/12558305.html

单节点

  1. 安装erlang和socat
rpm -ivh erlang-22.3-1.el7.x86_64.rpm   
rpm -ivh socat-1.7.3.2-2.el7.x86_64.rpm

2.安装rabbitmq

2.安装rabbitmq:
rpm -ivh rabbitmq-server-3.7.23-1.el7.noarch.rpm 
 ** 安装rabbitmq,  配置文件模板的位置需要修改
默认配置文件模板会在/usr/share/doc/rabbitmq-server-3.7.23/rabbitmq.config.example 。需要把配置文件copy到/etc/rabbimq/下
修改配置文件到/etc/rabbimq/下
#cp /usr/share/doc/rabbitmq-server-3.7.23/rabbitmq.config.example /etc/rabbitmq/
cd /etc/rabbitmq 
vim  rabbitmq.config
[{rabbit, [{loopback_users, []}]}].

3.安装rabbitmq的桌面插件:
rabbitmq-plugins enable rabbitmq_management

4. 启动rabbitmq
## 安装rabbitmq的后,这个服务会自动生成,rabbitmq-server可以直接使用
systemctl start rabbitmq-server   --启动
systemctl stop rabbimq-server     --停止服务
systemctl status rabbitmq-server  --查看启动状态

5. 可视化链接测试:
到步骤2.我们已经完成了rabbitmq单机版的安装,它可以满足一般业务请求。
访问:http://192.168.236.139:15672/#/ 注意:我自己搭建的主机是192.168.236.139,可视化端口是15672
登录用户默认用户 guest/guest

6.添加插件
cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.7.23/plugins/
上传插件# rabbitmq_delayed_message_exchange-3.8.0.ez
rabbitmq-plugins enable rabbitmq_delayed_message_exchange

rabbitmq 自动安装

install.sh

#!/bin/bash
#rabbitmq installation and configuration
mqdir=/application
cd $mqdir
# update gcc
yum -y install epel-release
yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC unixODBC-devel wxBase wxGTK SDL wxGTK-gl  
rpm -e --nodeps `rpm -qa|grep rabbitmq`
rpm -e --nodeps `rpm -qa|grep erlang`

# Install esl-erlang_22.0.3
echo Install esl-erlang_22.0.3

cd $mqdir

tar -xzvf otp_src_19.3.tar.gz
cd otp_src_19.3
./configure --prefix=/usr/local/erlang --with-ssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe 

make && make install
echo "PATH=$PATH:/usr/local/erlang/bin:/application/rabbitmq/sbin" >> /etc/profile
source /etc/profile

# Install rabbitmq-server-3.7.7


echo Install rabbitmq-server-3.7.7
cd /application && tar -xf rabbitmq-server-generic-unix-3.6.14.tar.xz && mv  /application/rabbitmq_server-3.6.14  /application/rabbitmq

source /etc/profile

# Start RabbitMQ service
rabbitmq-plugins enable rabbitmq_management

/application/rabbitmq/sbin/rabbitmq-server start

步骤:


上传rabbitmq-server-generic-unix-3.6.14.tar.xz   otp_src_19.3.tar.gz 两个安装包
和instll.sh 安装脚本

#将这三个文件上传导/application
#然后执行install.sh

安装完后需要手动添加账号及相关权限

/application/rabbitmq/sbin/rabbitmq-server start

默认的guest帐户相当于root帐户
rabbitmqctl add_user username password                     # 添加帐户
rabbitmqctl change_password username newpassword   # 修改密码
rabbitmqctl delete_user username                                # 删除帐户
rabbitmqctl list_users                                                   # 列出所有帐户
rabbitmqctl set_user_tags User Tag                               # 设置角色
角色:(administrator、monitoring、policymaker、management、其它)

#启动
/application/rabbitmq/sbin/rabbitmq-server start
#启动完毕之后ctrl+c,连按两次 退出当前启动输出界面 

#关闭
/application/rabbitmq/sbin/rabbitmqctl stop



以下为添加账号推荐操作


rabbitmqctl add_user  admin gzzxjdmqAaqwer123!
 
rabbitmqctl set_user_tags admin administrator

rabbitmqctl set_permissions -p "/" admin '.*' '.*' '.*' 
 
rabbitmqctl list_user_permissions admin

rabbitmq 操作

1.查看消息队列

./rabbitmqctl list_queues

2.清空某个消息队列内容

./rabbitmqctl purge_queue 队列名

相关文章

网友评论

      本文标题:rabbitmq单节点搭建

      本文链接:https://www.haomeiwen.com/subject/nyvbzltx.html