11g静默安装 centos系统

1 安装前环境:

  操作系统:CetnOS6.6x64 最小化安装,已配置好网络IP:10.10.10.12,物理内存32GB,硬盘300GB。

  已下载: linux.x64_11gR2_database_1of2.zip

               linux.x64_11gR2_database_2of2.zip

  位于目录: /sharedisk/11G/

    binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat unixODBC unixODBC-devel elfutils-libelf-devel pdksh

2 准备工作

 root用户登录后

 # yum install unzip       //下载unzip,用来解压上述两个压缩文件

 # cd /opt/hadoop/        //切换当前目录到oracle压缩文件所在目录

 # unzip linux.x64_11gR2_database_1of2.zip //解压

 # unzip linux.x64_11gR2_database_2of2.zip

 解压后新增一个/opt/hadoop/database目录,里面是解压后的所有oracle安装文件。

 

 在/etc/hosts文件中增加主机名(通过hostname获得)到回环IP的映射如下:

# vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.10.10.12   ora11g

 

 # vi /etc/selinux/confg  设置 SELINUX=disabled

 # setenforce 0   //关闭selinux

 # service iptables stop //临时关闭防火墙

 

3 安装必须的包

# yum install nfs-utils    //可以挂载nfs server

#yum install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel

检查那些包没有安装成功

rpm -q --queryformat %-{name}-%{version}-%{release}-%{arch}"\n" \ compat-db compat-gcc-34 compat-gcc-34-c++ compat-libstdc++-33 glibc-* glibc-*.i686 libXpm-*.i686 libXp.so.6 libXt.so.6 libXtst.so.6 libgcc_s.so.1 ksh libXp libaio-devel numactl numactl-devel unixODBC unixODBC-devel

 

4 准备安装用户及用户组

 # groupadd oinstall

 # groupadd dba

 # useradd -g oinstall -G dba oracle

 # passwd oracle          //设置oracle密码

 

5 修改内核参数配置文件

# vi /etc/sysctl.conf 在文件最后增加(根据文档要求kernel.shmmax设成物理内存的一半最合理)

fs.aio-max-nr = 1048576

fs.file-max = 6553600

kernel.shmall = 2097152

kernel.shmmax = 8588934592

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

 保存文件。

 # /sbin/sysctl -p          //让参数生效

 

6 修改用户的限制文件

# vi /etc/security/limits.conf 在文件后增加

oracle           soft    nproc           2047

oracle           hard    nproc           16384

oracle           soft    nofile          1024

oracle           hard    nofile          65536

oracle           soft    stack           10240

保存文件。

修改/etc/pam.d/login文件,增加如下:

session  required   /lib64/security/pam_limits.so  //64位系统时,千万别写成错/lib/security/pam_limits.so  //否则导致无法登录

session     required      pam_limits.so

 

修改/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

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

#mkdir -p /u01/app/oracle/product/11.2.0  //数据库系统安装目录

 #mkdir /u01/app/oracle/oradata   //数据库数据安装目录

 #mkdir /u01/app/oracle/inventory //此目录最好单独放一个目录下,不要放在oracle安装目录下

 #mkdir /u01/app/oracle/fast_recovery_area //此目录最好单独放一个目录下,不要放在oracle安装目录下

 #chown -R oracle:oinstall /u01/app/oracle

chown -R oracle:oinstall /opt/hadoop/database/

 

 #chmod -R 775 /u01/app/oracle

设置环境变量: 修改/home/oracle/.bash_profile文件,增加如下

# su - oracle

export ORACLE_BASE=/opt/hadoop/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0

export ORACLE_SID=ora11

export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

 

8 编辑静默安装响应文件

 # su - oracle

 $ cp -R /sharedisk/11G/database/response /home/oracle  //复制一份模板

 $ cd /home/oracle/response

 $ vi db_install.rsp     //开始修改这个安装响应文件,此文件只是安装数据库软件

 

需要设置的选项如下:

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0  //系统生成的,不要修改

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

ORACLE_HOSTNAME=ora11g             //通过hostname命令获得

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/u01/app/oracle/inventory

SELECTED_LANGUAGES=en,zh_CN

ORACLE_HOME=/u01/app/oracle/product/11.2.0

ORACLE_BASE=/u01/app/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.isCustomInstall=false

                               

oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0

 

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=dba

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

 

9 根据响应文件安装oracle

 $cd /sharedisk/11G/database

 $./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq

Starting Oracle Universal Installer...

 

Checking Temp space: must be greater than 120 MB.   Actual 1240 MB    Passed

Checking swap space: 0 MB available, 150 MB required.    Failed <<<<

Checking monitor: must be configured to display at least 256 colors

    >>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set.    Failed <<<<

 

Some requirement checks failed. You must fulfill these requirements before

 

continuing with the installation,

 

