1. 配置網絡 (虛擬機使用橋接模式)
ip addr
vi /etc/sysconfig/network-scripts/ifcfg-ens33
service network restart
2. 配置阿里雲鏡像
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
3. 安裝 net-tools, 之後就可以使用 ifconfig 命令了
yum -y install net-tools
4. 安裝 wget
yum -y install wget
5. 安裝 vim
yum -y install vim
6. 配置 ntp (此步驟可跳過, 推薦安裝 chrony 同步時間更精確)
yum -y install ntp
vim /etc/ntp.conf
# 注意在複製多行文本的時候, 最好先複製到 notepad++, 然後再複製出來, 避免多餘格式字符
driftfile /var/lib/ntp/drift
pidfile /var/run/ntpd.pid
logfile /var/log/ntp.log
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
server 127.127.1.0
fudge 127.127.1.0 stratum 10
server ntp.aliyun.com iburst minpoll 4 maxpoll 10
restrict ntp.aliyun.com nomodify notrap nopeer noquery
7. 修改主機名
hostnamectl set-hostname xxxxxxxxx
8. 設置時間
timedatectl status
timedatectl set-timezone Asia/Shanghai
timedatectl set-local-rtc 1 # 將硬件時間和本地時間設置一致, 最好在設置同步時間和時區之後執行
timedatectl list-timezones # 查看 timedatectl 支持的時區
ntpdate ntp.aliyun.com # 同步時間,注意: 如果要手動同步時間,要先停止 ntpd 服務
systemctl start ntpd
service ntpd start
systemctl stop ntpd
service ntpd stop
systemctl restart ntpd
service ntpd restart
systemctl enable ntpd # 開機啓動 ntpd 服務
systemctl disable ntpd # 禁用開機啓動 ntpd 服務
systemctl status ntpd
service ntpd status
9. 同步時間組件 chrony (推薦), 參考阿里雲官方NTP設置
yum install chrony
vim /etc/chrony.conf
server ntp.aliyun.com iburst
stratumweight 0
driftfile /var/lib/chrony/drift
rtcsync
makestep 10 3
bindcmdaddress 127.0.0.1
bindcmdaddress ::1
keyfile /etc/chrony.keys
commandkey 1
generatecommandkey
logchange 0.5
logdir /var/log/chrony
systemctl status chronyd
systemctl start chronyd
systemctl stop chronyd
# 開機啓動 chronyd
systemctl enable chronyd
# 禁止開機啓動 chronyd
systemctl disable chronyd
10. 配置 sudo 賬號
vim /etc/sudoers