1. Background
Recently I used RabbitMQ
in the project, but found that I did not install it locally. This article records the installation process of the local RabbitMQ. Note that the installation method of different systems is slightly different, here we record the installation method of Centos7.
Two, installation method
Here we use rpm
to install, the official introduction of 2 ways to install these rpm.
1. Dependencies required by the second installation method
The second way to install RabbitMQ
requires dependencies:
2. User permissions required to install RabbitMQ
Three, install RabbitMQ
1. Install erlang
1. The version of erlang required by RabbitMQ
Different RabbitMQ requires different erlang versions. Where can I download this version?
through the link below https://www.rabbitmq.com/which-erlang.html
2. Erlang source selection
erlang
may have multiple places, such as from the official erlang, from rabbitmq. In the RabbitMQ installation guide, it is recommended to use the erlang installation package provided by RabbitMQ. This installation package only provides the erlang components required by RabbitMQ.
3. Download erlang
The erlang downloaded here is provided by RabbitMQ. But here we also need to pay attention to the erlang version , because different versions of erlang may support different systems.
1. Pay attention to the version of the system openssl
Different versions of erlang require different versions of openssl. My system is centos7, and the version of openssl on the computer is 1.0x, so erlang 23 is chosen.
2. Install erlang23 version
1. Import the signature key of RabbitMQ
## primary RabbitMQ signing key
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
2. Configure the local yum source
# In /etc/yum.repos.d/rabbitmq_erlang.repo
[rabbitmq_erlang]
name=rabbitmq-rabbitmq-erlang
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/7/$basearch
repo_gpgcheck=1
enabled=1
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md
[rabbitmq_erlang-noarch]
name=rabbitmq-rabbitmq-erlang-noarch
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/7/noarch
repo_gpgcheck=1
enabled=1
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md
[rabbitmq_erlang-source]
name=rabbitmq-rabbitmq-erlang-source
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/7/SRPMS
repo_gpgcheck=1
enabled=1
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md
3. Install erlang
yum update -y
# 安装erlang
yum install -y erlang-23.3.4
# 验证erlang是否安装成功
erl --version
061aec73878879 is the installation successful" title="Verify whether the installation of erlang
2. Install RabbitMQ
# 下载rabbitmq server
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.11/rabbitmq-server-3.9.11-1.el7.noarch.rpm
# 安装需要的依赖
yum install socat logrotate -y
# 安装rabbitmq server
yum install rabbitmq-server-3.9.11-1.el7.noarch.rpm
3. Start RabbitMQ
# 启动rabbitmq
service rabbitmq-server start
4. Check the status of RabbitMQ
service rabbitmq-server status
5. Close RabbitMQ
service rabbitmq-server stop
Fourth, start the control console of RabbitMQ
1. Execute the enable command
rabbitmq-plugins enable rabbitmq_management
2. Release port 15672
By default, the rabbitmq_management
plug-in runs on 15672
. At this time, we need to allow port 15672 in the firewall to be accessible to the outside world.
# 查看防火墙放行的端口
[root@centos01 rabbitmq]# firewall-cmd --zone=public --list-ports
8091/tcp
# 放行15672端口
[root@centos01 rabbitmq]# firewall-cmd --zone=public --add-port=15672/tcp --permanent
success
# 使刚刚配置的防火墙生效
[root@centos01 rabbitmq]# firewall-cmd --reload
success
[root@centos01 rabbitmq]# firewall-cmd --zone=public --list-ports
8091/tcp 15672/tcp
[root@centos01 rabbitmq]#
3. Log in to the control console
1. Use the default guest user to log in
The password of the default guest
guest
, you can see that this account can only be accessed through localhost
. This limitation can be solved by modifying the configuration of RabbitMQ. We will not solve this here, but we will solve this problem by creating a new user.
2. Create an admin user
1. Create an admin user, the password is also admin
[root@centos01 rabbitmq]# rabbitmqctl add_user admin admin
2. Assign the administrator role to the user
[root@centos01 rabbitmq]# rabbitmqctl set_user_tags admin administrator
3. Give users all permissions on the virtual host/
[root@centos01 rabbitmq]# rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'
3. Log in with the admin user just created
Five, the ports involved in RabbitMQ
6. Matters needing attention and problems
1. RabbitMQ corresponds to the version number of the corresponding erlang. You can view through this link https://www.rabbitmq.com/which-erlang.html
2. RabbitMQ provides an erlang virtual machine itself, it is recommended to use this. The URL is https://github.com/rabbitmq/erlang-rpm
3. It should be noted that different versions of RabbitMQ require the version of openssl on the system. There are in the RabbitMQ installation guide.
4. The default request of RabbitMQ's node name is rabbit@hostname
, so we should not modify the host name casually, otherwise problems may occur.
5. After RabbitMQ is started, how to check the log file, RabbitMQ directory, configuration file, erlang cookie value?
The path of the log file under the default request is /var/log/rabbitmq
directory, we can open the log file in this directory to view.
less /var/log/rabbitmq/rabbit\@centos01.log
6. Modify the maximum number of files that the user can open ulimit -n
, most systems default to 1024
, it is recommended to modify it to 65536
7, RabbitMQ configuration file path
/etc/rabbitmq/rabbitmq.conf
The above is just a configuration file path of RabbitMQ, and it can also be placed in another directory.
Seven, reference link
1. required by RabbitMQ
2. provided by RabbitMQ
3. RabbitMQ rpm installation guide
4. RabbitMQ configuration
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。