rabbitmq安装

  sre

配置基本环境:
1.打开网络连接:
(1)cd /etc/sysconfig/network-scripts/ #进入网络配置文件目录
(2)vi ifcfg-eno16777736 #编辑配置文件,修改以下内容
(3)将onboot从no改为yes
(4)退出编辑
(5)service network restart
正式安装:
1.安装依赖文件
yum install gcc glibc-devel make ncurses-devel openssl-devel xmlto
2.安装Erlang
wget http://mirrors.neusoft.edu.cn/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
rpm -Uvh ‘http://mirrors.neusoft.edu.cn/epel/7/x86_64/e/epel-release-7-8.noarch.rpm’
yum install erlang
erl //检查是否安装好
3.安装rabbitmq

wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.0/rabbitmq-server-3.6.0-1.noarch.rpm
rpm –import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
yum install rabbitmq-server-3.6.0-1.noarch.rpm
启用web管理插件rabbitmq-plugins enable rabbitmq_management
rabbitmq-server有没有安装好,能查到说明已经安装成功了: rpm -qa|grep rabbitmq
开启rabbit-server用以下命令:service rabbitmq-server start chkconfig rabbitmq-server on /sbin/service rabbitmq-server start
关掉服务的话用:service rabbitmq-server stop
重启:service rabbitmq-server restart
4.用以下命令查看rabbit-server当前状态:rabbitmqctl status 浏览器上输入 :http://外网ip:15672/
如果连不上的话
1.看端口是否开放:
安装firewalld:yum install firewalld firewall-config
启动: systemctl start firewalld
开启端口firewall-cmd –zone=public –add-port=80/tcp –permanent
命令含义:–zone #作用域 –add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
重启防火墙:firewall-cmd –reload
查看状态:systemctl status firewalld 或者 firewall-cmd –state
停止: systemctl disable firewalld
禁用:systemctl stop firewalld
打开对应端口:开通防火墙上Web UI访问端口(默认:15672/tcp)
firewall-cmd –permanent –zone=public –add-port=5672/tcp
firewall-cmd –permanent –zone=public –add-port=15672/tcp
firewall-cmd –reload
2.vim /etc/rabbitmq/rabbitmq.config
输入:[{rabbit, [{loopback_users, []}]}].
5.创建账户:
rabbitmqctl add_user username password //创建账户add_user
rabbitmqctl set_user_tags username administrator //赋予管理员权限
rabbitmqctl list_users //查看创建的账户
rabbitmqctl delete_user username //删除账户
rabbitmqctl oldPassword Username newPassword //修改密码
6.安装pika
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip install pika

常用命令:
查看所有队列信息 rabbitmqctl list_queues
关闭应用 rabbitmqctl stop_app
启动应用,和上述关闭命令配合使用,达到清空队列的目的 rabbitmqctl start_app
清除所有队列 rabbitmqctl reset

cat /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.0/sbin/rabbitmq-defaults //配置文件

从错误提示 TCP connection succeeded but Erlang distribution failed,Authentication failed (rejected by the remote node), please check the Erlang cookie 可以看出是 Erlang cookie的问题,节点的cookie和主节点的cookie不一致。解决办法在每个主机的$HOME目录下新建一个.erlang.cookie,里面随便输入一段字符串。或者在/var/lib/rabbitmq这个目录下新建同样的文件,里面随便写些字符,但是要在/etc/rabbitmq/rabbit-env.conf里面通过HOME=/var/lib/rabbitmq来指定。所有节点的.erlang.cookie必须保持一致。
GGUVGWMZONIAKCGXQWTO
GGUVGWMZONIAKCGXQWTO

LEAVE A COMMENT

Captcha Code