1、环境准备
操作系统:最小化安装Centos7.9
2、系统初始配置
2.1、关闭防火墙
[root@centos79-base02 ~]# systemctl disable firewalld --now
2.2、关闭selinux
[root@centos79-base02 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
2.3、history记录添加时间和用户
[root@centos79-base02 ~]# vi /etc/profile
# 在最下方添加
export HISTTIMEFORMAT="%F %T `whoami` "
2.4、修改网卡名为传统模式(eth0、eth1)
[root@centos79-base02 ~]# vim /etc/default/grub
GRUB_CMDLINE_LINUX="biosdevname=0 net.ifnames=0"
# 也可以在安装系统时添加
On a system with UEFI boot mode:
# [root@centos79-base02 ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
On a system with legacy boot mode:
# [root@centos79-base02 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
# [root@centos79-base02 ~]# grub2-mkconfig -o /etc/grub2.cfg
# 更改好之后一定要记得更改网卡配置里面的网卡名
[root@centos79-base02 ~]# mv /etc/sysconfig/network-scripts/ifcfg-ens160 /etc/sysconfig/network-scripts/ifcfg-eth0
[root@centos79-base02 ~]# sed -i ''s/ens160/eth0' /etc/sysconfig/network-scripts/ifcfg-eth0
#重启系统
[root@centos79-base02 ~]# reboot
2.5、修改yum源
# 可以选择使用国内的镜像源,根据对应网站上配置方法去配置
https://developer.aliyun.com/mirror/
https://mirrors.tuna.tsinghua.edu.cn/
https://www.huaweicloud.com/product/mirrors.html
# 可以选择使用本地镜像源或者内网搭建的yum源服务器
[root@centos79-base02 ~]# vim /etc/yum.repos.d/local.repo
[local_base]
name=local_base
baseurl=http://192.168.1.10/centos/base/
enable=1
gpgcheck=0
[local_updates]
name=local_updates
baseurl=http://192.168.1.10/centos/updates/
enable=1
gpgcheck=0
[local_extras]
name=local_extras
baseurl=http://192.168.1.10/centos/extras/
enable=1
gpgcheck=0
[local_epel]
name=local_epel
baseurl=http://192.168.1.10/epel/
enable=1
gpgcheck=0
[root@centos79-base02 ~]# yum clean all;yum makecache
Loaded plugins: fastestmirror
Cleaning repos: local_base local_epel local_extras local_updates
Cleaning up list of fastest mirrors
Other repos take up 145 M of disk space (use --verbose for details)
Loaded plugins: fastestmirror
Determining fastest mirrors
local_base | 2.9 kB 00:00:00
local_epel | 2.9 kB 00:00:00
local_extras | 2.9 kB 00:00:00
local_updates | 2.9 kB 00:00:00
(1/12): local_base/filelists_db | 7.2 MB 00:00:00
(2/12): local_base/primary_db | 6.1 MB 00:00:00
(3/12): local_base/other_db | 2.6 MB 00:00:00
(4/12): local_epel/filelists_db | 12 MB 00:00:00
(5/12): local_epel/primary_db | 6.9 MB 00:00:00
(6/12): local_epel/other_db | 3.3 MB 00:00:00
(7/12): local_extras/primary_db | 249 kB 00:00:00
(8/12): local_extras/filelists_db | 276 kB 00:00:00
(9/12): local_extras/other_db | 149 kB 00:00:00
(10/12): local_updates/filelists_db | 10 MB 00:00:00
(11/12): local_updates/other_db | 1.2 MB 00:00:00
(12/12): local_updates/primary_db | 18 MB 00:00:00
2.6、最小化系统安装建议安装软件
yum install -y vim-enhanced tcpdump lrzsz tree telnet bash-completion net-tools wget bzip2 lsof tmux man-pages zip unzip nfs-utils gcc make gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel
2.7、修改ssh配置文件
# ssh客户端配置文件: /etc/ssh/ssh_config
# 首次登录不显示检查提示
StrictHostKeyChecking no
# ssh服务端配置文件: /etc/ssh/sshd_config
# 可以修改端口
Port 22
# 可以禁止root登录
PermitRootLogin yes
# 可以禁用提升连接速度
UseDNS no
GSSAPIAuthentication no
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END