Oracle for Linux 安装前环境配置脚本(转)

#!/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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/70109/viewspace-689622/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值