System environment: CentOS Release 6.7 (Final)
Kernel version: 2.6.32-573.el6.x86_64
Hardware environment: 20G HDD 2G memory Dual core CPU
IP Address deployment:
master:10.0.0.7 hostname:linux-node1.example.com
minion:10.0.0.8 hostname:linux-node2.example.com
[email protected] ~]# Yum install salt-master salt-minion-y
[Email protected] ~]# Cat/etc/salt/master | Grep-v "^#"
Client_acl:
Oldboy:
-Test.ping
-network.*
User01:
-Linux-node1.example.com:
-Test.ping
File_roots:
Base
-/srv/salt/base
Prod
-/srv/salt/prod
Test
-/srv/salt/test
Pillar_roots:
Base
-/srv/pillar/base
Master_job_cache:mysql
Mysql.host: ' 10.0.0.7 '
Mysql.user: ' Salt '
Mysql.pass: ' Salt '
Mysql.db: ' Salt '
mysql.port:3306
Etcd_pillar_config:
etcd.host:10.0.0.7
etcd.port:4001
Ext_pillar:
-Etcd:etcd_pillar_config root=/salt/haproxy/
[Email protected] ~]# Cat/etc/salt/minion | Grep-v "^#"
master:10.0.0.7
Id:linux-node1.example.com
Grains
Roles
-Webserver
-Memcache
Mysql.host: ' 10.0.0.7 '
Mysql.user: ' Salt '
Mysql.pass: ' Salt '
Mysql.db: ' Salt '
mysql.port:3306
[Email protected] ~]#/etc/init.d/salt-master restart
Stopping salt-master daemon: [OK]
Starting Salt-master daemon: [OK]
[Email protected] ~]#/etc/init.d/salt-minion restart
Stopping salt-minion daemon: [OK]
Starting salt-minion daemon: [OK]
[[email protected] ~]# salt-key-l-L Show all machines list
Accepted Keys:
Denied Keys:
unaccepted Keys:
Linux-node1.example.com
Linux-node2.example.com
Rejected Keys:
[[email protected] ~]# salt-key-a linux-node1.example.com-a designated to accept a machine
The following keys is going to be accepted:
unaccepted Keys:
Linux-node1.example.com
Proceed? [n/y] Y
Key for Minion Linux-node1.example.com accepted.
[Email protected] ~]# Salt-key
Accepted Keys:
Linux-node1.example.com
Denied Keys:
unaccepted Keys:
Linux-node2.example.com
Rejected Keys:
[[email protected] ~]# Salt-key-a-a accepts all machines
The following keys is going to be accepted:
unaccepted Keys:
Linux-node2.example.com
Proceed? [n/y] Y
Key for Minion Linux-node2.example.com accepted.
[[email protected] ~]# Salt-key without parameters default is-l
Accepted Keys:
Linux-node1.example.com
Linux-node2.example.com
Denied Keys:
unaccepted Keys:
Rejected Keys:
[[email protected] ~]# Salt ' * ' test.ping ======salt-master whether to establish contact with Salt-minion, if established then return True
Linux-node2.example.com:
True
Linux-node1.example.com:
True
The role of the top file:
Tell the Minion on which machine to perform the operation:
Example:
[Email protected] ~]# Cat/srv/salt/top.sls
Base: =============> indicate what environment
' *.example.com ': =============> indicate which machine
-Apache =============> indicates what state to perform
Apache.sls file:
Apache-install: ==============>id, free to take
Pkg.installed: ==============> Modules and methods
-Names: ==============> specify what modules need to be installed below
-which software package is required for httpd ==============>
-which software package is required for Httpd-devel ==============>
Apache-service: ==============>id, free to take
Service.running: ==============> Modules and methods
-NAME:HTTPD ==============> Program name
-Enable:true ==============> is powered on from boot
-Reload:true ==============> whether to allow overloading
[[email protected] salt]# Salt ' * ' State.sls Apache
Salt command
* Indicate which machine
State module
SLS method
Apache indicates which state file needs to be executed
############################################################################################################### ############################################################
############################################################################################################### ############################################################
############################################################################################################### ############################################################
[email protected] ~]# Yum install salt-minion-y
[Email protected] ~]# Cat/etc/salt/minion | Grep-v "^#"
master:10.0.0.7
Id:linux-node2.example.com
Mysql.host: ' 10.0.0.7 '
Mysql.user: ' Salt '
Mysql.pass: ' Salt '
Mysql.db: ' Salt '
mysql.port:3306
[Email protected] ~]#/etc/init.d/salt-minion restart
Stopping salt-minion daemon: [OK]
Starting salt-minion daemon: [OK]
Old boy Website: http://www.etiantian.org/
Contact qq:406564728
Welcome to make valuable suggestions
This article is from the "Linux" blog, so be sure to keep this source http://chenjisong.blog.51cto.com/7858025/1714016
Preliminary study on Saltstack