yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel libxml2-utils libxml2 \
libxslt openssl-devel unixODBC unixODBC-devel unixODBC-bin gtk2 fop wxWidgets-devel wxBase
ln -s /usr/bin/wx-config-3.0 /usr/bin/wx-config
mkdir /opt/erlang
cd /opt/erlang
wget http://soft.download/soft/linux/mq-server/erlang_otp_src_20.3.tar.gz
tar zxvf erlang_otp_src_20.3.tar.gz
cd otp_src_20.3
./configure --prefix=/usr/local/erlang --with-ssl -enable-threads \
-enable-smmp-support -enable-kernel-poll --enable-hipe --disable-javac
make && make install
参考java安装
export JAVA_HOME=/usr/local/java/
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
vim /etc/profile.d/erlang.sh
export ERLANG_HOME=/usr/local/erlang
export ERL_DIR=${ERLANG_HOME}/bin
export PATH=${ERLANG_HOME}/bin:$PATH
source /etc/profile
yum install -y xz
groupadd rabbitmq
useradd -g rabbitmq rabbitmq -d /var/lib/rabbitmq -s /sbin/nologin
mkdir /opt/rabbitmq
cd /opt/rabbitmq
wget http://soft.download/soft/linux/mq-server/rabbitmq-server-generic-unix-3.6.15.tar.xz
unxz rabbitmq-server-generic-unix-3.6.15.tar.xz
tar -xvf rabbitmq-server-generic-unix-3.6.15.tar
mv rabbitmq_server-3.6.15/ /data/rabbitmq-server
chown -R rabbitmq:rabbitmq /data/rabbitmq-server/
ln -s /data/rabbitmq-server/sbin/rabbitmqctl /usr/bin/rabbitmqctl
ln -s /data/rabbitmq-server/sbin/rabbitmq-defaults /usr/bin/rabbitmq-defaults
ln -s /data/rabbitmq-server/sbin/rabbitmq-env /usr/bin/rabbitmq-env
ln -s /data/rabbitmq-server/sbin/rabbitmq-plugins /usr/bin/rabbitmq-plugins
ln -s /data/rabbitmq-server/sbin/rabbitmq-server /usr/bin/rabbitmq-server
cd /data/rabbitmq-server/etc/rabbitmq/
##要修改node名称,结合/etc/hosts
wget http://soft.download/soft/linux/mq-server/config/rabbitmq-env.conf
wget http://soft.download/soft/linux/mq-server/config/rabbitmq.config
cat /data/rabbitmq-server/etc/rabbitmq/rabbitmq-env.conf
#RABBITMQ_NODE_IP_ADDRESS= //IP地址,空串bind所有地址,指定地址bind指定网络接口
#RABBITMQ_NODE_PORT= //TCP端口号,默认是5672
#RABBITMQ_NODENAME= //节点名称。默认是rabbit
#RABBITMQ_CONFIG_FILE= //配置文件路径 ,即rabbitmq.config文件路径
#RABBITMQ_MNESIA_BASE= //mnesia所在路径
#RABBITMQ_LOG_BASE= //日志所在路径
#RABBITMQ_PLUGINS_DIR= //插件所在路径
# mq01为主机名
RABBITMQ_NODENAME=rabbit@mq1
cat /data/rabbitmq-server/etc/rabbitmq/rabbitmq.config
[
{rabbit,
[
{vm_memory_high_watermark,0.6},
{vm_memory_watermark_paging_ratio,0.5}
]},
{kernel,
[]},
{rabbitmq_management,
[]},
{rabbitmq_shovel,
[{shovels,
[]}
]},
{rabbitmq_stomp,
[]},
{rabbitmq_mqtt,
[]},
{rabbitmq_amqp1_0,
[]},
{rabbitmq_auth_backend_ldap,
[]}
].
192.168.1.120 mq1
192.168.1.121 mq2
192.168.1.122 mq3
cd /etc/systemd/system/
wget http://soft.download/soft/linux/mq-server/config/rabbitmq-server.service -O /etc/systemd/system/rabbitmq-server.service
cat /etc/systemd/system/rabbitmq-server.service
[Unit]
Description=RabbitMQ broker
After=syslog.target network.target
[Service]
Type=simple
User=rabbitmq
Group=rabbitmq
LimitNOFILE=65535
WorkingDirectory=/data/rabbitmq-server
ExecStart=/data/rabbitmq-server/sbin/rabbitmq-server
ExecStop=/data/rabbitmq-server/sbin/rabbitmqctl stop
NotifyAccess=all
TimeoutStartSec=3600
[Install]
WantedBy=multi-user.target
vim +80 /data/rabbitmq-server/sbin/rabbitmq-server
#加入erlang环境变量
export ERLANG_HOME=/usr/local/erlang
export PATH=${ERLANG_HOME}/bin:$PATH
sed -i '80i export PATH=${ERLANG_HOME}/bin:$PATH' rabbitmq-server
sed -i '80i export ERLANG_HOME=/usr/local/erlang' rabbitmq-server
systemctl start rabbitmq-server.service
systemctl status rabbitmq-server.service
systemctl enable rabbitmq-server.service
firewall-cmd --zone=public --add-port=4369/tcp --permanent&&firewall-cmd --reload
firewall-cmd --zone=public --add-port=5672/tcp --permanent&&firewall-cmd --reload
firewall-cmd --zone=public --add-port=25672/tcp --permanent&&firewall-cmd --reload
firewall-cmd --zone=public --add-port=15672/tcp --permanent&&firewall-cmd --reload
rabbitmqctl list_users -n rabbit@mq01
rabbitmq-plugins enable rabbitmq_management -n rabbit@mq1
rabbitmqctl add_user gadmin 123456 -n rabbit@mq01
rabbitmqctl add_user dev 123456 -n rabbit@mq1
rabbitmqctl add_user cloud 123456 -n rabbit@mq1
rabbitmqctl add_user test 123456 -n rabbit@mq1
#分配用户标签
rabbitmqctl set_user_tags gadmin administrator
rabbitmqctl set_user_tags dev administrator
rabbitmqctl set_user_tags cloud administrator
rabbitmqctl set_user_tags test administrator
添加vhost
rabbitmqctl add_vhost /dev -n rabbit@mq1
rabbitmqctl add_vhost /cloud -n rabbit@mq1
rabbitmqctl add_vhost /test -n rabbit@mq1
授权账号vhost权限
rabbitmqctl set_permissions -p / gadmin '.*' '.*' '.*' -n rabbit@mq01
rabbitmqctl set_permissions -p /dev dev '.*' '.*' '.*' -n rabbit@mq1
rabbitmqctl set_permissions -p /cloud cloud '.*' '.*' '.*' -n rabbit@mq1
rabbitmqctl set_permissions -p /test test '.*' '.*' '.*' -n rabbit@mq1
查看集群状态
rabbitmqctl cluster_status -n rabbit@mq1
# 设置权限
rabbitmqctl set_permissions -p / gadmin '.*' '.*' '.*'
rabbitmqctl delete_user guest -n rabbit@mq1
注意:
所有节点的.erlang.cookie的值要一致
如果需要root账号也能执行rabbitmqctl命令,需要把.erlang.cookie拷贝到/root/路径下
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbit@mq1
rabbitmqctl start_app