CentOS 6.5上安装salt

简介:

一、环境准备

[root@salt-master ~]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=salt-master.contoso.com

[root@salt-master ~]# hostname

salt-master.contoso.com

[root@salt-master ~]# /etc/init.d/iptables status

iptables: Firewall is not running.

[root@salt-master ~]# iptables -nL

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         


Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         


Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination         

[root@salt-master ~]# getenforce

Disabled

[root@salt-master ~]# crontab -l

*/10 * * * * ntpdate time.nist.gov >/dev/null 2>&1

[root@salt-master ~]# cat /etc/redhat-release 

CentOS release 6.5 (Final)

[root@salt-master ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.1.100  salt-master     salt-master.contoso.com

172.16.1.101  salt-minion01   salt-minion01.contoso.com

172.16.1.102  salt-minion02   salt-minion02.contoso.com

二、安装salt

1、master安装

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

yum -y install salt-master

2、minion安装

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

yum -y install salt-minion

三、修改配置文件

1、master端配置文件

[root@salt-master ~]# cp /etc/salt/master.sample /etc/salt/master

[root@salt-master ~]# vi /etc/salt/master

[root@salt-master salt]# diff master.sample master

416,418c416,420

< #file_roots:

< #  base:

< #    - /srv/salt

---

> file_roots:

>   base:

>     - /srv/salt/base

>   prod:

>     - /srv/salt/prod

535a538,542

> pillar_roots:

>   base:

>     - /srv/pillar/base

>   prod:

>     - /srv/pillar/prod

2、minion端配置文件

[root@salt-minion01 ~]# cp /etc/salt/minion.sample /etc/salt/minion

[root@salt-minion01 ~]# vi /etc/salt/minion

[root@salt-minion01 ~]# diff /etc/salt/minion.sample /etc/salt/minion

16a17

> master: salt-master.contoso.com

78a80

> id: salt-minion01.contoso.com

四、启动salt服务

1、启动master服务

[root@salt-master ~]# /etc/init.d/salt-master start

[root@salt-master ~]# chkconfig salt-master on

检查服务运行状态:

[root@salt-master ~]# netstat -tnlp|grep 4506

tcp        0      0 0.0.0.0:4506                0.0.0.0:*                   LISTEN      1105/python2.6      

[root@salt-master ~]# ps -ef|grep salt

root       1075      1  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1076   1075  0 05:39 ?        00:00:26 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1078   1075  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1083   1075  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1084   1075  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1088   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1089   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1095   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1096   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1102   1084  0 05:39 ?        00:00:01 /usr/bin/python2.6 /usr/bin/salt-master -d

root       1105   1084  0 05:39 ?        00:00:00 /usr/bin/python2.6 /usr/bin/salt-master -d

root       2947   1151  0 07:10 pts/0    00:00:00 grep salt

[root@salt-master ~]# lsof -i :4506

COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

salt-mast 1105 root   20u  IPv4   9750      0t0  TCP *:4506 (LISTEN)

salt-mast 1105 root   23u  IPv4  11915      0t0  TCP salt-master:4506->salt-minion01:52639 (ESTABLISHED)

salt-mast 1105 root   28u  IPv4  11914      0t0  TCP salt-master:4506->salt-minion02:34798 (ESTABLISHED)

2、启动minion服务

[root@salt-minion01 ~]# /etc/init.d/salt-minion start

[root@salt-minion01 ~]# chkconfig salt-minion on

检查服务运行状态:

[root@salt-minion01 ~]# netstat -tunlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      950/sshd            

tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1026/master         

tcp        0      0 :::22                       :::*                        LISTEN      950/sshd            

tcp        0      0 ::1:25                      :::*                        LISTEN      1026/master         

[root@salt-minion01 ~]# lsof -i :4506

COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

salt-mini 1054 root   13u  IPv4   9848      0t0  TCP salt-minion01:52639->salt-master:4506 (ESTABLISHED)

[root@salt-minion01 ~]# ps -ef|grep salt

root       1054      1  0 05:39 ?        00:00:04 /usr/bin/python2.6 /usr/bin/salt-minion -d

root       1254   1100  0 07:13 pts/0    00:00:00 grep salt

五、简单测试

1)添加minion端

[root@salt-master ~]# salt-key -A

[root@salt-master ~]# salt-key -L

Accepted Keys:

salt-minion01.contoso.com

salt-minion02.contoso.com

Denied Keys:

Unaccepted Keys:

Rejected Keys:

2)test.ping方法测试

[root@salt-master ~]# salt '*' test.ping

salt-minion02.contoso.com:

    True

salt-minion01.contoso.com:

    True

3)cmd.run方法测试

[root@salt-master ~]# salt '*' cmd.run 'hostname'

