Installation Configuration of RabbitMQ

Posted by dcav on Thu, 11 Jul 2019 21:54:35 +0200

Environment: Ubuntu 16 Linux system, ERlang language source package: otp_src_22.0.tar.gz, rabbitMQ installation package: rabbitmq-server-generic-unix-3.7.16.tar, jdk1.8 (ERLang compilation needs jdk support)

To install rabbitMQ service components, you need to configure the dependencies of the ERlang language environment.

One: Installation and Configuration of ERLang Language

1. Updating system software packages. To install ERlang language environment, you need to configure support libraries first.

1.apt-get update
2.apt-get -y install libncurses5-dev   //2 or 2.1 Dependency Library Selection
2.1 apt-get -y install make g++ gcc libpcre3 libpcrecpp* libpcre3-dev libssl-dev autoconf automake libtool nfs-kernel-server libncurses5-dev libaio.dev ruby-dev rubygems vim    

2. Decompress the uploaded ERlang environment package upload server

tar xzvf /srv/ftp/otp_src_22.0.tar.gz -C /usr/local/src/

3. After compiling ERLang, you need to set up a storage directory of the compiled program.

mkdir -p /usr/local/erlang

4. Enter the ERLang source directory

cd /usr/local/src/otp_src_22.0/

5. Save the compiled content to the specified directory.

./configure --prefix=/usr/local/erlang

6. Compiling the source code

make && make install

7. After compilation, all content will be automatically saved in the previously specified "usr/local/erlang" directory. For convenience, modify the profile configuration file and set the content into the system environment.

vim /etc/profile      
export ERLANG_HOME=/usr/local/erlang
export PATH=:$ERLANG_HOME/bin:
source /etc/profile     //Activate after adding configuration

Note: If a Command'ls'is available in'/bin/ls' similar error occurs later, please refer to my environment variable location to add.

/ The usr/bin/vim/etc/profile command can use VIM to modify the profile file. https://www.cnblogs.com/austinspark-jessylu/p/6737877.html

export JAVA_HOME=/usr/local/jdk1.8
export MYSQL_HOME=/usr/local/mysql
export M2_HOME=/usr/local/maven
export ERLANG_HOME=/usr/local/erlang
export PATH=$PATH:$JAVA_HOME/bin:$MYSQL_HOME/bin:$M2_HOME/bin:$ERLANG_HOME/bin:
           

 

8. To check whether the environment configuration is normal, you can enter "erl" directly and command to start printing of erlang's interactive programming environment.

erl

io:format("Hello World!").

Exit compilation environment

halt().

9. If "Hello World!" is printed out successfully at this time. Explain that our ERL environment has been configured.

II: Installation and Configuration of RabbitMQ

1. Decompress the uploaded rabbitmq file rabbitmq-server-generic-unix-3.7.16.tar.xz

xz -d /srv/ftp/rabbitmq-server-generic-unix-3.7.16.tar.xz      //Decompression of "tar.xz"

tar xvf /srv/ftp/rabbitmq-server-generic-unix-3.7.16.tar -C /usr/local/     
 //Unzip the tar file to the specified folder

2. In order to facilitate the subsequent configuration, we rename the file directory.

mv /usr/local/rabbitmq_server-3.7.16/ /usr/local/rabbitmq

3. Start the rabbbitmq service. If the service starts successfully, send back a rabbit with code printing.

/usr/local/rabbitmq/sbin/rabbitmq-server start

4. In order to facilitate the use and background management of rabbitmq, the backup configuration parameters are added after the start command:

/usr/local/rabbitmq/sbin/rabbitmq-server start > /dev/null 2>&1 &

5. For security and convenience of background management, we can create a user with information of yu/hello.

/usr/local/rabbitmq/sbin/rabbitmqctl add_user yu hello

Note: When I added users, I had the following problems. The result was that the mapping configuration of / etc/hosts was incorrect.

Error: unable to perform an operation on node 'rabbit@rabbitmq-server'. Please see diagnostics information and suggestions below.

Most common reasons for this are:

 * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)
 * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)
 * Target node is not running

In addition to the diagnostics info below:

 * See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more
 * Consult server logs on node rabbit@rabbitmq-server
 * If target node is configured to use long node names, don't forget to use --longnames with CLI tools

DIAGNOSTICS
===========

attempted to contact: ['rabbit@rabbitmq-server']

rabbit@rabbitmq-server:
  * connected to epmd (port 4369) on rabbitmq-server
  * epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic 
  * can't establish TCP connection to the target node, reason: timeout (timed out)
  * suggestion: check if host 'rabbitmq-server' resolves, is reachable and ports 25672, 4369 are not blocked by firewall

Current node details:
 * node name: 'rabbitmqcli-6261-rabbit@rabbitmq-server'
 * effective user's home directory: /root
 * Erlang cookie hash: 1fUlYkhJd+nIoW03NSuzOQ==

After modification, users can be created and hosts can be modified:

127.0.0.1 ubuntu                                                                                     
127.0.0.1 localhost                                      
192.168.19.138 rabbitmq-server

 

6. If you want to use the current user to assign roles, you can add him to the management group.

/usr/local/rabbitmq/sbin/rabbitmqctl set_user_tags yu administrator

7. If we want to manage the WEB interface after RabbitMQ service starts, we need to start the management interface.

/usr/local/rabbitmq/sbin/rabbitmq-plugins enable rabbitmq_management

8. Now we can check the port usage to determine whether the service started successfully.

netstat -nptl

Browser page access

http://192.168.19.138:15672

Now we can manage it on the web interface.

Topics: PHP RabbitMQ Erlang Unix vim