Continue? (y/n) [n] y

 

 安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在进行,如果出现[FATAL],则安装程序已经停止了。打开另一个终端,执行

 #tail -100f /u01/app/oracle/inventory/logs/installActions......log

 可以实时跟踪查看安装日志,了解安装的进度。

 当出现如下提示,既安装成功:

be executed as the "root" user.

 #!/bin/sh

 #Root scripts to run

 

/u01/app/oracle/inventory/orainstRoot.sh

/u01/app/oracle/product/11.2.0/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.

 表示安装成功了。按照其提示操作。

 $exit  //退回到root

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

 # sh /u01/app/oracle/product/11.2.0/root.sh

 

10 静默配置监听

 $netca /silent /responsefile /home/oracle/response/netca.rsp

Parsing command line arguments:

    Parameter "silent" = true

    Parameter "responsefile" = /home/oracle/response/netca.rsp

Done parsing command line arguments.

Oracle Net Services Configuration:

Profile configuration complete.

Oracle Net Listener Startup:

    Running Listener Control:

      /u01/app/oracle/product/11.2.0/bin/lsnrctl start LISTENER

    Listener Control complete.

    Listener started successfully.

Listener configuration complete.

Oracle Net Services configuration successful. The exit code is 0

 

 成功运行后,在/u01/app/oracle/11.2.0/network/admin目录下生成sqlnet.ora和listener.ora两个文件。

 通过netstat –tlnp  命令,看到

tcp   0    0   :::1521   :::*   LISTEN      10760/tnslsnr  

 说明监听器已经在1521端口上开始工作了。

 

11 静默建立新库(同时也建立一个对应的实例)

 修改/home/oracle/response/dbca.rsp,设置如下:

[GENERAL]

RESPONSEFILE_VERSION = "11.2.0"  //不能更改

OPERATION_TYPE = " createDatabase "

[CREATEDATABASE]

GDBNAME = "ora11"  //数据库的名字

SID = "ora11"    //对应的实例名字

TEMPLATENAME = "General_Purpose.dbc" //建库用的模板文件

SYSPASSWORD = "oracle"   //SYS管理员密码

SYSTEMPASSWORD = "oracle"  //SYSTEM管理员密码

DATAFILEDESTINATION = /u01/app/oracle/oradata      //数据文件存放目录

RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area   //恢复数据存放目录

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

TOTALMEMORY = "3276"    //oracle内存3276MB(allmem*80%)

静默建库命令如下

 $dbca -silent -responseFile /home/oracle/response/dbca.rsp

 Copying database files

1% complete

3% complete

11% complete

18% complete

26% complete

37% complete

Creating and starting Oracle instance

40% complete

45% complete

50% complete

55% complete

56% complete

60% complete

62% complete

Completing Database Creation

66% complete

70% complete

73% complete

85% complete

96% complete

100% complete

Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/ora11/ora11.log" for further details.

 

 查看日志文件

 $ cat /u01/app/oracle/cfgtoollogs/dbca/ora11/ora11.log

Copying database files

DBCA_PROGRESS : 1%

DBCA_PROGRESS : 3%

DBCA_PROGRESS : 11%

DBCA_PROGRESS : 18%

DBCA_PROGRESS : 26%

DBCA_PROGRESS : 37%

Creating and starting Oracle instance

DBCA_PROGRESS : 40%

DBCA_PROGRESS : 45%

DBCA_PROGRESS : 50%

DBCA_PROGRESS : 55%

DBCA_PROGRESS : 56%

DBCA_PROGRESS : 60%

DBCA_PROGRESS : 62%

Completing Database Creation

DBCA_PROGRESS : 66%

DBCA_PROGRESS : 70%

DBCA_PROGRESS : 73%

DBCA_PROGRESS : 85%

DBCA_PROGRESS : 96%

DBCA_PROGRESS : 100%

Database creation complete. For details check the logfiles at:

 /u01/app/oracle/cfgtoollogs/dbca/ora11.

Database Information:

Global Database Name:ora11

System Identifier(SID):ora11

 

 建库后实例检查:

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

oracle   11279     1  0 12:04 ?        00:00:00 ora_pmon_ora11

oracle   11281     1  1 12:04 ?        00:00:02 ora_vktm_ora11

oracle   11285     1  0 12:04 ?        00:00:00 ora_gen0_ora11

oracle   11287     1  0 12:04 ?        00:00:00 ora_diag_ora11

oracle   11289     1  0 12:04 ?        00:00:00 ora_dbrm_ora11

oracle   11291     1  0 12:04 ?        00:00:00 ora_psp0_ora11

oracle   11293     1  0 12:04 ?        00:00:00 ora_dia0_ora11

oracle   11295     1  0 12:04 ?        00:00:00 ora_mman_ora11

oracle   11297     1  0 12:04 ?        00:00:00 ora_dbw0_ora11

