Centos7安装oracle11gr2

Centos7最小化安装后,安装Oracle11g r2过程记录。

更新yum源

把centos的yum源修改为163源

1
2
3
4
5
6
下载yum源文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
清理缓存
yum clean all
重建缓存
yum makecache

关闭selinux

关闭selinux,修改selinux的配置文件,通过sed流编辑器,把SELINUX=enforcing替换为SELINUX=disabled

1
2
3
4
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config

关闭selinux
setenforce 0

关闭防火墙

由于在centos7后,默认使用的是firewall,所以把firewalld禁用就可以了

1
2
systemctl stop firewalld.service
systemctl disable firewalld.service

时间同步ntp

用于同步服务器时间

1
2
3
4
yum install ntp
然后在crontab中增加定时时间同步,1小时同步一次。
crontab -e
00 */1 * * * /usr/sbin/ntpdate time.nuri.net

安装开发环境

一般在linux下搭建开发环境的基础是c/c++,为了一次性使用yum安装好该环境,最好使用的命令是

1
2
yum groupinstall 'Development Tools'

安装网络工具

为了使用netstat、arp等工具调试网络问题,所以需要安装net-tools包。

1
yum install net-tools

修改主机名

修改服务器的名称,使用hostnamectl命令修改

1
hostnamectl set-hostname dbserver

hostnamectl只会同步修改/etc/hostname, 不会更新/etc/hosts,所以需要手动更改/etc/hosts文件。

1
2
3
4
cd /etc/
vi hosts
127.0.0.1 dbserver
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

修改完后,reboot重启机器。

检查需要的包

1
2
3
rpm -qa binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers 
glibc-static kernel-headers pdksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel libstdc++-static make numactl-devel
sysstat unixODBC unixODBC-devel

发现没有的包通过yum install 包名安装好即可。

这里需要注意的是pdksh这个包,在centos5以后yum源里面就没有这个了。
所以需要下载rpm包或者源码编译。
我这里准备的是pdksh-5.2.14-30.x86_64.rpm包,安装如下:

1
2
3
4
rpm -ivh pdksh-5.2.14-30.x86_64.rpm 
警告:pdksh-5.2.14-30.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 73307de6: NOKEY
准备中... ################################# [100%]
试图安装 pdksh-5.2.14-30.x86_64 和 pdksh-5.2.14-30.x86_64 会导致文件 /usr/bin/ksh 冲突

通过–force强制安装选项来安装

1
2
3
4
5
rpm -ivh --force pdksh-5.2.14-30.x86_64.rpm 
警告:pdksh-5.2.14-30.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 73307de6: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:pdksh-5.2.14-30 ################################# [100%]

创建用户

创建用户组

1
2
groupadd dba
groupadd oinstall

创建用户oracle

1
2
3
4
添加oracle用户
useradd -m -g oinstall -G dba oracle
修改密码
passwd oracle

配置内核参数

配置内核参数。

修改/etc/sysctl.conf文件,配置内核参数。
修改配置完成后,通过syscrl -p使其生效。

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
kernel.shmall = 2097152    //表示系统一次可以使用的共享内存总量(以页为单位)。缺省值就是2097152,通常不需要修改
kernel.shmmax = 4294967296 //定义了共享内存段的最大尺寸(以字节为单位)。缺省为32M,
对于oracle来说,该缺省值太低了,通常将其设置为4G=4294967296/1024/1024/1024

kernel.shmmni = 4096 //用于设置系统范围内共享内存段的最大数量。该参数的默认值是 4096 。通常不需要更改
kernel.sem = 250 32000 100 128 //表示设置的信号量
fs.file-max = 65536 //表示文件句柄的最大数量。文件句柄表示在Linux系统中可以打开的文件数量。其实是由"fs.file-max = 512 * PROCESSES"得到的,我们指定PROCESSES的值为128,即为"fs.file-max =512 *128"。
fs.aio-max-nr = 1048576 //同时可以拥有的的异步IO请求数目。
net.ipv4.ip_local_port_range = 1024 65000 //应用程序可使用的Ipv4端口范围。

