activemq 安装
1. 安装activemq
下载 apache-activemq-5.15.2-bin.tar.gz 后解压到安装目录即可
tar zxvf activemq-5.15.2-bin.tar.gz
2. 配置activemq
使用官方例子配置文件
查看actvie环境变量
./activemq list
ACTIVEMQ_HOME: /data/apache-activemq-5.15.2
ACTIVEMQ_BASE: /data/apache-activemq-5.15.2
ACTIVEMQ_CONF: /data/apache-activemq-5.15.2/conf
ACTIVEMQ_DATA: /data/apache-activemq-5.15.2/data
Connecting to JMX URL: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
INFO: Broker not available at: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
3. 启动activemq
前台方式启动
cd [activemq_install_dir]/bin
./activemq console
后台方式启动
cd [activemq_install_dir]/bin ./activemq start
mcollective 安装
1. 在puppet5.x版本中 mcollective 已经随puppet安装,无需另外安装。
2. mcollective server 配置
vi /etc/puppetlabs/mcollective/client.cfg
main_collective = mcollective collectives = mcollective libdir = /opt/puppetlabs/mcollective/plugins # consult the "classic" libdirs too libdir = /usr/share/mcollective/plugins libdir = /usr/libexec/mcollective logfile = /var/log/puppetlabs/mcollective/mcollective.log loglevel = debug daemonize = 1 # Plugins securityprovider = psk plugin.psk = unset connector = activemq plugin.activemq.pool.size = 1 plugin.activemq.pool.1.host = centos2 plugin.activemq.pool.1.port = 61613 plugin.activemq.pool.1.user = mcollective plugin.activemq.pool.1.password = marionette # Facts factsource = yaml plugin.yaml = /etc/puppetlabs/mcollective/facts.yaml
3. mcollective client 配置
vi /etc/puppetlabs/mcollective/client.cfg
main_collective = mcollective collectives = mcollective libdir = /opt/puppetlabs/mcollective/plugins # consult the "classic" libdirs too libdir = /usr/share/mcollective/plugins libdir = /usr/libexec/mcollective logger_type = console loglevel = warn # Plugins securityprovider = psk plugin.psk = unset connector = activemq plugin.activemq.pool.size = 1 plugin.activemq.pool.1.host = centos2 plugin.activemq.pool.1.port = 61613 plugin.activemq.pool.1.user = mcollective plugin.activemq.pool.1.password = marionette connection_timeout = 3
4. 启动mcollective服务
# 启动
systemctl start mcollective
# 设为开机自动启动
systemctl enable mcollective
# log路径
/var/log/puppetlabs/mcollective/mcollective.log
# 测试命令
/opt/puppetlabs/puppet/bin/mco ping
插件安装
下载地址 https://github.com/puppetlabs/mcollective-plugins
shell插件 https://github.com/kisspuppet/mcollective-plugins
将下载的插件代码复制到下面路径
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/mcollective/
非root用户执行
1. 创建用户mcollective
useradd -c MCO -r -b /var/lib -M -s /sbin/nologin mcollective
2. 创建主目录
mkdir /var/lib/mcollective
chown mcollective /var/lib/mcollective
chmod 750 /var/lib/mcollective
3. 准备配置文件
cd /var/lib/mcollective
cp /etc/puppetlabs/mcollective/server.cfg .
chown mcollective server.cfg
vi server.cfg
#puppet配置文件
非root用户执行时必须配置在 ~/.puppetlabs/etc/puppet 目录下配置相关文件, 否则mco调用puppetd时会失败
cp -r /etc/puppetlabs/puppet/* /var/lib/mcollective/.puppetlabs/etc/puppet
#server.cfg文件内容如下
main_collective = mcollective
collectives = mcollective
# consult the "classic" libdirs too
libdir = /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/mcollective:/usr/share/mcollective/plugins
logfile = /var/log/mcollective/mcollective.log
loglevel = debug
daemonize = 1
# Plugins
securityprovider = psk
plugin.psk = unset
connector = activemq
plugin.activemq.pool.size = 1
plugin.activemq.pool.1.host = centos2
plugin.activemq.pool.1.port = 61613
plugin.activemq.pool.1.user = mcollective
plugin.activemq.pool.1.password = marionette
# Facts
factsource = yaml
plugin.yaml = /etc/puppetlabs/mcollective/facts.yaml
#创建log文件路径
mkdir /var/log/mcollective
chown mcollective /var/log/mcollective
4. 修改service文件
vi /usr/lib/systemd/system/mcollective.service
在[Service]下添加User=mcollective,并修改configfile和pidfile的路径。文件内容如下:
[Unit]
Description=The Marionette Collective
After=network.target
[Service]
User=mcollective
Type=forking
StandardOutput=syslog
StandardError=syslog
ExecStart=/opt/puppetlabs/puppet/bin/mcollectived --config=/var/lib/mcollective/server.cfg --pidfile=/var/lib/mcollective/mcollective.pid --daemonize
ExecReload=/bin/kill -USR1 $MAINPID
PIDFile=/var/lib/mcollective/mcollective.pid
KillMode=process
[Install]
WantedBy=multi-user.target
重新载入service文件
systemctl daemon-reload
5. 启动mcollective
systemctl start mcollective
mcollective 配置项说明
https://puppet.com/docs/mcollective/current/configure/server.html
https://puppet.com/docs/mcollective/current/configure/client.html