1. 程式人生 > >CentOS 6.5 SaltStack安裝配置

CentOS 6.5 SaltStack安裝配置

SaltStack 開源的叢集管理工具,基於Python開發,開源,簡單,快速,容易上手。

這裡寫圖片描述

Master 是主管理節點; (農場主)
Minion 是具體的服務裝置節點; (監工
Syndic 是一群Minion的代理管理節點;(奴隸

  1. 配置HOST
[root@23 bin]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain
6 192.168.198.23 salt-master 192.168.198.99 salt-minion

2.通過yum安裝

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

salt-master# yum install -y salt-master

salt-minion# yum -y install salt-minion

3.master 上配置防火牆

iptables -I INPUT 10 -p tcp --dport 4505:4506 -j ACCEPT

4.配置master節點

vim /etc/salt/master


# The file server works on environments passed to the master, each environment
# can have multiple root directories, the subdirectories in the multiple file
# roots cannot match, otherwise the downloaded files will not be able to be
# reliably ensured. A base environment is required to house the top file.
# Example: # file_roots: # base: # - /srv/salt/ # dev: # - /srv/salt/dev/services # - /srv/salt/dev/states # prod: # - /srv/salt/prod/services # - /srv/salt/prod/states # file_roots: base: - /srv/salt # Salt Pillars allow for the building of global data that can be made selectively # available to different minions based on minion grain filtering. The Salt # Pillar is laid out in the same fashion as the file server, with environments, # a top file and sls files. However, pillar data does not need to be in the # highstate format, and is generally just key/value pairs. pillar_roots: base: - /srv/pillar

5.配置minion節點

vim /etc/salt/minion

# Set the location of the salt master server. If the master server cannot be
# resolved, then the minion will fail to start.
master: salt-master

# 
Explicitly declare the id for this minion to use, if left commented the id
# will be the hostname as returned by the python call: socket.getfqdn()
# Since salt uses detached ids it is possible to run multiple minions on the
# same machine but with different ids, this can be useful for salt compute
# clusters.
id: salt-minion

6.啟動服務

salt-master# /etc/init.d/salt-master start

salt-minion# /etc/init.d/salt-minion start

minion啟動後,會向master發起認證請求,可以配置master預設接受一切認證請求,或者挨個接受。

7.接受認證

salt-master# salt-key -L  #List all public keys
Accepted Keys:
Denied Keys:
Unaccepted Keys:
salt-minion
Rejected Keys:

接受salt-minion的請求

salt-master# salt-key -a salt-minion #Accept the specified public key
The following keys are going to be accepted:
Unaccepted Keys:
salt-minion Proceed? [n/Y] y
Key for minion salt-minion accepted.
[[email protected] bin]# salt-key -L
Accepted Keys:
salt-minion Denied Keys: Unaccepted Keys: Rejected Keys:

8.簡單命令

# salt '*' test.ping    #檢查當前所有主機狀態
# salt 'salt-minion' test.ping
# salt '*' cmd.run 'df -h'

9.缺點就是太佔記憶體了,預設啟動10個程序,每個佔用1g的記憶體

top
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
31970 root 20 0 394m 34m 2916 S 0.0 0.9 5:07.42 salt-master
31977 root 20 0 1194m 33m 3008 S 0.0 0.9 0:01.13 salt-master
31974 root 20 0 1194m 33m 3008 S 0.0 0.9 0:01.13 salt-master
31976 root 20 0 1194m 33m 3004 S 0.0 0.9 0:01.15 salt-master
31982 root 20 0 1194m 33m 3008 S 0.0 0.9 0:01.13 salt-master
31975 root 20 0 1194m 33m 2996 S 0.0 0.9 0:01.13 salt-master
31972 root 20 0 370m 23m 1568 S 0.0 0.6 0:00.22 salt-master
31991 root 20 0 666m 21m 1720 S 0.0 0.6 0:00.17 salt-master
31971 root 20 0 370m 21m 1796 S 0.0 0.6 0:00.00 salt-master
31969 root 20 0 286m 21m 1320 S 0.0 0.6 0:00.01 salt-master