salt源码安装
salt是什么?
一种全新的基础设施管理方式,部署轻松,在几分钟内可运行起来,扩展性好,很容易管理上万台服务器,速度够快,服务器之间秒级通讯。
salt底层采用动态的连接总线, 使其可以用于编配, 远程执行, 配置管理等等.
离线安装只能源码来搞,机器python环境2.6.6,centos6.3,安装主要的是的依赖太多的包,现整理如下,安装前先安装如下依赖包
名称 | 下载地址 |
Jinja2 | https://pypi.python.org/pypi/Jinja2 |
requests | http://www.python-requests.org/en/latest/user/install/#install |
M2Crypto | https://pypi.python.org/pypi/M2Crypto |
MarkupSafe | https://pypi.python.org/pypi/MarkupSafe |
msgpack-python | https://pypi.python.org/pypi/msgpack-python/ |
PyYAML | https://pypi.python.org/pypi/PyYAML/ |
pyzmq | https://pypi.python.org/pypi/pyzmq/ |
salt | https://pypi.python.org/pypi/salt |
CherryPy-3.7.0(若使用salt-api需要安装) | https://pypi.python.org/pypi/CherryPy |
ws4py(若使用salt-api需要安装) | https://pypi.python.org/pypi/ws4py |
依次安装以上依赖包后
mkdir /etc/salt #创建配置目录 cp ${SALT_ROOT_DIR}/conf/master /etc/salt #拷贝master的配置文件 cp ${SALT_ROOT_DIR}/conf/minion /etc/salt #拷贝minion的配置文件(若不打算在本机使用可不拷贝)
编辑/etc/salt/master,注意该配置文件使用YAML格式,注意其中的换行空格一致
# cat /etc/salt/master user: root worker_threads: 10 publish_port : 4505 ret_port : 4506 syndic_master_port : 4506 pidfile: /var/run/salt-master.pid root_dir: / log_file: /var/log/salt_master.log nodegroups: group_all: '*' file_roots: base: - /srv/salt/ pillar_roots: base: - /srv/pillar
编辑/etc/salt/minion,其中所有minion的id必须各自唯一,不能冲突
# cat /etc/salt/minion id: host-4 user: root master : 127.0.0.1 master_port: 4506 backup_mode: minion output: nested acceptance_wait_time: 10 acceptance_wait_time_max: 0 random_reauth_delay: 60 log_file: /var/logs/salt/salt_minion.log file_roots: base: - /srv/salt/ pillar_roots: base: - /srv/pillar
启动salt-master
# salt-master
启动salt-minion
#salt-minion
执行命令
# salt-key L Accepted Keys: Unaccepted Keys: host-4 Rejected Keys: # salt-key -a host-4 # salt-key L Accepted Keys: host-4 Unaccepted Keys: Rejected Keys:
执行命令
#salt '*' cmd.run 'uname -ar' host-4: Linux host-4 2.6.32-279.el6.x86_64 #1 SMP Wed Sep 5 11:42:37 CST 2012 x86_64 x86_64 x86_64 GNU/Linux
done