Centos7 install/uninstall RabbitMQ

Centos7 install/uninstall RabbitMQ and Erlang

Recently, RabbitMQ is going to be used in the project, so it needs to be installed on the server. This thing is a bit particular about installing it. Let me share with you here.

Note: There is a big guy who wrote it in detail and I recommend it to everyone here. Post a link: Detailed tutorial on installing and configuring rabbitMQ under linux , you can directly refer to his.

It is necessary to install Erlang before installing RabbitMQ.

Install Erlang

1. Install from Erlang Solution

 # 添加erlang solutions源
 $ wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
 $ sudo rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
 $ sudo yum install erlang

2. Install from EPEL source (The Erlang version installed in this way may not be the latest, and sometimes it cannot meet the minimum version required by RabbitMQ)

 # 启动EPEL源
 $ sudo yum install epel-release 
 # 安装erlang
 $ sudo yum install erlang  

3. Manually download and install
Erlang corresponding to Centos, address: GitHub
Insert picture description here
because I am Centos7, so I downloaded 7 ( erlang-23.1.4-1.el7.x86_64.rpm ), after the download is complete, put it on your server , And then run the following code in the corresponding folder:

# 安装对应安装包
$ yum install erlang-23.1.4-1.el7.x86_64.rpm

Install RabbitMQ

Download and install as follows:

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

# 安装安装包
$ yum install rabbitmq-server-3.6.6-1.el7.noarch.rpm

After the installation is complete, if it is a cloud server, remember to open ports 15672 (front-end access web port) and 5672 (back-end write queue default interface)

Optional execution after installation

1. Open the web management interface (you can operate RabbitMQ more conveniently and quickly):

$ sudo rabbitmq-plugins enable rabbitmq_management

2. Summary of some commands (there are many ways to command, everyone likes it):

# 添加开机启动RabbitMQ服务
$ sudo chkconfig rabbitmq-server on 

# 启动服务
$ sudo /sbin/service rabbitmq-server start 
$ service rabbitmq-server start

# 查看服务状态
$ sudo /sbin/service rabbitmq-server status  

# 停止服务
$ sudo /sbin/service rabbitmq-server stop   
$ service rabbitmq-server stop

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

# 查看默认guest用户的权限
$ sudo rabbitmqctl list_user_permissions 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

3. Enable remote user access permissions.
Modify the content of the rabbitmq.config file and leave the loopback_users list blank, as follows:

{loopback_users, []}

Different versions will produce different things. For example, my rabbitmq.config file is not automatically generated. I thought it was not installed and uninstalled and reinstalled four or five times. Later I found out that the installed file can also be configured by yourself. I hope everyone Don’t worry if you find that this file does not exist, you can create one by yourself and it will take effect. After you have configured it, remember to stop the rabbitmq service and start it to make the configuration file take effect.

4. Rabbitmq.config configuration file

Please refer to the official documents for specific configuration according to your own needs . I am too lazy to read

Uninstall related

# 查看rabbitmq安装的相关列表
$ yum list | grep rabbitmq

# 卸载rabbitmq已安装的相关内容
$ yum -y remove rabbitmq-server.noarch

# 查看erlang安装的相关列表
$ yum list | grep erlang

# 卸载erlang已安装的相关内容
$ yum -y remove erlang-*
$ yum remove erlang.x86_64(当卸载不干净时执行这个)

# 部分相关文件夹大家看着删除,我就是记录一下
$ rm -rf /usr/lib64/erlang 
$ rm -rf /var/lib/rabbitmq
$ rm -rf /usr/local/erlang
$ rm -rf /usr/local/rabbitmq

Error sharing:

Insert picture description here
This is the need to execute a statement to delete the following files, anyway, you are reinstalling, this should be a conflict file:

# 移除文件(相关文件都要移除)
$ yum remove 文件名

Guess you like

Origin blog.csdn.net/weixin_43837119/article/details/110822067