CentOS6.5 install rabbitMQ-3.6.1

1. Install the compilation environment such as gcc gcc-c++

yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel

Second, install the erlang language environment

2.1 Download and install erlang

Because rabbitMQ is written in erlang language, before we start installing rabbitMQ, we need to install the erlang locale first.

We downloaded the otp_src_18.3.tar.gz version.

cd /usr/developSoft

wget http://erlang.org/download/otp_src_18.3.tar.gz

#Official download address, the download in centos may be slow, you can use Thunder to download locally, and then upload to the server.

#decompress

tar xvf otp_src_18.3.tar.gz

cd otp_src_18.3

#Configure the installation directory specified by '--prefix'

./configure --prefix=/usr/local/erlang --with-ssl -enable-threads -enable-smmp-support -enable-kernel-poll --enable-hipe --without-javac

#Edit and install

make && make install #Wait for the long compilation and installation process, go make a cup of coffee, and come back later.

2.2 Configure erlang language environment variables

vim  /etc/profile

#Add the following code at the end of the file 'ERLANG_HOME' is equal to the directory specified by '--prefix' in the previous step

ERLANG_HOME=/usr/local/erlang

PATH=$ERLANG_HOME/bin:$PATH

export ERLANG_HOME

export PATH

#Enable environment variables to take effect

source /etc/profile

#Enter the command to check if the installation was successful

erl

3. Install rabbitMQ-3.6.1

3.1 Install rabbitMQ

cd /usr/developSoft

#xz decompress to get the .tar package, and then use the tar command to decompress

tar -xvf rabbitmq-server-generic-unix-3.6.1.tar

#Move the directory to see personal preferences

cp -rf ./rabbitmq_server-3.6.1 /usr/local/

cd /usr/local/

#Open the web console management plugin

cd ./rabbitmq_server-3.6.1/sbin/

./rabbitmq-plugins enable rabbitmq_management

3.2 rabbitMQ start and stop commands

#Start command, the command will shut down the service after ctrl+c

./rabbitmq-server

#Start Rabbit in the background

./rabbitmq-server -detached

#Close the service

./rabbitmqctl stop

#Close the service (kill) Find the pid of the rabbitmq service [not recommended]

ps -ef | grep rabbitmq

kill -9 ****

3.3 Add administrator account

#Enter the RabbitMQ installation directory

cd /usr/local/rabbitmq-3.6.1/sbin

#Add user

#rabbitmqctl add_user Username Password

./rabbitmqctl add_user rabbitadmin  123456

#assign user labels

#rabbitmqctl set_user_tags User Tag

#[administrator]: administrator label

./rabbitmqctl set_user_tags rabbitadmin administrator

3.4 Log in to the management console

Browser input address: http://server IP:15672/

If you cannot access, please check your iptables firewall settings.

service iptables stop #Use this command to close the iptables firewall

你也可以在启用防火墙的情况下,开放rabbitMQ相应的端口。

vim /etc/sysconfig/iptables

#RabbitMQ

-A INPUT -p tcp -m state --state NEW -m tcp --dport 15672 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 25672 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 5672 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 4369 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 5671 -j ACCEPT

#RabbitMQ

3.5 启用mqtt协议插件

默认启用了AMPQ协议,但是没有启用mqtt协议。

cd /usr/local/rabbitmq-3.6.1

cd sbin

./rabbitmq-plugins enable rabbitmq_mqtt

启用mqtt协议后 需要重启rabbitMQ服务器。

Mqtt协议端口 1883, AMQP 端口5672

3.6 开机自启动rabbitMQ服务

echo  /usr/local/rabbitmq_server-3.6.1/sbin/rabbitmq-server  -detached  >> /etc/rc.d/rc.local

这样当系统启动初始化完成后,就会启动rabbitmq服务器了。



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325783460&siteId=291194637