CentOS下oracle11gR2静默安装

步骤:
1、上传oracle安装包
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip

2、检查依赖库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
rpm -q binutils | grep "not installed"
rpm -q compat-libstdc++-33 | grep "not installed"
rpm -q elfutils-libelf | grep "not installed"
rpm -q elfutils-libelf-devel | grep "not installed"
rpm -q expat | grep "not installed"
rpm -q gcc | grep "not installed"
rpm -q gcc -c++ | grep "not installed"
rpm -q binutils | grep "not installed"
rpm -q glibc | grep "not installed"
rpm -q glibc-common | grep "not installed"
rpm -q glibc-devel | grep "not installed"
rpm -q glibc-headers | grep "not installed"
rpm -q libaio | grep "not installed"
rpm -q libaio-devel | grep "not installed"
rpm -q libgcc | grep "not installed"
rpm -q libstdc++ | grep "not installed"
rpm -q libstdc++-devel | grep "not installed"
rpm -q make | grep "not installed"
rpm -q pdksh | grep "not installed"
rpm -q sysstat | grep "not installed"
rpm -q binutils | grep "not installed"
rpm -q unixODBC | grep "not installed"
rpm -q unixODBC-devel | grep "not installed"

若出现哪些依赖库没有安装,使用”yum install [依赖库]“进行安装

一般缺少依赖包: 

    compat-libstdc++-33

    elfutils-libelf-devel

    libaio-devel

    pdksh

    unixODBC

    unixODBC-devel

    pdksh可能安装不了,需另外单独下载,传到服务器上,加上执行权限,进行安装

 

Java代码 
  1. chmod 777 pdksh-5.2.14-37.el5_8.1.x86_64.rpm   

 

 

Java代码 
  1. rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm  

   下载pdksh,地址:http://vdisk.weibo.com/s/uqs9yi2YuoqLL?from=page_100505_profile&wvr=6

 

 

3、创建用户和用户组

1
2
3
4
5
6
groupadd oinstall
groupadd dba
groupadd asmadmin
groupadd asmdba
useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
passwd oracle

4、为oracle设置内核参数

sysctl.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
vi /etc/sysctl .conf
 
# 在底部追加以下内容
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.rp_filter = 1
fs. file -max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
# 使配置立即生效
sysctl -p
limits.conf
1
2
3
4
5
6
vi /etc/security/limits .conf
# 在底部追加以下内容
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

5、新建oracle目录

1
2
3
mkdir -p /u01/app/oracle/
chown -R oracle:oinstall /home/oracle
chown -R oracle:oinstall /u01

6、设置oracle环境变量

.bash_profile
1
2
3
4
5
6
7
8
9
10
11
12
vi .bash_profile
export PATHTH=$PATH:HOME /bin
export ORACLE_BASE= /u01
export ORACLE_HOME=$ORACLE_BASE /oracle
export ORACLE_SID=LED
export PATH=$PATH:$ORACLE_HOME /bin :$ORACLE_HOME /Apache/Apache/bin
# export TNS_ADMIN=$ORACLE_HOME/network/admin
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:ORACLE_HOME/lib
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
# export ORA_NLS10=$ORACLE_HOME/nls/data
unset USERNAME
umask 022

7、解压缩oracle安装文件

1
2
3
4
5
6
7
8
9
10
su - root
mv linux.x64_11gR2_database_1of2.zip /home/oracle/linux .x64_11gR2_database_1of2.zip
mv linux.x64_11gR2_database_2of2.zip /home/oracle/linux .x64_11gR2_database_2of2.zip
cd /home/oracle
chmod 777 *.zip
su - oracle
unzip linux.x64_11gR2_database_1of2.zip -d /u01
unzip linux.x64_11gR2_database_2of2.zip -d /u01
cd /u01/database
export DISTRIB=` pwd `

8、修改数据库安装响应文件

1
2
3
4
5
6
7
8
9
10
11
12
13
cd /u01/database/response
vi db_install.rsp
 
# 需要更改的参数,其他尽量不要更改,若非要更改请了解参数含义
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION= /u01/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN,zh_TW
ORACLE_HOME= /u01/app/oracle/product/11 .2.0 /dbhome_1
ORACLE_BASE= /u01/app/oracle
oracle. install .db.InstallEdition=EE
oracle. install .db.isCustomInstall= true
oracle. install .db.DBA_GROUP=dba
oracle. install .db.OPER_GROUP=oinstall

9、调整swap空间大小

1
2
3
4
5
6
7
8
9
10
11
su - root
# 查看swap大小
free -m
# 增加交换分区文件及大小,如果要增加2G大小的交换分区,则命令写法如下,其中的 count 等于想要的块大小。
dd if = /dev/zero of= /home/swap bs=1024 count=2048000
# 设置交换文件
mkswap /home/swap
# 立即启用交换分区文件
swapon /home/swap
# 如果要在引导时自动启用,则编辑 /etc/fstab 文件,添加行
/home/swap swap swap defaults 0 0

