基础优化
1、系统安全
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
sed -i '7s#enforcing#disable#g' /etc/selinux/config
2、源与常用工具
# 配置yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 常用工具
yum install -y vim tree wget bash-completion bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telent bc psmisc httpd-tools bind-utils nethogs expect cowsay sl ntpdate xorg-x11-xauth sl cowsay
# epel源
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
3、时间同步
# 查看时区
timedatectl status
# 安装ntpdate
yum install -y ntpdate
# 设置时区
timedatectl set-timezone Asia/Shanghai
# 设置定时任务,每 2 分钟执行一次
crontab -e
# 文本输入以下信息:
#1. sync time
*/2 * * * * /sbin/ntpdate ntp1.aliyun.com &>/dev/null
4、远程连接
sed -ri '$aGSSAPIAuthentication no\nUseDNS no' /etc/ssh/sshd_config
systemctl restart sshd
# 查看修改结果
egrep '^(UseDNS|GSSAPI)' /etc/ssh/sshd_config
# 假如进行上述配置后,无法ssh连接,进行以下操作即可。
sed -i '79d;115d' /etc/ssh/sshd_config
5、修改主机名
hostnamectl set-hostname template
6、脚本
一键修改主机名和ip地址的脚本basic.sh