YUM仓库配置
yum install wget -y
cd /etc/yum.repos.d/
cp -r ../yum.repos.d/ ../yum.repos.d.back
rm -rf *.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
yum clean all
yum makecache
yum install -y net-tools vim lrzsz tree screen lsof tcpdump bash-completion-extras wget ntp
关闭networkmanager
systemctl disable NetworkManager && systemctl stop NetworkManager
关闭防火墙
systemctl disable firewalld && systemctl stop firewalld
关闭 SELinux
# 检查 SELinux 的状态,如果它已经禁用,可以跳过后面的命令
sestatus
可以使用以下命令禁用 SELinux,或者修改配置文件。
# 通过命令临时禁用 SELinux
setenforce 0
# 或者修改配置文件
sed -i ‘s/^SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
接着,重启机器:
reboot
配置SSH服务
sed -i ‘s%#UseDNS yes%UseDNS no%g’ /etc/ssh/sshd_config
systemctl restart sshd
配置NTP服务
yum -y install chrony ntp
vim /etc/chrony.conf
server ntp1.aliyun.com iburst
systemctl enable chronyd
systemctl start chronyd
ntpstat
调整文件描述符
ulimit -n
cp /etc/security/limits.conf /etc/security/limits.confbak
cat >>/etc/security/limits.conf<< EOF
root soft nofile 102400
root hard nofile 102400
EOF
ulimit -n
配置pip国内源
腾讯源
mkdir -p ~/.pip/
cat > ~/.pip/pip.conf<<EOF
[global]
index-url = https://mirrors.cloud.tencent.com/pypi/simple
trusted-host = mirrors.cloud.tencent.com
EOF
清理模板虚拟机
> /var/log/messages
> /var/log/secre
history -c
> /root/.bash_history
poweroff