程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle數據庫基礎 >> Linux 安裝ORACLE的shell腳本

Linux 安裝ORACLE的shell腳本

編輯:Oracle數據庫基礎
在Linux平台下面安裝Oracle,要做好多的准備工作。比如建立user,修改環境變量,一些Oracle所需的參數。現在整理成shell腳本,以方便安裝。
一、創建安裝腳本
vi install.sh
#/bin/bash
. ./adduser.sh
. ./sysctl.sh
. ./limits.sh
. ./mkdir.sh
. ./chprofile.sh
二、添加用戶及用戶組
vi adduser.sh
#/bin/bash
ADDGROUPS="oinstall dba"
ADDUSERS="Oracle"
for group in $ADDGROUPS ; do
if [ -z "$( awk -F: '{print $1}' /etc/group |grep $group)" ]; then
groupadd $group
echo " Add new group $group"
else
echo " Group $group already existed"
fi
done
for user in $ADDUSERS ; do
if [ -z "$( awk -F: '{print $1}' /etc/passwd |grep $user)" ]; then
useradd $user
echo " Add new user $user"
else
echo " User $user already existed"
fi
done
if $(usermod -g oinstall -G dba Oracle) ; then
echo " Modify user Oracle account success"
else
echo " Modify user Oracle account failure"
fi
三、創建所需的目錄
vi mkdir.sh
#/bin/bash
ORACLE_FILE_BASE="/u01/app/Oracle"
ORACLE_FILE_VAR="/var/opt/Oracle"
ORACLE_FILE_HOME="$Oracle_FILE_BASE/product/10.2.0/db_1"
for directory in $ORACLE_FILE_BASE $ORACLE_FILE_VAR $Oracle_FILE_HOME ; do
if [ -d $directory ]; then
echo " Directory $directory already existed"
else
mkdir -p $directory
chown -R Oracle.dba $directory
echo " Change directory $directory owner and group success"
fi
done
四、修改Oracle用戶的環境變量
vi chprofile.sh
#/bin/bash
PROFILES="/home/Oracle/.bashrc"
for PROFILE in $PROFILES ; do
if [ -f "$PROFILE" ] ; then
if [ -z "$(grep "Oracle" $PROFILE)" ] ; then
cat >>$PROFILE << END
# Oracle configure profile parameters success
export ORACLE_BASE=/u01/app/Oracle
export ORACLE_HOME=\$Oracle_BASE/product/10.2.0/db_1
export PATH=\$Oracle_HOME/bin:\$PATH
export ORACLE_OWNER=Oracle
export Oracle_SID=orcl
export Oracle_TERM=vt100
export THREADS_FLAG=native
export LD_LIBRARY_PATH=\$Oracle_HOME/lib:\$LD_LIBRARY_PATH
export PATH=\$Oracle_HOME/bin:\$PATH
#
# change this NLS settings to suit your country:
# example:
# german_germany.we8iso8859p15, american_america.we8iso8859p2 etc.
#
export LANG=en_US
END
echo " Add Oracle configure $PROFILE parameters success"
else
echo " Oracle configure $PROFILE parameters already existed"
fi
else
echo "$0: $PROFILE not found "
fi
done
五、修改/etc/security/limits.conf文件
vi limits.sh
#/bin/bash
LIMITS_FILE="/etc/security/limits.conf"
if [ -f "$LIMITS_FILE" ] ; then
if [ -z "$(grep "Oracle" $LIMITS_FILE)" ] ; then
cat >>$LIMITS_FILE << END
#Oracle configure shell parameters
Oracle soft nofile 65536
Oracle hard nofile 65536
Oracle soft nproc 16384
Oracle hard nproc 16384
END
echo " Add Oracle configure shell parameters success"
else
echo " Oracle configure shell parameters already existed"
fi
else
echo "$0: $LIMITS_FILE not found "
fi
六、修改/etc/sysctl.conf 文件
#以下的參數設定是針對內存為1G的機器,硬件配置不同的請做相關的修改。
vi sysctl.sh
#/bin/bash
# echo 250 32000 100 128 > /proc/sys/kernel/sem
# echo 536870912 > /proc/sys/kernel/shmmax
# echo 4096 > /proc/sys/kernel/shmmni
# echo 2097152 > /proc/sys/kernel/shmall
# echo 65536 > /proc/sys/fs/file-max
# echo 1024 65000 > /proc/sys/net/ipv4/ip_local_port_range
SYSCTL_FILE="/etc/sysctl.conf"
RCLOCAL_FILE="/etc/rc.local"
if [ -f "$SYSCTL_FILE" ] ; then
if [ -z "$(grep "Oracle" $SYSCTL_FILE)" ] ; then
cat >>$SYSCTL_FILE << END
#Oracle configure kernel parameters
kernel.shmmax = 4294967296
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
END
/sbin/sysctl -p
echo " Add Oracle configure kernel parameters success"
else
echo " Oracle configure kernel parameters already existed"
fi
else
if [ -z "$(grep "Oracle" $RCLOCAL_FILE)" ] ; then
cat >>$RCLOCAL_FILE << END
#Oracle configure kernel parameters
echo 536870912 > /proc/sys/kernel/shmmax
echo 4096 > /proc/sys/kernel/shmmni
echo 2097152 > /proc/sys/kernel/shmall
echo 250 32000 100 128 > /proc/sys/kernel/sem
echo 65536 > /proc/sys/fs/file-max
echo 1024 65000 > /proc/sys/net/ipv4/ip_local_port_range
END
. $RCLOCAL_FILE
echo " Add Oracle configure kernel parameters success"
else
echo " Oracle configure kernel parameters already existed"
fi
fi
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved