1. Server configuration

Host: 192.168.36.128

Node1:192.168.36.129

2:192.168.36.130

2. Close the firewall and close Selinux (three servers)

[root@localhost ~]# systemctl stop firewalld

[root@localhost ~]# systemctl disable firewalld

[root@localhost ~]# setenforce 0

[root@localhost ~]# vim /etc/selinux/config

Modify the SELINUX = disabled

3. Time synchronization (three servers)

Install ntpdata

[root@node2 ~]#yum install -y ntpdate

Synchronization time

[root@node2 ~]# ntpdate ntp1.aliyun.com

[root@node2 ~]# cp -a /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Cp: overwrite ‘/ etc/localtime’? yes

4. Install EPEL source

[root@ansible ~]# yum install -y epel-release

5, Install Ansible

[root@ansible ~]# yum install -y ansible

Check the version

/ root @ ansible ~ # ansible – version

6. Key authentication (secret-free login)

Generate the key

[root@ansible ~]# ssh-keygen

Send the key to yourself

/ root @ ansible ~ # SSH – copy – id 192.168.36.128

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys

[email protected] ‘s password:

Number of key(s) added: 1

Now try logging into the machine, with: “SSH ‘192.168.36.128”

and check to make sure that only the key(s) you wanted were added.

Send the key to Node1

/ root @ ansible ~ # SSH – copy – id 192.168.36.129

The authenticity of host ‘192.168.36.129 ‘can’t be established.

ECDSA key fingerprint is a0:69:e4:de:f6:3e:e4:b5:cf:34:83:27:a2:cb:ea:e2.

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

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys

[email protected]’s password: Enter the password of the remote host

Number of key(s) added: 1

Now try logging into the machine, with: “SSH ‘192.168.36.129”

and check to make sure that only the key(s) you wanted were added.

Send the key to Node2

/ root @ ansible ~ # SSH – copy – id 192.168.36.130

The authenticity of host ‘192.168.36.130 ‘can’t be established.

ECDSA key fingerprint is 3a:dc:83:32:62:eb:2f:fe:60:46:9c:4d:8c:3f:ef:87.

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

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys

[email protected]’s password: Enter the password of the remote host

Number of key(s) added: 1

Now try logging into the machine, with: “SSH ‘192.168.36.130”

and check to make sure that only the key(s) you wanted were added.