参考
http://5lexin.com/blog/view/225/mco-ping-%E8%BE%93%E5%87%BA%E9%94%99%E8%AF%AF%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95
环境 :
1、2台centos6.5虚拟机已装好puppet
选用rabbitMQ
安装过程:
1、安装rabbitmq
yum install erlang
yum install rabbitmq-server
/etc/rc.d/init.d/rabbitmq-server start #启动rabbitmq服务
/etc/rc.d/init.d/rabbitmq-server status #查看rabbitmq状态
加载
amqp_client
和rabbit_stomp
插件
ln -s /usr/lib/rabbitmq/lib/rabbitmq_server-3.1.5/sbin/rabbitmq-plugins /usr/sbin/rabbitmq-plugins #创建命令rabbitmq-plugins的软连接
ln -s /usr/lib/rabbitmq/lib/rabbitmq_server-3.1.5/sbin/rabbitmq-env /usr/sbin/rabbitmq-env #创建命令rabbitmq-env的软连接
rabbitmq-plugins enable rabbitmq_stomp #开启rabbitmq_stomp插件
rabbitmq-plugins enable rabbitmq_management #开启rabbitmq_management插件为后边建立exchanges队列最准备
默认的登录用户名密码均为guest
/etc/rc.d/init.d/rabbitmq-server restart
tailf /var/log/rabbitmq/rabbit\@puppetserver.log
#可以从日志看到stomp插件加载
成功,而且能够查到遇到的错误原因,根据原因去google就能找到问题原因。
创建rabbitmq.config
配置文件,修改监听端口为61613
vim /etc/rabbitmq/rabbitmq.config
[
{
rabbitmq_stomp
, [{tcp_listeners, [61613]}]}
].
/etc/rc.d/init.d/rabbitmq-server restart
netstat -nlp | grep beam #默认监听端口为61613
删除默认账户guest,为MCollective创建账户“mcollective”
并设置密码为“secret”
,然后设置权限。
创建虚拟主机组
rabbitmqctl add_vhost /mcollective
Creating vhost "/mcollective" ...
...done.
设置用户访问虚拟主机组的权限
rabbitmqctl set_permissions -p "/mcollective" mcollective ".*" ".*" ".*"
Setting permissions for user "mcollective" in vhost "/mcollective" ...
...done.
[root@puppetserver rpms]# rabbitmqctl delete_user guest Deleting user "guest" ... ...done. [root@puppetserver rpms]# rabbitmqctl add_user mcollective secret Creating user "mcollective" ... ...done. [root@puppetserver rpms]# rabbitmqctl set_permissions -p "/" mcollective ".*" ".*" ".*" Setting permissions for user "mcollective" in vhost "/" ... ...done. [root@puppetserver sbin]# rabbitmqctl list_users #查看监听用户 Listing users ... mcollective [] ...done.
我的/etc/mcollective/cilent.cfg配置文件
main_collective = mcollective
collectives = mcollective
libdir = /usr/libexec/mcollective
logger_type = console
loglevel = warn
# Plugins
securityprovider = psk
#plugin.psk = unset
plugin.psk = a36cd839414370e10fd281b8a38a4f48
connector = rabbitmq
plugin.rabbitmq.vhost = /mcollective
plugin.rabbitmq.pool.size = 1
plugin.rabbitmq.initial_reconnect_delay = 0.01
plugin.rabbitmq.max_reconnect_delay = 30.0
plugin.rabbitmq.use_exponential_back_off = true
plugin.rabbitmq.max_reconnect_attempts = 0
plugin.rabbitmq.randomize = false
plugin.rabbitmq.timeout = -1
plugin.rabbitmq.pool.1.host = master.wei.com
plugin.rabbitmq.pool.1.port = 61613
plugin.rabbitmq.pool.1.user = mcollective
plugin.rabbitmq.pool.1.password = secret
plugin.rabbitmq.pool.1.ssl = false
# Facts
factsource = yaml
plugin.yaml = /etc/mcollective/facts.yaml
/etc/mcollective/server.cfg配置文件
main_collective = mcollective
collectives = mcollective
libdir = /usr/libexec/mcollective
logfile = /var/log/mcollective.log
loglevel = info
daemonize = 1
# Plugins
securityprovider = psk
#plugin.psk = unset
plugin.psk = a36cd839414370e10fd281b8a38a4f48
connector = rabbitmq
plugin.rabbitmq.vhost = /mcollective
plugin.rabbitmq.pool.size = 1
plugin.rabbitmq.initial_reconnect_delay = 0.01
plugin.rabbitmq.max_reconnect_delay = 30.0
plugin.rabbitmq.use_exponential_back_off = true
plugin.rabbitmq.max_reconnect_attempts = 0
plugin.rabbitmq.randomize = false
plugin.rabbitmq.timeout = -1
plugin.rabbitmq.pool.1.host = master.wei.com
plugin.rabbitmq.pool.1.port = 61613
plugin.rabbitmq.pool.1.user = mcollective
plugin.rabbitmq.pool.1.password = secret
plugin.rabbitmq.pool.1.ssl = false
# Facts
factsource = yaml
plugin.yaml = /etc/mcollective/facts.yaml
服务端重启mcollective服务 service mcollective restart
client端mco ping
![](http://wiki.cnsuning.com/download/attachments/17925279/%E7%BB%93%E6%9E%9C.png?version=1&modificationDate=1407124681984&api=v2)
就说明可以了。
安装的时候遇到的问题:
一、
![](http://wiki.cnsuning.com/download/attachments/17925279/%E9%94%99%E8%AF%AF%E4%B8%80.jpeg?version=1&modificationDate=1407124682015&api=v2)
这错误是由于新版本2.5.2以上连接mq是不支持用stomp方式去连的
将配置文件中的connector用rabbitmq
二、
![](http://wiki.cnsuning.com/download/attachments/17925279/%E9%94%99%E8%AF%AF2.jpg?version=1&modificationDate=1407124682000&api=v2)
参考
http://5lexin.com/blog/view/225/mco-ping-%E8%BE%93%E5%87%BA%E9%94%99%E8%AF%AF%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95解决。
注意:启用rabbitmq-management插件时会把你前面建立的用户mcollective删掉,这是你需要重新建立mcollective用户。