net.core.rmem_default = 262144 //默认的接收窗口大小
net.core.rmem_max = 4194304 //接收窗口的最大大小
net.core.wmem_default = 262144 //默认的发送窗口大小
net.core.wmem_max = 1048586 //发送窗口的最大大小

fs.aio-max-nr = 1048576
fs.file-max = 6815744

kernel.shmall = 2097152
kernel.shmmax = 536870912
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 = 1048586

修改资源参数

修改/etc/secrity/limits.conf文件,增加如下内容:

1
2
3
4
5
6
7
oracle   soft    nproc    2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

* soft nofile 8192
* hard nofile 8192

创建安装目录

1
2
mkdir /home/app
mkdir /home/oradata

设置目录权限

1
2
3
4
chown oracle:oinstall /home/app
chown oracle:oinstall /home/oradata
chmod 755 /home/app
chmod 755 /home/oradata

配置环境变量

修改全局环境变量

修改oracle登录后的环境变量,vi /etc/profile增加如下内容:

1
2
3
4
5
6
7
8
if [ $USER = "oracle" ]; then 
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

重新加载属性文件,使其改动内容生效。

1
source /etc/profile

修改oracle环境变量

使用oracle用户登录系统,设置环境变量
vi .bash_profile添加以下内容:

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
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

umask 022

TMP=/tmp
TMPDIR=/tmp
export TMP TMPDIR


# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH


export ORACLE_BASE=/home/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0.4/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap rman"

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

关联设置

编辑文件:vi /etc/pam.d/login 加入以下语句:
session required /lib/security/pam_limits.so
session required pam_limits.so

准备oracle11gr2的安装文件

解压安装文件

1
tar jxvf database.tar.bz2

oracle响应文件

制作oracle静默安装的响应文件db.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
####################################################################
## Copyright(c) Oracle Corporation 1998,2008. All rights reserved.##
## ##
## Specify values for the variables listed below to customize ##
## your installation. ##
## ##
## Each variable is associated with a comment. The comment ##
## can help to populate the variables with the appropriate ##
## values. ##
## ##
## IMPORTANT NOTE: This file contains plain text passwords and ##
## should be secured to have read permission only by oracle user ##
## or db administrator who owns this installation. ##
## ##
####################################################################

#标注响应文件版本,这个版本必须和要#安装的数据库版本相同,安装检验无法通过,不能更改
#------------------------------------------------------------------------------
# Do not change the following system generated value.
#------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0

#选择安装类型
#------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# 1. INSTALL_DB_SWONLY 只装数据库软件
# 2. INSTALL_DB_AND_CONFIG 安装数据库软件并建库
# 3. UPGRADE_DB 升级数据库
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY

#指定操作系统主机名,通过hostname命令获得
#-------------------------------------------------------------------------------
# Specify the hostname of the system as set during the install. It can be used
# to force the installation to use an alternative hostname rather than using the
# first hostname found on the system. (e.g., for systems with multiple hostnames
# and network interfaces)
#-------------------------------------------------------------------------------
ORACLE_HOSTNAME=dbserver

#指定oracle inventory目录的所有者,通常会是oinstall或者dba
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=oinstall

#指定产品清单oracle inventory目录的路径,如果是Win平台下可以省略
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/home/app/oraInventory

#指定数据库语言,可以选择多个,使用逗号分开
#-------------------------------------------------------------------------------
# Specify the languages in which the components will be installed.
#
# en : English ja : Japanese
# fr : French ko : Korean
# ar : Arabic es : Latin American Spanish
# bn : Bengali lv : Latvian
# pt_BR: Brazilian Portuguese lt : Lithuanian
# bg : Bulgarian ms : Malay
# fr_CA: Canadian French es_MX: Mexican Spanish
# ca : Catalan no : Norwegian
# hr : Croatian pl : Polish
# cs : Czech pt : Portuguese
# da : Danish ro : Romanian
# nl : Dutch ru : Russian
# ar_EG: Egyptian zh_CN: Simplified Chinese
# en_GB: English (Great Britain) sk : Slovak
# et : Estonian sl : Slovenian
# fi : Finnish es_ES: Spanish
# de : German sv : Swedish
# el : Greek th : Thai
# iw : Hebrew zh_TW: Traditional Chinese
# hu : Hungarian tr : Turkish
# is : Icelandic uk : Ukrainian
# in : Indonesian vi : Vietnamese
# it : Italian
#
# Example : SELECTED_LANGUAGES=en,fr,ja
#------------------------------------------------------------------------------
SELECTED_LANGUAGES=en,zh_CN