10、开始静默安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
su - oracle
cd /u01/database
. /runInstaller -silent -force -responseFile /u01/database/response/db_install .rsp
 
# 安装成功会出现
[oracle@iZ94dzd0zvxZ database]$ The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/u01/oraInventory/orainstRoot .sh
/u01/oracle/root .sh
To execute the configuration scripts:
          1. Open a terminal window
          2. Log in as "root"
          3. Run the scripts
          4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.

这一步操作最容易出错,在执行安装脚本时就会报错,经反复测试,只要保证以下规律就能出现”Successfully Setup Software“,
在执行此步操作时,最好再次执行下以下命令:

1
2
cd /u01/database
export DISTRIB=` pwd `

oracle静默安装时会需找此变量,另外附加个安装成功的db_install.rsp的响应文件,点击下载

11、在root用户下运行脚本

1
2
3
4
cd /u01/oraInventory/
. /orainstRoot .sh
cd /u01/oracle/
. /root .sh

12、静默配置监听

1
2
3
4
5
6
7
8
# 切换到oracle用户
su - oracle
# 执行监听的响应文件安装
$ORACLE_HOME /bin/netca /silent /responsefile /u01/database/response/netca .rsp
# 查看是否已经生成listener.ora和sqlnet.ora监听文件
ll $ORACLE_HOME /network/admin/ *.ora
# 检查监听启动状态
lsnrctl status

13、静默建库

dbca.rsp
1
2
3
4
5
6
7
8
9
vi /u01/database/response/dbca .rsp
 
#以下参数必须设置
[CREATEDATABASE]
GDBNAME = "ORCL.LK"
TEMPLATENAME = "General_Purpose.dbc"
#以下参数不设置则使用默认值,建议设置
CHARACTERSET = "utf8"
TOTALMEMORY = "1024"

执行静默安装

1
2
3
$ORACLE_HOME /bin/dbca -silent -responseFile /u01/database/response/dbca .rsp
Enter SYS user password:
Enter SYSTEM user password:

由于没有更改dbca.rsp文件中的SYS和SYSTEM的密码,所以oracle缺省密码分别为chang_on_installmanager

14、检查建库实列

1
2
ps -ef | grep ora_ | grep - v grep | wc -l
ps -ef | grep ora_ | grep - v grep

监听、进程正常,启动成功。关于创建用户、表空间和分配权限,请点击

创建Oracle表空间,临时表空间,用户名

Java代码 
  1. CREATE SMALLFILE TEMPORARY TABLESPACE TQBAY_TEMP TEMPFILE '/bosyun/u01/oradata/orcl11g/TQBAY_TEMP' SIZE 2048M AUTOEXTEND ON NEXT 512M MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;  
  2.      
  3. CREATE SMALLFILE TABLESPACE TQBAY_DATA DATAFILE '/bosyun/u01/oradata/orcl11g/TQBAY_DATA' SIZE 2048M AUTOEXTEND ON NEXT 512M MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;  
  4.      
  5. CREATE USER 用户名 PROFILE "DEFAULT" IDENTIFIED BY 密码 DEFAULT TABLESPACE TQBAY_DATA TEMPORARY TABLESPACE TQBAY_TEMP ACCOUNT UNLOCK;  
  6.      
  7. GRANT CONNECT TO 用户名 WITH ADMIN OPTION;  
  8. GRANT DBA TO 用户名;  
  9. GRANT RESOURCE TO 用户名;  

FAQ:

FAQ1:[FATAL] [INS-13013] Target environment do not meet some mandatory requirements

解决安装是:安装命令中加入选项-ignorePrereq

FAQ2: LRM-00109: could not open parameter file '/home/oracle/oracle10g/dbs/initoms

今天连接Oracle数据库的时候,发现数据没启动,利用startup命令,出现错误提示如下:

SQL> startup

ORA-01078: failure in processing system   parameters

LRM-00109: could not open parameter file   '/oracle/10g/dbs/init10g.ora'

 

按提示查找相关目录的文件,果然不存在。

到网上查了一下资料。得到如果有用信息:是因为在oracle10g中,oracle默认将使用spfile启动数据库,如果spfile不存在,则就会出现上述错误。

解决方法:

将$ORACLE_BASE/admin/你的数据库名称/pfile/init.ora.628201264542(这串数字未必一样)

copy到$ORACLE_HOME/dbs目录下,并改名为你的数据库实例名即可。

例如:上面提示找不到init10g.ora这个文件,就改成 init10g.ora

参考命令:

export $ORACLE_HOME --输出使用中的环境变量Home

cat /home/oracle/.bash_profile --或.bashrc文件,务必确定$ORACLE_HOME的值与当前使用的一致

(我就遇到过不一致的)

mv $ORACLE_BASE/admin/orcl/pfile/init.ora.628201264542 /oracle/10g/dbs/init10g.ora  

--复制文件到指定目录

sqlplus "/as sysdba"

startup

 搞定!

FAQ3: SQL> shutdown immediate;

           ORA-01507: database not mounted

