該腳本適用于從模板克隆出的數(shù)據(jù)庫,包括建庫、調(diào)整參數(shù)、修改相關(guān)配置文件、生產(chǎn)數(shù)據(jù)庫配置文件。該腳本目錄在suse 11、suse 12上測試通過。
冠縣網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),冠縣網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為冠縣千余家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的冠縣做網(wǎng)站的公司定做!
#!/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
該腳本內(nèi)容可根據(jù)實(shí)際情況進(jìn)行相關(guān)調(diào)整。