0%

Oracle数据库静默安装

系统配置

内存要求

查看系统内存

1
$ grep Memtotal /proc/meminfo

查看Swap

1
$ grep SwapTotal /proc/meminfo

内存要求不低于1G,且swap需根据memory设置

Memory Swap
1G~2G RAM的1.5倍
2G~16G RAM
>16G 16G

磁盘要求

/tmp目录不少于1G
/u01目录不少于100G

配置yum源

挂载镜像

1
$ mount /dev/cdrom /mnt -o loop

编辑yum源文件

1
2
3
4
5
6
$ vi /etc/yum.repos.d/source
[redhat]
name =Linux 6.3 DVD
baseurl=file:///mnt/
gpgcheck=0
enabled=1

安装依赖包

1
$ yum install -y binutils-* compat-libcap1-* compat-libstdc++* compat-libstdc++* gcc-* gcc-c++* glibc-* glibc-devel-* ksh libaio-* libaio-devel-* libgcc-* libstdc++* libstdc++-devel-* libXi-* libXtst-* make-* unixODBC-* unixODBC-devel-*

关闭selinux

1
2
3
$ setenforce 0
$ vi /etc/sysconfig/selinux
SELINUX=disabled

关闭iptables

1
2
$ service iptables stop
$ chkconfig --level 2345 iptables off

系统内核配置

参数
kernel.sem 250 32000 100 128
kernel.shmall shmmax/getconf PAGESIZE
kernel.shmmax 超过一半的物理内存(90%)
kernel.shmmni 4096
fs.file-max 6815744
fs.aio-max-nr 1048576
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

关闭Transparent HugePages

1
2
3
4
$ echo never >  /sys/kernel/mm/transparent_hugepage/enabled
$ echo never > /sys/kernel/mm/transparent_hugepage/defrag
$ echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.local
$ echo "echo never > /sys/kernel/mm/transparent_hugepage/defrag" >> /etc/rc.local

创建用户和组

1
2
3
4
5
6
7
8
$ /usr/sbin/groupadd -g 501 oinstall
$ /usr/sbin/groupadd -g 502 dba
$ /usr/sbin/groupadd -g 503 oper
$ /usr/sbin/groupadd -g 504 asmadmin
$ /usr/sbin/groupadd -g 505 asmdba
$ /usr/sbin/groupadd -g 506 asmoper
$ /usr/sbin/useradd -u 502 -g oinstall -G dba,asmdba,oper oracle
$ /usr/sbin/useradd -u 503 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid

配置limit

1
2
3
4
5
6
7
8
9
10
11
12
grid        soft   nproc   2047 
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768

创建目录

1
2
3
4
5
6
7
8
$ mkdir -p  /u01/app/11.2.0/grid
$ mkdir -p /u01/app/grid
$ mkdir -p /u01/app/oracle
$ chown grid:oinstall /u01/app/11.2.0/grid
$ chown grid:oinstall /u01/app/grid
$ chown oracle:oinstall /u01/app/oracle
$ chmod -R 775 /u01/
$ chown -R grid:oinstall /u01

配置用户环境变量

Oracle((/home/oracle/.bash_profile))

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export TMP=/tmp; 
export TMPDIR=$TMP;
export ORACLE_HOSTNAME=source;
export ORACLE_BASE=/u01/app/oracle;
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1;
export ORACLE_UNQNAME=source;
export ORACLE_SID=source;
export ORACLE_TERM=xterm;
export PATH=/usr/sbin:$PATH;
export PATH=$ORACLE_HOME/bin:$PATH;
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export TNS_ADMIN=$ORACLE_HOME/network/admin
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS";
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;
umask 022;

Grid(/home/grid/.bash_profile)

1
2
3
4
5
6
7
8
9
10
export TMP=/tmp; 
export TMPDIR=$TMP;
export ORACLE_HOSTNAME=source;
export ORACLE_SID=+ASM1;
export ORACLE_BASE=/u01/app/grid;
export ORACLE_HOME=/u01/app/11.2.0/grid;
export NLS_DATE_FORMAT="yy-mm-dd HH24:MI:SS";
export PATH=$ORACLE_HOME/bin:$PATH;
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;
umask 022;

使环境变量生效

1
2
$ source /home/oracle/.bash_profile
$ source /home/grid/.bash_profile

绑定ASM磁盘

获取磁盘设备ID

1
$ scsi_id -g -u /dev/sdc

编辑绑定规则

1
2
$ cat /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c2925e6b664b62fdd12b6eeaf353", NAME="asmgrid-ocr", OWNER="grid", GROUP="asmadmin", MODE="0660"

重新加载规则文件

1
$ /sbin/udevadm control --reload-rules

启动UDEV

1
start_udev

Grid安装

编辑响应文件(/解压目录/response/grid_install.rsp)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v11_2_0
##系统主机名
ORACLE_HOSTNAME=t-luhxdb01
##清单目录
INVENTORY_LOCATION=/u01/app/oraInventory
##选择语言
SELECTED_LANGUAGES=en,zh_CN
##安装类型
oracle.install.option=HA_CONFIG
##ORACLE_BASE
ORACLE_BASE=/u01/app/grid
##ORACLE_HOME
ORACLE_HOME=/u01/app/11.2.0/grid
##指定OSDBA
oracle.install.asm.OSDBA=asmdba
##指定OSOPER
oracle.install.asm.OSOPER=asmoper
##指定ASMADMIN
oracle.install.asm.OSASM=asmadmin
##配置存储方式
oracle.install.crs.config.storageOption=ASM_STORAGE
##配置ASM相关用户密码
oracle.install.asm.SYSASMPassword=luhengxing
##指定ASM磁盘组名称
oracle.install.asm.diskGroup.name=DATA
##指定ASM冗余方式
oracle.install.asm.diskGroup.redundancy=EXTERNAL
##指定ASM AUSize
oracle.install.asm.diskGroup.AUSize=1
##指定ASM磁盘
oracle.install.asm.diskGroup.disks=/dev/asmgrid-data
##指定ASM相关用户密码
oracle.install.asm.monitorPassword=luhengxing
oracle.install.asm.SYSASMPassword=oracle
##关闭更新
oracle.install.asm.upgradeASM=false
oracle.installer.autoupdates.option=SKIP_UPDATES

