linux ansible工具应用

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 /

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值