Install and configure RabbitMQ (yum source and docker installation) on Centos7

Posted by Cagez on Wed, 21 Aug 2019 09:09:05 +0200

I. docker installation

1. Enter docker hub mirror

  • Warehouse address: https://hub.docker.com/

2. Search rabbitMq image

  • When you enter the official image, you can see the following types of images; we choose a version with "mangement" (including web management pages);

3. Pull out the mirror

# docker pull rabbitmq:3.7.7-management

View all mirrors

# docker images

4. Create and start containers based on downloaded images

# docker run -d --name rabbitmq3.7.7 -p 5672:5672 -p 15672:15672 -v `pwd`/data:/var/lib/rabbitmq --hostname myRabbit -e RABBITMQ_DEFAULT_VHOST=my_vhost  -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin df80af9ca0c9

Explain:

- d Background running container;
- name specifies the container name;
- p Specifies the port of the service (5672: Application Access Port; 15672: Console Web Port Number);
- v Mapping directories or files;
- hostname host name (RabbitMQ's important note is that it stores data according to the so-called "node name" and defaults to host name);
- e specifies environment variables; (RABBITMQ_DEFAULT_VHOST: default virtual machine name; RABBITMQ_DEFAULT_USER: default user name; RABBITMQ_DEFAULT_PASS: password for default user name)

5. View the running container

# docker ps -a

6. Browser can be used to open the web management side: http://Server-IP:15672

II. yum Source Installation

1. Installing Erlang Environment

1. Install the dependency file before installing erlang (otherwise error will be reported later. / configure):

	# yum install gcc glibc-devel make ncurses-devel openssl-devel xmlto

2. Download the erlang installation package on the erlang website

Official address: http://www.erlang.org/downloads

	# wget -c http://erlang.org/download/otp_src_20.2.tar.gz

Decompression:

	# tar -zxvf otp_src_20.2.tar.gz
	# cd otp_src_20.2/

3. Compile and install (I specify here that the compile and install will be placed in the / usr/local/erlang directory, which you can change to something else):

# ./configure --prefix=/usr/local/erlang
# make && make install

4. Test whether the installation is successful:

# cd /usr/local/erlang/bin/ 
# ./erl

If the following interface appears, then we have erlang configuration OK
     
Enter halt(). Exit the console. Note that there is a little bit behind halt.

5. Configure environment variables (ps: This is similar to java's environment variable configuration)

# vim /etc/profile

	export PATH=$PATH:/usr/local/erlang/bin 

# source /etc/profile #Update configuration

Verification: If you can enter erl anywhere on the command line, the configuration is successful.

2. Installation of rabbitmq

1. Download the latest installation package on the official website: http://www.rabbitmq.com/releases/rabbitmq-server/

# cd /usr/local/
# wget -c http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-generic-unix-3.6.15.tar.xz

Decompression:

# xz -d rabbitmq-server-generic-unix-3.6.15.tar.xz 
# tar -xvf rabbitmq-server-generic-unix-3.6.15.tar

2. Configure rabbitmq environment variables (this is similar to the erlang configuration and java environment variables above)

# vim /etc/profile

	export PATH=$PATH:/usr/local/rabbitmq_server-3.6.15/sbin

# source /etc/profile

3. Basic operation of rabbitmq:

rabbitmq-server -detached #start-up
rabbitmqctl stop #Close
rabbitmqctl status #state

4. Configure rabbitmq web page management plug-in

rabbitmq-plugins enable rabbitmq_management #Enabling plug-ins

Access Management Page: http://172.18.???: Port 15672 defaults to 15672
Default guest User: guest, guest User Password: guest
    
Note: Log in rabbitmq to report an error User can only log in via localhost

  • Rabbit MQ has been banned from 3.3.0 from using guest/guest privileges to access other than localhost.

Solve:

  • Rabbit MQ has been banned from 3.3.0 from using guest/guest privileges to access other than localhost.

  • If you want to use guest/guest to access a remote machine, you need to set loopback_users to [] in the rabbitmq configuration file (find the rabbit.app file under / rabbitmq_server-3.6.15/ebin).

  • Find the complete contents of the rabbit.app file under / rabbitmq_server-3.6.15/ebin as follows (note the following half-horn period):
    Find: <guest> delete from loopback_users.
    [{rabbit, [{loopback_users, []}]}].

  • restart

5. Open rabbitmq remote access

Add user: rabbitmqctl add_user XRom XRom 123 //XRom is user name, XRom 123 is user password
Add permissions: rabbitmqctl set_permissions-p "/" XRom ".". ". *"
Modify user roles: rabbitmqctl set_user_tags XRom administrator
Then you can access it remotely, and you can configure information such as user privileges directly.

Common commands of rabbitmq

add_user        <UserName> <Password>
delete_user    <UserName>
change_password <UserName> <NewPassword>
list_users
add_vhost    <VHostPath>
delete_vhost <VHostPath>
list_vhostsset_permissions  [-p <VHostPath>] <UserName> <Regexp> <Regexp> <Regexp>
clear_permissions [-p <VHostPath>] <UserName>
list_permissions  [-p <VHostPath>]
list_user_permissions <UserName>
list_queues    [-p <VHostPath>] [<QueueInfoItem> ...]
list_exchanges [-p <VHostPath>] [<ExchangeInfoItem> ...]
list_bindings  [-p <VHostPath>]
list_connections [<ConnectionInfoItem> ...]

Reference: https://blog.csdn.net/typ1805/article/details/82744899

Topics: RabbitMQ Erlang Docker Unix