oracle11.2.0.1静默安装之dbca静默建库

1) 生成响应文件:

[oracle@srcxtts response]$ cp netca.rsp ../netca.rsp^C
[oracle@srcxtts response]$ pwd
/home/oracle/database/response
[oracle@srcxtts response]$

2)更改拷贝的响应文件:

#--------------------------------------------------------------------

#以下参数不要更改

[GENERAL]

RESPONSEFILE_VERSION = "11.2.0"

OPERATION_TYPE = "createDatabase"

#以下参数必须设置

[CREATEDATABASE]

GDBNAME = "orcl"

TEMPLATENAME = "General_Purpose.dbc"

#以下参数不设置则使用默认值,建议设置

CHARACTERSET = "ZHS16GBK"

TOTALMEMORY = "1024"

#--------------------------------------------------------------------

3)静默建库:

$ $ORACLE_HOME/bin/dbca -silent -responseFile $DISTRIB/db_create.rsp

Enter SYS user password: 

<输入sys用户密码> 

Enter SYSTEM user password: 

<输入system用户密码> 

Copying database files

...

37% complete

Creating and starting Oracle instance

...

62% complete

Completing Database Creation

...

100% complete

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

 

各参数含义如下:

-silent 表示以静默方式安装

-responseFile 表示使用哪个响应文件,必需使用绝对路径

RESPONSEFILE_VERSION 响应文件模板的版本,该参数不要更改

OPERATION_TYPE 安装类型,该参数不要更改

GDBNAME 全局数据库名,点号前面默认是db_name,点号后面默认就是db_domain

