配置IP和网关
vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static #静态注册
ONBOOT=yes
IPADDR=10.0.0.7 #需要和设置的IP段统一
PREFIX=24
GATEWAY=10.0.0.254 #需要和虚拟网卡设置的网关一致
DNS1=8.8.8.8 #这个必须设置,否则会导致能ping通外部IP,ping不通域名
# 重启网络服务
systemctl restart network.service
设置主机名
#设置一个主机的变量因为主机名从node1-node9
a=1
#$a为变量
hostnamectl set-hostname node$a.host.com
关闭SELinux
setenforce 0
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
#或者
vi /etc/selinux/config
SELINUX=disabled
修改SELINUX 为 disabled ,需要重启。如果不想重启系统,使用命令setenforce 0。
关闭防火墙
systemctl stop firewalld&&systemctl disable firewalld
关闭IPv6
sed -i 's/^GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"ipv6.disable=1 /g' /etc/default/grub && grub2-mkconfig -o /boot/grub2/grub.cfg
更改YUM源
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
运行 yum makecache 生成缓存
时间同步
yum install -y chrony;systemctl enable chronyd.service&&systemctl start chronyd.service
安装epel源
yum install epel-release -y
常用软件
yum install -y lrzsz wget vim git tree bash-completion sysstat lsof net-tools unzip
SSH设置
sed -i 's/#UseDNS no/UseDNS no/g' /etc/ssh/sshd_config
重启
shutdown -r now