#设置oracle的安装目录
#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#------------------------------------------------------------------------------
ORACLE_HOME=/home/app/oracle/product/11.2.0.4/db_1

#设置oracle base目录
#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base.
#------------------------------------------------------------------------------
ORACLE_BASE=/home/app

#设定数据库的安装版本
#------------------------------------------------------------------------------
# Specify the installation edition of the component.
#
# The value should contain only one of these choices.
# EE : Enterprise Edition 企业版
# SE : Standard Edition 标准版
# SEONE : Standard Edition One 标准版1
# PE : Personal Edition (WINDOWS ONLY) 个人版
#------------------------------------------------------------------------------
oracle.install.db.InstallEdition=EE

#是否自定义oracle的组件,如果选择false则会使用默认的组件
#如果选择true,则需要在下面罗列出需要安装的组件,再不是很清楚需要的时候,
#建议使用true,然后把所有的都安装上。
#------------------------------------------------------------------------------
# This variable is used to enable or disable custom install.
#
# true : Components mentioned as part of 'customComponents' property
# are considered for install.
# false : Value for 'customComponents' is not considered.
#------------------------------------------------------------------------------
oracle.install.db.isCustomInstall=false

#oracle的可选安装组件
#------------------------------------------------------------------------------
# This variable is considered only if 'IsCustomInstall' is set to true.
#
# Description: List of Enterprise Edition Options you would like to install.
#
# The following choices are available. You may specify any
# combination of these choices. The components you choose should
# be specified in the form "internal-component-name:version"
# Below is a list of components you may specify to install.
#
# oracle.oraolap:11.2.0.4.0 - Oracle OLAP
# oracle.rdbms.dm:11.2.0.4.0 - Oracle Data Mining RDBMS Files
# oracle.rdbms.dv:11.2.0.4.0- Oracle Database Vault option
# oracle.rdbms.lbac:11.2.0.4.0 - Oracle Label Security
# oracle.rdbms.partitioning:11.2.0.4.0 - Oracle Partitioning
# oracle.rdbms.rat:11.2.0.4.0 - Oracle Real Application Testing
#------------------------------------------------------------------------------
oracle.install.db.customComponents=

###############################################################################
# #
# PRIVILEGED OPERATING SYSTEM GROUPS #
# ------------------------------------------ #
# Provide values for the OS groups to which OSDBA and OSOPER privileges #
# needs to be granted. If the install is being performed as a member of the #
# group "dba", then that will be used unless specified otherwise below. #
# #
###############################################################################

#指定oracle dba组
#------------------------------------------------------------------------------
# The DBA_GROUP is the OS group which is to be granted OSDBA privileges.
#------------------------------------------------------------------------------
oracle.install.db.DBA_GROUP=dba

#指定oracle oper组
#------------------------------------------------------------------------------
# The OPER_GROUP is the OS group which is to be granted OSOPER privileges.
#------------------------------------------------------------------------------
oracle.install.db.OPER_GROUP=oinstall

#如果是RAC的安装,在这里指定所有的节点
#------------------------------------------------------------------------------
# Specify the cluster node names selected during the installation.
#------------------------------------------------------------------------------
oracle.install.db.CLUSTER_NODES=

#指定是否rac安装
#------------------------------------------------------------------------------
# This variable is used to enable or disable RAC One Node install.
#
# - true : Value of RAC One Node service name is used.
# - false : Value of RAC One Node service name is not used.
#
# If left blank, it will be assumed to be false.
#------------------------------------------------------------------------------
oracle.install.db.isRACOneInstall=false

#指定Rac一个节点服务名称
#------------------------------------------------------------------------------
# Specify the name for RAC One Node Service.
#------------------------------------------------------------------------------
oracle.install.db.racOneServiceName=

#指定数据库类型
#-------------------------------------------------------------------------------
# Specify the type of database to create.
# It can be one of the following:
# - GENERAL_PURPOSE/TRANSACTION_PROCESSING 通用数据库
# - DATA_WAREHOUSE 数据仓库
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE

