Oracle 12c Grid Infrastructure for a Standalone Server with a New Database on Oracle Linux 7

Oracle 12CR2发布了,学习的季节也到了,学习的第一步就是得安装数据库,这篇文章介绍如何在Oracle Linux 7.1上安装Oracle 12c Grid Infrastructure for a Standalone Server with a New Database

检查Linux内核与软件包
1.检查linux版本

[root@jytest ~]# cat /etc/oracle-release
Oracle Linux Server release 7.1
[root@jytest ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 (Maipo)

2.检查内核版本

[root@jytest ~]# uname -r
3.8.13-55.1.6.el7uek.x86_64

3.检查需要的软件包是否安装

rpm -q package_name

也可以指定系统结构信息,例如:

rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" | grep package_name

也可以将查询多个软件包的语句组合在一起,并查看正确的软件版本.

[root@jytest ~]# rpm -q binutils compat-libstdc++ gcc glibc libaio libgcc libstdc++ make sysstat unixodbc
binutils-2.23.52.0.1-30.el7.x86_64
package compat-libstdc++ is not installed
gcc-4.8.3-9.el7.x86_64
glibc-2.17-78.0.1.el7.x86_64
libaio-0.3.109-12.el7.x86_64
libgcc-4.8.3-9.el7.x86_64
libstdc++-4.8.3-9.el7.x86_64
make-3.82-21.el7.x86_64
sysstat-10.1.5-7.el7.x86_64
package unixodbc is not installed

禁用Transparent HugePages
对于Red Hat Enterprise Linux kernels:

#cat /sys/kernel/mm/redhat_transparent_hugepage/enabled

其它kernels:

#cat /sys/kernel/mm/transparent_hugepage/enabled

下面是输出示例,显示Transparent HugePages被使用[always]标记被启用
[always] never
如果Transparent HugePages从内核中被删除,那么/sys/kernel/mm/transparent_hugepage或/sys/kernel/mm/redhat_transparent_hugepage文件会不存在。

为了禁用transparent hugepage执行以下操作:
1.向内核心/etc/grub.conf文件中增加以下记录

transparent_hugepage=never

2.重启操作系统

#reboot

创建用户组

[root@jytest /]# groupadd asmadmin
[root@jytest /]# groupadd asmdba
[root@jytest /]# groupadd asmoper
[root@jytest /]# groupadd dba
[root@jytest /]# groupadd oper
[root@jytest /]# groupadd oinstall
[root@jytest /]# groupadd backupdba
[root@jytest /]# groupadd dgdba
[root@jytest /]# groupadd kmdba
[root@jytest /]# groupadd racdba

创建用户

[root@jytest /]# useradd  -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper 
oracle
[root@jytest /]# useradd  -g oinstall -G asmadmin,asmdba,asmoper,dba grid

[root@jytest /]# passwd oracle
Changing password for user oracle.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@jytest /]# passwd grid
Changing password for user grid.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

以root用户创建“Oracle inventory 目录”

[root@jytest /]# mkdir -p /u01/app/oraInventory
[root@jytest /]# chown -R grid:oinstall /u01/app/oraInventory
[root@jytest /]# chmod -R 775 /u01/app/oraInventory

以root用户创建“Grid Infrastructure BASE 目录”

[root@jytest /]# mkdir -p /u01/app/grid
[root@jytest /]# chown -R grid:oinstall /u01/app/grid
[root@jytest /]# chmod -R 775 /u01/app/grid

以root用户创建“Grid Infrastructure Home 目录”

[root@jytest /]# mkdir -p /u01/app/product/12.2.0/crs
[root@jytest /]# chown -R grid:oinstall /u01/app/product/12.2.0/crs
[root@jytest /]# chmod -R 775 /u01/app/product/12.2.0/crs

以root用户创建“Oracle Base 目录”

[root@jytest /]# mkdir -p /u01/app/oracle
[root@jytest /]# chown -R oracle:oinstall /u01/app/oracle
[root@jytest /]# chmod -R 775 /u01/app/oracle

以root用户创建“Oracle RDBMS Home 目录”

[root@jytest /]# mkdir -p /u01/app/oracle/product/12.2.0/db
[root@jytest /]# chown -R oracle:oinstall /u01/app/oracle/product/12.2.0/db
[root@jytest /]# chmod -R 775 /u01/app/oracle/product/12.2.0/db

创建一个tmp目录

[root@jytest /]# mkdir /u01/tmp
[root@jytest /]# chmod a+wr /u01/tmp

设置环境变量

[root@jytest /]# su - grid
[grid@jytest ~]$ vi .bash_profile
# .bash_profile

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

# User specific environment and startup programs

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

export PATH

TEMP=/u01/tmp
TMPDIR=/u01/tmp
export TEMP TMPDIR
export LD_ASSUME_KERNEL=3.8.13
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/product/12.2.0/crs
export ORACLE_SID=+ASM
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
export PATH=$PATH:$ORACLE_HOME/bin
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
export CLASSPATH
umask=022


TEMP=/u01/tmp
TMPDIR=/u01/tmp
export TEMP TMPDIR
export LD_ASSUME_KERNEL=3.8.13
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/db
export ORACLE_SID=jy
export ORACLE_UNQNAME=jy
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
export PATH=$PATH:$ORACLE_HOME/bin
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
export CLASSPATH
umask=022

修改内核参数编辑/etc/sysctl.conf文件

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
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 = 1048576


[root@jytest3 ~]# sysctl -p
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
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 = 1048576

修改oarcle参数的shell限制
在/etc/security/limits.conf中添加以下参数:

grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
grid soft memlock 3145728
grid hard memlock 3145728

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle soft memlock 3145728
oracle hard memlock 3145728

修改shell的默认参数文件,在/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


