saltstack 安装及配置(Centos篇)

服务器信息说明

Linux

# uname -a
Linux centos7 3.10.0-514.2.2.el7.x86_64 #1 SMP Tue Dec 6 23:06:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

安装

主机域名配置

为了便于后期服务器资源的管理,需要给每台要监控的主机配置对应的域名信息

# cat /etc/hosts
192.168.137.101 centos7

配置 EPEL 源

# rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm  
获取https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm                       
警告:/var/tmp/rpm-tmp.D7fGsT: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY              
准备中...                          ################################# [100%]                 
正在升级/安装...                                                                               
   1:epel-release-7-9                 ################################# [100%]           

安装 Master 端

# yum install salt-master -y

安装 Minion 端

  • 安装 minion 端程序
# yum install salt-minion -y
  • 配置 minion 端
# vi /etc/salt/minion 
master: centos7

PS:此处填写的 master 端域名信息

启动相应的服务并完成测试

启动 Master 端

  • 配置 salt-master 为自动启动
# systemctl enable salt-master
Created symlink from /etc/systemd/system/multi-user.target.wants/salt-master.service to /usr/lib/systemd/system/salt-master.service.
  • 启动 salt-master 服务
# systemctl start salt-master
  • 检查 salt-master 服务运行情况
# systemctl status salt-master
● salt-master.service - The Salt Master Server
   Loaded: loaded (/usr/lib/systemd/system/salt-master.service; enabled; vendor preset: disabled)
   Active: active (running) since 三 2017-02-15 11:51:44 CST; 9s ago
 Main PID: 3130 (salt-master)
   CGroup: /system.slice/salt-master.service
           ├─3130 /usr/bin/python /usr/bin/salt-master
           ├─3139 /usr/bin/python /usr/bin/salt-master
           ├─3140 /usr/bin/python /usr/bin/salt-master
           ├─3141 /usr/bin/python /usr/bin/salt-master
           ├─3142 /usr/bin/python /usr/bin/salt-master
           ├─3147 /usr/bin/python /usr/bin/salt-master
           ├─3148 /usr/bin/python /usr/bin/salt-master
           ├─3149 /usr/bin/python /usr/bin/salt-master
           ├─3150 /usr/bin/python /usr/bin/salt-master
           ├─3159 /usr/bin/python /usr/bin/salt-master
           ├─3160 /usr/bin/python /usr/bin/salt-master
           └─3598 /usr/bin/python /usr/bin/salt-master

215 11:51:42 centos7 systemd[1]: Starting The Salt Master Server...
215 11:51:44 centos7 systemd[1]: Started The Salt Master Server.

启动 Minion 端

  • 设置 minion 为自动启动
# systemctl enable salt-minion
Created symlink from /etc/systemd/system/multi-user.target.wants/salt-minion.service to /usr/lib/systemd/system/salt-minion.service.
  • 启动 minion 服务
# systemctl start salt-minion
  • 检查 minion 服务的运行情况
# systemctl status salt-minion
● salt-minion.service - The Salt Minion
   Loaded: loaded (/usr/lib/systemd/system/salt-minion.service; enabled; vendor preset: disabled)
   Active: active (running) since 三 2017-02-15 12:11:08 CST; 9s ago
 Main PID: 4210 (salt-minion)
   CGroup: /system.slice/salt-minion.service
           ├─4210 /usr/bin/python /usr/bin/salt-minion
           └─4213 /usr/bin/python /usr/bin/salt-minion

215 12:11:08 centos7 systemd[1]: Started The Salt Minion.
215 12:11:08 centos7 systemd[1]: Starting The Salt Minion...
215 12:11:12 centos7 salt-minion[4210]: [ERROR   ] The Salt Master has cached the public key for this node, this salt minion will wait for 10 seconds ...thenticate
Hint: Some lines were ellipsized, use -l to show in full.

PS:上述报错 2月 15 12:11:12 centos7 salt-minion[4210]: [ERROR ] The Salt Master has cached the public key for this node, this salt minion will wait for 10 seconds ...thenticate 是因为没有将 minion 端添加到 master 的监控列表中

将 minion 添加到 master 监控列表中

# salt-key 
Accepted Keys:
Denied Keys:
Unaccepted Keys:
centos7
Rejected Keys:

# salt-key -a centos7
The following keys are going to be accepted:
Unaccepted Keys:
centos7
Proceed? [n/Y] y
Key for minion centos7 accepted.

# salt-key 
Accepted Keys:
centos7
Denied Keys:
Unaccepted Keys:
Rejected Keys:

测试

# salt '*' test.ping
centos7:
    True

# salt '*' cmd.run 'df -h'
centos7:
    Filesystem               Size  Used Avail Use% Mounted on
    /dev/mapper/centos-root   18G  6.1G   12G  35% /
    devtmpfs                 905M     0  905M   0% /dev
    tmpfs                    920M   16K  920M   1% /dev/shm
    tmpfs                    920M  8.7M  912M   1% /run
    tmpfs                    920M     0  920M   0% /sys/fs/cgroup
    /dev/sda1                497M  186M  312M  38% /boot
    tmpfs                    184M     0  184M   0% /run/user/0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值