Message middleware – RabbitMQ (1) Windows/Linux environment construction (full version)

Foreword

This chapter of this article mainly introduces environment construction. This time it is mainly a stand-alone construction (conditions are limited), including construction in Windows and Linux environments, as well as the construction of RabbitMQ monitoring platform.

Environment Preparation

Before setting up RabbitMQ, please make sure that the following environment has been set up

  • Java environment (my JDK1.8)
  • Maven environment (my current latest version 3.6.1)
  • Git environment

Students who have not built one use the portal:

JDK environment construction: JAVA8 environment construction
Maven environment construction: Using Nexus 3.X to build a Maven private server and introduction to its use in a Windows environment
Git environment construction: Git environment construction and configuration

1.Build in Windows environment

You need to download the erlang and RabbitMQ installation packages separately and install them. If you encounter a situation where the official website cannot be opened, you can scan the QR code below to follow the public account: Coder Programming Reply to RabbitMQ to obtain the installation file.

1.1 Download and install erlang

Reason: The RabbitMQ server code is written in the concurrent language Erlang. The prerequisite for installing Rabbit MQ is to install Erlang.

  • Download address: Downloads – Erlang/OTP “867”>

The latest version is: 22.0

  • Download the corresponding version according to the number of computers. Most computers now are 64-bit. I chose the 64-bit one to download.

1.2 Installation and environment configuration steps

1.2.1 Installation Package

After downloading, you will get the following installation package

Message middleware - RabbitMQ (1) Windows/Linux environment setup (full version) transfer

1.2.2 Installation Process
  • Double-click the installation package and click next
  • Select a location to save the software installation, and then click next and finish in sequence.
1.2.3 Configuring environment variables

After the installation is complete, let’s configure the environment variables.

Computer –> Right-click “Properties” –> Advanced System Settings –> Environment Variables –> “New” system environment variable

Variable name: ERLANG_HOME The variable value is the installation address of erlang just now, click OK. Then double-click the system variable path

Click “New” and add %ERLANG_HOME%\bin to the path

1.2.4 Test

Finally, press the Windows key + R key, enter cmd, and then enter erl. When you see the version number, it means that the erlang installation is successful.

1.3 Download and install RabbitMQ

1.3.1 Installation and Configuration

Download address: Downloading and Installing RabbitMQ – RabbitMQ

  • Double-click the downloaded .exe file. The installation process is the same as that of erlang.
  • After RabbitMQ is installed, install RabbitMQ-Plugins. Open the command line cd and enter the sbin directory of RabbitMQ.

Installation directory: E:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.16

Then enter the rabbitmq-plugins enable rabbitmq_management command later to install it.

Open the sbin directory and double-click rabbitmq-server.bat

1.3.2 Test

Enter the address: http://localhost:15672/

Display the graphical interface and indicate success!

1.4 Solve the crash problem

Enter the rabbitmq-plugins enable rabbitmq_management command, and then fail to start rabbitmq-service.bat

Recommendation:

  • First enter on the command line: rabbitmq-service stop
  • Then enter rabbitmq-service remove
  • Then enter rabbitmq-service install
  • Then enter rabbitmq-service start
  • Finally re-enter rabbitmq-plugins enable rabbitmq_management

2. Build in Linux environment

There are two installation methods for installing RabbitMQ in the Linux environment: one is the yum installation method, and the other is the compilation installation method. For novices, we recommend: yum installation method

The following is an introduction using the yum installation method.

RabbitMQ official website download address: RabbitMQ: easy to use, flexible messaging and streaming – RabbitMQ

Precautions
The version of erlang will affect the installation of rabbitmq, and there is a version comparison between the two. View the comparison address: RabbitMQ Erlang Version Requirements – RabbitMQ

2.1 Preparation

2.1.1 Install the JDK environment.

You can refer to the following articles:
Installation of jdk under linux (two methods)-CSDN Blog

2.1.2 Turn off the firewall