#数据库全局名称
#-------------------------------------------------------------------------------
# Specify the Starter Database Global Database Name.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.globalDBName=orcl

#数据库实例名称
#-------------------------------------------------------------------------------
# Specify the Starter Database SID.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.SID=orcl

#字符集,ZHS16GBK汉字2个字节建议使用
#-------------------------------------------------------------------------------
# Specify the Starter Database character set.
#
# One of the following
# AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2,
# EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257,
# BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6,
# AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8,
# IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE,
# KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950,
# ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.characterSet=ZHS16GBK

#内存自动管理
#------------------------------------------------------------------------------
# This variable should be set to true if Automatic Memory Management
# in Database is desired.
# If Automatic Memory Management is not desired, and memory allocation
# is to be done manually, then set it to false.
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.memoryOption=true

#数据库内存最大值
#-------------------------------------------------------------------------------
# Specify the total memory allocation for the database. Value(in MB) should be
# at least 256 MB, and should not exceed the total physical memory available
# on the system.
# Example: oracle.install.db.config.starterdb.memoryLimit=512
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.memoryLimit=6357

#是否安装样例
#-------------------------------------------------------------------------------
# This variable controls whether to load Example Schemas onto
# the starter database or not.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.installExampleSchemas=false

#是否启用安全设置
#-------------------------------------------------------------------------------
# This variable includes enabling audit settings, configuring password profiles
# and revoking some grants to public. These settings are provided by default.
# These settings may also be disabled.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.enableSecuritySettings=true

###############################################################################
# #
# Passwords can be supplied for the following four schemas in the #
# starter database: #
# SYS #
# SYSTEM #
# SYSMAN (used by Enterprise Manager) #
# DBSNMP (used by Enterprise Manager) #
# #
# Same password can be used for all accounts (not recommended) #
# or different passwords for each account can be provided (recommended) #
# #
###############################################################################

#默认的所有用户的密码
#------------------------------------------------------------------------------
# This variable holds the password that is to be used for all schemas in the
# starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.ALL=manager

#-------------------------------------------------------------------------------
# Specify the SYS password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYS=

#-------------------------------------------------------------------------------
# Specify the SYSTEM password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYSTEM=

#-------------------------------------------------------------------------------
# Specify the SYSMAN password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYSMAN=

#-------------------------------------------------------------------------------
# Specify the DBSNMP password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.DBSNMP=

#设定数据库管理类型
#-------------------------------------------------------------------------------
# Specify the management option to be selected for the starter database.
# It can be one of the following:
# - GRID_CONTROL 网格集中管理
# - DB_CONTROL 本地管理
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.control=DB_CONTROL

#-------------------------------------------------------------------------------
# Specify the Management Service to use if Grid Control is selected to manage
# the database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=

###############################################################################
# #
# SPECIFY BACKUP AND RECOVERY OPTIONS #
# ------------------------------------ #
# Out-of-box backup and recovery options for the database can be mentioned #
# using the entries below. #
# #
###############################################################################

#自动备份
#------------------------------------------------------------------------------
# This variable is to be set to false if automated backup is not required. Else
# this can be set to true.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.enable=false

#------------------------------------------------------------------------------
# Regardless of the type of storage that is chosen for backup and recovery, if
# automated backups are enabled, a job will be scheduled to run daily to backup
# the database. This job will run as the operating system user that is
# specified in this variable.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.osuid=

#-------------------------------------------------------------------------------
# Regardless of the type of storage that is chosen for backup and recovery, if
# automated backups are enabled, a job will be scheduled to run daily to backup
# the database. This job will run as the operating system user specified by the
# above entry. The following entry stores the password for the above operating
# system user.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.ospwd=

#存储类型
#-------------------------------------------------------------------------------
# Specify the type of storage to use for the database.
# It can be one of the following:
# - FILE_SYSTEM_STORAGE 文件
# - ASM_STORAGE asm自动管理
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE

#数据库文件目录
#-------------------------------------------------------------------------------
# Specify the database file location which is a directory for datafiles, control
# files, redo logs.
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/home/app/oradata

#-------------------------------------------------------------------------------
# Specify the backup and recovery location.
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=

