Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1026829
  • 博文数量: 171
  • 博客积分: 55
  • 博客等级: 民兵
  • 技术积分: 2077
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-04 10:11
个人简介

pugna

文章分类

全部博文(171)

文章存档

2021年(4)

2020年(1)

2019年(4)

2018年(5)

2017年(7)

2016年(9)

2015年(36)

2014年(8)

2013年(96)

2012年(1)

分类: Oracle

2013-02-18 01:01:28

CentOS平台Oracle11gR2静默安装及静默建库

系统环境:CentOS mini x64

 

说明:以“#”开头的命令是使用root身份执行的,以“$”开头的命令是使用oracle身份执行的。

 

 

 

一、准备工作

1.设置好网络,安装常用软件

2.准备好Oracle安装文件

 

 

 

二、关闭selinux

#vim /etc/selinux/config

***********************************************************

SELINUX=disabled

SELINUXTYPE=targeted

***********************************************************

 

#setenforce 0

 

 

 

三、关闭防火墙

#service iptables stop

 

 

 

四、检查主机配置和安装依赖包

#grep MemTotal /proc/meminfo

#grep SwapTotal /proc/meminfo

 

#rpm -q gcc make binutils openmotif setarch compat-db compat-gcc-34 compat-gcc-34-c++ compat-libstdc++- libXp ksh sysstat libaio glibc elfutils unixODBC

 

#yum -y install gcc make binutils openmotif setarch compat-db compat-gcc-34 compat-gcc-34-c++ compat-libstdc++- libXp ksh sysstat libaio glibc elfutils unixODBC

#yum -y install glibc.i686

 

 

 

五、准备安装用户及用户组

#groupadd oinstall

#groupadd dba

#useradd -m -g oinstall -G dba oracle

#id oracle

#passwd oracle

 

 

 

六、修改内核参数配置文件

#vim /etc/sysctl.conf
注意等号两边的空格

***********************************************************

fs.aio-max-nr = 1048576

fs.file-max = 65536

kernel.shmall = 2097152

kernel.shmmax = 402653184

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 1024 65000

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048586

***********************************************************

 

让参数生效

#sysctl -p

 

 

 

七、限制oracle用户对系统资源的使用

#vim /etc/security/limits.conf

***********************************************************

oracle soft   nproc  2047

oracle hard   nproc  16384

oracle soft   nofile 1024

oracle hard   nofile 65536

oracle soft   stack  10240

***********************************************************

 

 

 

八、要使limits.conf文件的配置生效,必须要将pam_limits.so文件加入到启动文件中

#vim /etc/pam.d/login

***********************************************************

session    required    /lib64/security/pam_limits.so #64为系统位数

session    required    pam_limits.so

***********************************************************

 

 

 

九、功能和步骤七和八相同,都是为了限制oracle用户对系统资源的使用

#vim /etc/profile

***********************************************************

if [ $USER = "oracle" ]; then

 if [ $SHELL = "/bin/ksh" ]; then

  ulimit -p 16384

  ulimit -n 65536

 else

  ulimit -u 16384 -n 65536

 fi

fi

***********************************************************

 

 

 

十、创建安装目录和设置文件权限

#mkdir -p /home/oracle/app/oracle

#mkdir -p /home/oracle/app/oracle/product/11.2.0/dbhome_1

#mkdir -p /home/oracle/app/oracle/inventory

#mkdir -p /home/oracle/app/oracle/oradata

#mkdir -p /home/oracle/app/oracle/oradata_bk

#chown -R oracle:oinstall /home/oracle/

#chmod -R 775 /home/oracle/app/

 

#logout

 

 

 

十一、配置oracle用户环境变量

oracle用户登陆

$id

$cd ~

$pwd

$cat /home/oracle/.bash_profile

$vim /home/oracle/.bash_profile

***********************************************************

umask 022

export ORACLE_SID=orcldb

export ORACLE_BASE=/home/oracle/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

export PATH=$ORACLE_HOME/bin:$PATH

***********************************************************

$echo 'umask 022' >> /home/oracle/.bash_profile

$echo 'export ORACLE_SID=orcldb' >> /home/oracle/.bash_profile

$echo 'export ORACLE_BASE=/home/oracle/app/oracle' >> /home/oracle/.bash_profile

$echo 'export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1' >> /home/oracle/.bash_profile

$echo 'export PATH=$ORACLE_HOME/bin:$PATH' >> /home/oracle/.bash_profile

***********************************************************

$cat /home/oracle/.bash_profile

$source /home/oracle/.bash_profile

 

 

 

十二、解压Oracle11gR2的安装包压缩文件

$unzip linux.x64_11gR2_database_1of2.zip

$unzip linux.x64_11gR2_database_2of2.zip

 

 

 

十三、编辑静默安装响应文件