执行安装

1
$ ./runInstaller -silent -ignorePrereq -showProgress -responseFile /u01/soft/grid/response/grid_install.rsp

以root执行提示需要执行的脚本

1
2
$ /u01/app/oraInventory/orainstRoot.sh
$ /u01/app/11.2.0/grid/root.sh

检查CRS

1
2
3
4
5
6
[grid@adg grid]$ crsctl check has
CRS-4638: Oracle High Availability Services is online
[grid@adg grid]$ crsctl check css
CRS-4529: Cluster Synchronization Services is online
[grid@adg grid]$ crsctl check evm
CRS-4533: Event Manager is online

创建密码文件

1
$ orapwd file=$ORACLE_HOME/dbs/orapw+ASM password=luhengxing entries=10 ignorecase=y

加载配置

1
$ /u01/app/11.2.0/grid/cfgtoollogs/configToolAllCommands RESPONSE_FILE=/u01/soft/grid/response/grid_install.rsp

编辑ASM参数文件

1
2
3
4
5
6
INSTANCE_TYPE=ASM
DB_UNIQUE_NAME=+ASM
ASM_POWER_LIMIT=1
ASM_DISKSTRING=/dev/asmgrid-*
ASM_DISKGROUPS=data1
LARGE_POOL_SIZE=16M

启动ASM实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[grid@adg dbs]$ sqlplus / as sysasm
  
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 13 04:00:32 2018
  
Copyright (c) 1982, 2013, Oracle. All rights reserved.
  
Connected to an idle instance.
  
SQL> startup nomount pfile='/u01/app/11.2.0/grid/dbs/init+ASM.ora'
ASM instance started
  
Total System Global Area 1135747072 bytes
Fixed Size 2260728 bytes
Variable Size 1108320520 bytes
ASM Cache 25165824 bytes

创建ASM Group

1
sql> create diskgroup data  external redundancy disk '/dev/asmgrid-data';

注册ASM服务

1
$ srvctl add asm

重启ASM服务

1
2
3
4
5
6
7
8
9
10
11
12
13
SQL> create spfile from pfile;
  
File created.
  
SQL> startup
ASM instance started
  
Total System Global Area 1135747072 bytes
Fixed Size 2260728 bytes
Variable Size 1108320520 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
ASM diskgroups volume enabled

DB安装

编辑响应文件(/解压路径/response/db_install.rsp)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
##安装类型
oracle.install.option=INSTALL_DB_SWONLY
##主机名称
ORACLE_HOSTNAME=adg
##用户组
UNIX_GROUP_NAME=oinstall
##清单目录
INVENTORY_LOCATION=/u01/app/oraInventory
##选择语言
SELECTED_LANGUAGES=en,zh_CN
##ORACLE_HOME
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
##ORACLE_BASE
ORACLE_BASE=/u01/app/oracle
##安装企业版
oracle.install.db.InstallEdition=EE
##不用安全更新
DECLINE_SECURITY_UPDATES=true
##DBA用户组
oracle.install.db.DBA_GROUP=dba
##oper用户组
oracle.install.db.OPER_GROUP=oper
##跳过更新
oracle.installer.autoupdates.option

执行安装

1
$ ./runInstaller -silent -force -ignorePrereq -noconfig -responseFile /u01/soft/database/response/db_install.rsp

以root执行提示的脚本

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

监听安装

编辑响应文件(/解压目录/response/netca.rsp)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[GENERAL]
RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
  
[oracle.net.ca]
INSTALLED_COMPONENTS="server","net8","javavm"
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES="LISTENER"
LISTENER_PROTOCOLS="TCP;1521"
LISTENER_START=""LISTENER""
NAMING_METHODS="TNSNAMES","ONAMES","HOSTNAME"
NSN_NUMBER=1
NSN_NAMES="EXTPROC_CONNECTION_DATA"
NSN_SERVICE="PLSExtProc"
NSN_PROTOCOLS="TCP;HOSTNAME;1521"

执行安装

1
$ $ORACLE_HOME/bin/netca /silent /responsefile /app/database/response/netca.rsp

DBCA建库

编辑响应文件(/解压目录/response/dbca.rsp)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
  
[CREATEDATABASE]
GDBNAME = "adg"
SID = "adg"
TEMPLATENAME = "General_Purpose.dbc"
CHARACTERSET="ZHS16GBK"
MEMORYPERCENTAGE = "60"
EMCONFIGURATION = "NONE"
SYSPASSWORD = "luhengxing"
SYSTEMPASSWORD = "luhengxing"
SYSMANPASSWORD = "luhengxing"
DBSNMPPASSWORD = "luhengxing"
STORAGETYPE=FS
ASMSNMP_PASSWORD="luhengxing"

执行安装

1
$ $ORACLE_HOME/bin/dbca -silent -responsefile /app/database/response/dbca.rsp

参考链接

  1. Oracle Database Installation Guide for Linux
  2. 文档ID 169706.1