SaltStack is a centralized server infrastructure management platform that provides configuration management, remote execution, monitoring, and other functions. Generally, it can be understood as a simplified version of puppet and an enhanced version of func. SaltStack is implemented based on the Python language and combined with the lightweight Message Queue (ZeroMQ) and Python third-party modules (Pyzmq, PyCrypto, Pyjinjia2, python-msgpack, and PyYAML.
1. Introduction
SaltStack is a centralized server infrastructure management platform that provides configuration management, remote execution, monitoring, and other functions. Generally, it can be understood as a simplified version of puppet and an enhanced version of func. SaltStack is implemented based on the Python language and combined with the lightweight Message Queue (ZeroMQ) and Python third-party modules (Pyzmq, PyCrypto, Pyjinjia2, python-msgpack, and PyYAML.
By deploying the SaltStack environment, we can perform batch execution on thousands of servers.CommandConfiguration of centralized management, file distribution, server data collection, operating system basics, and software package management based on different business characteristics, saltStack is a powerful tool for O & M personnel to improve work efficiency and standardize business configuration and operations.
2. Features
(1) The deployment is simple and convenient;
(2) supports most UNIX/Linux and Windows environments;
(3) centralized master-slave management;
(4) simple configuration, powerful functions, and strong scalability;
(5) the master and minion are certificate-based, secure and reliable;
(6) supports APIs and custom modules, which can be easily expanded using Python.
3. Master and Minion Authentication
(1) When minion is started for the first time, it will automatically generate minion in/etc/salt/pki/minion/(this path is set in/etc/salt/minion. pem (private key) and minion. pub (public key), and then set minion. pub sends data to the master.
(2) After the master receives the minion public key, it uses the salt-key command to accept minion public key, in this way, the public key named by minion id will be stored in/etc/salt/pki/master/minions of the master, and then the master will be able to send commands to minion.
4. connection between the Master and Minion
(1) After the SaltStack master is started, it listens to port 4505 and port 4506 by default. 4505 (publish_port) is the message publishing system of saltstack, and 4506 (ret_port) is the port on which the saltstack client communicates with the server. If you use lsof to view port 4505, you will find that all the minion stays in the ESTABLISHED State on port 4505.
(2) The communication mode between minion and master is as follows:
5. Test Environment
IPAddress |
Role |
System Environment |
10.133.33.85 |
Master |
CentOS 1, 6.3 |
10.130.87.151 |
Minion |
CentOS 1, 6.3 |
========================================================== ========================================================== ============
Ii. Basic installation and configuration of SaltStack
========================================================== ========================================================== ============
1. Dependency Component Description
Http://docs.saltstack.com/en/latest/topics/installation/index.html
SaltStack's communication modes are divided into two modes: ZeroMQ and REAT. Given that REAT is not yet too stable, we chose ZeroMQ. This installation adopts the source code installation method.
After extracting the source code, components in these text files are also dependent on the instructions:
2. Basic installation of SaltStack
(1) install python 2.7
Https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
# Tar xvzf Python-2.7.8.tgz
# Cd Python-2.7.8
#./Configure -- prefix =/usr/local
# Make -- jobs = 'grep processor/proc/cpuinfo | wc-l'
# Make install
# Copy the python header file to the standard directory to avoid missing the required header file when compiling the saltstack.
# Cd/usr/local/include/python2.7
# Cp-a./*/usr/local/include/
# Back up the old version of python and link the new version of python with symbols
# Cd/usr/bin
# Mv python python2.6
# Ln-s/usr/local/bin/python
# Modify the yum script to point it to the old version of python, so that it cannot run
# Vim/usr/bin/yum
#! /Usr/bin/python --> #! /Usr/bin/python2.6
(2) install the PyYAML Module
Http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
Https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz
# Tar xvzf yaml-0.1.5.tar.gz
# Cd yaml-0.1.5
#./Configure -- prefix =/usr/local
# Make -- jobs = 'grep processor/proc/cpuinfo | wc-l'
# Make install
# Tar xvzf PyYAML-3.11.tar.gz
# Cd PyYAML-3.11
# Python setup. py install
(3) install the setuptools Module
Https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz
# Tar xvzf setuptools-7.0.tar.gz
# Cd setuptools-7.0
# Python setup. py install
(4) markupsafe module Installation
Https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.9.3.tar.gz
# Tar xvzf MarkupSafe-0.9.3.tar.gz
# Cd MarkupSafe-0.9.3
# Python setup. py install
(5) jinja2 module Installation
Https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
# Tar xvzf Jinja2-2.7.3.tar.gz
# Cd Jinja2-2.7.3
# Python setup. py install
(6) install the pyzmq Module
Http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
Note:
The autoconf version that comes with the system is 2.63. When compiling ZeroMQ, an error may fail due to a low version. Therefore, you must install a version later than 2.63.
# Tar xvzf autoconf-2.69.tar.gz
# Cd autoconf-2.69
#./Configure -- prefix =/usr
# Make
# Make install
# Install other dependent Libraries
# Yum-y install libuuid. x86_64 libuuid-devel.x86_64
# Yum-y install uuid. x86_64 uuid-devel.x86_64
# Yum-y install uuid-c ++. x86_64 uuid-c ++-devel. x86_64
Https://github.com/jedisct1/libsodium/archive/1.0.1.tar.gz
# Tar xvzf libsodium-1.0.1.tar.gz
# Cd libsodium-1.0.1
#./Autogen. sh
#./Configure -- prefix =/usr/local
# Make -- jobs = 'grep processor/proc/cpuinfo | wc-l'
# Make install
Http://download.zeromq.org/zeromq-4.0.5.tar.gz
Https://pypi.python.org/packages/source/p/pyzmq/pyzmq-14.4.1.tar.gz
# Tar xvzf zeromq-4.0.5.tar.gz
# Cd zeromq-4.0.5
#./Autogen. sh
#./Configure -- prefix =/usr/local
# Make -- jobs = 'grep processor/proc/cpuinfo | wc-l'
# Make install
# Tar xvzf pyzmq-14.4.1.tar.gz
# Cd pyzmq-14.4.1
# Python setup. py configure -- zmq =/usr/local
# Python setup. py install
(7) M2Crypto module Installation
# Yum-y install swig. x86_64
Http://www.openssl.org/source/openssl-1.0.1g.tar.gz
# Tar xvzf openssl-1.0.1g.tar.gz
# Cd openssl-1.0.1g
#./Config shared -- prefix =/usr/local
# Make & make install
Https://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.22.3.tar.gz
# Tar xvzf M2Crypto-0.22.3.tar.gz
# Cd M2Crypto-0.22.3
# Python setup. py install
Note:
If the preceding error is reported, run the following command:
# Cp-a/usr/local/include/openssl/usr/include/
(8) msgpack module Installation
Https://pypi.python.org/packages/source/m/msgpack-python/msgpack-python-0.4.2.tar.gz
# Tar xvzf msgpack-python-0.4.2.tar.gz
# Cd msgpack-python-0.4.2
# Python setup. py install
(9) msgpack-pure module Installation
Https://pypi.python.org/packages/source/m/msgpack-pure/msgpack-pure-0.1.3.tar.gz
# Tar xvzf msgpack-pure-0.1.3.tar.gz
# Cd msgpack-pure-0.1.3
# Python setup. py install
(10) install the pycrypto Module
Https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz
# Tar xvzf pycrypto-2.6.1.tar.gz
# Cd pycrypto-2.6.1
# Python setup. py install