查看CentOS版本

  1. cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)

IP地址配置

ifcfg-**的为配置网卡的文件,不同服务器不一样,本文使用VirtualBox虚拟机

vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=f6d5a2c5-0946-43bb-b75b-4a4e317b9101
DEVICE=enp0s3
ONBOOT=yes
IPADDR=10.150.8.101
GATEWAY=10.150.8.1

修改主机名

方法一:

vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=hadoop101

保存退出,重启后生效

方法二:

hostnamectl set-hostname hadoop101

退出登录后生效


添加本地Hosts解析

vi /etc/hosts

10.150.8.101 hadoop101
10.150.8.102 hadoop102
10.150.8.103 hadoop103
10.150.8.104 hadoop104

防火墙

查看状态

[root@hadoop101 sbin]# firewall-cmd --state
running
[root@hadoop101 sbin]# service firewalld status
Redirecting to /bin/systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 六 2020-01-11 20:05:02 CST; 3h 59min ago
     Docs: man:firewalld(1)
 Main PID: 745 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─745 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

1月 11 20:04:58 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
1月 11 20:05:02 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.

关闭防火墙

[root@hadoop101 sbin]# service firewalld stop
Redirecting to /bin/systemctl stop firewalld.service