zoukankan      html  css  js  c++  java
  • Saltstack

    第一步,安装依赖

    根据官方文档的安装说明,安装相关依赖包:

    依赖

    Salt可以运行在类Unix平台,安装时需要解决如下依赖:

    • Python 2.6 >= 2.6 <3.0
    • msgpack-python - 高性能的消息交换格式

    • YAML - Python YAML bindings
    • Jinja2 - 解析Salt States (在master配置文件中配置)

    • MarkupSafe - Implements a XML/HTML/XHTML Markup safe string for Python
    • apache-libcloud - 与大量的主流云服务提供者进行交互时统一API的Python类

    • Requests - HTTP library
    • Tornado - Web framework and asynchronous networking library
    • futures - Backport of the concurrent.futures package from Python 3.2

    Depending on the chosen Salt transport, ZeroMQ or RAET, dependencies vary:

    • ZeroMQ:
    • RAET:
      • libnacl - Python bindings to libsodium
      • ioflo - The flo programming interface raet and salt-raet is built on
      • RAET - The worlds most awesome UDP protocol

    1. Python

    本文使用的操作系统为:

    默认的 python 版本为:

    2. msgpack-python

    1)地址

    https://pypi.python.org/pypi/msgpack-python/

    2)版本

    msgpack-python-0.4.8.tar.gz

    3)安装

    # tar zxvf msgpack-python-0.4.8.tar.gz
    # cd msgpack-python-0.4.8
    # python setup.py install

    3. YAML

    1)地址

    http://pyyaml.org/

    2)版本

    yaml-0.1.7.tar.gz

    PyYAML-3.12.tar.gz

    3)安装

    LibYAML 0.1.7

    # tar zxvf yaml-0.1.7.tar.gz
    # cd yaml-0.1.7
    # ./configure
    # make
    # make install

    PyYAML 3.12

    需要先安装相关依赖:

    # yum install gcc libffi-devel python-devel openssl-devel

    安装:

    # tar zxvf PyYAML-3.12.tar.gz
    # cd PyYAML-3.12
    # python setup.py --with-libyaml install

    4. MarkupSafe

    1)地址

    https://pypi.python.org/pypi/MarkupSafe

    2)版本

    MarkupSafe-1.0.tar.gz

    3)安装

    # tar zxvf MarkupSafe-1.0.tar.gz
    # cd MarkupSafe-1.0
    # python setup.py install

    5. Jinja2

    1)地址

    https://pypi.python.org/pypi/Jinja2

    2)版本

    Jinja2-2.9.5.tar.gz

    3)安装

    # tar zxvf Jinja2-2.9.5.tar.gz
    # cd Jinja2-2.9.5
    # python setup.py install

    6 . apache-libcloud

    1)地址

    http://libcloud.apache.org/downloads.html

    2)版本

    apache-libcloud-1.5.0.tar.gz

    3)安装

    # tar zxvf apache-libcloud-1.5.0.tar.gz
    # cd apache-libcloud-1.5.0
    # python setup.py install

    7. Requests

    1)地址

    http://docs.python-requests.org/en/latest/user/install/#install

    2)版本

    kennethreitz-requests-v2.13.0-90-g993cbf5.tar.gz

    3)安装

    # tar zxvf kennethreitz-requests-v2.13.0-90-g993cbf5.tar.gz
    # cd kennethreitz-requests-993cbf5
    # python setup.py install

    8. Tornado

    1)backports-abc

    地址

    https://pypi.python.org/simple/backports-abc/

    版本

    backports_abc-0.5.tar.gz

    安装

    # tar zxvf backports_abc-0.5.tar.gz
    # cd backports_abc-0.5
    # python setup.py install

    2)certifi

    地址

    https://pypi.python.org/simple/certifi/

    版本

    certifi-1.0.0.tar.gz

    安装

    # tar zxvf certifi-1.0.0.tar.gz
    # cd certifi-1.0.0
    # python setup.py install

    3)singledispatch

    地址

    https://pypi.python.org/simple/singledispatch/

    版本

    singledispatch-3.4.0.2.tar.gz

    安装

    # tar zxvf singledispatch-3.4.0.2.tar.gz
    # cd singledispatch-3.4.0.2
    # python setup.py install

    4)tornado

    地址

    https://pypi.python.org/pypi/tornado/4.4.2

    版本

    tornado-4.4.2.tar.gz

    安装

    # tar zxvf tornado-4.4.2.tar.gz
    # cd tornado-4.4.2
    # python setup.py install

    9. futures

    1)地址

    https://github.com/agronholm/pythonfutures

    2)版本

    pythonfutures-master.zip

    3)安装

    # unzip pythonfutures-master.zip
    # cd pythonfutures-master
    # python setup.py install

    10. ZeroMQ

    1)地址

    http://zeromq.org/intro:get-the-software

    2)版本

    zeromq-4.2.1.tar.gz

    3)安装

    # tar zxvf zeromq-4.2.1.tar.gz
    # cd zeromq-4.2.1
    # ./configure
    # make
    # make install

    11. pyzmq

    1)Cython

    地址

    https://pypi.python.org/pypi/Cython/

    版本

    Cython-0.25.2.tar.gz

    安装

    # tar zxvf Cython-0.25.2.tar.gz
    # cd Cython-0.25.2
    # python setup.py install

    2)pyzmq

    地址

    https://github.com/zeromq/pyzmq

    版本

    pyzmq-master.zip

    安装

    # unzip pyzmq-master.zip
    # cd pyzmq-master
    # python setup.py install

    12. PyCrypto

    1)地址

    https://www.dlitz.net/software/pycrypto/

    2)版本

    pycrypto-2.6.1.tar.gz

    3)安装

    # tar zxvf pycrypto-2.6.1.tar.gz
    # cd pycrypto-2.6.1
    # python setup.py install

    第二步,安装 Saltstack

    1. 地址

    https://github.com/saltstack/salt

    https://pypi.python.org/pypi/salt/

    2. 版本

    salt-develop.zip

    3. 安装

    # unzip salt-develop.zip
    # cd salt-develop
    # python setup.py install

    4. 测试

    执行以下命令:

    # salt --versions-report

    返回信息:

    第三步,配置

    1. master

    1)配置

    # mkdir /etc/salt
    # cd salt-develop/
    # cp -a conf/master /etc/salt/
    # cp -a pkg/suse/salt-master /etc/init.d/
    # chmod +x /etc/init.d/salt-master
    # chkconfig --level 235 salt-master on

    2)编辑 /etc/salt/master

    # vim /etc/salt/master

    master 中的内容:

    interface: 192.168.6.128
    auto_accept: True

    3)启动

    # service salt-master start

    4)查看

    # netstat -ntlp

    # ps aux | grep python

    2. minion

    1)配置

    # mkdir /etc/salt
    # cd salt-develop
    # cp -a conf/minion /etc/salt/
    # cp -a pkg/suse/salt-minion /etc/init.d/
    # chmod +x /etc/init.d/salt-minion
    # chkconfig --level 235 salt-minion on

    2)编辑 /etc/salt/minion

    # vi /etc/salt/minion

    minion 文件的内容:

    master: 192.168.6.128
    id: minion-192-168-6-128

    3)启动

    # service salt-minion start

    4)查看

    # ps aux | grep python

    3. 查看 salt key 信息

    执行命令:

    # salt-key -L

    返回信息:

    如果在 /etc/salt/master 的配置文件中没有配置自动接收 key,可以使用以下命令:

    # salt-key -A

    返回信息:

    再次查看:

    第四步,测试

    1. 测试被控主机的连通性

    执行命令:

    # salt '*' test.ping

    返回信息:

    2. 远程命令执行测试

    执行命令:

    # salt '*' cmd.run 'uptime'

    返回信息:

    3. 根据被控主机的grains信息进行匹配过滤

    执行命令:

    # salt -G 'os:Centos' test.ping

    返回信息:

    4. 显示被控主机的操作系统类型

    执行命令:

    # salt '*' grains.item os

    返回信息:

    5. 远程代码执行测试

    执行命令:

    # salt '*' cmd.exec_code python 'import sys; print sys.version'

    返回信息:

    第五步,常用模块

    1. cp 模块

    实现远程文件、目录的复制,以及下载URL文件等操作。
    1)将主服务器 file_roots 指定位置下的目录复制到被控主机
    # salt '*' cp.get_dir salt://hellotest /data

    2)将主服务器file_roots指定位置下的文件复制到被控主机
    # salt '*' cp.get_file salt://hellotest/rocketzhang /root/rocketzhang

    3)下载指定URL内容到被控主机指定位置
    # salt '*' cp.get_url http://xxx.xyz.com/download/0/files.tgz /root/files.tgz

    2. cmd 模块

    实现远程的命令行调用执行
    # salt '*' cmd.run 'netstat -ntlp'

    3. cron 模块

    实现被控主机的crontab操作
    1)为指定的被控主机、root用户添加crontab信息
    # salt '*' cron.set_job root '*/5' '*' '*' '*' '*' 'date >/dev/null 2>&1'
    # salt '*' cron.raw_cron root

    2)删除指定的被控主机、root用户的crontab信息
    # salt '*' cron.rm_job root 'date >/dev/null 2>&1'
    # salt '*' cron.raw_cron root

    4. dnsutil 模块

    实现被控主机通用DNS操作
    为被控主机添加指定的hosts主机配置项
    # salt '*' dnsutil.hosts_append /etc/hosts 127.0.0.1 rocketzhang.qq.com

    5. file 模块

    被控主机文件常见操作,包括文件读写、权限、查找、校验等

    # salt '*' file.get_sum /etc/resolv.conf md5
    # salt '*' file.stats /etc/resolv.conf

    6. network 模块

    返回被控主机网络信息

    # salt '*' network.ip_addrs
    # salt '*' network.interfaces

    7. pkg 包管理模块

    被控主机程序包管理,如 yum、apt-get 等
    # salt '*' pkg.install nmap
    # salt '*' pkg.file_list nmap

    8. service 服务模块

    被控主机程序包服务管理

    # salt '*' service.enable crond

    # salt '*' service.disable crond

    # salt '*' service.status crond

    # salt '*' service.stop crond

    # salt '*' service.start crond

    # salt '*' service.restart crond

    # salt '*' service.reload crond

    9. 更多功能

    如:grains、pillar、states、modules、returner、runners、reactor等,以及模板配置的渲染、扩展模块的二次开发等。

  • 相关阅读:
    vue中用v-for循环出出来的div下面的span不给宽度也能相对于div居中
    日期格式化
    在vue中写一个跟着鼠标跑的div,div里面动态显示数据
    计算两个时间相差的分钟数,显示方式为(分钟数:秒数)
    vue中引入json数据,不用本地请求
    解决vue中模态框内数据和外面的数据绑定的问题
    使用js控制文本超出部分显示省略号
    vue自己写了一个div菜单,点击按钮展开,点击其他地方关闭这个div菜单
    解决SMON_SCN_TO_TIME_AUX表损坏故障
    Drop user 报ORA-00600 [KTSSDRP1]
  • 原文地址:https://www.cnblogs.com/RUReady/p/6641104.html
Copyright © 2011-2022 走看看