#-------------------------------------------------------------------------------
# Specify the existing ASM disk groups to be used for storage.
#
# Applicable only when oracle.install.db.config.starterdb.storageType=ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.diskGroup=

#-------------------------------------------------------------------------------
# Specify the password for ASMSNMP user of the ASM instance.
#
# Applicable only when oracle.install.db.config.starterdb.storage=ASM_STORAGE
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.ASMSNMPPassword=

#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username.
#
# Example : MYORACLESUPPORT_USERNAME=abc@oracle.com
#------------------------------------------------------------------------------
MYORACLESUPPORT_USERNAME=

#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username password.
#
# Example : MYORACLESUPPORT_PASSWORD=password
#------------------------------------------------------------------------------
MYORACLESUPPORT_PASSWORD=

#------------------------------------------------------------------------------
# Specify whether to enable the user to set the password for
# My Oracle Support credentials. The value can be either true or false.
# If left blank it will be assumed to be false.
#
# Example : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
#------------------------------------------------------------------------------
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false

#是否配置安全更新,此处必须设置true
#------------------------------------------------------------------------------
# Specify whether user doesn't want to configure Security Updates.
# The value for this variable should be true if you don't want to configure
# Security Updates, false otherwise.
#
# The value can be either true or false. If left blank it will be assumed
# to be false.
#
# Example : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true

#------------------------------------------------------------------------------
# Specify the Proxy server name. Length should be greater than zero.
#
# Example : PROXY_HOST=proxy.domain.com
#------------------------------------------------------------------------------
PROXY_HOST=

#------------------------------------------------------------------------------
# Specify the proxy port number. Should be Numeric and at least 2 chars.
#
# Example : PROXY_PORT=25
#------------------------------------------------------------------------------
PROXY_PORT=

#------------------------------------------------------------------------------
# Specify the proxy user name. Leave PROXY_USER and PROXY_PWD
# blank if your proxy server requires no authentication.
#
# Example : PROXY_USER=username
#------------------------------------------------------------------------------
PROXY_USER=

#------------------------------------------------------------------------------
# Specify the proxy password. Leave PROXY_USER and PROXY_PWD
# blank if your proxy server requires no authentication.
#
# Example : PROXY_PWD=password
#------------------------------------------------------------------------------
PROXY_PWD=

#------------------------------------------------------------------------------
# Specify the proxy realm.
#
# Example : PROXY_REALM=metalink
#------------------------------------------------------------------------------
PROXY_REALM=
#------------------------------------------------------------------------------
# Specify the Oracle Support Hub URL.
#
# Example : COLLECTOR_SUPPORTHUB_URL=https://orasupporthub.company.com:8080/
#------------------------------------------------------------------------------
COLLECTOR_SUPPORTHUB_URL=

#------------------------------------------------------------------------------
# Specify the auto-updates option. It can be one of the following:
# - MYORACLESUPPORT_DOWNLOAD
# - OFFLINE_UPDATES
# - SKIP_UPDATES
#------------------------------------------------------------------------------
oracle.installer.autoupdates.option=SKIP_UPDATES
#------------------------------------------------------------------------------
# In case MYORACLESUPPORT_DOWNLOAD option is chosen, specify the location where
# the updates are to be downloaded.
# In case OFFLINE_UPDATES option is chosen, specify the location where the updates
# are present.
#------------------------------------------------------------------------------
oracle.installer.autoupdates.downloadUpdatesLoc=
#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username which has the patches download privileges
# to be used for software updates.
# Example : AUTOUPDATES_MYORACLESUPPORT_USERNAME=abc@oracle.com
#------------------------------------------------------------------------------
AUTOUPDATES_MYORACLESUPPORT_USERNAME=

#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username password which has the patches download privileges
# to be used for software updates.
#
# Example : AUTOUPDATES_MYORACLESUPPORT_PASSWORD=password
#------------------------------------------------------------------------------
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=

应答文件下载

开始安装

1、使用oracle用户登录,然后执行安装命令

1
2
3
4
5
6
7
8
./runInstaller -ignoreSysPrereqs -silent -noconfig -responseFile /opt/database/response/install.rsp

