下面给你一份CentOS Minimal(最小化安装)初始化的常用标准流程,适用于 CentOS 7 / 8 / Stream,按顺序做即可。
ip addr
vi /etc/sysconfig/network-scripts/ifcfg-ens33
DHCP 示例
BOOTPROTO=dhcp
ONBOOT=yes
静态 IP 示例
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=114.114.114.114
# CentOS 7
systemctl restart network
# CentOS 8 / Stream
nmcli c reload
nmcli c up ens33
yum update -y
或(CentOS 8 / Stream):
dnf update -y
Minimal 默认非常干净,建议安装:
yum install -y \
net-tools \
vim \
wget \
curl \
bash-completion \
lrzsz \
rsync \
chrony
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
查看状态:
systemctl status firewalld
开放端口示例(SSH):
firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload
关闭防火墙(不推荐生产):
systemctl stop firewalld
systemctl disable firewalld
systemctl enable chronyd
systemctl start chronyd
timedatectl set-timezone Asia/Shanghai
useradd admin
passwd admin
usermod -aG wheel admin
vim /etc/ssh/sshd_config
建议:
PermitRootLogin no
PasswordAuthentication yes
systemctl restart sshd
hostnamectl set-hostname node1
#!/bin/bash
yum install -y vim wget curl net-tools bash-completion
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
systemctl enable chronyd && systemctl start chronyd
timedatectl set-timezone Asia/Shanghai
echo "init done"
如果你告诉我:
我可以给你更精准的初始化方案。