oracle   11299     1  0 12:04 ?        00:00:00 ora_lgwr_ora11

oracle   11301     1  0 12:04 ?        00:00:01 ora_ckpt_ora11

oracle   11303     1  0 12:04 ?        00:00:00 ora_smon_ora11

oracle   11305     1  0 12:04 ?        00:00:00 ora_reco_ora11

oracle   11307     1  1 12:04 ?        00:00:02 ora_mmon_ora11

oracle   11309     1  0 12:04 ?        00:00:01 ora_mmnl_ora11

oracle   11311     1  0 12:04 ?        00:00:00 ora_d000_ora11

oracle   11313     1  0 12:04 ?        00:00:00 ora_s000_ora11

oracle   11323     1  0 12:04 ?        00:00:01 ora_qmnc_ora11

oracle   11340     1  0 12:04 ?        00:00:01 ora_cjq0_ora11

oracle   11342     1  0 12:04 ?        00:00:01 ora_q000_ora11

oracle   11344     1  0 12:04 ?        00:00:00 ora_q001_ora11

 

 查看监听状态

 $ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-AUG-2014 12:07:54

 

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date                26-AUG-2014 11:11:10

Uptime                    0 days 0 hr. 56 min. 44 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/ora11g/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=1521)))

Services Summary...

Service "ora11" has 1 instance(s).

  Instance "ora11", status READY, has 1 handler(s) for this service...

Service "ora11XDB" has 1 instance(s).

  Instance "ora11", status READY, has 1 handler(s) for this service...

The command completed successfully

 

12 修改数据库为归档模式(归档模式才能热备份,增量备份)

$ sqlplus / as sysdba

 SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 26 13:37:34 2014

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

 Connected to:

 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

 With the Partitioning, OLAP, Data Mining and Real Application Testing options

 SQL> shutdown immediate;

 Database closed.

 Database dismounted.

 ORACLE instance shut down.

 SQL> startup mount

 ORACLE instance started.

Total System Global Area 1603411968 bytes

Fixed Size                  2213776 bytes

Variable Size             402655344 bytes

Database Buffers         1191182336 bytes

Redo Buffers                7360512 bytes

 Database mounted.

 SQL> alter database archivelog;

 Database altered.

 SQL> alter database flashback on;

 Database altered.

 SQL> alter database open;

 Database altered.

 SQL> execute utl_recomp.recomp_serial();

 PL/SQL procedure successfully completed.

 SQL> alter system archive log current;

 System altered.

 SQL> exit

 

13 修改oracle启动配置文件

 $vi /etc/oratab

 ora11:/u01/app/oracle/product/11.2.0:Y

 这样就可以通过dbstart 启动此实例,也可以通过dbshut关闭此实例了。

 $ dbshut /u01/app/oracle/product/11.2.0

 Processing Database instance "ora11": log file /u01/app/oracle/product/11.2.0/shutdown.log

 此时所有oracle的进程关闭,监听器也停止。

 $dbstart /u01/app/oracle/product/11.2.0

 Processing Database instance "ora11": log file /u01/app/oracle/product/11.2.0/startup.log

 此时监听器工作,hello实例运行,再次查看监听器状态。

 $ lsnrctl status

 

开机启动方法:

方法1:

要想让oracle服务随着系统启动而自动启动,需要在/etc/rc.local文件中增加如下:

su - oracle -c "/u01/app/oracle/product/11.2.0/bin/dbstart /u01/app/oracle/product/11.2.0"

 

方法2:建立启动脚本

# vi /etc/rc.d/init.d/oracle

 

#!/bin/bash

 

# oracle: Start/Stop Oracle Database 11g R2

#

# chkconfig: 345 90 10

# description: The Oracle Database is an Object-Relational Database Management System.

#

# processname: oracle

. /etc/rc.d/init.d/functions

LOCKFILE=/var/lock/subsys/oracle

ORACLE_HOME=/u01/app/oracle/product/11.2

ORACLE_USER=oracle

case "$1" in

'start')

   if [ -f $LOCKFILE ]; then

      echo $0 already running.

      exit 1

   fi

   echo -n $"Starting Oracle Database:"

   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"

   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"

   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"

   touch $LOCKFILE

   ;;

'stop')

   if [ ! -f $LOCKFILE ]; then

      echo $0 already stopping.

      exit 1

   fi

   echo -n $"Stopping Oracle Database:"

   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"

   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"

   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"

   rm -f $LOCKFILE

   ;;

'restart')

   $0 stop

   $0 start

   ;;

'status')

   if [ -f $LOCKFILE ]; then

      echo $0 started.

      else

      echo $0 stopped.

   fi

   ;;

*)

   echo "Usage: $0 [start|stop|status]"

   exit 1

esac

exit 0

 

#service oracle on

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值