ansible 是一款linux 集群自动化运维工具,具有非常强大的集群运维能力。下面就简单的运维命令进行记录
此次测试总共有三台机,分别如下:
ansible服务器:10.0.0.20
client01:10.0.0.21
client02:10.0.0.22
一、安装ansible
1、 python版本需要2.6以上,不过通过centos7都会默认安装上python2.7.5,查看方法:python -V
3、 yum clean all
4、 安装ansible:yum install ansible -y
二、配置ansible
1、 使用ansible前需实现ansible服务器对另外两台机的ssh无密码访问,操作如下:
a、 输入命令:ssh-keygen,一直按回车,直至完成操作;
b、 命令:ssh-copy-id root@172.16.0.92 ,然后输入连接密码即可实现无密码访问,另外一台机的设置方式一样,不再赘述。
2、 添加ansible客户机组,命令:cat /etc/ansible/hosts,在最后面添加如下内容:
[hadoop]
172.16.0.91
172.16.0.92
172.16.0.93
[root@k8s-master ansible]# cat hosts
# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
# - Comments begin with the '#' character
# - Blank lines are ignored
# - Groups of hosts are delimited by [header] elements
# - You can enter hostnames or ip addresses
# - A hostname/ip can be a member of multiple groups
# Ex 1: Ungrouped hosts, specify before any group headers.
## green.example.com
## blue.example.com
## 192.168.100.1
## 192.168.100.10
# Ex 2: A collection of hosts belonging to the 'webservers' group
## [webservers]
## alpha.example.org
## beta.example.org
## 192.168.1.100
## 192.168.1.110
# If you have multiple hosts following a pattern you can specify
# them like this:
## www[001:006].example.com
# Ex 3: A collection of database servers in the 'dbservers' group
## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57
# Here's another example of host ranges, this time there are no
# leading 0s:
## db-[99:101]-node.example.com
[hadoop]
172.16.0.91
172.16.0.92
172.16.0.93
[root@k8s-master ansible]# cd /