Chinaunix首页 | 论坛 | 博客
  • 博客访问: 56711
  • 博文数量: 23
  • 博客积分: 1415
  • 博客等级: 上尉
  • 技术积分: 255
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-18 17:22
文章分类

全部博文(23)

文章存档

2010年(1)

2009年(10)

2008年(12)

我的朋友
最近访客

分类: Oracle

2009-01-14 16:44:29

#!/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
读者可以更改上述脚本中相应行即可。
阅读(1727) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~