cd /etc/yum.repos.d/
mkdir bak
mv * bak/
echo '[aliBase]
name=aliBase
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-$releasever' > /etc/yum.repos.d/aliBase.repo
echo '[aliEpel]
name=aliEpel
baseurl=https://mirrors.aliyun.com/epel/$releasever\Server/$basearch/
enabled=1
gpgcheck=0' > /etc/yum.repos.d/aliEpel.repo
2、一些基本设定
sed -i '/^SELINUX/s/enforcing/disabled/' /etc/selinux/config
sed -i '/^HISTSIZE/s/=1000.*/=10000/' /etc/profile
echo 'HISTTIMEFORMAT="%Y-%m-%d:%H-%M-%S:`whoami`: "
export HISTTIMEFORMAT' >> /etc/bashrc
echo 'PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\\$ \[\e[33;40m\]"' >> /etc/profile
echo '* soft memlock unlimited
* hard memlock unlimited
* soft stack unlimited
* hard stack unlimited
' >> /etc/security/limits.conf
3、安装一些必要的工具
yum -y install zip unzip bzip2 bzip2-devel zlib zlib-devel screen wget lsof net-tools tree unix2dos dos2unix sysstat vim-common vim-enhanced deltarpm tcp_wrappers psmisc hdparm
echo 'alias vi=vim' >> /etc/profile
reboot
4、配置windows文件共享
mkdir /home/share
chmod 777 /home/share/
echo "[global]
log file = /var/log/samba/log.%m
max log size = 50
security = user
map to guest = Bad User
[share]
path=/home/share
readonly=yes
browseable=yes
writable = yes
guest ok=yes" > /etc/samba/smb.conf
systemctl enable smb
firewall-cmd --add-port=137/udp --permanent
firewall-cmd --add-port=138/udp --permanent
firewall-cmd --add-port=139/tcp --permanent
firewall-cmd --add-port=445/tcp --permanent
firewall-cmd --add-port=389/tcp --permanent
firewall-cmd --reload
5、安装和配置环境变量加载模块
yum -y install environment-modules
mkdir /home/software
mkdir /home/software/modules
echo 'export MODULEPATH=/home/software/modules/' >> /etc/profile.d/modules.sh
6、定义主机名
echo "192.168.2.130 mgr
192.168.2.131 node1
192.168.2.132 node2" >> /etc/hosts
echo 'mgr' > /etc/hostname