Saltstack Introduction
Saltstack is a new infrastructure management tool. At present in the rapid development stage, can be regarded as the strengthened func+ weakening Puppet combination. The two main functions of Saltstack are reflected indirectly: remote execution and configuration management. Saltstack is a very easy-to-use and lightweight management tool developed using Python . Consists of Master and Minion , which communicates through ZeroMQ .
First, Saltstack Basic installation
1.
installation Source
1.1 Installing the Epel source
cd/usr/local/src/
wget http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
RPM-IVH epel-release-6-8.noarch.rpm
1.2 Installing Rpmforge
This step is important, there is no python-jinja2 on the Epel source of Redhat 6 and CentOS 6.
Cat/etc/issue
wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
RPM-UVH rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
2.
Install dependent packages
Vim/etc/yum.repos.d/epel.repo
[Epel]
baseurl=http://mirrors.hustunique.com/epel/6/x86_64/
Yum Install PYTHON-JINJA2
3.
Installing Saltstack
Only one installation master is required, and all other installations are minion.
3.1 Installing Salt-master
yum-y Install Salt-master enablerepr=epel-testin g
3.2 Installing Salt-minion
Yum-y Install salt-minion enablerepr=epel-testing
4.
Configure Saltstack
4.1 Minion Configuration
Master with two spaces in front, this line of code indicates that the master of the Saltstack I'm connecting to is 10.102.36.67:
cat/etc/salt/minion| grep "^ Master"
You need to modify the master option in the Minion configuration file/etc/salt/minion to do the following:
master:10.102.36.67
Id:1
ID: The identity of the client, which is used to connect the client with the server,
such as: Salt ' 1 ' cmd.run ' df-h '
4.2master Configuration
Master Monitor 10.102.36.67 , the old look in front also has two space, otherwise when start will error.
Cat/etc/salt/master | grep ' ^ interface '
By default, salt Master listens on 4505 and 45,062 ports on all interfaces (0.0.0.0). If you want to bind a specific IP, you need to make the following changes to the "interface" option in the/etc/salt/master configuration file:
interface:10.102.36.67
Modify Auto_accept to True, automatically accept the client's key, of course, can not be set here, manually accept the line, accept the way: Salt-key-akeyname (KeyName is the ID that the client just set to identify)
Auto_accept:true
Clients every 30s to the server to synchronize resources, time can be casual DIY mintus:hours: such a format
Same as Client manual execution Salt-call state.highstate command;
Schedule
Highstate:
Function:state.highstate
Seconds:30
5.
Start Saltstack
5.1 Start Master
Service Salt-master Start
5.2 Start Minion
Service Salt-minion Start
6.
Test Saltstack
The next commands are executed on master.
Format of the command: Salt ' parameter ' object ' command
6.1 View Minion list
Salt-key–l
6.2 Accept all keys
Salt-key–a
In the prompt, Y confirm. You can then send the command to minion.
6.3 Simple test
Salt ' * ' test.ping
Second, master Batch management configuration
Server-side Write SLS mode, his default path under/srv/salt/, do not create a new directory, and then create a new Top.sls is similar to Puppet's import file SITE.PP.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/22/wKiom1Sp82-BOBJnAAAq-ATwomY257.jpg "style=" float: none; "title=" 1.png "alt=" Wkiom1sp82-bobjnaaaq-atwomy257.jpg "/>
· Base: The default start configuration item:
· ' * ': This is a matching object within this quotation mark, for all managed hosts
· Rd.sc: Refers to the resource file/srv/salt/rd/sc.sls
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/22/wKiom1Sp83CjSX1QAACrTrHdIOk767.jpg "title=" 2.png " Style= "Float:none;" alt= "wkiom1sp83cjsx1qaacrtrhdiok767.jpg"/>
Look at the resource file under the RD directory
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/1E/wKioL1Sp9C2x5iVBAAIjgaCpZvk535.jpg "title=" 3.png " Style= "Float:none;" alt= "wkiol1sp9c2x5ivbaaijgacpzvk535.jpg"/>
Using the PY mode of the SLS configuration file (in fact, the Python script, as long as the return to the YAML format dictionary file is good), we can simplify the above operations into 1 steps, the idea is as follows:
Write the configuration in 1,/srv/pillar/top.sls:
Base
‘*‘:
-Custom
2 , write /srv/pillar/custom/init.slsusing the PY mode, and automatically read the pillar configuration, such as salt The ID is: 10.1.1.1-centos.game.web, then project is game, and then the Pillar_root group is synthesized according to the obtained path/srv/pillar/custom/game/10.1.1.1- Centos.game.web.yaml, using the Yaml module to read information from the file, return to the dictionary
3, match all minion in the/srv/salt/top.sls file
‘*’:
-Centos.public_services
4 ,/srv/salt/centos/public_services/ The Init.sls file is written in py mode and the configuration obtains the pillar information for the corresponding Minion, and if the MySQL configuration information is included and configured correctly, the configuration of the MySQL instance is returned.
Now how to use it, very simple, for example, your ID is 10.1.1.1-centos.game.web, first in the/srv/pillar/custom/directory to build a game directory (from the Salt ID to get the project name), Then in the game directory to create a new file 10.1.1.1-centos.game.web.yaml, which write the configuration information:
Mysql:
Ports
-3306
-3307
-3308
Version: ' 5_5_25 '
Final execution Command:
Salt 10.1.1.1-centos.game.web state.highstate-v-T 300
Wait for the execution to finish quietly!
This article is from "It laborer-----Xiao Ying" blog, please be sure to keep this source http://itxiaoying.blog.51cto.com/8783886/1599201
Saltstack installation Configuration