Oracle for Linux 安裝前環境配置指令碼(轉)

wdnmg發表於2011-03-16
#!/usr/bin/PERL
#Ver 1.0
#nailxu
#License GPL
print "***********************************************************************\n";
print "** Now,let's begining to make preparation for installing the ORACLE. **\n";
print "-----------------------------------------------------------------------\n";
#this is the function to set Oracle's Version.
sub VER{
print "1st>,please set the Version of the ORACLE(cann't be blank):";
$ver=;
chomp $ver;
while($ver eq ""){
 VER();
}
}
VER();
print "the oracle's version is ${ver}\n";
#this is the function to set $ORACLE_HOME.
sub HOMEDIR{
print "2nd>,please set the ORACLE_HOME of the Database(cann't be blank):";
$homedir=;
chomp $homedir;
while($homedir eq ""){
        HOMEDIR();
}
}
HOMEDIR();
print "the \$ORACLE_HOME is ${homedir}\n";
#this is the function to set SID.
sub SID{
print "3rd>,please set the SID(cann't be blank):";
$sid=;
chomp $sid;
while($sid eq ""){
        SID();
}
}
SID();
print "the SID is $sid\n";
#this is the function to set CharacterSet.
sub CHA{
print "4th>,please set the CharacterSet of the Database(cann't be blank):";
$cha=;
chomp $cha;
while($cha eq ""){
        CHA();
}
}
CHA();
print "the characterSet is $cha\n";
print "----------------------------------------------------------------------\n";
sub verifyINPUT{
print "OK,ALL the paramter have been input as follow:\n";
print "Oracle version is $ver\n";
print "ORACLE_HOME is $homedir\n";
print "ORACLE SID is $sid\n";
print "ORACLE CharacterSet is $cha\n";
print "Are U sure your input[y is yes,n is no]:";
$input=;
chomp $input;
if($input ne "y"){
 print "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
 print "U think you have something wrong input,please reexecute the script.\n";
 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
 exit;
}else{
 print "-------------------------------------------------------------------\n";
 print "U have finished the input,I will prepare the envirment for your oracle installation,please wait ... ...\n";
 createuser();
 createdir();
 formatpro();
 formatker();
 formatlim();
}
}
verifyINPUT();
#create the oracle user
sub createuser{
system("groupadd dba");
system("groupadd oinstall");
system("useradd -g oinstall -G dba oracle");
#the init password of oracle is oracle
system("echo oracle|passwd --stdin oracle");
}
#create the oracle_home
sub createdir{
system("mkdir -p ${homedir}/${ver}");
system("chown -R oracle.oinstall ${homedir}");
system("chmod -R 766 ${homedir}");
}
#format the oracle.bash_profile
sub formatpro{
system("echo export ORACLE_BASE=${homedir} >> /home/oracle/.bash_profile");
system("echo export ORACLE_HOME=${homedir}/${ver} >> /home/oracle/.bash_profile");
system("echo export ORACLE_SID=$sid >> /home/oracle/.bash_profile");
system("echo export ORACLE_TERM=xterm >> /home/oracle/.bash_profile");
system("echo export LD_ASSUME_KERNEL=2.4.19 >> /home/oracle/.bash_profile");
system("echo export NLS_LANG=AMERICAN_AMERICA.$cha >> /home/oracle/.bash_profile");
system("echo 'export ORA_NLS33=\$ORACLE_HOME/ocommon/nls/admin/data' >> /home/oracle/.bash_profile");
system("echo 'LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib' >> /home/oracle/.bash_profile");
system("echo 'LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib' >> /home/oracle/.bash_profile");
system("echo export LD_LIBRARY_PATH >> /home/oracle/.bash_profile");
system("echo 'export PATH=\$PATH:\$ORACLE_HOME/bin' >> /home/oracle/.bash_profile");
}
sub getmem{
$mem=`cat /proc/meminfo|grep MemTotal |tr -d ' '`;
chomp($mem);
$len=length($mem);
$mem=substr("$mem",9,$len-11);
$mem=$mem*1024;
$shmmax=$mem/2;
#print "The memory  is ${mem}Byte,and the kernel.shmmax should be ${shmmax}\n";
}
sub formatker{
getmem();
system("echo kernel.shmmax = ${shmmax} >> /etc/sysctl.conf");
system("echo kernel.shmmni = 4096 >> /etc/sysctl.conf");
system("echo kernel.shmall = 2097152 >> /etc/sysctl.conf");
system("echo kernel.sem = 250 3200 100 128 >> /etc/sysctl.conf");
system("echo fs.file-max = 65536 >> /etc/sysctl.conf");
system("echo.NET.ipv4.ip_local_port_range = 1024 6500 >> /etc/sysctl.conf");
}
sub formatlim{
system("echo oracle  soft    nofile  65536 >> /etc/security/limits.conf");
system("echo oracle  hard    nofile  65536 >> /etc/security/limits.conf");
system("echo oracle  soft    nproc   16384 >> /etc/security/limits.conf");
system("echo oracle  hard    nproc   16384 >> /etc/security/limits.conf");
}
 
 
*************************************************************************
LINUX中也有自己的RMAN工具,而非oracle的RMAN,所以如果沒有在環境變數中設定oracle的RMAN的話,就需要到ORALCE/HOME目錄中的rman目錄下去執行RMAN命令,這時候就會進入ORACLE的RMAN.
[oracle@smsdbrac1 oracle]$ which rman
/usr/X11R6/bin/rman
在Oracle使用者的環境變數下,將$ORACLE_HOME/bin放在PATH變數前就可以了:
export PATH=$ORACLE_HOME/bin:$PATH
讀者可以更改上述指令碼中相應行即可。
詳細出處參考:http://www.itqun.net/content-detail/101693_3.html

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70109/viewspace-689622/,如需轉載,請註明出處,否則將追究法律責任。

相關文章