CentOS 6.7 静默安装Oracle 11g R2 详细操作总结

CentOS 6.7 
  静默Oracle 11g R2 
  操作总结 
  

一、环境准备

1.1、下载所需软件

1.1.1CentOS 6x86_64
    http://mirrors.163.com/centos/
1.1.2Oracle 11g R2Linux x86-64
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

1.2、光盘挂载,补全依赖包使用

1.2.1将系统盘设为yum先将CentOS 6.7安装镜像挂载至/mnt/cdrom

# mkdir -p /mnt/cdrom

# mount -o loop /opt/software/CentOS-6.7-x86_64-bin-DVD1.iso /mnt/cdrom

1.2.2local repo

# cd /etc/yum.repos.d/

# mkdir bak;mv Cent* ./bak

# vim CentOS-Media.repo

[base]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release

1.2.3清除cache并重建

# yum clean all

# yum makecache       

 

二、机器基础配置修改

2.1、机器名修改

vim /etc/sysconfig/network

2.2系统检查

2.2.1内存推荐2GB以上

# grep MemTotal /proc/meminfo
    # free -g

2.2.2/tmp 目录大于1G

# df -h /tmp
    # du -sm /tmp

2.2.3磁盘空间应该都没问题,需安装目录20G以上

# df -h

2.2.4、系统架构

# cat /proc/version
# uname -a
# uname -r
# lsb_release -a

2.2.5设置系统

2.2.5.1操作系统系统只支持Red Hat Enterprise Linux 6CentOS 6其实就是RHEL6,但Oracle不认,所以要改一下

# vim /etc/redhat-release

#CentOS release 6.3 (Final) 这行注释掉,加上下面的
Red Hat Enterprise Linux 6

2.2.5.2、系统核心

# uname -r 检查一下

2.6.32-573.18.1.el6.x86_64

2.2.5.3机器基础信息关闭,selinux,防火墙,不必要服务

# vim /etc/sysconfig/selinux

SELINUX=enforcing改成SELINUX=disabled

# service iptables stop

# chkconfig iptables off

# vim /etc/hosts

添加一行内容:IP 机器名

2.2.5.4修改用户的限制文件

# 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

2.2.5.5修改内核参数

# vi /etc/sysctl.conf   //末尾添加如下,如该参数已设置过,则不需添加该项 

net.ipv4.ip_local_port_range= 9000 65500 
fs.file-max = 6815744 
kernel.shmall = 10523004 
kernel.shmmax = 6465333657 
kernel.shmmni = 4096 
kernel.sem = 250 32000 100128 
net.core.rmem_default=262144 
net.core.wmem_default=262144 
net.core.rmem_max=4194304 
net.core.wmem_max=1048576 
fs.aio-max-nr = 1048576

 

# sysctl -p  //使配置生效

2.2.6依赖检查安装,总结执行依赖如下,如果出现某个包安装失败,则需要手动下载相关的rpm包,然后执行安装即可。

yum -y install \
binutils \
compat-libcap1 \
  compat-libstdc++-33 \
compat-libstdc++-33*.i686 \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc*.i686 \
glibc \
glibc-devel \
glibc-devel*.i686 \
ksh \
libgcc*.i686 \
libgcc \
libstdc++ \
libstdc++*.i686 \
libstdc++-devel \
libstdc++-devel*.i686 \
libaio \
libaio*.i686 \
libaio-devel \
libaio-devel*.i686 \
make \
sysstat \
unixODBC \
unixODBC*.i686 \
unixODBC-devel \
unixODBC-devel*.i686 \
libXp

 

附:rpm包检查包、安装包、卸载包命令

# rpm -qa|grep xxx

# rpm -ivh xxx.rpm

# rpm -e --nodeps xxx.rpm

 

2.2.7建立用户,组,安装目录

2.2.7.1、执行命令

# groupadd oinstall
# groupadd dba
# groupadd oper
# useradd -g oinstall -G dba,oper oracle
echo "oracle" | passwd --stdin oracle

2.2.7.2查看一下
# id oracle
uid=501(oracle) gid=501(oinstall) =501(oinstall),502(dba),503(oper)

2.2.7.3、新建安装目录

# mkdir -p /var/app
# mkdir -p /var/app/oracle
# mkdir -p /var/app/oracle/product 
# mkdir -p /var/app/oracle/product/11.2.0                
# mkdir -p /var/app/oracle/product/11.2.0/dbhome_1
# mkdir -p /home/oracle/backup        //数据备份目录                               

# mkdir -p /home/oracle/oraInventory     //清单目录                                

# chown -R oracle:oinstall /var/app
# chown -R oracle:oinstall /home/oracle/backup 
# chown -R oracle:oinstall /home/oracle/oraInventory

# chmod -R 775 /var/app

2.2.8设置并刷新环境变量

# vim /home/oracle/.bash_profile

umask 022

export ORACLE_BASE=/var/app

exportORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1

export ORACLE_SID=ora11g

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

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

 

# source /home/oracle/.bash_profile    //环境变量生效

 

三、安装Oracle

3.1、拷贝oracle安装文件到指定目录

# cp /opt/software/linux.x64_11gR2_database_1of2.zip /var/app/oracle

# cp /opt/software/linux.x64_11gR2_database_2of2.zip /var/app/oracle

