標籤:stdin acl instance mod 指令碼 comm top util shel
指令碼主要用於redhat平台安裝11g和12c軟體 依賴包檢查與安裝 使用者、組檢查與安裝 系統核心、使用者限制 防火牆、selinux關閉 注意,linux組指令碼中只建立了dba,通常會建立oinstall和dba ####################create : 2018/01/22#version : v0.0#describe : Oracle 11g/12c setup single instance install environment#參考網址 http://blog.csdn.net/xcl168/article/details/19571443# http://blog.51cto.com/hxw168/1424626################# DATE=`date +%Y%m%d%H%M%S`SYSCTLCONF="/etc/sysctl.conf"LIMITSCONF="/etc/security/limits.conf"LOGINFILE="/etc/pam.d/login"PROFILE="/etc/profile"YUMFILE="/etc/yum.repos.d/rhel-source.repo" echo -e "\nTo determine the distribution and version of Linux installed.\n"echo "`cat /proc/version`" echo -e "\nTo determine whether the required kernel is installed.\n"echo "`uname -a`" echo -e "\nLeast 4GB of RAM.\n"echo "`grep MemTotal /proc/meminfo`" echo -e "\nTo determine the size of the configured swap space,enter the following command.\n"echo "`grep SwapTotal /proc/meminfo`" echo -e "\nChecking the Software Requirements.\n"yes|cp -p ${YUMFILE} ${YUMFILE}.bak.${DATE} read -p "Enter installl oracle version:[12c]" ORA_VERSION#echo "You have entered ${ORA_VERSION}" if [ -z "${ORA_VERSION}" ];thenORA_VERSION="12c"fiecho "You have entered ${ORA_VERSION}"if [ ${ORA_VERSION} == "12c" ];thenrpmpack="binutilscompat-libstdc++*elfutils-libelfelfutils-libelf-develgccgcc-c++glibcglibc-commonglibc-develglibc-headerskernel-headerskshlibaiolibaio-devellibgcclibgomplibstdc++libstdc++-develmakesysstatunixODBCunixODBC-devel"elserpmpack="binutilscompat-libstdc++*elfutils-libelfelfutils-libelf-develelfutils-libelf-devel-staticgccgcc-c++glibcglibc-commonglibc-develglibc-headerskernel-headerspdkshlibaiolibaio-devellibgcclibgomplibstdc++libstdc++-develmakesysstatunixODBCunixODBC-devel" fi read -p "Enter yum source address:" URL_PTAH#echo "You have entered ${URL_PTAH}"echo ${#URL_PTAH} if [ ${#URL_PTAH} -gt 0 ];thenecho "You have entered ${URL_PTAH}"`grep ${URL_PTAH} ${YUMFILE} > /dev/null`if [ $? -ne 0 ];thenecho "#add yum resouce ${DATE}" >${YUMFILE}echo "[rhel-source]" >>${YUMFILE}echo "name=Red Hat Enterprise Linux \$releasever - \$basearch - Source" >>${YUMFILE}echo "baseurl=${URL_PTAH}" >>${YUMFILE}echo "enabled=1" >>${YUMFILE}echo "gpgcheck=0" >>${YUMFILE}echo "gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release" >>${YUMFILE}fiyum grouplistfi for pack in $rpmpack; do rpm -qa | grep $pack > /dev/null if [ $? -eq 1 ];then echo "$pack not install" yum -y install $pack fi echo "rpm -qa | grep $pack is already install."#read -p "Enter yum source address:" URL_PTAH#echo "You have entered ${URL_PTAH}" done echo -e "\nTo determine if the Oracle Inventory group exit.\n"echo " `grep oinstall /etc/group`"echo " `grep dba /etc/group`" echo -e "\nTo determine whether the oraInstall.loc file exists.\n"echo "`cat /etc/oraInst.loc`"################################# ################################# echo -e "\nCreating Required Operating System Groups and Users.\n"`grep dba /etc/group > /dev/null`if [ $? -ne 0 ];thenecho "groupadd dba"`groupadd dba`fi `grep oracle /etc/passwd > /dev/null`if [ $? -ne 0 ]; thenecho "useradd -g dba oracle"`useradd -g dba oracle`echo "pcq#1234" | `passwd --stdin oracle`fi echo "`id oracle`" if [ ! -d "/u01/app/oracle" ];thenecho -e "\nmkdir -p /u01/app/oracle\nmkdir -p /u01/app/oraInventory\nmkdir -p /u01/app/oracle/product/11.2.0/dbhome_1\nchown -R oracle.dba /u01\nchmod -R 775 /u01\n"mkdir -p /u01/app/oraclemkdir -p /u01/app/oraInventoryif [ ${ORA_VERSION} == "12c" ];thenmkdir -p /u01/app/oracle/product/12.2.0/dbhome_1elsemkdir -p /u01/app/oracle/product/11.2.0/dbhome_1fichown -R oracle.dba /u01chmod -R 775 /u01fils -al /u01 ############################# #SYSCTLCONF="/etc/sysctl.conf"#LIMITSCONF="/etc/security/limits.conf"#LOGINFILE="/etc/pam.d/login"#PROFILE="/etc/profile" #############################echo -e "\nCheckResource Limits for the Oracle Software Installation Users.\n"yes|cp -p ${LIMITSCONF} ${LIMITSCONF}.bak.${DATE} echo -e "\nInstallation Owner Resource Limit Recommended Ranges.\n"`grep "#add limit" ${LIMITSCONF} > /dev/null`if [ $? -ne 0 ];thenecho "#add limit ${DATE}" >>${LIMITSCONF}fi `grep "oracle soft nproc 2047" ${LIMITSCONF} > /dev/null`if [ $? -ne 0 ];thenecho "oracle soft nproc 2047" >> ${LIMITSCONF}fi `grep "oracle hard nproc 16384" ${LIMITSCONF} > /dev/null`if [ $? -ne 0 ];thenecho "oracle hard nproc 16384" >> ${LIMITSCONF}fi `grep "oracle soft nofile 1024" ${LIMITSCONF} > /dev/null`if [ $? -ne 0 ];thenecho "oracle soft nofile 1024" >> ${LIMITSCONF}fi `grep "oracle hard nofile 65536" ${LIMITSCONF} > /dev/null`if [ $? -ne 0 ];thenecho "oracle hard nofile 65536" >> ${LIMITSCONF}fi echo "`tail -n 5 /etc/security/limits.conf`"######################## ########################echo -e "\nConfiguring Kernel Parameters for Linux.\n"yes|cp -p ${SYSCTLCONF} ${SYSCTLCONF}.bak.${DATE} `grep "#add sysctl" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "#add sysctl ${DATE}" >> ${SYSCTLCONF}fi `grep "kernel.shmmni = 4096" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "kernel.shmmni = 4096" >> ${SYSCTLCONF}fi`grep "kernel.sem = 250 32000 100 142" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "kernel.sem = 250 32000 100 142" >> ${SYSCTLCONF}fi`grep "fs.aio-max-nr = 1048576" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "fs.aio-max-nr = 1048576" >> ${SYSCTLCONF}fi`grep "fs.file-max = 6815744" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "fs.file-max = 6815744" >> ${SYSCTLCONF}fi`grep "net.ipv4.ip_local_port_range = 9000 65000" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "net.ipv4.ip_local_port_range = 9000 65000" >> ${SYSCTLCONF}fi`grep "net.core.rmem_default = 262144" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "net.core.rmem_default = 262144" >> ${SYSCTLCONF}fi`grep "net.core.rmem_max = 4194304" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "net.core.rmem_max = 4194304" >> ${SYSCTLCONF}fi`grep "net.core.wmem_default =262144" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "net.core.wmem_default =262144" >> ${SYSCTLCONF}fi`grep "net.core.wmem_max = 10485" ${SYSCTLCONF} > /dev/null`if [ $? -ne 0 ];thenecho "net.core.wmem_max = 10485" >> ${SYSCTLCONF}fi/sbin/sysctl -p######################## #######################echo -e "\nedit /etc/pam.d/login file:\n"yes|cp -p ${LOGINFILE} ${LOGINFILE}.bak.${DATE} `grep "session required pam_limits.so" ${LOGINFILE} >/dev/nulll`if [ $? -ne 0 ];thenecho "#add login ${DATE}" >>${LOGINFILE}echo "session required pam_limits.so" >> ${LOGINFILE}fiecho "`tail -n 2 ${LOGINFILE}`"####################### ######################echo -e "\nedit /etc/pfole file:\n"yes|cp -p ${PROFILE} ${PROFILE}.bak.${DATE} `grep "#add ulimit profile" ${PROFILE} >/dev/null`if [ $? -ne 0 ];thenecho "#add ulimit profile ${DATE}" >>${PROFILE}echo "if [ \$USER = \"oracle\" ]; then" >>${PROFILE}echo " if [ \$SHELL = \"/bin/ksh\" ]; then" >>${PROFILE}echo " ulimit -p 16384" >>${PROFILE}echo " ulimit -n 65536" >>${PROFILE}echo " else" >>${PROFILE}echo " ulimit -u 16384 -n 65536" >>${PROFILE}echo " fi" >> ${PROFILE}echo "fi" >>${PROFILE}fiecho "`tail -n 9 ${PROFILE}`"###################### #####################echo -e "\nDisabled system firewall.\n"`chkconfig iptables off&&chkconfig ip6tables off&&service iptables stop&&service ip6tables stop`echo `chkconfig --list|grep iptables`echo `chkconfig --list|grep ip6tables`##################### #####################echo -e "\nDisabled system selinux.\n"`sed -i ‘s/^SELINUX=enforcing/#SELINUX=enforcing/g‘ /etc/selinux/config``grep "^SELINUX=disabled" /etc/selinux/config >/dev/null`if [ $? -ne 0 ];thenecho "SELINUX=disabled" >> /etc/selinux/configfiecho "`cat -n /etc/selinux/config|grep SELINUX`"#####################
Oracle->oracle單一實例Shell指令碼[20180122]