实验模板机制作以及配置常用软件和环境
当前版本
[root@osker ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@osker ~]# uname -a
Linux osker 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
配置阿里云yum仓库
rm -fr /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安装常用软件
#参考软件: net-tools vim tree htop iftop iotop lrzsz sl wget unzip telnet nmap nc psmisc dos2unix bash-completion bash-completion-extras sysstat rsync nfs-utils httpd-tools ntpdate
[root@osker ~]# yum install -y ntpdate wget vim tree lsof net-tools lrzsz nmap dos2unix nc telnet bash-completion bash-completion-extras ncurses-devel libaio-devel autoconf gcc-c++ gcc glibc cmake
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
关闭SELinux
setenfore 0
vim /etc/selinux/conf
SELINUX=disabled
优化ssh远程连接
vim /etc/ssh/sshd_config
略
配置hosts主机解析
vim /etc/hosts
略
添加定时时间同步
[root@osker ~]# crontab -e
#rsyn time from aliyun ntpdate
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com &>/dev/null
扩大同时打开文件数量为65535
[root@osker ~]# echo '* - nofile 65535 ' >>/etc/security/limits.conf
[root@osker ~]# tail -1 /etc/security/limits.conf
* - nofile 65535
[root@osker ~]# reboot
[root@osker ~]# ulimit -a
core file size (blocks, -c) 0
...
open files (-n) 65535
...
修改字符集
[root@osker ~]# localectl set-locale LANG="en_US.UTF-8"
[root@osker ~]# echo $LANG
en_US.UTF-8
优化环境变量
[root@osker ~]# echo "PS1='[\[\e[33;40m\]\u\[\e[37;40m\]@\h \[\e[33;40m\]\w\[\e[0m\]]\\$ '" >> .bashrc
模板机配置完成,关机,添加快照。
使用链接克隆新机器,开机后修改主机名及IP 地址
修改主机名
[root@osker ~]# hostnamectl set-hostname backup
修改ip地址
[root@osker ~]# grep "100" /etc/sysconfig/network-scripts/ifcfg-ens3{3,7}
IPADDR=192.168.186.100
IPADDR=172.16.1.100
[root@osker ~]# sed -i 's#100#41#g' /etc/sysconfig/network-scripts/ifcfg-ens3{3,7}
[root@osker ~]# sed -i '/UUID/d' /etc/sysconfig/network-scripts/ifcfg-ens3{3,7}
关机,做快照。
[root@osker ~]# poweroff