#!/bin/bash
echo -e "\x1B[01;96m --------1.关闭防火墙: \x1B[0m"
fw=`grep '^AllowZoneDrifting=' /etc/firewalld/firewalld.conf |awk -F= '{print $2}'`
if [ "$fw" == "no" ];then
echo AllowZoneDrifting=no
else
echo 变更为echo AllowZoneDrifting=no
sed -i '/AllowZoneDrifting/{s/'$fw'/no/}' /etc/firewalld/firewalld.conf
echo 修改结果:
grep '^AllowZoneDrifting=' /etc/firewalld/firewalld.conf
fi
systemctl restart firewalld
systemctl stop firewalld && systemctl disable firewalld && systemctl status firewalld
echo -e "\x1B[01;91m 完成 \x1B[0m"
echo \
echo -e "\x1B[01;96m --------2.关闭selinux: \x1B[0m"
st=`grep '^SELINUX=' /etc/selinux/config |awk -F= '{print $2}'`
if [ "$st" == "disabled" ];then
echo 已经是disabled状态!
else
echo 变更为disabled状态!
sed -i '/SELINUX/{s/'$st'/disabled/}' /etc/selinux/config
echo 修改结果:
grep '^SELINUX=' /etc/selinux/config
fi
setenforce 0
echo -e "\x1B[01;91m 完成 \x1B[0m"
echo \
echo -e "\x1B[01;96m --------3.修改服务器主机名: \x1B[0m"
echo 现用主机名: `hostname`
echo \
read -t 120 -p "是否需要更改主机名 1.更改 2.不更改:" cnum
echo \
if [ $cnum == 1 ];then
read -t 120 -p "请输入服务器新主机名:" cname
echo $cname > /etc/hostname
echo 当前修改后主机名:
cat /etc/hostname
else
echo 不需要修改!
fi
echo -e "\x1B[01;91m 完成 \x1B[0m"
echo \
echo -e "\x1B[01;96m --------4.修改/etc/hosts文件: \x1B[0m"
net=`ifconfig | awk -F: '{print $1}' |awk 'NR==1'`
wip=`ifconfig $net | grep netmask | awk '{print $2}'`
wname=`cat /etc/hostname`
sed -i "/$wip/d" /etc/hosts
echo "$wip $wname" >> /etc/hosts
echo \
echo 修改之后的/etc/hosts文件内容:
cat /etc/hosts
echo -e "\x1B[01;91m 完成 \x1B[0m"
echo \
echo -e "\x1B[01;96m --------5.修改/etc/security/limits.conf文件 \x1B[0m"
echo \
mem=`grep MemTotal /proc/meminfo | awk '{print $2}'`
nnum=$(($mem/1024/1024))
nnumxs=`echo "scale = 1;$mem/1024/1024" | bc| awk -F. '{print $2}'`
if [ $nnumxs -ge 5 ];then
nnum=$(($nnum+1))
echo 内存大小为:$nnum G
fi
sed -i '/oracle/d' /etc/security/limits.conf
echo \
sganum=$(($nnum*8/10*8/10))
pganum=$(($nnum*8/10*2/10))
pgaxs=`echo "scale = 1;$nnum*8/10*2/10" | bc| awk -F. '{print $2}'`
if [ $pgaxs -ge 5 ];then
pganum=$(($pganum+1))
fi
shmax=$((($nnum*8/10+1)*1024*1024*1024))
shmall=$((($nnum*8/10+1)*1024*1024/4))
hugnum=$((($sganum*1024)/2+200))
mnum=$((($sganum*1024+200)*1048))
echo 开始修改/etc/security/limits.conf文件:
cat >> /etc/security/limits.conf /etc/sysctl.conf /etc/pam.d/login /etc/pam.d/login /etc/profile /etc/yum.repos.d/yum.repo /etc/yum.repos.d/yum.repo > /home/oracle/.bash_profile /etc/fstab