CentOs7.3 build RabbitMQ 3.6 stand-alone service

CentOs7.3 build RabbitMQ 3.6 stand-alone service#

Introduction to RabbitMQ##

RabbitMQ is an open source implementation of AMQP. The server is written in Erlang language and supports a variety of clients, such as: Python, Ruby, .NET, Java, JMS, C, PHP, ActionScript, XMPP, STOMP, etc., and supports AJAX. It is used to store and forward messages in a distributed system. It performs well in terms of ease of use, scalability, and high availability.

AMQP, namely Advanced message Queuing Protocol, Advanced [Message Queuing] (https://cloud.tencent.com/product/cmq?from=10680) protocol, is an open standard for application layer protocol, designed for message-oriented middleware. Message middleware is mainly used for decoupling between components, the sender of the message does not need to know the existence of the message user, and vice versa.

The main characteristics of AMQP are message-oriented, queue, routing (including point-to-point and publish/subscribe), reliability, and security.

surroundings##

Precautions##

Turn off the firewall

Centos 6.x close iptables

$ service iptables stop #Close command:

Centos 7.x close firewall

$ systemctl stop firewalld.service #Stop firewall

If you don’t want to turn off the firewall, just open port 15672. After setting, you can manage MQ through the web

Install iptables firewall

yum install iptables-services

Edit configuration

$ vi /etc/sysconfig/iptables-config

Add configuration

iptables -I INPUT -p tcp --dport 5672-j ACCEPT
iptables -I INPUT -p tcp --dport 15672-j ACCEPT

Save configuration

$ service iptables save

Reboot

systemctl restart iptables.service

Set up auto start

systemctl enable iptables.service 

CentOS7.3 install iptables and detailed usage https://segmentfault.com/a/1190000010713423

installation#

Install Erlang

RabbitMQ installation needs to rely on Erlang environment

$ cd /opt
$ wget http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm

$ yum install erlang-19.0.4-1.el7.centos.x86_64.rpm

Install RabbitMQ

$ cd /opt
$ wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
$ yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm

Start service##

$ service rabbitmq-server start

service status##

$ service rabbitmq-server status
# service rabbitmq-server status
Redirecting to /bin/systemctl status  rabbitmq-server.service
● rabbitmq-server.service - RabbitMQ broker
 Loaded:loaded(/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled)
 Active:active(running) since Wed 2017-08-1611:43:33 CST; 8s ago
 Main PID:17919(beam)
 Status:"Initialized"
 CGroup:/system.slice/rabbitmq-server.service
   ├─17919/usr/lib64/erlang/erts-8.0.3/bin/beam -W w -A 64-P 1048576-t 5000000-stbt db -zdbbl 32000-K true---root /usr/lib64/erlang -progname erl ---home /var/lib/rabbitmq ---pa /us...
   ├─18062/usr/lib64/erlang/erts-8.0.3/bin/epmd -daemon
   ├─18160 erl_child_setup 1024
   ├─18165 inet_gethost 4
   └─18166 inet_gethost 4

Aug 1611:43:32 localhost.localdomain rabbitmq-server[17919]: RabbitMQ 3.6.10.Copyright(C)2007-2017 Pivotal Software, Inc.
Aug 1611:43:32 localhost.localdomain rabbitmq-server[17919]: ##  ##      Licensed under the MPL.  See http://www.rabbitmq.com/
Aug 1611:43:32 localhost.localdomain rabbitmq-server[17919]: ##  ##
Aug 1611:43:32 localhost.localdomain rabbitmq-server[17919]: ##########  Logs:/var/log/rabbitmq/[email protected]
Aug 1611:43:32 localhost.localdomain rabbitmq-server[17919]: ######  ##        /var/log/rabbitmq/[email protected]
Aug 1611:43:32 localhost.localdomain rabbitmq-server[17919]: ##########
Aug 1611:43:32 localhost.localdomain rabbitmq-server[17919]: Starting broker...
Aug 1611:43:33 localhost.localdomain rabbitmq-server[17919]: systemd unit for activation check:"rabbitmq-server.service"
Aug 1611:43:33 localhost.localdomain systemd[1]: Started RabbitMQ broker.
Aug 1611:43:33 localhost.localdomain rabbitmq-server[17919]: completed with0 plugins.

View log##

$ less /var/log/rabbitmq/[email protected]
= INFO REPORT====16-Aug-2017::11:43:32===
Starting RabbitMQ 3.6.10 on Erlang 19.0.4Copyright(C)2007-2017 Pivotal Software, Inc.
Licensed under the MPL.  See http://www.rabbitmq.com/=INFO REPORT====16-Aug-2017::11:43:32===
node           : rabbit@localhost
home dir       :/var/lib/rabbitmq
config file(s):/etc/rabbitmq/rabbitmq.config(not found)
cookie hash    : kuUba2xGLitNNO48qE0Hrg==
log            :/var/log/rabbitmq/[email protected]
sasl log       :/var/log/rabbitmq/[email protected]
database dir   :/var/lib/rabbitmq/mnesia/rabbit@localhost

= INFO REPORT====16-Aug-2017::11:43:33===
Memory limit set to 390MB of 976MB total.=INFO REPORT====16-Aug-2017::11:43:33===
Enabling free disk space monitoring

= INFO REPORT====16-Aug-2017::11:43:33===
Disk free limit set to 50MB

= INFO REPORT====16-Aug-2017::11:43:33===
Limiting to approx 924 file handles(829 sockets)=INFO REPORT====16-Aug-2017::11:43:33===
FHC read buffering:  OFF
FHC write buffering: ON

= INFO REPORT====16-Aug-2017::11:43:33===
Database directory at /var/lib/rabbitmq/mnesia/rabbit@localhost is empty. Initialising from scratch...=INFO REPORT====16-Aug-2017::11:43:33===
Waiting for Mnesia tables for30000 ms,9 retries left

= INFO REPORT====16-Aug-2017::11:43:33===
Waiting for Mnesia tables for30000 ms,9 retries left

The configuration file shown here is not found, we can create this file by ourselves

config file(s):/etc/rabbitmq/rabbitmq.config(not found)

Create rabbitmq.config

$ cd /etc/rabbitmq/
$ vi rabbitmq.config

The edit content is as follows:

[{ rabbit,[{loopback_users,[]}]}].

Restart the service after saving the configuration

$ service rabbitmq-server restart

Open the management UI

$ /sbin/rabbitmq-plugins enable rabbitmq_management

Restart service

$ service rabbitmq-server restart

Access management UI

Use guest through http://ip:15672, guest logged in

If you cannot access, please check the firewall

Authorized operation#

Add user##

For security reasons, the default user of guest can only log in through http://localhost:15672, and other IPs cannot directly use this account. It is impossible to manage and maintain the situation where the desktop is not installed on the server, unless you add a layer of agent in front to provide services to the outside, this is a bit troublesome, here is the configuration file to achieve this function

Command format

rabbitmqctl add_user <username><newpassword>
$ rabbitmqctl add_user ymq 123456
Creating user "ymq"

delete users##

Command format

rabbitmqctl delete_user <username>
$ rabbitmqctl  delete_user penglei
Deleting user "penglei"

change Password##

Command format

rabbitmqctl  change_password  <username><newpassword>
$ rabbitmqctl  change_password  ymq 123456
Changing password for user "ymq"

User authorization##

Command format

rabbitmqctl set_permissions [-pvhostpath]{user}{conf}{write}{read}

This command allows the user ymq / (can access the virtual host) to configure, write, and read permissions for all resources in order to manage the resources therein

$ rabbitmqctl set_permissions -p "/" ymq ".*"".*"".*"
Setting permissions for user "ymq"in vhost "/"

View user authorization##

Command format

rabbitmqctl  list_permissions  [-p  VHostPath]
$ rabbitmqctl list_permissions -p /
Listing permissions in vhost "/"
guest	.*.*.*
ymq	.*.*.*

View current user list##

You can see that the user is successfully added, but it is not the role of administrator

$ rabbitmqctl list_users
Listing users
guest	[administrator]
ymq	[]

Add role##

Here we also set the ymq user to the administrator role

Command format

rabbitmqctl set_user_tags <username><tag>
$ rabbitmqctl set_user_tags ymq administrator
Setting tags for user "ymq" to [administrator]

Check permissions again

$ rabbitmqctl list_users
Listing users
guest	[administrator]
ymq	[administrator]

Clear permission information

Command format

rabbitmqctl  clear_permissions  [-p VHostPath]  ymq
rabbitmqctl  clear_permissions  -p /  ymq
Clearing permissions for user "ymq"in vhost "/"

Official document##

Background operation#

Login new user##

You can see that ymq and guest have the same permissions

Add user##

Click with the mouse to draw a red line and choose one

Setting permissions##

The user does not have permission to access any virtual host

Click Set permission

Contact

Recommended Posts

CentOs7.3 build RabbitMQ 3.6 stand-alone service
CentOs7.3 build Solr stand-alone service
CentOs7.3 build ZooKeeper-3.4.9 stand-alone service
Centos6.9 build rabbitmq 3.6.8 cluster
CentOS 7 deploys RabbitMQ service
Centos7 build DNS service
CentOs7.3 build SolrCloud cluster service
Build WeChat applet service based on CentOS
Build WeChat applet service based on CentOS
CentOS7 build jenkins
Centos build lnmp
Centos7 build python3.8.5+scrapy+gerapy
centOs install rabbitMQ
CentOS7 build gerrit code review service method
centos6.9 rabbitmq 3.6.8 upgrade 3.8.2
CentOS7.3 64 bit, build Zabbix3.4
CentOS online installation RabbitMQ3.7
CentOS build private git
CentOS 8 enable NTP service
Linux (centos7) build gitlab
Build k8s1.9.9 on centos7
CentOS6.7 build LNMP environment
CentOS 7 install Docker service
Centos7.6 build LNMP environment
Install RabbitMQ on CentOS 7
CentOS 7 deploy saltstack service
Centos7 build Kubernetes cluster
Centos 7.4 install stand-alone Spark
Jenkins build on centos
Build Hadoop in CentOS
CentOS7 deploys NFS service
Centos6.8 deploy vnc service
install RabbitMQ on centos
Install RabbitMQ on CentOS 7
CentOS online installation RabbitMQ3.7
Install RabbitMQ on CentOS7
CentOS 7 build LNMP environment
CentOS7 deploy vsftp (FTP) service
Build docker environment under Centos6.5
Build OpenV** Server under CentOS7
Build zabbix monitoring zabbix4.2 in CentOS7.6
Build OpenLDAP server under CentOS7
CentOS7 install rabbitmq cluster (binary)
Build zabbix monitoring zabbix4.2 in CentOS7.6
Build MariaDB replication on CentOS
Centos7.2 deployment vnc service record
centos6.9 rabbitmq set up SSL
CentOS 6 automatically installs RabbitMQ script
Centos 7 install jdk and package service service
CentOS 7 set up NTP, SSH service
RabbitMQ cluster deployment record under Centos6.9
CentOS8.1 build Gitlab server detailed tutorial
Build a PXC cluster under CentOS8
CentOS builds a cloud service platform
CentOS 8 - install and configure NFS service
Centos6 method steps to build gitlab
Build an FTP server under centos7
Build Elasticsearch 6.2.4 (centos) based on docker
Build Nginx environment on Linux (CentOS)
CentOS 7 Tomcat service installation and configuration
(centos7) linux build nginx load balancing build