参数介绍:
-ignoreSysPrereqs:让oracle忽略系统检查,因为oracle官方声明只支持Linux服务器产品,所以要在非服务器的Linux上安装就必须指定该参数
-silent:表示已静默安装的方式安装,不会有任何提示
-noconfig:表示不运行配置助手netca
-force:表示安装到一个非空目录
-responseFile:表示使用哪个响应文件,必须使用绝对路径

2、等待安装
执行命令后,如果没有不满足的条件,则会进行安装,如下:

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
正在启动 Oracle Universal Installer...

检查临时空间: 必须大于 120 MB。 实际为 135861 MB 通过
检查交换空间: 必须大于 150 MB。 实际为 7935 MB 通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2016-10-10_09-22-45PM. 请稍候...
[WARNING] [INS-32055] 主产品清单位于 Oracle 基目录中。
原因: 主产品清单位于 Oracle 基目录中。
操作: Oracle 建议将此主产品清单放置在 Oracle 基目录之外的位置中。
[WARNING] [INS-30011] 输入的 ADMIN 口令不符合 Oracle 建议的标准。
原因: Oracle 建议输入的口令应该至少长为 8 个字符, 至少包含 1 个大写字符, 1 个小写字符和 1 个数字 [0-9]。
操作: 提供符合 Oracle 建议标准的口令。
[WARNING] [INS-13014] 目标环境不满足一些可选要求。
原因: 不满足一些可选的先决条件。有关详细信息, 请查看日志。/tmp/OraInstall2016-10-10_09-22-45PM/installActions2016-10-10_09-22-45PM.log
操作: 从日志 /tmp/OraInstall2016-10-10_09-22-45PM/installActions2016-10-10_09-22-45PM.log 中确定失败的先决条件检查列表。然后, 从日志文件或安装手册中查找满足这些先决条件的适当配置, 并手动进行修复。
可以在以下位置找到本次安装会话的日志:
/home/app/oraInventory/logs/installActions2016-10-10_09-22-45PM.log
Oracle Database 11g 的 安装 已成功。
请查看 '/home/app/oraInventory/logs/silentInstall2016-10-10_09-22-45PM.log' 以获取详细资料。

以 root 用户的身份执行以下脚本:
1. /home/app/oraInventory/orainstRoot.sh
2. /home/app/oracle/product/11.2.0.4/db_1/root.sh


以安装用户的身份执行以下脚本来完成配置。
1. /home/app/oracle/product/11.2.0.4/db_1/cfgtoollogs/configToolAllCommands RESPONSE_FILE=<response_file>

注:
1. 此脚本必须在已运行安装程序的同一主机上运行。
2. 对于需要口令的 Configuration Assistant, 此脚本需要一个较小的口令属性文件 (请参阅安装指南文档)。


Successfully Setup Software.

系统初始化

1、使用root用户登录
2、运行以下2个脚本

1
2
sh /home/app/oraInventory/orainstRoot.sh
sh /home/app/oracle/product/11.2.0.4/db_1/root.sh

安装网络监听器

1、使用oracle登录系统
2、没有网络监听器,客户端就无法通过网络连接Oralce服务器。要在命令行安装网络监听器,也只能使用静默模式
3、执行以下命令:

1
$ORACLE_HOME/bin/netca /silent /responseFile /mnt/hgfs/tmp/oracle11g/response/netca.rsp

4、查看监听器状态
执行命令:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ORACLE_HOME/bin/lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 11-OCT-2016 00:20:54

Copyright (c) 1991, 2013, 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.4.0 - Production
Start Date 10-OCT-2016 21:36:02
Uptime 0 days 2 hr. 44 min. 55 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/app/oracle/product/11.2.0.4/db_1/network/admin/listener.ora
Listener Log File /home/app/diag/tnslsnr/dbserver/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver)(PORT=1521)))
The listener supports no services
The command completed successfully

安装数据库

1、以root用户登录系统
2、编辑安装目录response下的应答文件dbca.rsp文件,修改以下项:

