Oracle11g 自動化建庫及調整相關引數
該指令碼適用於從模板克隆出的資料庫,包括建庫、調整引數、修改相關配置檔案、生產資料庫配置檔案。該指令碼目錄在suse 11、suse 12上測試透過。
#!/usr/bin/env bash
echo "========================================="
echo "This script is for install a test oracle db"
echo "Please use oracle user execute !!!!!!!!!!!"
echo "Execute this script about 5-10 mins "
echo "Script has been test on suse 11sp4 12sp3"
echo "========================================"
uid=`id -u`
uname=`cat /etc/passwd| grep $uid | awk -F ":" '{print $1}'`
function exit_script()
{
exit 1
}
function crt_db()
{
local mem=`free -g | grep Mem | awk {'print $2'}`
local perc=30
if [ "$mem" -lt 5 ]; then
perc=50
echo "Machine memory is $mem GB, Oracle mem percet is 50%"
else
echo "Machine memory is $mem GB, Oracle mem percet is 30%"
fi
echo "Begin create database ..."
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname gycdb -sid gycdb -sysPassword gyc_pwd123 -systemPassword gyc_pwd123 -responseFile NO_VALUE -characterSet ZHS16GBK -memoryPercentage $perc -emConfiguration NONE -datafileDestination /oradata/ -redoLogFileSize 500 -initParams processes=2000
if [ $? -eq 0 ]; then
echo "Create database has been completed!!!"
else
echo "Create database failed, Please connect to Oracle DBA"
exit_script
fi
}
function change_prm()
{
local fname=/oracle/app/oracle/product/11.2.0/rdbms/admin/gyc_dev.sql
if [ -f "$fname" ]; then
echo "Parameter file is exits!, Begin change default parameters"
else
echo "Parameter file is not exits, Please connect to Oracle DBA"
exit_script
fi
sed -i '1d' $fname
echo "shutdown immediate" >> $fname
echo "startup" >> $fname
echo "exit" >> $fname
export ORACLE_SID=gycdb
sqlplus "/ as sysdba" @$fname
if [ $? -eq 0 ]; then
echo "Database has changed default parameters !!!!"
else
echo "Change paramter failed, Please connect to Oracle DBA"
exit_script
fi
}
function change_hostname()
{
echo "Begin change hostname and oracle sid...."
sed -i "s/GYCTEST/`hostname`/g" $ORACLE_HOME/network/admin/listener.ora
lsnrctl start
sed -i "s/icbcdb/gycdb/g" /home/oracle/.profile
if [ $? -eq 0 ]; then
echo "Listener has changed hostnane, Listener was started"
else
echo "Start listener failed, Please connect to Oracle DBA"
exit_script
fi
}
function db_info()
{
echo "Begin create db info file...."
local fname=/home/oracle/db_info.txt
touch $fname
echo "db_name:gycdb" >> $fname
echo "port:1521" >> $fname
echo "sys/system:gyc_pwd123" >> $fname
if [ $? -eq 0 ]; then
echo "Db_info file has been created!!"
else
echo "Db_info has failed, Please connect to Oracle DBA"
exit_script
fi
}
if [ "$uname" == "oracle" ]; then
echo "Begin execute script ......"
crt_db
change_prm
change_hostname
db_info
echo "End execute script !!!!!!"
else
echo "Current user is not oracle, Please change to oracle then execute this script"
exit_script
fi
function db_info()
{
echo "Begin create db info file...."
local fname=/home/oracle/db_info.txt
touch $fname
echo "db_name:testdb" >> $fname
echo "port:1521" >> $fname
echo "sys/system:SysCs_100010" >> $fname
if [ $? -eq 0 ]; then
echo "Db_info file has been created!!"
else
echo "Db_info has failed, Please connect to Oracle DBA"
exit_script
fi
}
if [ "$uname" == "oracle" ]; then
echo "Begin execute script ......"
crt_db
change_prm
change_hostname
db_info
echo "End execute script !!!!!!"
else
echo "Current user is not oracle, Please change to oracle then execute this script"
exit_script
fi
該指令碼內容可根據實際情況進行相關調整。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24585765/viewspace-2214029/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux 核心引數及Oracle相關引數調整LinuxOracle
- (轉)Linux 核心引數及Oracle相關引數調整LinuxOracle
- Linux核心引數(如kernel.shmmax)及Oracle相關引數調整LinuxHMMOracle
- Linux 核心引數 和 Oracle相關引數調整LinuxOracle
- Oracle11g自動記憶體管理(AMM)相關的初始化引數Oracle記憶體
- 自動記憶體調整中真正決定自動調整的引數記憶體
- oracle 記憶體引數調整優化相關傾力整理Oracle記憶體優化
- oracle 記憶體引數調整最佳化相關傾力整理Oracle記憶體
- Linux核心引數(如kernel.shmmax)及Oracle相關引數調整(如SGA_MAX_SIZE)LinuxHMMOracle
- 調整資料庫引數資料庫
- 資料庫安裝初始化引數調整資料庫
- Oracle 資料庫引數調整Oracle資料庫
- swoole優化核心引數調整優化
- MySQL記憶體引數及調整MySql記憶體
- MySQL引數調整MySql
- solaris記憶體引數調整及管理記憶體
- 達夢資料庫引數調整方法資料庫
- AIX fsfastpath 引數調整AIAST
- dg庫日誌應用慢引數調整
- 【調優篇基本原理】優化器相關引數配置優化
- Linux環境安裝Oracle11g(二)——作業系統引數及服務調整LinuxOracle作業系統
- ORACLE RAC SGA引數調整Oracle
- 引數調整案例總結
- redis持久化相關引數解釋Redis持久化
- oracle記憶體調整相關Oracle記憶體
- Linux核心引數以及Oracle引數調整(updated)LinuxOracle
- 關於AIX上VMO調整引數的若干說明AI
- LinuxSysctl調整核心引數Linux
- HP-UX調整核心引數UX
- Python 環境下的自動化機器學習超引數調優Python機器學習
- [最佳化]Oracle 內在索引和引數數的調整(轉)Oracle索引
- Kafka 配置引數彙總及相關說明Kafka
- 檢視JVM預設引數及微調JVM啟動引數JVM
- oracle11g 手動建庫Oracle
- MySQL change buffer介紹和相關引數調整建議MySql
- ORACLE建庫過程中自動生成的跟鎖相關的VIEWOracleView
- PGA自動管理原理深入分析及效能調整(六)
- PGA自動管理原理深入分析及效能調整(一)