$cd /home/oracle/

$mkdir oracle_response

$ls -l /home/oracle/oracle_response

$cp /home/oracle/database/response/*.rsp /home/oracle/oracle_response/

$vim /home/oracle/oracle_response/db_install.rsp

 

***********************************************************

oracle.install.option=INSTALL_DB_SWONLY               //只安装软件,不安装启动数据库

ORACLE_HOSTNAME=zfr.centos                            //通过hostname命令获得

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/home/oracle/app/oracle/inventory

SELECTED_LANGUAGES=en,zh_CN

ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1

ORACLE_BASE=/home/oracle/app/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.isCustomInstall=false

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=dba

DECLINE_SECURITY_UPDATES=true                         //一定要设置为true

***********************************************************

 

 

 

十四、使用响应文件进行安装Oracle11gR2软件

$cd /home/oracle/database

$./runInstaller -silent -responseFile /home/oracle/oracle_response/db_install.rsp

 

根据提示,使用root执行脚本

#sh /home/oracle/app/oracle/inventory/orainstRoot.sh

#sh /home/oracle/app/oracle/product/11.2.0/dbhome_1/root.sh

 

 

 

十五、使用响应文件配置监听

$cd ~

$vim /home/oracle/oracle_response/netca.rsp

 

一般不用修改netca.rsp,直接使用此文件生成默认监听

$$ORACLE_HOME/bin/netca /silent /responsefile /home/oracle/oracle_response/netca.rsp

 

$netstat -tlnp

 

查看监听状态

$lsnrctl status

 

 

 

十六、使用响应文件静默建库

$vim /home/oracle/oracle_response/dbca.rsp

 

***********************************************************

OPERATION_TYPE = "createDatabase"

GDBNAME = "orcldb.zfr.centos"

SID = "orcldb"

TEMPLATENAME = "General_Purpose.dbc"

SYSPASSWORD = "dba"

SYSTEMPASSWORD = "dba"

DATAFILEDESTINATION =/home/oracle/app/oradata

RECOVERYAREADESTINATION=/home/oracle/app/oradata_bk

CHARACTERSET = "AL32UTF8"    //字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。

NATIONALCHARACTERSET= "UTF8"

TOTALMEMORY = "768"

***********************************************************

 

$$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/oracle_response/dbca.rsp

 

建库后实例检查:

$ps -ef | grep ora_ | grep -v grep

$ps -ef | grep ora_ | grep -v grep | wc -l

 

 

 

静默删除数据库的命令

$dbca -silent -deleteDatabase -sourceDB orcldb -sysDBAUserName sys -sysDBAPassword sys_passwd

 

$logout



安装rlwraprlwrap依赖readline
这里说明一下为什么安装rlwrap
在使用远程工具登陆Linux主机,在sqlplusrman中使用 deletehomeend及方向键时,界面显示为乱码。安装rlwrap后,使用rlwrap sqlplus可以正常使用这些功能键。

#yum -y install readline*

~hlub/uck/rlwrap/

#cd ~
#pwd
#wget ~hlub/uck/rlwrap/rlwrap-0.37.tar.gz
#tar -zxvf rlwrap-0.37.tar.gz
#cd rlwrap-0.37
#./configure && make && make install

#logout



使用别名
$vim /home/oracle/.bash_profile
***********************************************************
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
***********************************************************
echo "alias sqlplus='rlwrap sqlplus'" >> ~/.bash_profile
echo "alias rman='rlwrap rman'" >> ~/.bash_profile
***********************************************************
$source /home/oracle/.bash_profile



解决在sqlplusrman中输入 BACKSPACE 键变成 ^h 的问题
$vim /home/oracle/.bash_profile
***********************************************************
stty erase ^h
***********************************************************
$source /home/oracle/.bash_profile




修改数据库为归档模式(归档模式才能热备份,增量备份)
$sqlplus /as sysdba
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database flashback on;
SQL> alter database open;
SQL> archive log list;
SQL> exit

 

 

 

安装过程中,主要参考http://blog.csdn.net/smstong/article/details/7352036的说明。

 

 

 

最后附上几个静默安装软件的过程中出现过的错误

错误1
/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

解决办法:
#yum -y install glibc.i686

 

参考

错误2
WARNING: A log of this session is currently saved as: /tmp/OraInstall2012-11-20_05-33-57PM/installActions2012-11-20_05-33-57PM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.
INFO: Finding the most appropriate exit status for the current application
INFO: Exit Status is -2
INFO: Shutdown Oracle Database 11g Release 2 Installer

解决办法:
在响应文件db_install.rsp中,设置DECLINE_SECURITY_UPDATES=true即可。

 

参考http://www.itpub.net/thread-1241747-1-2.html

                                                                                                                                                2013-02-18 01:01


阅读(3092) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~