1
2
3
4
5
6
7
8
9
10
11
RESPONSEFILE_VERSION = "11.2.0"  //不能更改
OPERATION_TYPE = "createDatabase"
GDBNAME="orcl" 全局数据库的名字=SID+主机域名,会影响生成的文件夹名称
SID="orcl" 数据库的SID
TEMPLATENAME = "General_Purpose.dbc" //建库用的模板文件
SYSPASSWORD="manager" SYS用户的初始密码,我设置为manager
SYSTEMPASSWORD="manager" SYSTEM用户的初始密码,我设置为manager
DATAFILEDESTINATION = /app/oradata //数据文件存放目录
RECOVERYAREADESTINATION=/app/oradata_back //恢复数据存放目录
CHARACTERSET="ZHS16GBK" 数据库字符集,重要!!!! 建库后一般不能更改(中文为 ZHS16GBK)
TOTALMEMORY = "1000" //oracle内存0000MB

3、使用oracle账户执行安装命令

1
dbca -silent -responseFile /opt/database/response/dbca.rsp -cloneTemplate

4、系统提示信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
复制数据库文件
1% 已完成
3% 已完成
11% 已完成
18% 已完成
26% 已完成
37% 已完成
正在创建并启动 Oracle 实例
40% 已完成
45% 已完成
50% 已完成
55% 已完成
56% 已完成
60% 已完成
62% 已完成
正在进行数据库创建
66% 已完成
70% 已完成
73% 已完成
85% 已完成
96% 已完成
100% 已完成
有关详细信息, 请参阅日志文件 "/home/app/cfgtoollogs/dbca/orcl/orcl.log"

设置自动启动

修改/etc/oratab文件,设置自动启动,把N修改为Y

1
2
3
4
修改前:
orcl:/home/app/oracle/product/11.2.0.4/db_1:N
修改后:
orcl:/home/app/oracle/product/11.2.0.4/db_1:Y

这样数据库就会在oracle服务启动起来后自动启动了。

启动关闭数据库

以oracle身份登录系统,执行以下操作:

监听器启动

检查监听器是否启动,执行命令

1
$ORACLE_HOME/bin/lsnrctl status

没有启动,可以输入启动命令

1
$ORACLE_HOME/bin/lsnrctl start

启动oracel实例

1、sqlplus启动
使用sysdba身份登录sqlplus,输入:

1
2
3
4
sqlplus sys/manager@orcl as sysdba
登录后输入:
sql>statuup
启动数据库

2、脚本启动
通过$ORACLE_HOME/bin/dbstart 启动数据库实例
此方法通过读取/etc/oratab中查找SID的数据库实例启动。

关闭oracel实例

1、sqlplus关闭
使用sysdba身份登录sqlplus,输入:

1
2
3
4
sqlplus sys/manager@orcl as sysdba
登录后输入:
sql>shutdown immediate
关闭数据库

2、脚本关闭
通过$ORACLE_HOME/bin/dbstart 关闭数据库实例
此方法通过读取/etc/oratab中查找SID的数据库实例关闭。

关闭监听

$ORACLE_HOME/bin/lsnrctl stop

使用说明

1、根据需求,首先创建表空间、创建用户、授权用户使用的表空间。
2、使用用户登录后创建表、函数、存储过程、视图等完成功能需要。

文章目录
  1. 1. 更新yum源
  2. 2. 关闭selinux
  3. 3. 关闭防火墙
  4. 4. 时间同步ntp
  5. 5. 安装开发环境
  6. 6. 安装网络工具
  7. 7. 修改主机名
  8. 8. 检查需要的包
  9. 9. 创建用户
    1. 9.1. 创建用户组
    2. 9.2. 创建用户oracle
  10. 10. 配置内核参数
    1. 10.1. 配置内核参数。
    2. 10.2. 修改资源参数
  11. 11. 创建安装目录
  12. 12. 配置环境变量
    1. 12.1. 修改全局环境变量
    2. 12.2. 修改oracle环境变量
  13. 13. 关联设置
  14. 14. 准备oracle11gr2的安装文件
  15. 15. oracle响应文件
  16. 16. 开始安装
  17. 17. 系统初始化
  18. 18. 安装网络监听器
  19. 19. 安装数据库
  20. 20. 设置自动启动
  21. 21. 启动关闭数据库
    1. 21.1. 监听器启动
    2. 21.2. 启动oracel实例
    3. 21.3. 关闭oracel实例
    4. 21.4. 关闭监听
  22. 22. 使用说明