Sql代码 
  1. [oracle@iZ286r3394hZ orcl11g]$ ps -ef | grep oracle  
  2. oracle   29729     1  0 10:17 ?        00:00:00 /bosyun/u01/app/oracle/bin/tnsl  
  3. nr LISTENER -inherit  
  4. root     30074 30038  0 10:34 pts/0    00:00:00 su - oracle  
  5. oracle   30075 30074  0 10:34 pts/0    00:00:00 -bash  
  6. oracle   30831     1  0 10:37 ?        00:00:00 ora_pmon_orcl11g  
  7. oracle   30833     1  0 10:37 ?        00:00:01 ora_vktm_orcl11g  
  8. oracle   30837     1  0 10:37 ?        00:00:00 ora_gen0_orcl11g  
  9. oracle   30839     1  0 10:37 ?        00:00:00 ora_diag_orcl11g  
  10. oracle   30841     1  0 10:37 ?        00:00:00 ora_dbrm_orcl11g  
  11. oracle   30843     1  0 10:37 ?        00:00:00 ora_psp0_orcl11g  
  12. oracle   30845     1  0 10:37 ?        00:00:00 ora_dia0_orcl11g  
  13. oracle   30847     1  0 10:37 ?        00:00:00 ora_mman_orcl11g  
  14. oracle   30849     1  0 10:37 ?        00:00:00 ora_dbw0_orcl11g  
  15. oracle   30851     1  0 10:37 ?        00:00:00 ora_lgwr_orcl11g  
  16. oracle   30853     1  0 10:37 ?        00:00:00 ora_ckpt_orcl11g  
  17. oracle   30855     1  0 10:37 ?        00:00:00 ora_smon_orcl11g  
  18. oracle   30857     1  0 10:37 ?        00:00:00 ora_reco_orcl11g  
  19. oracle   30859     1  0 10:37 ?        00:00:00 ora_mmon_orcl11g  
  20. oracle   30861     1  0 10:37 ?        00:00:00 ora_mmnl_orcl11g  
  21. oracle   30863     1  0 10:37 ?        00:00:00 ora_d000_orcl11g  
  22. oracle   30865     1  0 10:37 ?        00:00:00 ora_s000_orcl11g  
  23. oracle   30971     1  0 10:37 ?        00:00:00 ora_qmnc_orcl11g  
  24. oracle   30986     1  0 10:37 ?        00:00:00 ora_cjq0_orcl11g  
  25. oracle   30988     1  0 10:37 ?        00:00:00 ora_q000_orcl11g  
  26. oracle   30990     1  0 10:37 ?        00:00:00 ora_q001_orcl11g  
  27. oracle   31041     1  0 10:47 ?        00:00:00 ora_smco_orcl11g  
  28. oracle   31043     1  0 10:47 ?        00:00:00 ora_w000_orcl11g  
  29. oracle   31285 30075  0 10:56 pts/0    00:00:00 ps -ef  
  30. oracle   31286 30075  0 10:56 pts/0    00:00:00 grep --color=auto oracle  
  31.   
  32. [oracle@iZ286r3394hZ orcl11g]$ kill -9 30831  
  33. [oracle@iZ286r3394hZ orcl11g]$ ps -ef | grep oracle  
  34. oracle   29729     1  0 10:17 ?        00:00:00 /bosyun/u01/app/oracle/bin/tnsls  
  35. nr LISTENER -inherit  
  36. root     30074 30038  0 10:34 pts/0    00:00:00 su - oracle  
  37. oracle   30075 30074  0 10:34 pts/0    00:00:00 -bash  
  38. oracle   31293 30075  0 10:57 pts/0    00:00:00 ps -ef  
  39. oracle   31294 30075  0 10:57 pts/0    00:00:00 grep --color=auto oracle  
  40.   
  41. [oracle@iZ286r3394hZ orcl11g]$ ipcs -s  
  42.   
  43. ------ Semaphore Arrays --------  
  44. key        semid      owner      perms      nsems  
  45.   
  46. [oracle@iZ286r3394hZ orcl11g]$ ipcs -mp  
  47.   
  48. ------ Shared Memory Creator/Last-op PIDs --------  
  49. shmid      owner      cpid       lpid  
  50.   
  51. [oracle@iZ286r3394hZ orcl11g]$ ps -ef | grep ora_  
  52. oracle   31300 30075  0 10:58 pts/0    00:00:00 grep --color=auto ora_  
  53. [oracle@iZ286r3394hZ orcl11g]$ sqlplus /nolog  
  54. SQL> connect / as sysdba  
  55. SQL> startup  
  56. ORACLE instance started.  
  57.   
  58. Total System Global Area 1068937216 bytes  
  59. Fixed Size                  2220200 bytes  
  60. Variable Size             616566616 bytes  
  61. Database Buffers          444596224 bytes  
  62. Redo Buffers                5554176 bytes  
  63. Database mounted.  
  64. Database opened. 

猜你喜欢

转载自jatter.iteye.com/blog/2296041