TEMPLATENAME 建库模板名,参考各模板定义:$ORACLE_HOME/assistants/dbca/templates/*.dbc

CHARACTERSET 字符集,默认是WE8MSWIN1252

TOTALMEMORY 实例内存,默认是服务器物理内存的40%

4)建库后实例检查

ps -ef|grep ora_

5)建库后监听检查

lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 23-APR-2018 18:09:25

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                23-APR-2018 16:52:30
Uptime                    0 days 1 hr. 16 min. 55 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.1/db_home1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/srcxtts/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=srcxtts)(PORT=1521)))
Services Summary...
Service "ORCLXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

6)启动实例

SQL> startup
ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0.1/db_home1/dbs/initorcl.ora'

oracle11.2.0.1静默安装之dbca静默建库_第1张图片

文件不存在,直接根据模板init.ora拷贝一份

cp init.ora initorcl.ora

然后把里面相关路径改一下,此处主要把换成/u01/app/oracle

[oracle@srcxtts dbs]$ cat initorcl.ora
# 
# $Header: rdbms/admin/init.ora /main/23 2009/05/15 13:35:38 ysarig Exp $ 
# 
# Copyright (c) 1991, 1997, 1998 by Oracle Corporation
# NAME
#   init.ora
# FUNCTION
# NOTES
# MODIFIED
#     ysarig     05/14/09  - Updating compatible to 11.2
#     ysarig     08/13/07  - Fixing the sample for 11g
#     atsukerm   08/06/98 -  fix for 8.1.
#     hpiao      06/05/97 -  fix for 803
#     glavash    05/12/97 -  add oracle_trace_enable comment
#     hpiao      04/22/97 -  remove ifile=, events=, etc.
#     alingelb   09/19/94 -  remove vms-specific stuff
#     dpawson    07/07/93 -  add more comments regarded archive start
#     maporter   10/29/92 -  Add vms_sga_use_gblpagfile=TRUE 
#     jloaiza    03/07/92 -  change ALPHA to BETA 
#     danderso   02/26/92 -  change db_block_cache_protect to _db_block_cache_p
#     ghallmar   02/03/92 -  db_directory -> db_domain 
#     maporter   01/12/92 -  merge changes from branch 1.8.308.1 
#     maporter   12/21/91 -  bug 76493: Add control_files parameter 
#     wbridge    12/03/91 -  use of %c in archive format is discouraged 
#     ghallmar   12/02/91 -  add global_names=true, db_directory=us.acme.com 
#     thayes     11/27/91 -  Change default for cache_clone 
#     jloaiza    08/13/91 -         merge changes from branch 1.7.100.1 
#     jloaiza    07/31/91 -         add debug stuff 
#     rlim       04/29/91 -         removal of char_is_varchar2 
#   Bridge     03/12/91 - log_allocation no longer exists
#   Wijaya     02/05/91 - remove obsolete parameters
#
##############################################################################
# Example INIT.ORA file
#
# This file is provided by Oracle Corporation to help you start by providing
# a starting point to customize your RDBMS installation for your site. 
# 
# NOTE: The values that are used in this file are only intended to be used
# as a starting point. You may want to adjust/tune those values to your
# specific hardware and needs. You may also consider using Database
# Configuration Assistant tool (DBCA) to create INIT file and to size your
# initial set of tablespaces based on the user input.
###############################################################################

# Change '' to point to the oracle base (the one you specify at
# install time)

db_name='orcl'
memory_target=900M
processes = 150
audit_file_dest='/u01/app/oracle/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle/'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300 
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = (ora_control1, ora_control2)
compatible ='11.2.0'
[oracle@srcxtts dbs]$ 

再次启动:

SQL> startup nomount
ORACLE instance started.


Total System Global Area  939495424 bytes
Fixed Size                  2218952 bytes
Variable Size             545260600 bytes
Database Buffers          385875968 bytes

Redo Buffers                6139904 bytes

7)启动到mount

SQL> alter database mount;
alter database mount
*
ERROR at line 1:

ORA-01102: cannot mount database in EXCLUSIVE mode

解决办法:

网上找了一篇帖子,如下做的:

 

分析原因:

一、在HA系统中,已经有其他节点启动了实例,将双机共享的资源(如磁盘阵列上的裸设备)占用了;

二、说明Oracle被异常关闭时,有资源没有被释放,一般有以下几种可能,

1、 Oracle的共享内存段或信号量没有被释放;

2、 Oracle的后台进程(如SMON、PMON、DBWn等)没有被关闭;

3、 用于锁内存的文件lk和sgadef.dbf文件没有被删除。

 

解决思路:

当发生1102错误时,可以按照以下流程检查、排错:

如果是HA系统,检查其他节点是否已经启动实例检查Oracle进程是否存在,如果存在则杀掉进程检查信号量是否存在,如果存在,则清除信号量检查共享内存段是否存在,如果存在,则清除共享内存段检查锁内存文件lk和sgadef.dbf是否存在,如果存在,则删除。

具体做法:

首先,虽然我们的系统是HA系统,但是备节点的实例始终处在关闭状态,这点通过在备节点上查数据库状态可以证实。

其次、是因系统掉电引起数据库宕机的,系统在接电后被重启,因此我们排除了第二种可能种的1、2点。最可疑的就是第3点了。

查$ORACLE_HOME/dbs目录:

$ cd $ORACLE_HOME/dbs

$ ls sgadef*

sgadef* not found

$ ls lk*

/opt/oracle/product/ 10.2.0/db_1/dbs/lkSIMPLY

lkSIMPLY

果然,lk文件没有被删除。将它删除掉

$ rm lk*

删除后再次启动

SQL> alter database mount ;
alter database mount
*
ERROR at line 1:

ORA-00205: error in identifying control file, check alert log for more info

错误变成找不到控制文件了,这好办,我们新库,还没有控制文件,这个后面在说。

然后按照上面那篇帖子:

https://blog.csdn.net/lzwgood/article/details/26368323

把oracle的共享内存清了:

查看共享内存段

[root@simply bdump]# ipcs -map

 

------ Shared Memory Creator/Last-op --------

shmid   owner  cpid    lpid

786444  root    6490   6438

819213  root    6549   6438

1409040 oracle   31502  16728

根据ID号清楚共享内存段

ipcrm –m 1409040

我这里操作是没有成功的,不过执行了下面的操作就ok了!

 

查看信号量

[root@simply bdump]# ipcs -s

 

key       semid      owner   perms    nsems

0x17ff6454 360448     oracle    640     154

 

清除oracle的信号量

[root@simply bdump]# ipcrm -s 360448

 

再次查询确认

[root@simply bdump]# ipcs -s

 

------ Semaphore Arrays --------

key  semid  owner  perms   nsems

 

再查询共享内存段也ok了!

[root@simply bdump]# ipcs -m

再次启动的时候,又报了下面的错:

SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system

后来df -h发现/dev/shm总共930M,现在可用只有400多M,而memory_target设置的是900M。

memory_max_target                    big integer 900M

memory_target                        big integer 900M

考虑/dev/shm大小不够,增大之:

 mount -t tmpfs shmfs -o size=2g /dev/shm

修改配置文件/etc/fstab

tmpfs                   /dev/shm                tmpfs   defaults,size=2g        0 0

全量重新挂载

mount -a

[oracle@srcxtts dbs]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_srcxtts-lv_root
                       21G   12G  7.3G  62% /
tmpfs                 2.0G  538M  1.5G  27% /dev/shm
/dev/sda1             477M   60M  392M  14% /boot

shmfs                 2.0G  538M  1.5G  27% /dev/shm

再次重新启动到mount:

SQL> alter database mount ;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info

又回到控制文件的问题了,不要急,接着来。

截止到现在我们数据库用的还是pfile文件,要改成使用spfile文件:

SQL> show parameter pfile


NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
spfile                               string


SQL> create spfile from pfile ;


File created.


SQL> show parameter pfile


NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
spfile                               string


SQL> shutdown immediate 
ORA-01507: database not mounted




ORACLE instance shut down.
SQL> startup nomount ;
ORACLE instance started.


Total System Global Area  939495424 bytes
Fixed Size                  2218952 bytes
Variable Size             545260600 bytes
Database Buffers          385875968 bytes
Redo Buffers                6139904 bytes
SQL> show parameter pfile


NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
spfile                               string
/u01/app/oracle/product/11.2.0

.1/db_home1/dbs/spfileorcl.ora

现在已经改成使用spfile文件了。

8)下面就来搞控制文件,oracle静默安装好后,默认给了个空文件在/u01/app/oracle/oradata/orcl/control01.ctl

拷贝两份到/u01/app/oracle/product/11.2.0.1/db_home1/dbs/control01.ctl,/u01/app/oracle/product/11.2.0.1/db_home1/dbs/control02.ctl

oracle11.2.0.1静默安装之dbca静默建库_第2张图片

改初始化参数配置

SQL> show parameter control  


NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
control_file_record_keep_time        integer
7
control_files                        string
/u01/app/oracle/product/11.2.0
.1/db_home1/dbs/ora_control1,
/u01/app/oracle/product/11.2.0
.1/db_home1/dbs/ora_control2
control_management_pack_access       string

DIAGNOSTIC+TUNING

SQL> alter system set control_files="/u01/app/oracle/product/11.2.0.1/db_home1/dbs/control01.ctl","/u01/app/oracle/product/11.2.0.1/db_home1/dbs/control02.ctl" scope=spfile
  2  ;


System altered.

SQL> show parameter control


NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
control_file_record_keep_time        integer
7
control_files                        string
/u01/app/oracle/product/11.2.0
.1/db_home1/dbs/ora_control1,
/u01/app/oracle/product/11.2.0
.1/db_home1/dbs/ora_control2
control_management_pack_access       string
DIAGNOSTIC+TUNING
SQL> shutdown immediate
ORA-01507: database not mounted




ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.


Total System Global Area  939495424 bytes
Fixed Size                  2218952 bytes
Variable Size             545260600 bytes
Database Buffers          385875968 bytes
Redo Buffers                6139904 bytes
SQL> show parameter control


NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
control_file_record_keep_time        integer
7
control_files                        string
/u01/app/oracle/product/11.2.0
.1/db_home1/dbs/control01.ctl,
 /u01/app/oracle/product/11.2.
0.1/db_home1/dbs/control02.ctl
control_management_pack_access       string
DIAGNOSTIC+TUNING
SQL> alter database mount;


Database altered.


SQL> alter database open;


Database altered.


SQL> select instance_name,status from v$instance ;


INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

最后改完重启数据,然后就可以打开了。

你可能感兴趣的:(oracle)