Installing RABBITMQ
RabbitMQ is a popular open source Message Queuing system developed in Erlang language, so it is necessary to install Erlang dependencies and Erlang first.
Install the basic environment that Erlang relies on and install it in Yum mode:
yum -y install gcc glibc-devel make ncurses-devel openssl-devel autoconf |
Download and install Erlang, which uses erlang-r15b-02.1.el6.x86_64.rpm, copies it to a virtual machine and installs it in Yum mode:
yum -y install erlang-R15B-02.1.el6.x86_64.rpm |
- Test the Erlang environment, enter the ERL
Download RABBITMQ official Server Edition and install
Address: http://www.rabbitmq.com/install-rpm.html
This is the rabbitmq-server-3.3.5-1.noarch.rpm version, which is uploaded to the virtual machine via the XFTP software or other means, and is installed using the Yum method:
yum -y install rabbitmq-server-3.3.5-1.noarch.rpm |
Start RABBITMQ
Starting Rabbitmq-server through System services
If it doesn't start properly, you can troubleshoot by logging
Alternatively, you can see whether the RABBITMQ service has started with the Chkconfig command:
chkconfig --list rabbitmq-server |
Open the RABBITMQ Web management plugin
First look at the plugin list for information about:
To start the Web management plug-in:
rabbitmq-plugins enable rabbitmq_management |
If the plugin is successfully started, use the service rabbitmq-server Restart command to restart the RABBITMQ services for it to take effect.
Accessing the Web Management plug-in interface
Open the Web interface through the browser, the address is http://ip:15672/mgmt/, the default user name and password are guest.
If you cannot access the RABBITMQ log information, there are two possible reasons: Port 15672 is occupied and the firewall is turned on.
To turn off the firewall with the following command, it is recommended to turn it on automatically:
service iptables stop chkconfig iptables off |
Guest account cannot log on to Web admin interface
For security reasons, RABBITMQ from 3.3, the guest user is only allowed to log on via localhost by default.
You can remove these access restrictions by creating a Rabbitmq.config file.
vi /etc/rabbitmq/rabbitmq
.config
# 内容如下
[{rabbit,
[
%%%% Network Connectivity
%% ====================
%%
%% By default, RabbitMQ will listen on all interfaces, using
%% the standard (reserved) AMQP port.
%%
{tcp_listeners, [5672]},
{loopback_users, [
"admin"
]}
]
}].
|
Build RABBITMQ Cluster
RABBITMQ clusters are dependent on Erlang's clusters to work, so you must first build a clustered environment of Erlang.
The nodes in Erlang's cluster are implemented by a magic cookie, which is stored in the. Erlang.cookie,
-
Set node cookie
Cookie file under/VAR/LIB/RABBITMQ
Place the contents of the. erlang.cookie file for that node (such as "xxxxxxxxxxxxx "string) copied to all other nodes in the same file,
chmod 700. Erlang.cookie Code class= "Bash functions" >echo -n " Xxxxxxxxxxxxx " > .erlang.cookie chmod 400. Erlang.cookie |
Note: When copying a string, do not use such useless information as the sky grid
 
- Ensure that host names between nodes can be resolved with each other
Add all machines in the cluster (IP address hostname) separately to the hosts file for each machine:
Nodes make up a cluster
Start the Rabbitmq-server service first, run the nodes of each machine, and view the status:
service rabbitmq-server start rabbitmqctl stop rabbitmq-server -detached rabbitmqctl status |
Assuming there are three machines, Node1, Node2, Node3, then Node2 and Node3 and Node1 are clustered (i.e., in Node2 and Node3 two machines):
rabbitmqctl stop_app rabbitmqctl join_cluster [email protected] rabbitmqctl start_app |
After the configuration is complete, you can perform rabbitmqctl cluster_status on any node machine to see if the cluster configuration is successful:
Set up a mirroring queue policy
Execute the following policy on any node, setting all queues as mirror queues, that is, the queues are replicated to each node, and the state of each node remains consistent. When a new node joins the cluster, the queue is mirrored to that node.
rabbitmqctl set_policy ha-all "^" ‘{"ha-mode":"all"}‘ |
Node exits the cluster
Take the Node1 node, for example, if you need to exit the cluster
rabbitmqctl stop_app rabbitmqctl rest |
Create a clustered user
Due to the subsequent deployment of Buildplatform, the RABBITMQ account used is admin and the password is 123456.
So here we need to create a user first, with two main methods:
- Web Administration page creation
After logging into the Web management interface using the Guest account, click on the Admin tab, which originally had only one guest account,
Create a new Admin account here, set the password, and select tags named [Admin]:
Click on the Virtual Host tab on the right side of the page to enter the link to the Chinese box:
Locate the Set Permission section and add the Admin user to the current permissions:
Command-line mode creation
Create Admin user
rabbitmqctl add_user admin 123456 |
Set Admin user Administrator role
rabbitmqctl set_user_tags admin administrator |
View created Users
give Admin user permission
rabbitmqctl set_permissions -p / admin ‘.*‘ ‘.*‘ ‘.*‘ |
The above command ensures that user admin has all the resource configuration, write, and read permissions in this virtual host in order to manage the resources in it
Recommended
It is highly recommended that the RABBITMQ service be set to boot from:
chkconfig rabbitmq-server on
RABIBTMQ installation and cluster configuration-linux