RabbitMQ server deployment

1. Introduction
RabbitMQ itself is written based on Erlang. Erlang language is inherently distributed (implemented by synchronizing the erlang.cookie of each node of the Erlang cluster). Therefore, RabbitMQ naturally supports clusters. RabbitMQ is an open source AMQP implementation that 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.
2. Installation and configuration
1. Configure epel
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2. Install erlang
yum install -y erlang socat
3. Download rabbitmq
wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
4. Install
rpm -ivh rabbitmq-server- 3.6.10-1.el7.noarch.rpm
5. Start the service
systemctl start rabbitmq-server
systemctl enable rabbitmq-server
6. Open the web management interface
rabbitmq-plugins enable rabbitmq_management
7. Verification
address: http://172.16.120.101:15672/
User: guest
Password: guest
RabbitMQ server deployment

Three, cluster deployment
1. Environment description

operating system IP address CPU name
CentOS-7.2 172.16.120.101 mq-disc-01
CentOS-7.2 172.16.120.102 mq-disc-02
CentOS-7.2 172.16.120.103 mq-ram-01

Note: There are two types of nodes in the cluster: memory node/disk node
2. Configure hosts
vim /etc/hosts

172.16.120.101 mq-disc-01
172.16.120.102 mq-disc-02
172.16.120.103 mq-ram-01

3. For the installation
process, see above
4. Synchronize cookie file
cd /var/lib/rabbitmq/
scp .erlang.cookie 172.16.120.102:/var/lib/rabbitmq
scp .erlang.cookie 172.16.120.103:/var/lib/ rabbitmq
Note: The file permission is 400, and the owner and group are rabbitmq
5. With mq-disc-01 as the main node, execute
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@mq-disc-01
rabbitmqctl start_app on the other two machines
6. Set Memory node
rabbitmqctl change_cluster_node_type ram
7. View the cluster status
rabbitmqctl cluster_status
8. Set the policy to automatically synchronize all nodes
rabbitmqctl set_policy ha-all "^"'{"ha-mode":"all","ha-sync-mode":" automatic"}'
9. View the policy
rabbitmqctl list_policies
4. Common commands
# View all current users
rabbitmqctl list_users #Delete
users
rabbitmqctl delete_user guest #Add
user
rabbitmqctl add_user admin passwd #Set
user tag
rabbitmqctl set_user_tags admin administrator #Give the
user full operation permissions of the default vhost
rabbitmqctl set_permissions -p / username “. ”“. ” “.*” #View
user permissions
rabbitmqctl list_user_permissions list_user_tags admin administrator username #Generate
queue
rabbitmqadmin declare queue name=test durable=true #Generate
message
rabbitmqadmin publish routing_key=test payload="this is a testing" #View
queue
rabbitmqadmin list queues #Consumer
message
rabbitmqadmin get queue=test requeue=true #Delete
queue
rabbitmqadmin -q delete queue name=test

Guess you like

Origin blog.51cto.com/7965676/2597285