装完系统 然后
配置ssh登录:
yum install -y openssh-server
vi /etc/ssh/sshd_config
将 以下几行的注释取消:
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
PermitRootLogin yes
PasswordAuthentication yes
:wq
systemctl enable sshd
systemctl start sshd
firewall-cmd --permanent --zone=public --add-port=22/tcp;
firewall-cmd --reload;
reboot;
这时候可以远程登录了;
然后可选更新内核:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-lt -y
yum remove kernel-3.* kernel-tools-libs-3.* kernel-tools-3.*
rpm -e kernel-3.*
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot;
这时候就内核就换成较新的了;
接下来yum安装erlang和rpm安装rabbitmq:
yum clean all;
yum makecache;
yum install -y epel-release;
yum install -y erlang;
yum install -y socat;
yum install -y logrotate;
rpm -i http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-3.6.15-1.el7.noarch.rpm;
rabbitmq-plugins enable rabbitmq_management;
systemctl enable rabbitmq-server
systemctl start rabbitmq-server
这时候 rabbitmq 基础环境就装好了 并且单机模式已经启动了
集群需要构建需要修改主机名:
先设立两台样例主机:
rabbit1 对应ip 192.168.1.18
rabbit3 对应ip 192.168.1.19
rabbit1上:
hostnamectl set-hostname rabbit1
rabbit3上:
hostnamectl set-hostname rabbit3
所有节点上都配置所有集群上的主机名与ip的对应:
vi /etc/hosts
在尾部增加:
rabbit1 192.168.1.18
rabbit3 192.168.1.18
wq:
处理erlang cookie文件(所有节点):
rm -rf /var/lib/rabbitmq/.erlang.cookie;echo "NICAYNNZGMAHW1LRVQQU" >> /var/lib/rabbitmq/.erlang.cookie;chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie;chmod 600 /var/lib/rabbitmq/.erlang.cookie;
rm -rf /root/.erlang.cookie; ln -s /var/lib/rabbitmq/.erlang.cookie /root/.erlang.cookie;chown root:root /root/.erlang.cookie;chmod 777 /root/.erlang.cookie;
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie;chmod 600 /var/lib/rabbitmq/.erlang.cookie;
配置文件:
vi /etc/rabbitmq/rabbitmq.conf
loopback_users.guest = false
listeners.tcp.default = 5672
default_pass = 123abc
default_user = admin
default_vhost = my_vhost
hipe_compile = false
management.listener.port = 15672
management.listener.ssl = false
:wq
chown rabbitmq:rabbitmq /etc/rabbitmq/rabbitmq.conf;chmod 644 /etc/rabbitmq/rabbitmq.conf;
注意RABBITMQ_NODENAME这里我因为直接准备用主机的hostname所以没有设;
如果需要设:
vi /etc/rabbitmq/rabbitmq-env.conf
RABBITMQ_NODENAME=rabbit3(换成你自己具体的节点名)
:wq
firewall-cmd --permanent --zone=public --add-port=4369/tcp;
firewall-cmd --permanent --zone=public --add-port=5671/tcp;
firewall-cmd --permanent --zone=public --add-port=5672/tcp;
firewall-cmd --permanent --zone=public --add-port=15671/tcp;
firewall-cmd --permanent --zone=public --add-port=15672/tcp;
firewall-cmd --permanent --zone=public --add-port=25672/tcp;
firewall-cmd --reload;
原文地址:https://www.cnblogs.com/sfissw/p/10581739.html