salt-minion01.contoso.com:

    salt-minion01.contoso.com

salt-minion02.contoso.com:

    salt-minion02.contoso.com



本文转自 jerry1111111 51CTO博客,原文链接:http://blog.51cto.com/jerry12356/1929155,如需转载请自行联系原作者

相关文章
|
2月前
|
存储 Ubuntu Linux
VMware-安装CentOS系统教程及安装包
虚拟机相当于是一个独立于你电脑的环境,在这个环境上面,你可以安装Linux、Windows、Ubuntu等各个类型各个版本的系统,在这个系统里面你不用担心有病读等,不用担心文件误删导致系统崩溃。 虚拟机也和正常的电脑系统是一样的,也可以开关机,不用的时候,你关机就可以了,也不会占用你的系统资源,使用起来还是比较方便 这里也有已经做好的CentOS 7系统,下载下来解压后直接用VMware打开就可以使用
512 69
|
19天前
|
存储 分布式计算 Linux
安装篇--CentOS 7 虚拟机安装
VMware 装 CentOS 7 不知道从哪下手?这篇超详细图文教程手把手教你在 VMware Workstation 中完成 CentOS 7 桌面系统的完整安装流程。从 ISO 镜像下载、虚拟机配置,到安装图形界面、设置用户密码,每一步都有截图讲解,适合零基础新手快速上手。装好之后无论你是要搭 Hadoop 集群,还是练 Linux ,这个环境都够你折腾一整天!
404 2
|
2月前
|
Ubuntu Linux 索引
Centos 7、Debian及Ubuntu系统中安装和验证tree命令的指南。
通过上述步骤,我们可以在CentOS 7、Debian和Ubuntu系统中安装并验证 `tree`命令。在命令行界面中执行安装命令,然后通过版本检查确认安装成功。这保证了在多个平台上 `tree`命令的一致性和可用性,使得用户无论在哪种Linux发行版上都能使用此工具浏览目录结构。
269 78
|
19天前
|
安全 关系型数据库 MySQL
CentOS 7 yum 安装 MySQL教程
在CentOS 7上安装MySQL 8,其实流程很清晰。首先通过官方Yum仓库来安装服务,然后启动并设为开机自启。最重要的环节是首次安全设置:需要先从日志里找到临时密码来登录,再修改成你自己的密码,并为远程连接创建用户和授权。最后,也别忘了在服务器防火墙上放行3306端口,这样远程才能连上。
270 16
|
3月前
|
Linux 网络安全 Apache
针对在Centos/Linux安装Apache过程中出现的常见问题集锦
以上每个问题的解决方案应深入分析错误日志、系统消息和各种配置文件,以找到根本原因并加以解决。务必保持系统和Apache软件包更新到最新版本,以修复已知的bugs和安全漏洞。安装和管理Web服务器是一项需要细致关注和不断学习的任务。随着技术的发展,推荐定期查看官方文档和社区论坛,以保持知识的更新。
187 80
|
2月前
|
存储 关系型数据库 MySQL
在CentOS 8.x上安装Percona Xtrabackup工具备份MySQL数据步骤。
以上就是在CentOS8.x上通过Perconaxtabbackup工具对Mysql进行高效率、高可靠性、无锁定影响地实现在线快速全量及增加式数据库资料保存与恢复流程。通过以上流程可以有效地将Mysql相关资料按需求完成定期或不定期地保存与灾难恢复需求。
182 10
|
3月前
|
人工智能 数据挖掘 Linux
Centos安装Python3.7(亲测可用)
本指南详细介绍了在基于Linux(以CentOS系统为例,使用yum包管理器)的系统上安装Python 3.7版本的完整流程。Python是一种广泛使用的高级编程语言,在各种领域如软件开发、数据分析、人工智能和区块链开发等都有着重要的应用。
323 2
|
2月前
|
运维 网络协议 Linux
CentOS下Bind服务的安装与故障排查
通过以上的步骤,您应该能够在CentOS系统上安装并配置BIND DNS服务,并进行基本的故障排查。
210 0
|
4月前
|
机器人 Linux
CentOS 7系统中安装特定版本CMake 3.21.2的方法。
到这里,过程已经全部完成。如果你跟随上面的步骤来,那么你现在已经拥有了一个全新的CMake版本在你的CentOS 7系统上了。这个过程就像是你通过一系列仪式,唤醒了一个沉睡已久的古老机器人,它现在完全按照你的意愿来帮你构建和编译软件了。
286 18
|
2月前
|
存储 Ubuntu Linux
安卓手机免root安装各种Linux系统:Ubuntu, Centos,Kali等
此外还可以安装Slackware、Archstrike等系统,还可以通过github查找方法安装更多有趣的东西。 昨日小编就是通过Termux安装的Kali Linux工具包。