Installing on RPM-based Linux (CentOS, Fedora, OpenSuse, RedHat)
安装新版本的RabbitMQ出错:
centos端口转发神器:socat安装及使用
socat作用是在两个流之间建立双向的通道,且支持众多协议和链接方式:ip,tcp,udp,ipv6,pipe,exec,system,open,proxy,openssl,socket等
yum 方式安装:
wget –no-cache http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo -O /etc/yum.repos.d/convirt.repo yum makecache yum install socat -y
cat /etc/yum.repos.d/convirt.repo
[convirt-dep] name=ConVirt Dependencies baseurl=http://www.convirture.com/repos/deps/RHEL/6.x enabled=1 gpgcheck=0 gpgkey=http://www.convirture.com/repos/convirture_packaging_pub_key
使用方式:
sudo nohup socat tcp-l:外部访问端口,reuseaddr,fork tcp:192.168.xxx.xxx:内部转发端口
1、安装Erlang:http://www.rabbitmq.com/releases/erlang/
yum -y install openssl*
rpm -ivh http://www.rabbitmq.com/releases/erlang/erlang-17.4-1.el6.x86_64.rpm (old)
rpm -ivh http://www.rabbitmq.com/releases/erlang/erlang-18.3-1.el6.x86_64.rpm (new)
2、安装RabbitMQ
rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc yum install http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.4/rabbitmq-server-3.5.4-1.noarch.rpm -y (old)
yum install http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.2/rabbitmq-server-3.6.2-1.noarch.rpm -y (new)
3、修改配置
mkdir -p /data/rabbitmq/log/ chown -R rabbitmq:rabbitmq /data/rabbitmq vim /usr/lib/rabbitmq/bin/rabbitmq-defaults --修改日志文件和数据库文件存放路经 vim /usr/lib/rabbitmq/bin/rabbitmq-env 修改端口号
4、启动RabbitMQ
chkconfig rabbitmq-server on /sbin/service rabbitmq-server stop/start 或 service rabbitmq-server start/stop
5、安装监控插件
rabbitmq-plugins enable rabbitmq_management --安装监控插件
6、设置用户
rabbitmqctl add_user user1 **** --添加用户user1和密码 rabbitmqctl set_permissions -p / user1 ".*" ".*" ".*" --设置user1用户在虚拟主机/下面的权限 rabbitmqctl list_user_permissions user1 --显示user1权限 rabbitmqctl set_user_tags user1 administrator --设置user1为管理员标示 rabbitmqctl delete_user guest --删除默认guest用户 rabbitmqctl list_users --显示所有用户 rabbitmqctl add_vhost vhost1 --添加虚拟主机vhost1,虚拟主机只是起到一个命名空间的作用,所以可以多个user共同使用一个virtual host
7、设置防火墙
iptables -I INPUT -p tcp --dport 5672 -j ACCEPT --rabbitmq端口 iptables -I INPUT -p tcp --dport 15672 -j ACCEPT --监控端口 service iptables save service iptables restart cat /etc/sysconfig/iptables
参考文献:
http://www.rabbitmq.com/man/rabbitmqctl.1.man.html#User%20management --用户管理
http://www.cnblogs.com/daizhj/archive/2010/10/21/1857374.html --基本设置
http://blog.163.com/sky20081816@126/blog/static/16476102320107173226920/ --虚拟主机的作用
http://www.ttlsa.com/linux/install-rabbitmq-on-linux/ --配置文件