绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
ansible安装及使用
2019-09-09 16:08:01

Director:

192.168.0.118 director.shamereedwine.com dr

webserver:

node1:node1.shamereedwine.com(192.168.0.119)

node2:node2.shamereedwine.com(192.168.0.120)

dbserver:

node2.shamereedwine.com(192.168.0.120)

node3.shamereedwine.com(192.168.0.122)

一、安装ansible

DR上

1、配置epel的yum源,使用yum安装ansible

yum install ansible

二、各节点配置互信

1、各节点上编辑/etc/hosts配置文件,以实现各主机的互相解析,配置如下:

192.168.0.118 director.shamereedwine.com dr

192.168.0.119 node1.shamereedwine.com node1

192.168.0.120 node2.shamereedwine.com node2

192.168.0.122 node3.shamereedwine.com node3

2、dr节点配置ssh互信

[root@localhost ~]# ssh-keygen -t rsa -P ''

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): 

Created directory '/root/.ssh'.

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

a5:ce:85:ba:74:67:51:3c:ae:4b:0d:7e:d6:4d:ef:e1 root@director.shamereedwine.com

The key's randomart image is:

+--[ RSA 2048]----+

|                 |

|           .     |

|          . +    |

|         + o .   |

|        S + .   .|

|       + o = . o.|

|      o + * + ..o|

|     . o + +  ...|

|      .   .    E.|

+-----------------+

[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node1.shamereedwine.com

[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node2.shamereedwine.com

The authenticity of host 'node2.shamereedwine.com (192.168.0.120)' can't be established.

RSA key fingerprint is cf:98:8a:b1:33:6d:1b:6c:85:34:54:0b:33:f5:27:99.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'node2.shamereedwine.com,192.168.0.120' (RSA) to the list of known hosts.

root@node2.shamereedwine.com's password: 

Now try logging into the machine, with "ssh 'root@node2.shamereedwine.com'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node3.shamereedwine.com

The authenticity of host 'node3.shamereedwine.com (192.168.0.122)' can't be established.

RSA key fingerprint is cf:98:8a:b1:33:6d:1b:6c:85:34:54:0b:33:f5:27:99.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'node3.shamereedwine.com,192.168.0.122' (RSA) to the list of known hosts.

root@node3.shamereedwine.com's password: 

Now try logging into the machine, with "ssh 'root@node3.shamereedwine.com'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

三、使用ansible

1、探测各节点是否在线

分享好友

分享这个小栈给你的朋友们,一起进步吧。

IT基础架构
创建时间:2020-06-17 15:29:51
IT基础架构是相对于IT应用架构而言的,指的是为了各种应用系统能够顺利、可靠地运行,而提供的一系列硬件、软件的集合体。正是因为有了这些IT基础架构的各种设施,IT应用架构才能运行并提供服务。
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

技术专家

查看更多
  • 栈栈
    专家
戳我,来吐槽~