3.2、解压安装包,注意切换用户

# su - oracle

$ cd /var/app/oracle
$ unzip linux.x64_11gR2_database_1of2.zip
$ unzip linux.x64_11gR2_database_2of2.zip

解压后得到database目录,其中包含response目录,该目录中有三个rsp文件,用来作为静默安装时的应答文件的模板。三个文件作用分别是:
db_install.rsp:安装应答
dbca.rsp:创建数据库应答
netca.rsp:建立监听、本地服务名等网络设置的应答

3.3、修改配置文件,安装oracle软件

3.3.1复制一份模板,添加备份

$ cp -R /var/app/oracle/database/response /home/oracle         

3.3.2、修改后的静默安装配置文件db_install.rsp,(如果oracle用户没有操作文件的权限,可使用root用户修改该文件,保存退出即可),修改相关的配置项,修改后的文件内容如下。

$ less /opt/database/response/db_install.rsp |grep -v "#"|grep -v "^$"
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=bigdata06
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/var/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/var/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/var/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=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=ora11g
oracle.install.db.config.starterdb.SID=ora11g
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1500
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true    //一定要设为 true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=

3.3.3开始静默安装

$ cd /var/app/oracle/database

$./runInstaller -silent -responseFile  /var/app/oracle/database/response/db_install.rsp

 CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第1张图片

 

3.3.4、查看安装进度

$ cd /var/app/oracle/oraInventory/logs

$ tail -f installActions*log

 

3.3.5当安装界面出现如下信息的时候
The installation of Oracle Database 11g was successful.
.....................

....................

As a root user, execute the following script(s):
 1. /var/app/oracle/oraInventory/orainstRoot.sh
 2. /var/app/oracle/product/11.2.0/dbhome_1/root.sh


Successfully Setup Software.

 

3.3.6在新打开的客户端使用root登录的窗口中执行下面的脚本
#/var/app/oracle/oraInventory/orainstRoot.sh
#/var/app/oracle/product/11.2.0/dbhome_1/root.sh


3.3.7执行完上面的脚本后回到安装界面按下Enter键以继续

 

3.4配置oracle监听

3.4.1、运行监听文件

$cd /var/app/oracle/database/response

$netca /silent /responsefile /var/app/oracle/database/response/netca.rsp

 CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第2张图片

成功运行后,在/var/app/oracle/product/11.2.0/dbhome_1/network/admin目录下生成sqlnet.oralistener.ora两个文件。

 CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第3张图片

通过 netstat -tlnp | grep 1521 命令,看到监听器已经在1521端口上开始工作了

 

3.4.2、如果监听没有启动,则手动启动监听程序。

/var/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER

3.5、配置oracle数据库

3.5.1、修改建库配置文件

$ vim /var/app/oracle/database/response/dbca.rsp

GDBNAME = "ora11g.dg01"     //78 行 全局数据库的名字=SID+主机域名
SID="ora11g"    //149SID

SYSPASSWORD = "oracle"    //190

SYSTEMPASSWORD = "oracle"   //200
CHARACTERSET="AL32UTF8" //415行 编码
NATIONALCHARACTERSET="UTF8" //425行 编码

3.5.2、创建dbca数据库



 $ORACLE_HOME/bin/dbca -silent -responseFile  /var/app/oracle/database/response/dbca.rsp 


Enter SYS user password: 
  
Enter SYSTEM user password: 
 
sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
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
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete
100% complete

CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第4张图片

四、启动数据库

4.1、进入oracle SQL命令行

$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri May 12 15:37:09 2017

 

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

 

Connected to an idle instance.

 CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第5张图片

 

SQL> start
SP2-1506: START, @ or @@ command has no arguments

 

SQL> select * from tab;

4.2、需注意ORACLE_SID的问题,确认静默dbca建库时配置(SID="ora11g" //149SID)与环境变量export ORACLE_SID=ora11g配置相同,否则出现错误。

错误提示:

ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/var/app/oracle/product/11.2.0/dbhome_1/dbs/initxtwl.ora'

 

五、参数修改

5.1、修改最大连接数:
sql> show parameter processes;
sql> alter system set processes=2000 scope = spfile;

5.2、禁止回收站功能:
SQL> show parameter recyclebin;
SQL> alter system set recyclebin=off scope=spfile;

CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第6张图片
5.3、关闭审计功能:
SQL> show parameter audit;
SQL> alter system set audit_trail=NONE scope=spfile;

 CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第7张图片

5.4、修改用户密码用不过期:
SQL> select * from dba_profiles s where s.profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';

CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第8张图片

SQL> alter profile default limit password_life_time unlimited;
Profile altered.
SQL> select * from dba_profiles s where s.profile='DEFAULT' and resource_name='FAILED_LOGIN_ATTEMPTS';

CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第9张图片


SQL> alter profile default limit failed_login_attempts unlimited;
Profile altered.


5.5、修改控制文件里可重复使用的记录所能保存的最小天数:(一般设置为45天)
SQL> show parameter control;

 CentOS 6.7 静默安装Oracle 11g R2 详细操作总结_第10张图片


SQL> alter system set control_file_record_keep_time=45 scope=spfile;

System altered.

 

你可能感兴趣的:(部署)