lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
(3)修改 /etc/sysconfig/network-scripts/ifcfg-eth0 文件,修改 DEVICE、HWADDR 和 IPADDR,并 service network restart 重启网络服务。
修改slave1配置信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[root@master ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth1 #修改成ifconfig -a显示的信息 HWADDR=00:0C:29:90:31:E2 #修改成ifconfig -a显示的信息 TYPE=Ethernet UUID=f994c111-ad55-4c32-8178-6c6069d8818c ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=192.168.146.172 #修改ip NETMASK=255.255.255.0 GATEWAY=192.168.146.2 DNS1=192.168.146.2 [root@master ~]# service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: Determining if ip address 192.168.146.172 is already in use for device eth1... [ OK ]
[root@slave1 ~]# vi /etc/ntp.conf # the administrative functions. restrict 127.0.0.1 restrict -6 ::1
# Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server master
[root@master ~]# ssh slave1 Last login: Mon Nov 23 02:18:41 2020 from 192.168.146.171 [root@slave1 ~]# ntpdate master 23 Nov 02:22:40 ntpdate[1396]: adjust time server 192.168.146.171 offset 0.488075 sec [root@slave1 ~]# service ntpd start & chkconfig ntpd on [1] 1411 [root@slave1 ~]# Starting ntpd: [ OK ]
[1]+ Done service ntpd start [root@slave1 ~]# exit logout Connection to slave1 closed. [root@master ~]# ssh slave2 Last login: Mon Nov 23 02:22:54 2020 from master [root@slave2 ~]# ntpdate master 23 Nov 02:23:37 ntpdate[1329]: adjust time server 192.168.146.171 offset 0.497395 sec [root@slave2 ~]# service ntpd start & chkconfig ntpd on [1] 1330 [root@slave2 ~]# Starting ntpd: [ OK ]
[1]+ Done service ntpd start [root@slave2 ~]# exit logout Connection to slave2 closed. [root@master ~]#
(6)查看个节点的时间:时间应该同步,非常接近
节点时间
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[root@master ~]# date Mon Nov 23 02:32:52 CST 2020 [root@master ~]# ssh slave1 Last login: Mon Nov 23 02:23:11 2020 from master [root@slave1 ~]# date Mon Nov 23 02:32:57 CST 2020 [root@slave1 ~]# exit logout Connection to slave1 closed. [root@master ~]# ssh slave2 Last login: Sun Nov 22 18:29:36 2020 from 192.168.146.100 [root@slave2 ~]# date Mon Nov 23 02:33:05 CST 2020 [root@slave2 ~]# exit logout Connection to slave2 closed. [root@master ~]#