CentOS 7 模版 #
本文档,用于 CentOS-7-x86_64-Everything-2207-02.iso
安装完成后的初始化
一、安装过程 #
设置时区为: Asia/Shanghai
设置 root
密码为: ******
添加用户 admin
密码为: ******
,并且标记为 Administrator
安装过程中其余配置保持默认
二、网络初始化 #
1、编辑文件 /etc/sysconfig/network-scripts/ifcfg-ens192
在最下面加入
ONBOOT=yes
PROXY_METHOD=none
BROWSER_ONLY=no
2、在 DHCP 服务器,为该服务器绑定固定ip
3、执行如下命令重启网络
systemctl restart network
4、关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
三、包管理器初始化 #
1、安装 EPEL 库(不安装这个的话 CentOS 本身可以通过 yum 安装的软件就很少)
yum install epel-release -y
四、其他 #
同步硬件时间 #
hwclock -w
关闭 SELinux #
#查看selinux状态
getenforce
#临时关闭selinux
setenforce 0
#永久关闭
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
禁用root通过ssh登陆 #
修改 SSH 的配置文件 /etc/ssh/sshd_config
,修改如下配置
PermitRootLogin no
然后重启 sshd
systemctl restart sshd
设置 admin 用户可以 sudo 到 root #
在 /etc/sudoers.d
目录中增加文件 admin
,内容如下
admin ALL=(ALL) NOPASSWD: ALL
设置 admin 用户的免密登录 #
把本地的 ~/.ssh/id_rsa.pub
中的内容拷贝到目标服务器的 /home/admin/.ssh/authorized_keys
中,并且执行如下命令
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
设置时区 #
timedatectl set-timezone Asia/Shanghai
五、常用软件安装 #
测速软件 #
yum install iperf iperf3 nuttcp -y
安装 2.x
版本的 git
#
yum remove -y git
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm -y
yum install git -y
安装 unzip
#
yum install unzip -y
安装 wget
#
yum install wget -y
安装 lrzsz
#
yum install lrzsz -y
root 下安装 zsh
以及 ohmyzsh
#
yum install zsh -y
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
编辑 .zshrc
文件,替换为如下内容:
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="pygmalion"
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
# 禁用oh-my-zsh自动更新
DISABLE_AUTO_UPDATE="true"
DISABLE_UPDATE_PROMPT="true"
下载并安装 oh-my-zsh 插件
# 下载
wget -P /tmp https://yun.kazmodan.com/uPic/ohmyzsh-custom-plugins.zip
# 安装
unzip -d /root/.oh-my-zsh/custom/plugins /tmp/ohmyzsh-custom-plugins.zip
# 清理数据
rm -rf /root/.oh-my-zsh/custom/plugins/__MACOSX/
cd /root/.oh-my-zsh/custom/plugins && find . -name ".DS_Store" -delete
rm -rf /tmp/ohmyzsh-custom-plugins.zip
ntp 安装 #
yum install ntpdate -y
ntpdate ntp1.aliyun.com
yum -y install ntp
systemctl enable ntpd
systemctl start ntpd
六、常见问题解决 #
1、SSH 连接很慢 #
编辑文件 /etc/ssh/sshd_config
,在其中修改如下两项:
UseDNS no
GSSAPIAuthentication no
后执行如下命令重启 sshd
systemctl restart sshd