Rate This Document
Findability
Accuracy
Completeness
Readability

Migrating from RabbitMQ to RabbitMQ

  1. Download the Erlang source package and RabbitMQ source package.
  2. Upload and decompress the Erlang and RabbitMQ source packages. Here, the packages are uploaded to the /opt path.
    1
    2
    tar -xzvf otp_src_24.3.4.4.tar.gz
    tar -Jxvf rabbitmq-server-generic-unix-3.9.28.tar.xz
    
  3. Install the dependency packages required by Erlang. The following uses Kylin as an example.
    1
    yum -y install glibc-headers autoconf automake pkgconfig bison flex openssl openssl-devel unixODBC unixODBC-devel make gcc gcc-c++ kernel-devel m4 ncurses-devel tk tc xz glibc-devel xmlto perl gtk2-devel binutils-devel
    
  4. Compile and install Erlang.

    Create and configure the Erlang installation path, for example, /opt/erlang. If a message is displayed indicating that the dependency does not exist during the installation, install the missing dependency as prompted.

    cd /opt/otp_src_24.3.4.4
    mkdir /opt/erlang
    ./configure --prefix=/opt/erlang
    make -j4 && make install
  5. Configure the Erlang and RabbitMQ installation directories.
    1. Open the /etc/profile file.
      1
      vi /etc/profile
      
    2. Press i to enter the insert mode and add the following content:
      export PATH=/opt/erlang/bin:$PATH
      export PATH=/opt/rabbitmq_server-3.9.28/sbin:$PATH
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
    4. Make the environment variables take effect.
      1
      source /etc/profile
      
  6. Enable the page management function and start RabbitMQ.
    1
    2
    3
    cd rabbitmq_server-3.9.28/sbin
    ./rabbitmq-plugins enable rabbitmq_management
    ./rabbitmq-server
    

    If the RabbitMQ version information and "Starting broker... completed with 3 plugins" are displayed, RabbitMQ is successfully installed.

  7. Migrate the configuration, data, and log files.

    The default paths of the RabbitMQ configuration, data, and log files on the source host are as follows:

    1
    2
    3
    /etc/rabbitmq
    /var/lib/rabbitmq
    /var/log/rabbitmq
    
    • For an RPM package installation on the source host, the preceding three files are stored in the root directory by default. If the installation is performed by compiling the source code, the preceding three files are stored in the source package directory.
    • The source package is used for compilation and installation on the target host. The configuration, data, and log files are also stored in the corresponding directories of the source package rabbitmq_server-3.9.28.

    Use the preceding paths as an example. Copy the rabbitmq folders in the /etc, /var/lib, and /var/log paths on the source host to the /opt/rabbitmq_server-3.9.28/etc/rabbitmq, /opt/rabbitmq_server-3.9.28/var/lib/rabbitmq, and /opt/rabbitmq_server-3.9.28/var/log/rabbitmq folders on the target host.

  8. If the host name of the source host is different from that of the target host, change the host name of the target host.
    1. Create the rabbitmq-env.conf file in the /opt/rabbitmq_server-3.9.28/etc/rabbitmq directory on the target host.
      1
      vi rabbitmq-env.conf
      
    2. Press i to enter the insert mode and add the following content: (server is the host name of the source host.)
      NODENAME=rabbit@server
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
    4. Change the host name of the target host to that of the source host.
      hostnamectl set-hostname server
  9. Enable the firewall port.
    1
    2
    firewall-cmd --add-port=15672/tcp --permanent
    firewall-cmd --reload
    

    --permanent indicates that the setting is permanent. Check whether the setting complies with security specifications. If you do not set this option, it becomes invalid after the firewalld is restarted.

  10. Start RabbitMQ on the target host, access http://IP_address:15672 using a browser, and log in to RabbitMQ using the RabbitMQ username and password for the source host. If the switches and message queues created and all messages transmitted on the source host exist on the target host, and the target host can receive and send messages properly, the migration is successful.