if [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

对C shell(csh or tcsh)在/etc/csh.login文件中增加以下代码

if ( $USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
endif

if ( $USER == "grid" ) then
limit maxproc 16384
limit descriptors 65536
endif

配置创建ASM磁盘组的asm磁盘

[root@jytest3 ~]# fdisk -l

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000209aa

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   104857599    51915776   8e  Linux LVM

Disk /dev/mapper/ol-root: 47.7 GB, 47747956736 bytes, 93257728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/ol-swap: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

查看磁盘uuid

[root@jytest3 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdb
36000c295f8b38933c37ef4a42f446599
[root@jytest3 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdc
36000c29739826dc8ef28ef9a3589d3a0

udev绑定

[root@jytest3 ~]# vi /etc/udev/rules.d/99-my-asmdevices.rules


KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block",  PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode",  RESULT=="36000c295f8b38933c37ef4a42f446599", RUN 
+="/bin/sh -c 'mknod /dev/asmdisk01 b  $major $minor; chown grid:oinstall /dev/asmdisk01; chmod 0660 /dev/asmdisk01'"

KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block",  PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode",  RESULT=="36000c29739826dc8ef28ef9a3589d3a0", RUN 
+="/bin/sh -c 'mknod /dev/asmdisk02 b  $major $minor; chown grid:oinstall /dev/asmdisk02; chmod 0660 /dev/asmdisk02'"

~

[root@jytest3 ~]# /sbin/udevadm trigger --type=devices --action=change
[root@jytest3 ~]# ls -lrt /dev/asm*
brw-rw----. 1 grid oinstall 8, 32 Mar  8 22:24 /dev/asmdisk02
brw-rw----. 1 grid oinstall 8, 16 Mar  8 22:24 /dev/asmdisk01

解压GI安装压缩包:

[grid@jytest3 soft]cd /u01/app/grid/product/12.2.0/crs/
[grid@jytest3 soft]# unzip -q /soft/linuxx64_12201_grid_home.zip


配置vnc
检查系统是否已经安装vncserver软件包
[root@jytest3 system]# rpm -qa|grep tigervnc
tigervnc-server-minimal-1.2.80-0.30.20130314svn5065.el7.x86_64
tigervnc-license-1.2.80-0.30.20130314svn5065.el7.noarch

没有安装执行以下命令进行安装

[root@jytest3 /]# cd soft
[root@jytest3 soft]# yum -y install tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64.rpm
Loaded plugins: langpacks
Examining tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64.rpm: tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64
Marking tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package tigervnc-server.x86_64 0:1.2.80-0.30.20130314svn5065.el7 will be installed
--> Finished Dependency Resolution
http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR3/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: public-yum.oracle.com; Unknown error"
Trying other mirror.
http://public-yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: public-yum.oracle.com; Unknown error"
Trying other mirror.

Dependencies Resolved

=======================================================================================================================================================================
 Package                     Arch               Version                                      Repository                                                           Size
=======================================================================================================================================================================
Installing:
 tigervnc-server             x86_64             1.2.80-0.30.20130314svn5065.el7              /tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64             488 k

Transaction Summary
=======================================================================================================================================================================
Install  1 Package

Total size: 488 k
Installed size: 488 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64                                                                                              1/1 
  Verifying  : tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64                                                                                              1/1 

Installed:
  tigervnc-server.x86_64 0:1.2.80-0.30.20130314svn5065.el7                                                                                                             

Complete!

之前的版本,如果安装vnc一般都需要使用vncserver命令来设置口令,然后配置/etc/sysconfig/vncservers文件。
在Oracle Linux7中,虽然然还存在这个文件,不过其内容只有如下一行:

root@jytest3 soft]#  cat /etc/sysconfig/vncservers
# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service

复制文件

[root@jytest3 soft]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver_root@:2.service

编辑vncserver_root@:2.service文件将文件中的用root替换

[root@jytest3 soft]# cd /etc/systemd/system/
[root@jytest3 system]# vi vncserver_root@:2.service
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@:.service
# 2. Edit  and vncserver parameters appropriately
#   ("runuser -l  -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, you should
# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer' manual page.


[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
"vncserver_root@:2.service" 45L, 1739C written

启用vncserver配置

[root@jytest3 system]# systemctl enable vncserver_root@:2.service
ln -s '/etc/systemd/system/vncserver_root@:2.service' '/etc/systemd/system/multi-user.target.wants/vncserver_root@:2.service'

启动vncserver服务

[root@jytest3 system]# vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth:  file /root/.Xauthority does not exist

New 'jytest3:1 (root)' desktop is jytest3:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/jytest3:1.log

关闭防火墙

[root@jytest3 system]# systemctl stop firewalld
[root@jytest3 system]# systemctl disable firewalld
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
rm '/etc/systemd/system/basic.target.wants/firewalld.service'


用vnc登录服务器安装软件

[root@jytest3 Desktop]# xhost +
access control disabled, clients can connect from any host
[root@jytest3 Desktop]# su - grid
Last login: Tue Mar  7 17:50:57 CST 2017 on pts/0
[grid@jytest3 ~]$ cd /soft/grid


[grid@jytest3 crs]$ ./gridSetup.sh 
ERROR: Unable to verify the graphical display setup. This application requires X display. Make sure that xdpyinfo exist under PATH variable.

Can't connect to X11 window server using '10.138.135.167:1.0' as the value of the DISPLAY variable.

出现在错误,并且错误信息提示需要设置环境变量DISPLAY,下面设置环境变量DISPLAY

[grid@jytest3 grid]$ exit
logout
[root@jytest3 Desktop]# xdpyinfo
name of display:    :1
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    11500000
X.Org version: 1.15.0
maximum request size:  16777212 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    6
...省略...只需要记录name of display:的值
[root@jytest3 Desktop]# xhost +
access control disabled, clients can connect from any host
[root@jytest3 Desktop]# su - grid
Last login: Tue Mar  7 17:50:40 CST 2017 on pts/0
[grid@jytest3 ~]$ export DISPLAY=:1(这时设置为name of display的值:1)
[grid@jytest3 ~]$ xdpyinfo
name of display:    :1
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    11500000
X.Org version: 1.15.0
maximum request size:  16777212 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    6
...省略...
[grid@jytest3 ~]$cd /u01/app/grid/product/12.2.0/crs/
[grid@jytest3 crs]$ ./gridSetup.sh

选择for a Standalone Server (Oracle Restart)


现在可以让安装程序来以root用户自动执行安装所需要执行的脚本,指定root用户的密码


检查磁盘组data是否创建成功

[grid@jytest3 ~]$ asmcmd lsdg
State    Type    Rebal  Sector  Logical_Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  NORMAL  N         512             512   4096  4194304     40960    40760                0           20380              0             N  DATA/

安装数据库软件

[root@jytest3 soft]# unzip linuxx64_12201_database.zip -d 

[root@jytest3 Desktop]# xhost +
access control disabled, clients can connect from any host

[root@jytest3 Desktop]# xdpyinfo
name of display:    :1
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    11500000
X.Org version: 1.15.0
maximum request size:  16777212 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    6
...省略...只需要记录name of display:的值

[root@jytest3 Desktop]# su - oracle
Last login: Thu Mar  9 04:17:35 CST 2017 on pts/2
[oracle@jytest3 ~]$ export DISPLAY=:1
[oracle@jytest3 ~]$ cd /soft/database
[oracle@jytest3 database]$ ./runInstaller


执行脚本

[root@jytest3 /]# ./u01/app/oracle/product/12.2.0/db/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/12.2.0/db

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.

Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes|[no] : 
yes
Installing Oracle Trace File Analyzer (TFA).
Log File: /u01/app/oracle/product/12.2.0/db/install/root_jytest3_2017-03-09_15-33-03-156667468.log
Finished installing Oracle Trace File Analyzer (TFA)

创建数据库

[oracle@jytest3 database]$ dbca









在创建的过程中出现了以下错误

[Thread-301] [ 2017-03-09 22:15:26.774 CST ] [PostDBCreationStep.executeImpl:1156]  Exception while Starting with HA Database Resource PRCR-1079 : Failed to start resource ora.jy.db
CRS-5017: The resource action "ora.jy.db start" encountered the following error: 
ORA-01017: invalid username/password; logon denied
. For details refer to "(:CLSN00107:)" in "/u01/app/grid/diag/crs/jytest3/crs/trace/ohasd_oraagent_grid.trc".

CRS-2674: Start of 'ora.jy.db' on 'jytest3' failed
ORA-01017: invalid username/password; logon denied

数据库jy确实没能通过oracle restart自动启动

[grid@jytest3 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       jytest3                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       jytest3                  STABLE
ora.asm
               ONLINE  ONLINE       jytest3                  Started,STABLE
ora.ons
               OFFLINE OFFLINE      jytest3                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.driver.afd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.evmd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.jy.db
      1        ONLINE  OFFLINE                               Instance Shutdown,ST
                                                             ABLE
--------------------------------------------------------------------------------

如是手动启动数据库

[root@jytest3 ~]# su - oracle
Last login: Thu Mar  9 22:08:36 CST 2017 on pts/4
[oracle@jytest3 ~]$ echo $ORACLE_SID
jy
[oracle@jytest3 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Thu Mar 9 22:17:21 2017

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 2516582400 bytes
Fixed Size                  8795904 bytes
Variable Size            1358956800 bytes
Database Buffers         1140850688 bytes
Redo Buffers                7979008 bytes
Database mounted.
Database opened.

[grid@jytest3 trace]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       jytest3                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       jytest3                  STABLE
ora.asm
               ONLINE  ONLINE       jytest3                  Started,STABLE
ora.ons
               OFFLINE OFFLINE      jytest3                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.driver.afd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.evmd
      1        ONLINE  ONLINE       jytest3                  STABLE
ora.jy.db
      1        ONLINE  ONLINE       jytest3                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
--------------------------------------------------------------------------------

到此安装完成!

Oracle 12CR2 Install the Sample Schemas

在Oracle 12CR2中在创建数据库时不能安装sample schemas,Oracle将sample schemas的安装脚本存储在GitHub上了,可以通过以下链接地址进行下载

https://github.com/oracle/db-sample-schemas/releases/latest

下载到的是一个zip文件,例如我下载的文件名为db-sample-schemas-12.2.0.1.zip,将其解压

[oracle@jytest1 schema]$ unzip db-sample-schemas-12.2.0.1.zip

[oracle@jytest1 schema]$ ls -lrt
total 36584
-rw-r--r--  1 oracle oinstall     2322 Apr  3  2009 drop_sch.sql
-rw-r--r--  1 oracle oinstall    16894 Jul  1  2014 sted_mkplug.sql.dbl
-rw-r--r--  1 oracle oinstall    27570 Jul  1  2014 mkplug.sql
-rw-r--r--  1 oracle oinstall     1685 Nov  6  2015 mk_dir.sql.sbs
drwxr-xr-x  2 oracle oinstall        6 Mar 20 19:50 log
-rw-r--r--  1 oracle oinstall     1824 Mar 20 19:51 mk_dir.sql
drwxr-xr-x  2 oracle oinstall     4096 May 18 17:12 human_resources
-rw-r--r--  1 oracle oinstall 37389564 May 18 17:48 db-sample-schemas-12.2.0.1.zip
drwxrwxrwx 10 oracle oinstall     4096 May 18 18:46 db-sample-schemas-12.2.0.1

创建sample schemas只需执行db-sample-schemas-12.2.0.1目录下的mksample.sql脚本,其语法如下:

mksample          EXAMPLE TEMP $ORACLE_HOME/demo/schema/log/ localhost:1521/pdb

其参数分别指system,sys,hr,oe,pm,ix,sh,bi用户的密码,与缺省表空间,临时表空间名,以及存储生成日志文件的目录和连接数据库的连接串

[oracle@jytest1 db-sample-schemas-12.2.0.1]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu May 18 18:01:54 2017

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

SQL> @mksample.sql xxzx7817600 xxzx7817600 hr oe pm id sh bi users temp /u01/app/oracle/product/12.2.0/db/demo/schema/db-sample-schemas-12.2.0.1/log/ jypdb

specify password for SYSTEM as parameter 1:

specify password for SYS as parameter 2:

specify password for HR as parameter 3:

specify password for OE as parameter 4:

specify password for PM as parameter 5:

specify password for IX as parameter 6:

specify password for  SH as parameter 7:

specify password for  BI as parameter 8:

specify default tablespace as parameter 9:

specify temporary tablespace as parameter 10:

specify log file directory (including trailing delimiter) as parameter 11:

specify connect string as parameter 12:

Sample Schemas are being created ...

mkdir: cannot create directory 鈥u01/app/oracle/product/12.2.0/db/demo/schema/db-sample-schemas-12.2.0.1鈥 File exists

Connected.
DROP USER hr CASCADE
          *
ERROR at line 1:
ORA-01918: user 'HR' does not exist


DROP USER oe CASCADE
          *
ERROR at line 1:
ORA-01918: user 'OE' does not exist


DROP USER pm CASCADE
          *
ERROR at line 1:
ORA-01918: user 'PM' does not exist


DROP USER ix CASCADE
          *
ERROR at line 1:
ORA-01918: user 'IX' does not exist


DROP USER sh CASCADE
          *
ERROR at line 1:
ORA-01918: user 'SH' does not exist


DROP USER bi CASCADE
          *
ERROR at line 1:
ORA-01918: user 'BI' does not exist


Connected.
SP2-0310: unable to open file "__SUB__CWD__/human_resources/hr_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/order_entry/oe_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/product_media/pm_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/info_exchange/ix_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/sales_history/sh_main.sql"
Connected.
SP2-0310: unable to open file "__SUB__CWD__/bus_intelligence/bi_main.sql"
Connected.
not spooling currently
SP2-0310: unable to open file "__SUB__CWD__/mkverify.sql"

上面的错误显示不能打开__SUB__CWD__/目录下的相关脚本文件,这里我们需要将__SUB__CWD__/目录使用相关脚本存储的目录的绝对路径来替,下面执行替换

[oracle@jytest1 db-sample-schemas-12.2.0.1]$ perl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat

重新执行

[oracle@jytest1 ~]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu May 18 19:05:33 2017

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

SQL>@mksample.sql xxzx7817600 xxzx7817600 hr oe pm id sh bi users temp /u01/app/oracle/product/12.2.0/db/demo/schema/db-sample-schemas-12.2.0.1/log/ jypdb

specify password for SYSTEM as parameter 1:

specify password for SYS as parameter 2:

specify password for HR as parameter 3:

specify password for OE as parameter 4:

specify password for PM as parameter 5:

specify password for IX as parameter 6:

specify password for  SH as parameter 7:

specify password for  BI as parameter 8:

specify default tablespace as parameter 9:

specify temporary tablespace as parameter 10:

specify log file directory (including trailing delimiter) as parameter 11:

specify connect string as parameter 12:

Sample Schemas are being created ...
....省略....

Index cardinality (without  LOB indexes)

OWNER  INDEX_NAME                DISTINCT_KEYS   NUM_ROWS
------ ------------------------- ------------- ----------
HR     COUNTRY_C_ID_PK                      25         25
HR     DEPT_ID_PK                           27         27
HR     DEPT_LOCATION_IX                      7         27
HR     EMP_DEPARTMENT_IX                    11        106
HR     EMP_EMAIL_UK                        107        107
HR     EMP_EMP_ID_PK                       107        107
HR     EMP_JOB_IX                           19        107
HR     EMP_MANAGER_IX                       18        106
HR     EMP_NAME_IX                         107        107
HR     JHIST_DEPARTMENT_IX                   6         10
HR     JHIST_EMPLOYEE_IX                     7         10
HR     JHIST_EMP_ID_ST_DATE_PK              10         10
HR     JHIST_JOB_IX                          8         10
HR     JOB_ID_PK                            19         19
HR     LOC_CITY_IX                          23         23
HR     LOC_COUNTRY_IX                       14         23
HR     LOC_ID_PK                            23         23
HR     LOC_STATE_PROVINCE_IX                17         17
HR     REG_ID_PK                             4          4
IX     AQ$_STREAMS_QUEUE_TABLE_Y             0          0
OE     ACTION_TABLE_MEMBERS                132        132
OE     CUSTOMERS_PK                        319        319
OE     CUST_ACCOUNT_MANAGER_IX               4        319
OE     CUST_EMAIL_IX                       319        319
OE     CUST_LNAME_IX                       176        319
OE     CUST_UPPER_NAME_IX                  319        319
OE     INVENTORY_IX                       1112       1112
OE     INV_PRODUCT_IX                      208       1112
OE     ITEM_ORDER_IX                       105        665
OE     ITEM_PRODUCT_IX                     185        665
OE     LINEITEM_TABLE_MEMBERS              132        132
OE     ORDER_ITEMS_PK                      665        665
OE     ORDER_ITEMS_UK                      665        665
OE     ORDER_PK                            105        105
OE     ORD_CUSTOMER_IX                      47        105
OE     ORD_ORDER_DATE_IX                   105        105
OE     ORD_SALES_REP_IX                      9         70
OE     PRD_DESC_PK                        8640       8640
OE     PRODUCT_INFORMATION_PK              288        288
OE     PROD_NAME_IX                       3727       8640
OE     PROD_SUPPLIER_IX                     62        288
OE     PROMO_ID_PK                           2          2
OE     WAREHOUSES_PK                         9          9
OE     WHS_LOCATION_IX                       9          9
PM     ONLINEMEDIA_PK                        9          9
PM     PRINTMEDIA_PK                         4          4
SH     CHANNELS_PK                           5          5
SH     COSTS_PROD_BIX                        0          0
SH     COSTS_TIME_BIX                        0          0
SH     COUNTRIES_PK                         23         23
SH     CUSTOMERS_GENDER_BIX                  2          5
SH     CUSTOMERS_MARITAL_BIX                11         18
SH     CUSTOMERS_PK                      55500      55500
SH     CUSTOMERS_YOB_BIX                    75         75
SH     DR$SUP_TEXT_IDX$RC
SH     DR$SUP_TEXT_IDX$X                     0          0
SH     FW_PSC_S_MV_CHAN_BIX                  4          4
SH     FW_PSC_S_MV_PROMO_BIX                 4          4
SH     FW_PSC_S_MV_SUBCAT_BIX               21         21
SH     FW_PSC_S_MV_WD_BIX                  210        210
SH     PRODUCTS_PK                          72         72
SH     PRODUCTS_PROD_CAT_IX                  5         72
SH     PRODUCTS_PROD_STATUS_BIX              1          1
SH     PRODUCTS_PROD_SUBCAT_IX              21         72
SH     PROMO_PK                            503        503
SH     SALES_CHANNEL_BIX                     4         92
SH     SALES_CUST_BIX                     7059      35808
SH     SALES_PROD_BIX                       72       1074
SH     SALES_PROMO_BIX                       4         54
SH     SALES_TIME_BIX                     1460       1460
SH     SUP_TEXT_IDX
SH     TIMES_PK                           1826       1826

72 rows selected.

SQL> select username from dba_users;

USERNAME
------------------------------------------------------------------------------------------
SYS
SYSTEM
XS$NULL
LBACSYS
OUTLN
DBSNMP
APPQOSSYS
DBSFWUSER
GGSYS
ANONYMOUS
CTXSYS
SI_INFORMTN_SCHEMA
DVSYS
DVF
GSMADMIN_INTERNAL
ORDPLUGINS
MDSYS
OLAPSYS
ORDDATA
XDB
WMSYS
ORDSYS
GSMCATUSER
MDDATA
SYSBACKUP
REMOTE_SCHEDULER_AGENT
PDBADMIN
GSMUSER
SYSRAC
HR
BI
OJVMSYS
AUDSYS
DIP
JY
OE
PM
SYSKM
ORACLE_OCM
SYS$UMF
QS_ADM
IX
SYSDG
SPATIAL_CSW_ADMIN_USR
SH

45 rows selected.

相关sample schemas创建成功。

Oracle 12CR2 using create database command for create non-CDB rac database on Oracle Linux

在Oracle Linux7,数据库版本为12.2中使用create database来创建non-CDB数据库
1.设置实例标识符(SID)

[root@jytest1 ~]# su - oracle
Last login: Fri Apr 21 11:24:50 CST 2017
[oracle@jytest1 ~]$ export ORACLE_SID=orcl1

2.创建相关目录

ASMCMD [+data] > mkdir orcl
ASMCMD [+data] > ls
jy/
orcl/
ASMCMD [+data] > mkdir +data/orcl/CONTROLFILE
ASMCMD [+data] > mkdir +data/orcl/DATAFILE
ASMCMD [+data] > mkdir +data/orcl/ONLINELOG
ASMCMD [+data] > mkdir +data/orcl/TEMPFILE
ASMCMD [+data] > mkdir +data/orcl/PASSWORD
ASMCMD [+data] > mkdir +data/orcl/PARAMETERFILE

3.创建密码文件

[oracle@jytest1 dbs]$ orapwd file='/u01/app/oracle/product/12.2.0/db/dbs/orapworcl1'  force=y password=xxzx#7817600

4.创建参数文件,参数文件至少要包含db_name,control_files与memory_target参数

[oracle@jytest1 dbs]$ vi initorcl1.ora
db_name=orcl
control_files='+data/orcl/controlfile/control01.ctl','+data/orcl/controlfile/control02.c tl'
memory_target=1G

5.连接实例

[oracle@jytest1 dbs]$ sqlplus sys/xxzx#7817600 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Apr 19 19:15:50 2017

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

Connected to an idle instance.

6.启动实例

SQL> startup nomount pfile='/u01/app/oracle/product/12.2.0/db/dbs/initorcl1.ora'
ORACLE instance started.

Total System Global Area 1073741824 bytes
Fixed Size                  8628936 bytes
Variable Size             750781752 bytes
Database Buffers          306184192 bytes
Redo Buffers                8146944 bytes

7.创建服务器参数文件spfile

SQL>create spfile='+DATA/orcl/PARAMETERFILE/spfileorcl.ora' from pfile='/u01/app/oracle/product/12.2.0/db/dbs/initorcl1.ora';

8.执行create database语句

SQL> CREATE DATABASE orcl
  2  USER SYS IDENTIFIED BY xxzx#7817600
  3  USER SYSTEM IDENTIFIED BY xxzx#7817600
  4  LOGFILE GROUP 1 ('+data/orcl/onlinelog/redo01.log') SIZE 100M BLOCKSIZE 512,
  5  GROUP 2 ('+data/orcl/onlinelog/redo02.log') SIZE 100M BLOCKSIZE 512,
  6  GROUP 3 ('+data/orcl/onlinelog/redo03.log') SIZE 100M BLOCKSIZE 512
  7  MAXLOGHISTORY 1
  8  MAXLOGFILES 16
  9  MAXLOGMEMBERS 3
 10  MAXDATAFILES 1024
 11  CHARACTER SET ZHS16GBK
 12  NATIONAL CHARACTER SET AL16UTF16
 13  EXTENT MANAGEMENT LOCAL
 14  DATAFILE '+data/orcl/datafile/system01.dbf'
 15  SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
 16  SYSAUX DATAFILE '+data/orcl/datafile/sysaux01.dbf'
 17  SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
 18  DEFAULT TABLESPACE users
 19  DATAFILE '+data/orcl/datafile/users01.dbf'
 20  SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
 21  DEFAULT TEMPORARY TABLESPACE tempts1
 22  TEMPFILE '+data/orcl/tempfile/temp01.dbf'
 23  SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
 24  UNDO TABLESPACE undotbs1
 25  DATAFILE '+data/orcl/datafile/undotbs01.dbf'
 26  SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
 27  USER_DATA TABLESPACE usertbs
 28  DATAFILE '+data/orcl/datafile/usertbs01.dbf'
 29  SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

Database created.

9.运行脚本来创建数据字典视图
用sys用户执行以下脚本

SQL> @$ORACLE_HOME/rdbms/admin/catalog.sql

Session altered.

SQL>@$ORACLE_HOME/rdbms/admin/catproc.sql

SQL> Rem END catproc.sql

SQL>@$ORACLE_HOME/rdbms/admin/utlrp.sql

SQL> Rem END utlrp.sql

使用system用户执行以下脚本

SQL>@$ORACLE_HOME/sqlplus/admin/pupbld.sql

SQL> alter session set "_ORACLE_SCRIPT" = false;

Session altered.

10.将数据库注册为RAC数据库,在节点2配置实例orcl2的参数文件

[oracle@jytest2 dbs]$ vi initorcl2.ora
SPFILE='+DATA/orcl/PARAMETERFILE/spfileorcl.ora'

设置RAC数据库所需要的相关参数

SQL> alter system set thread=1 scope=spfile sid='orcl1';

System altered.

SQL> alter system set thread=2 scope=spfile sid='orcl2';

System altered.

SQL> alter system set instance_number=1 scope=spfile sid='orcl1';

System altered.

SQL> alter system set instance_number=2 scope=spfile sid='orcl2';

System altered.

SQL> alter system set cluster_database=true scope=sfpile sid='*';

System altered.

SQL> alter system set cluster_database_instances=2 scope=sfpile sid='*';

System altered.

添加重做线程

SQL> alter database add logfile thread 2 group 4('+data/orcl/onlinelog/redo04.log') SIZE 100M BLOCKSIZE 512;

Database altered.

SQL> alter database add logfile thread 2 group 5('+data/orcl/onlinelog/redo05.log') SIZE 100M BLOCKSIZE 512;

Database altered.

SQL> alter database add logfile thread 2 group 6('+data/orcl/onlinelog/redo06.log') SIZE 100M BLOCKSIZE 512;

Database altered.

SQL> alter database enable thread 2;

Database altered.

向crs注册数据库

[oracle@jytest1 dbs]$ srvctl add database -db orcl -oraclehome  /u01/app/oracle/product/12.2.0/db/  -dbtype RAC -spfile  +DATA/orcl/PARAMETERFILE/spfileorcl.ora -diskgroup 'data'


[oracle@jytest1 dbs]$ srvctl add instance -db orcl -instance orcl1 -node jytest1
[oracle@jytest1 dbs]$ srvctl add instance -db orcl -instance orcl2 -node jytest2
[oracle@jytest1 dbs]$ srvctl config database -db orcl
Database unique name: orcl
Database name:
Oracle home: /u01/app/oracle/product/12.2.0/db/
Oracle user: oracle
Spfile: +DATA/orcl/PARAMETERFILE/spfileorcl.ora
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: orcl1,orcl2
Configured nodes: jytest1,jytest2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

11.将密码文件存储在ASM磁盘组中

[oracle@jytest1 dbs]$ orapwd file='+data/orcl/password/pwdorcl' dbuniquename='orcl'

Enter password for SYS:

ASMCMD [+data/orcl/password] > ls -lt
Type      Redund  Striped  Time             Sys  Name
PASSWORD  UNPROT  COARSE   APR 21 11:00:00  Y    pwdorcl.294.941886275
PASSWORD  UNPROT  COARSE   APR 21 11:00:00  N    pwdorcl =>  +DATA/orcl/PASSWORD/pwdorcl.294.941886275

Enter password for SYS:
[oracle@jytest1 dbs]$ srvctl config database -db orcl
Database unique name: orcl
Database name:
Oracle home: /u01/app/oracle/product/12.2.0/db/
Oracle user: oracle
Spfile: +DATA/orcl/PARAMETERFILE/spfileorcl.ora
Password file: +DATA/orcl/password/pwdorcl
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: orcl1,orcl2
Configured nodes: jytest1,jytest2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

12.检查crs状态信息

[grid@jytest2 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.CRS.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.DATA.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.TEST.dg
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.chad
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.net1.network
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.ons
               ONLINE  ONLINE       jytest1                  STABLE
               ONLINE  ONLINE       jytest2                  STABLE
ora.proxy_advm
               OFFLINE OFFLINE      jytest1                  STABLE
               OFFLINE OFFLINE      jytest2                  STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       jytest1                  169.254.123.145 88.8
                                                             8.88.1,STABLE
ora.asm
      1        ONLINE  ONLINE       jytest1                  Started,STABLE
      2        ONLINE  ONLINE       jytest2                  Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.jy.db
      1        ONLINE  ONLINE       jytest1                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
      2        ONLINE  ONLINE       jytest2                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db,STABLE
ora.jytest1.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.jytest2.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       jytest1                  Open,STABLE
ora.orcl.db
      1        ONLINE  ONLINE       jytest1                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db/,STABLE
      2        ONLINE  ONLINE       jytest2                  Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db/,STABLE
ora.qosmserver
      1        ONLINE  INTERMEDIATE jytest1                  CHECK TIMED OUT,STAB
                                                             LE
ora.scan1.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
--------------------------------------------------------------------------------

到此操作完成!

11.2 rac emctl start dbconsole OC4J Configuration issue

某RAC数据库的em在服务器重启之后,手动执行启动不能成功,错误信息如下:

[oracle@jyrac1 ~]$ emctl start dbconsole
OC4J Configuration issue. /u01/app/oracle/product/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_rac not found. 

上面的信息显示找不到OC4J_DBConsole_jyrac1_rac

查看em配置信息:

[oracle@jyrac1 ~]$ emca -displayConfig dbcontrol -cluster

STARTED EMCA at Nov 23, 2016 2:28:21 PM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle.  All rights reserved.

Enter the following information:
Database unique name: jyrac
Service name: jyrac
Do you wish to continue? [yes(Y)/no(N)]: y
Nov 23, 2016 2:28:32 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/jyrac/emca_2016_11_23_14_28_20.log.
Nov 23, 2016 2:28:35 PM oracle.sysman.emcp.EMDBPostConfig showClusterDBCAgentMessage
INFO: 
****************  Current Configuration  ****************
 INSTANCE            NODE           DBCONTROL_UPLOAD_HOST
----------        ----------        ---------------------

jyrac             jyrac1             jyrac1
jyrac             jyrac2             jyrac1


Enterprise Manager configuration completed successfully
FINISHED EMCA at Nov 23, 2016 2:28:35 PM

如是,检查OC4J_DBConsole_jyrac1_rac目录是否存在:

[oracle@jyrac1 ~]$ cd /u01/app/oracle/product/11.2.0/db/oc4j/j2ee/
[oracle@jyrac1 j2ee]$ ls
deploy_db_wf.ini  oc4j_applications  OC4J_DBConsole_jyrac1_jyrac  OC4J_Workflow_Component_Container   utilities
home              OC4J_DBConsole     OC4J_DBConsole_jyrac2_jyrac  OC4J_Workflow_Management_Container

发现确实不存在,但是存在类似的目录(OC4J_DBConsole_jyrac1_jyrac) ,如是打算copy一份:

[oracle@jyrac1 j2ee]$ cp OC4J_DBConsole_jyrac1_jyrac OC4J_DBConsole_jyrac1_rac

再次启动em,发现缺少jyrac1_rac目录:

[oracle@jyrac1 j2ee]$ emctl start dbconsole
EM Configuration issue. /u01/app/oracle/product/11.2.0/db/jyrac1_rac not found. 

在目录/u01/app/oracle/product/11.2.0/db/发现了类似的jyrac_jyrac目录:

[oracle@jyrac1 db]$ ls -lrt
....
drwxr-----  3 oracle oinstall  4096 Nov 22 19:37 jyrac2_jyrac
drwxr-----  3 oracle oinstall  4096 Nov 22 19:38 jyrac1_jyrac
drwxr-xr-x  7 oracle oinstall  4096 Nov 22 19:39 install
drwxr-----  3 oracle oinstall  4096 Nov 22 19:40 jyrac1_jyrac1
drwxr-xr-x  2 oracle oinstall  4096 Nov 23 08:18 dbs
drwxr-----  3 oracle oinstall  4096 Nov 23 14:36 jyrac1_rac

如是打算copy一份jyrac-rac

[oracle@jyrac1 db]$ cp -r jyrac1_jyrac jyrac1_rac

再次启动EM

[oracle@jyrac1 db]$ emctl status dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0 
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
https://jyrac1:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is not running. 
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/db/jyrac1_rac/sysman/log 
[oracle@jyrac1 db]$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0 
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
https://jyrac1:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ........ started. 
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.2.0/db/jyrac1_rac/sysman/log 

不必须重新创建EM,到此完成。

dbca -silent创建rac数据库

刚好有一个网友问我,dbca -silent是否能创建rac数据库,是否能启用归档,下面是测试过程
一.先删除已经存在的rac数据库jyrac

ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576      5120     4892                0            4892              0             N  BACKUPDG/
MOUNTED  EXTERN  N         512   4096  1048576      5120     4724                0            4724              0             Y  CRSDG/
MOUNTED  EXTERN  N         512   4096  1048576     10240        2                0               2              0             N  DATADG/
ASMCMD> ls -lt
Type           Redund  Striped  Time             Sys  Name
                                                 Y    TEMPFILE/
                                                 Y    PARAMETERFILE/
                                                 Y    ONLINELOG/
                                                 Y    DATAFILE/
                                                 Y    CONTROLFILE/
                                                 N    spfilejyrac.ora => +DATADG/JYRAC/PARAMETERFILE/spfile.268.864825131

[oracle@jyrac1 ~]$ dbca -silent -deleteDatabase -sourceDB jyrac -sysDBAUserName sys -sysDBAPassword system
Connecting to database
9% complete
14% complete
19% complete
23% complete
28% complete
33% complete
38% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instances and datafiles
66% complete
80% complete
95% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/jyrac.log" for further details.
ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576      5120     4892                0            4892              0             N  BACKUPDG/
MOUNTED  EXTERN  N         512   4096  1048576      5120     4724                0            4724              0             Y  CRSDG/
MOUNTED  EXTERN  N         512   4096  1048576     10240    10138                0           10138              0             N  DATADG/
[root@jyrac1 jyrac]# ps -ef | grep pmon
grid      4185     1  0 Jan26 ?        00:01:59 asm_pmon_+ASM1
root     32023 26194  0 16:57 pts/3    00:00:00 grep pmon

[grid@jyrac2 ~]$ ps -ef | grep pmon
grid      4144     1  0 Jan26 ?        00:02:03 asm_pmon_+ASM2
grid     30617 22435  0 16:57 pts/1    00:00:00 grep pmon

说明rac数据库jyrac确实已经删除了,下面以dbca -silent模式来创建rac数据库jyrac

二.使用dbca -silent来创建rac数据库jyrac,并使用-initParams参数设置归档目录,使用-nodeinfo来指定rac节点,但-nodeinfo参数在dbca的帮助信息中并没有显示。

[oracle11@oracle11g ~]$ dbca -help
dbca  [-silent | -progressOnly | -customCreate] {  }  | { [ [options] ] -responseFile   } [-continueOnNonFatalErrors ]
Please refer to the manual for details.
You can enter one of the following command:

Create a database by specifying the following parameters:
        -createDatabase
                -templateName 
                [-cloneTemplate]
                -gdbName 
                [-sid ]
                [-sysPassword ]
                [-systemPassword ]
                [-emConfiguration 
                        -dbsnmpPassword 
                        -sysmanPassword 
                        [-hostUserName 
                         -hostUserPassword 
                         -backupSchedule ]
                        [-centralAgent ]]
                [-disableSecurityConfiguration 
                [-datafileDestination  |  -datafileNames ]
                [-redoLogFileSize ]
                [-recoveryAreaDestination ]
                [-datafileJarLocation  ]
                [-storageType < FS | ASM >
                        [-asmsnmpPassword     ]
                         -diskGroupName   
                         -recoveryGroupName       
                [-characterSet ]
                [-nationalCharacterSet  ]
                [-registerWithDirService 
                        -dirServiceUserName    
                        -dirServicePassword    
                        -walletPassword    ]
                [-listeners  ]
                [-variablesFile   ]]
                [-variables  ]
                [-initParams ]
                [-sampleSchema   ]
                [-memoryPercentage ]
                [-automaticMemoryManagement ]
                [-totalMemory ]
                [-databaseType ]]

Configure a database by specifying the following parameters:
        -configureDatabase
                -sourceDB    
                [-sysDBAUserName     
                 -sysDBAPassword     ]
                [-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword 
                        -dirServiceUserName    
                        -dirServicePassword    
                        -walletPassword    ]
                [-disableSecurityConfiguration 
                [-enableSecurityConfiguration 
                [-emConfiguration 
                        -dbsnmpPassword 
                        -sysmanPassword 
                        [-hostUserName 
                         -hostUserPassword 
                         -backupSchedule ]
                        [-centralAgent ]]


Create a template from an existing database by specifying the following parameters:
        -createTemplateFromDB
                -sourceDB    ::>
                -templateName      
                -sysDBAUserName     
                -sysDBAPassword     
                [-maintainFileLocations ]


Create a clone template from an existing database by specifying the following parameters:
        -createCloneTemplate
                -sourceSID    
                -templateName      
                [-sysDBAUserName     
                 -sysDBAPassword     ]
                [-maintainFileLocations ]
                [-datafileJarLocation       ]

Generate scripts to create database by specifying the following parameters:
        -generateScripts
                -templateName 
                -gdbName 
                [-scriptDest       ]

Delete a database by specifying the following parameters:
        -deleteDatabase
                -sourceDB    
                [-sysDBAUserName     
                 -sysDBAPassword     ]
Query for help by specifying the following options: -h | -help

下面创建rac数据库jyrac,使用-initParams参数设置了归档目录为+backupdg/,节点为jyrac1,jyrac2

[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname jyrac  -sid jyrac -datafileDestination 'datadg/' -redoLogFileSize 50 -recoveryAreaDestination 'datadg/' -storageType ASM -asmsnmpPassword system  -diskGroupName 'datadg' -responseFile NO_VALUE -characterset ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -automaticMemoryManagement true -totalMemory 500 -initParams log_archive_dest_1='location=+backupdg/' -nodeinfo jyrac1,jyrac2
Enter SYS user password:

Enter SYSTEM user password:

Copying database files
1% complete
3% complete
9% complete
15% complete
21% complete
27% complete
30% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
44% complete
45% complete
48% complete
50% complete
Creating cluster database views
52% complete
70% complete
Completing Database Creation
73% complete
76% complete
85% complete
94% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/jyrac/jyrac.log" for further details.

三.检查数据库状态

[root@jyrac1 ~]# ps -ef | grep pmon
grid      4185     1  0 Jan26 ?        00:01:59 asm_pmon_+ASM1
oracle    6545     1  0 17:33 ?        00:00:00 ora_pmon_jyrac1
root      7059  6061  0 17:36 pts/4    00:00:00 grep pmon
[grid@jyrac2 ~]$  ps -ef | grep pmon
grid      4144     1  0 Jan26 ?        00:02:03 asm_pmon_+ASM2
oracle    6320     1  0 17:34 ?        00:00:00 ora_pmon_jyrac2
grid      6756 22435  0 17:36 pts/1    00:00:00 grep pmon

[grid@jyrac2 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.BACKUPDG.dg
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.CRSDG.dg
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.DATADG.dg
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.LISTENER.lsnr
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.asm
               ONLINE  ONLINE       jyrac1                   Started
               ONLINE  ONLINE       jyrac2                   Started
ora.gsd
               OFFLINE OFFLINE      jyrac1
               OFFLINE OFFLINE      jyrac2
ora.net1.network
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.ons
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.registry.acfs
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jyrac2
ora.cvu
      1        ONLINE  ONLINE       jyrac2
ora.jyrac.db
      1        ONLINE  ONLINE       jyrac1                   Open
      2        ONLINE  ONLINE       jyrac2                   Open
ora.jyrac1.vip
      1        ONLINE  ONLINE       jyrac1
ora.jyrac2.vip
      1        ONLINE  ONLINE       jyrac2
ora.oc4j
      1        ONLINE  ONLINE       jyrac2
ora.scan1.vip
      1        ONLINE  ONLINE       jyrac2


[grid@jyrac2 ~]$ srvctl status database -d jyrac
Instance jyrac1 is running on node jyrac1
Instance jyrac2 is running on node jyrac2

[grid@jyrac2 ~]$ srvctl config database -d jyrac
Database unique name: jyrac
Database name: jyrac
Oracle home: /u01/app/oracle/product/11.2.0/db
Oracle user: oracle
Spfile: +DATADG/jyrac/spfilejyrac.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: jyrac
Database instances: jyrac1,jyrac2
Disk Groups: DATADG
Mount point paths:
Services:
Type: RAC
Database is administrator managed

[grid@jyrac2 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-APR-2015 17:39:01

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                26-JAN-2015 10:48:15
Uptime                    81 days 6 hr. 50 min. 46 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/11.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/jyrac2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.154)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "jyrac" has 1 instance(s).
  Instance "jyrac2", status READY, has 1 handler(s) for this service...
Service "jyracXDB" has 1 instance(s).
  Instance "jyrac2", status READY, has 1 handler(s) for this service...
The command completed successfully

[grid@jyrac2 ~]$ lsnrctl status listener_scan1

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-APR-2015 17:39:33

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_SCAN1
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                26-JAN-2015 10:48:10
Uptime                    81 days 6 hr. 51 min. 23 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/11.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/product/11.2.0/crs/log/diag/tnslsnr/jyrac2/listener_scan1/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.159)(PORT=1521)))
Services Summary...
Service "jyrac" has 2 instance(s).
  Instance "jyrac1", status READY, has 1 handler(s) for this service...
  Instance "jyrac2", status READY, has 1 handler(s) for this service...
Service "jyracXDB" has 2 instance(s).
  Instance "jyrac1", status READY, has 1 handler(s) for this service...
  Instance "jyrac2", status READY, has 1 handler(s) for this service...
The command completed successfully
[grid@jyrac1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-APR-2015 17:39:08

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                26-JAN-2015 10:48:32
Uptime                    81 days 6 hr. 50 min. 36 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/11.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/jyrac1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.153)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "DBUA4235414" has 1 instance(s).
  Instance "DBUA4235414", status BLOCKED, has 1 handler(s) for this service...
Service "jyrac" has 1 instance(s).
  Instance "jyrac1", status READY, has 1 handler(s) for this service...
Service "jyracXDB" has 1 instance(s).
  Instance "jyrac1", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@jyrac1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Apr 17 17:40:53 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
jyrac1

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            +BACKUPDG
Oldest online log sequence     4
Current log sequence           5

[oracle@jyrac2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Apr 17 17:40:35 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
jyrac2

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            +BACKUPDG
Oldest online log sequence     1
Current log sequence           1

数据库虽然指定了归档目录,但是没有启动归档。

四.使用dbca -silent方式创建rac数据库的使用示例,更详细信息请阅读Real Application Clusters Installation Guide

Using DBCA Noninteractive (Silent) Configuration for Oracle RAC

You can perform a noninteractive, or “silent” configuration of Oracle RAC using DBCA. To perform a silent configuration, you must have completed an Oracle Clusterware installation, run the root.sh script from the Oracle Database or Oracle ASM homes, and defined the Oracle home and ASM home directory environment variables.

The following command syntax creates an ASM instance and one disk group:

# su oracle -c “$ORA_ASM_HOME/bin/dbca -silent -configureASM -gdbName NO -sid NO -emConfiguration NONE -diskList ASM_Disks -diskGroupName ASM_Group_Name -datafileJarLocation $ORACLE_HOME/assistants/dbca/templates -nodeinfo $NODE1,$NODE2 -obfuscatedPasswords false -asmSysPassword My_ASM_password -redundancy ASM_redundancy”

In the preceding syntax example:

ASM_Disks represent disk addresses, such as /dev/sda1,/dev/sdb1
ASM_Group_Name represents the name of an ASM disk group
ASM_ Redundancy represents an ASM disk redundancy setting, such as ‘NORMAL’.
My_ASM_password represents the ASM SYS user password.
The following command syntax creates an Oracle RAC database on an existing ASM disk group, where the cluster nodes are node1 and node2, and where the disk group name is ASMgrp1, the passwords are my_password, and the ASM SYS password is My_ASM_Password:

# su oracle -c “$ORACLE_HOME/bin/dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName $DBNAME -sid $SID -sysPassword my_password -systemPassword my_password -sysmanPassword my_password -dbsnmpPassword my_password -emConfiguration LOCAL -storageType ASM -diskGroupName ASMgrp1 -datafileJarLocation $ORACLE_HOME/assistants/dbca/templates -nodeinfo node1,node2 -characterset WE8ISO8859P1 -obfuscatedPasswords false -sampleSchema false -asmSysPassword My_ASM_password”

dbca -silent方式可以创建rac数据库,并指定归档目录,但没有选项设置归档,还是需要执行alter database archivelog来启动归档。网友lhrbest后面通过修改创建数据库的模板文件(创建数据库的模板文件存储在$ORACLE_HOME/assistants/dbca/templates目录中)中的参数 <archivelogmode>false</archivelogmode>,将false修改为true就可以完成归档,下面是通用目的数据库模板文件
[oracle@jyrac1 templates]$ cat General_Purpose.dbc
…省略…
<archivelogmode>false</archivelogmode&gt
…省略…

下面对General_Purpose.dbc文件创建一份副本并启用归档

[oracle@jyrac1 templates]$ cp General_Purpose.dbc General_Purpose_archivelog.dbc
[oracle@jyrac1 templates]$ vi General_Purpose_archivelog.dbc
…省略…
<archivelogmode>true</archivelogmode&gt
…省略…

再次删除rac数据库jyrac

[oracle@jyrac2 ~]$ dbca -silent -deleteDatabase -sourceDB jyrac -sysDBAUserName sys -sysDBAPassword system
Connecting to database
9% complete
14% complete
19% complete
23% complete
28% complete
33% complete
38% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instances and datafiles
66% complete
80% complete
95% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/jyrac.log" for further details.
ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576      5120     4892                0            4892              0             N  BACKUPDG/
MOUNTED  EXTERN  N         512   4096  1048576      5120     4724                0            4724              0             Y  CRSDG/
MOUNTED  EXTERN  N         512   4096  1048576     10240    10138                0           10138              0             N  DATADG/

[root@jyrac1 jyrac]# ps -ef | grep pmon
grid      4185     1  0 Jan26 ?        00:01:59 asm_pmon_+ASM1
root     32023 26194  0 16:57 pts/3    00:00:00 grep pmon

[grid@jyrac2 ~]$ ps -ef | grep pmon
grid      4144     1  0 Jan26 ?        00:02:03 asm_pmon_+ASM2
grid     30617 22435  0 16:57 pts/1    00:00:00 grep pmon

使用新创建的模板文件来创建数据库:

[oracle@jyrac1 templates]$ dbca -silent -createDatabase -templateName General_Purpose_archivelog.dbc -gdbname jyrac  -sid jyrac -datafileDestination 'datadg/' -redoLogFileSize 50 -recoveryAreaDestination 'datadg/' -storageType ASM -asmsnmpPassword system  -diskGroupName 'datadg' -responseFile NO_VALUE -characterset ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -automaticMemoryManagement true -totalMemory 500 -initParams log_archive_dest_1='location=+backupdg/' -nodeinfo jyrac1,jyrac2
Enter SYS user password:

Enter SYSTEM user password:

Copying database files
1% complete
3% complete
9% complete
15% complete
21% complete
27% complete
30% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
44% complete
45% complete
48% complete
50% complete
Creating cluster database views
52% complete
70% complete
Completing Database Creation
73% complete
76% complete
85% complete
94% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/jyrac/jyrac0.log" for further details.

检查数据库状态:

[grid@jyrac1 ~]$ ps -ef | grep pmon
grid      4185     1  0 Jan26 ?        00:02:02 asm_pmon_+ASM1
oracle   18015     1  0 18:06 ?        00:00:00 ora_pmon_jyrac1
grid     18377 18077  0 18:08 pts/4    00:00:00 grep pmon

[grid@jyrac2 ~]$ ps -ef | grep pmon
grid      4144     1  0 Jan26 ?        00:02:06 asm_pmon_+ASM2
oracle    8184     1  0 18:07 ?        00:00:00 ora_pmon_jyrac2
grid      8398  7717  0 18:08 pts/2    00:00:00 grep pmon
[grid@jyrac2 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.BACKUPDG.dg
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.CRSDG.dg
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.DATADG.dg
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.LISTENER.lsnr
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.asm
               ONLINE  ONLINE       jyrac1                   Started
               ONLINE  ONLINE       jyrac2                   Started
ora.gsd
               OFFLINE OFFLINE      jyrac1
               OFFLINE OFFLINE      jyrac2
ora.net1.network
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.ons
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
ora.registry.acfs
               ONLINE  ONLINE       jyrac1
               ONLINE  ONLINE       jyrac2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       jyrac2
ora.cvu
      1        ONLINE  ONLINE       jyrac2
ora.jyrac.db
      1        ONLINE  ONLINE       jyrac1                   Open
      2        ONLINE  ONLINE       jyrac2                   Open
ora.jyrac1.vip
      1        ONLINE  ONLINE       jyrac1
ora.jyrac2.vip
      1        ONLINE  ONLINE       jyrac2
ora.oc4j
      1        ONLINE  ONLINE       jyrac2
ora.scan1.vip
      1        ONLINE  ONLINE       jyrac2
[grid@jyrac2 ~]$ srvctl status database -d jyrac
Instance jyrac1 is running on node jyrac1
Instance jyrac2 is running on node jyrac2

[grid@jyrac2 ~]$ srvctl config database -d jyrac
Database unique name: jyrac
Database name: jyrac
Oracle home: /u01/app/oracle/product/11.2.0/db
Oracle user: oracle
Spfile: +DATADG/jyrac/spfilejyrac.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: jyrac
Database instances: jyrac1,jyrac2
Disk Groups: DATADG
Mount point paths:
Services:
Type: RAC
Database is administrator managed
[grid@jyrac1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-APR-2015 18:09:58

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                26-JAN-2015 10:48:32
Uptime                    83 days 7 hr. 21 min. 25 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/11.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/jyrac1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.153)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "DBUA4235414" has 1 instance(s).
  Instance "DBUA4235414", status BLOCKED, has 1 handler(s) for this service...
Service "jyrac" has 1 instance(s).
  Instance "jyrac1", status READY, has 1 handler(s) for this service...
Service "jyracXDB" has 1 instance(s).
  Instance "jyrac1", status READY, has 1 handler(s) for this service...
The command completed successfully

Database is administrator managed

[grid@jyrac2 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-APR-2015 18:09:54

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                26-JAN-2015 10:48:15
Uptime                    83 days 7 hr. 21 min. 40 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/11.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/jyrac2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.154)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "jyrac" has 1 instance(s).
  Instance "jyrac2", status READY, has 1 handler(s) for this service...
Service "jyracXDB" has 1 instance(s).
  Instance "jyrac2", status READY, has 1 handler(s) for this service...
The command completed successfully
[grid@jyrac2 ~]$ lsnrctl status listener_scan1

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-APR-2015 18:10:43

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_SCAN1
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                26-JAN-2015 10:48:10
Uptime                    83 days 7 hr. 22 min. 33 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/11.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/product/11.2.0/crs/log/diag/tnslsnr/jyrac2/listener_scan1/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.159)(PORT=1521)))
Services Summary...
Service "jyrac" has 2 instance(s).
  Instance "jyrac1", status READY, has 1 handler(s) for this service...
  Instance "jyrac2", status READY, has 1 handler(s) for this service...
Service "jyracXDB" has 2 instance(s).
  Instance "jyrac1", status READY, has 1 handler(s) for this service...
  Instance "jyrac2", status READY, has 1 handler(s) for this service...
The command completed successfully

检查归档设置:

[oracle@jyrac1 templates]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Apr 19 18:11:17 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +BACKUPDG
Oldest online log sequence     4
Next log sequence to archive   5
Current log sequence           5

SQL> alter system switch logfile;

System altered.

[oracle@jyrac2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Apr 19 18:11:51 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +BACKUPDG
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2
SQL> alter system switch logfile;

System altered.
ASMCMD> pwd
+backupdg/jyrac/archivelog/2015_04_19
ASMCMD> ls -lt
Type        Redund  Striped  Time             Sys  Name
ARCHIVELOG  UNPROT  COARSE   APR 19 18:00:00  Y    thread_2_seq_2.306.877457527
ARCHIVELOG  UNPROT  COARSE   APR 19 18:00:00  Y    thread_2_seq_1.307.877457191
ARCHIVELOG  UNPROT  COARSE   APR 19 18:00:00  Y    thread_1_seq_5.312.877457503

可以看到确实启用了归档,在执行alter system switch logfile命令后两个实例都生成了归档重做日志,使用模板来创建数据库,还是需要仔细阅读模板文件中的参数,这里谢谢网友lhrbest,dbca- silent是可以创建rac数据库,可以通过-initParams参数设置归档目录,通过修改创建数据库的模板文件中archivelogmode参数启用归档。

Proudly powered by WordPress | Indrajeet by Sus Hill.