firewall-cmd –permanent –add-port=5672/tcp

firewall-cmd –reload

setsebool -P nis_enabled 1 (turn off selinux)

2.1.3 Install dependent packages

Dependency packages required by rabbitmq

yum install build-essential openssl openssl-devel unixODBC unixODBC-devel make gcc gcc-c++ kernel-devel m4 ncurses-devel tk tc xz

2.2 Install Erlang and RabbitMQ

2.2.1 Download the installation package
wget www.rabbitmq.com/releases/erlang/erlang-18.3-1.el7.centos.x86_64.rpm
wget http://repo.iotti.biz/CentOS/7/x86_64/socat-1.7.3.2-5.el7.lux.x86_64.rpm
wget www.rabbitmq.com/releases/rabbitmq-server/v3.6.5/rabbitmq-server-3.6.5-1.noarch.rpm
2.2.2 Installation Service Command
rpm -ivh erlang-18.3-1.el7.centos.x86_64.rpm

rpm -ivh socat-1.7.3.2-5.el7.lux.x86_64.rpm
rpm -ivh rabbitmq-server-3.6.5-1.noarch.rpm

The above must be installed in order, otherwise an error will be reported!

2.2.3 Modify configuration file

Note the modification: vim /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.5/ebin/rabbit.app file

Modification: <<"guest">> in loopback_users, only keep guest

Modification: heartbeat is 1

Message middleware - RabbitMQ (1) Windows/Linux environment setup (full version) transfer

2.2.4 Start/stop services and other commands
## Start rabbitmq service
/etc/init.d/rabbitmq-server start

## Stop rabbitmq service
/etc/init.d/rabbitmq-server stop

## Check rabbitmq service status
/etc/init.d/rabbitmq-server status

## Restart rabbitmq service
/etc/init.d/rabbitmq-server restart

## Check whether the service is started

lsof -i:5672 or netstat -tnlp|grep 15672
2.2.5 Install RabbitMQ management interface
rabbitmq-plugins enable rabbitmq_management

After the installation is complete, the service needs to be restarted.

Then you can pass http://ip:15672

Use guest, guest to log in to the web page.

2.2.6 Possible pitfalls

During the installation process, I encountered the following pitfalls:

Message middleware - RabbitMQ (1) Windows/Linux environment setup (full version) transfer

BOOT FAILED
===========
Error description:
   {error,{missing_dependencies,[compiler],[mochiweb]}}

Log files (may contain more information):
   /var/log/rabbitmq/[email protected]
   /var/log/rabbitmq/[email protected]
Stack trace:
   [{rabbit_plugins,ensure_dependencies,1,
                    [{file,"src/rabbit_plugins.erl"},{line,176}]},
    {rabbit_plugins,prepare_plugins,1,
                    [{file,"src/rabbit_plugins.erl"},{line,195}]},
    {rabbit,broker_start,0,[{file,"src/rabbit.erl"},{line,280}]},
    {rabbit,start_it,1,[{file,"src/rabbit.erl"},{line,403}]},
    {init,start_it,1,[]},
    {init,start_em,1,[]}]

{"init terminating in do_boot",{error,{missing_dependencies,[compiler],[mochiweb]}}}
/usr/lib/rabbitmq/bin/rabbitmq-server: Line 236: 105442 User-defined signal 2 start_rabbitmq_server "$@"

After searching for a long time, I couldn’t find a solution. I just uninstalled and reinstalled it again. There were some operational errors in the middle.

2.2.7 Uninstall RabbitMQ operation
/sbin/service rabbitmq-server stop
yum list | grep rabbitmq
yum -y remove rabbitmq-server.noarch
 
yum list | grep erlang
yum -y remove erlang-*
yum remove erlang.x86_64
rm -rf /usr/lib64/erlang
rm -rf /var/lib/rabbitmq

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Cloud native entry-level skills treeHomepageOverview 16822 people are learning the system