YJ的博客
个人生活、工作的随笔

本站部分文章、资源来自互联网,版权归原作者及网站所有,如侵犯了您的权利,请及时致信告知我

粤ICP备15050546号

网站地图

CentOS7最小化安装基础部署优化脚本

此脚本将卸载CentOS7默认的FireWalld防火墙,而使用iptables防火墙
脚本下载地址:
jichusetup_iptables.sh

[php]
#!/bin/bash
systemctl stop firewalld
systemctl disable firewalld
systemctl list-unit-files | grep firewalld
echo "已关闭firewall"

sleep 2
sed -i 's/enforcing/disabled/' /etc/selinux/config
setenforce 0
echo "已关闭selinux"

sleep 2
chmod +x /etc/rc.d/rc.local
echo "现在开始安装常用到的软件包括:gcc psmisc vim net-tools ntpdate epel-release htop iptables"
yum install -y gcc gcc-c++
if [ $? -eq 0 ]
then
echo "gcc安装完成"
else
echo "gcc安装失败"
fi
sleep 2

yum install -y psmisc
if [ $? -eq 0 ]
then
echo "psmisc安装完成"
else
echo "psmisc安装失败"
fi
sleep2

yum install -y wget
if [ $? -eq 0 ]
then
echo "wget安装完成"
else
echo "psmisc安装失败"
fi
sleep 2

yum install -y unzip
if [ $? -eq 0 ]
then
echo "unzip安装完成"
else
echo "unzip安装失败"
fi
sleep 2

yum install -y vim
if [ $? -eq 0 ]
then
echo "vim安装完成"
else
echo "vim安装失败"
fi
sleep 2

yum install -y net-tools
if [ $? -eq 0 ]
then
echo "net-tools安装完成"
else
echo "net-tools安装失败"
fi
sleep 2

yum install -y ntpdate
if [ $? -eq 0 ]
then
echo "ntpdate安装完成"
else
echo "ntpdate安装失败"
fi
sleep 2

yum install -y epel-release
if [ $? -eq 0 ]
then
echo "epel-release安装完成"
else
echo "epel-release安装失败"
fi
sleep 2

yum install -y htop
if [ $? -eq 0 ]
then
echo "htop安装完成"
else
echo "htop安装失败"
fi
sleep 2

yum install -y iptables-services
if [ $? -eq 0 ]
then
echo "iptables安装完成"
else
echo "iptables安装失败"
fi
sleep 2

echo "开始同步时间"
ntpdate time.windows.com

sleep 2
echo "启动并清空iptables规则同时设定开机启动iptables"
systemctl start iptables
systemctl enable iptables
iptables -F
iptables -I INPUT -p tcp --dport=22 -j ACCEPT
service iptables save

sleep 2
echo "开始设定主机名"
read -p "请输入要修改的主机名:" hname
hostnamectl set-hostname "$hname"
echo "以下是你设定的主机名内容:"
hostnamectl status | grep "hostname"

echo "cxdx ()
{
du -cksm * | sort -rn | head -n 10
}" >> /etc/profile

echo "* soft nofile 65535
* hard nofile 65535" >> /etc/security/limits.conf
echo "调整系统最大文件打开数为65535,需重启系统后运行ulimit -a命令查看"
[/php]

2016-04-15
339 views
暂无评论

发表评论