Linux Use ODBC Connect Oracle

因为工作需要,需要使用ODBC访问Oracle,下面是ODBC访问Oracle的具体配置
1.下载unixODBC和Oracle简易客户端软件包
1.1下载地址:

http://www.unixodbc.org/

1.1.1下载文件:

unixODBC-2.3.0.tar.gz

2 Oracle ODBC Driver
2.1下载地址:

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

2.1.1下载文件:

instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
instantclient-basic-linux.x64-12.2.0.1.0.zip
instantclient-sdk-linux.x64-12.2.0.1.0.zip
instantclient-jdbc-linux.x64-12.2.0.1.0.zip
instantclient-odbc-linux.x64-12.2.0.1.0-2.zip
instantclient-basiclite-linux.x64-12.2.0.1.0.zip
instantclient-tools-linux.x64-12.2.0.1.0.zip

将这些软件包上传到/soft目录

3.安装unixODBC(root用户)

#cd /soft
#tar xvf unixODBC-2.3.0.tar.gz
#cd /soft/unixODBC-2.3.0
#./configure
#make
#make install

(默认是被安装到/usr/local)

4.安装Oracle ODBC(root用户)

#cd /soft/
#unzip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
#unzip instantclient-basic-linux.x64-12.2.0.1.0.zip
#unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip
#unzip instantclient-jdbc-linux.x64-12.2.0.1.0.zip
#unzip instantclient-odbc-linux.x64-12.2.0.1.0-2.zip
#unzip instantclient-basiclite-linux.x64-12.2.0.1.0.zip
#unzip instantclient-tools-linux.x64-12.2.0.1.0.zip
[root@dmks instantclient_12_2]# ./odbc_update_ini.sh /usr/local
 *** ODBCINI environment variable not set,defaulting it to HOME directory!

更新操作完成后,会在/usr/local/etc/odbcinst.ini增加Oracle12C的驱动描述信息。

[root@dmks etc]# cat odbcinst.ini
[DM7 ODBC DRIVER]
Description = ODBC DRIVER FOR DM7
Driver = /dm_home/dmdbms/bin/libdodbc.so


[Oracle 12c ODBC driver]
Description     = Oracle ODBC driver for Oracle 12c
Driver          = /soft/instantclient_12_2/libsqora.so.12.1
Setup           =
FileUsage       =
CPTimeout       =
CPReuse         =

并且会在HOME目录下也就是/root,生成.odbc.ini文件,修改.odbc.ini文件

[root@dmks ~]# cat .odbc.ini
[OracleODBC-12c]
Application Attributes = T
Attributes = W
BatchAutocommitMode = IfAllSuccessful
BindAsFLOAT = F
CloseCursor = F
DisableDPM = F
DisableMTS = T
Driver = Oracle 12c ODBC driver
DSN = OracleODBC-12c
EXECSchemaOpt =
EXECSyntax = T
Failover = T
FailoverDelay = 10
FailoverRetryCount = 10
FetchBufferSize = 64000
ForceWCHAR = F
Lobs = T
Longs = T
MaxLargeData = 0
MetadataIdDefault = F
QueryTimeout = T
ResultSets = T
ServerName = shardcat 与tnsnames.ora文件中的服务器一致
SQLGetData extensions = F
Translation DLL =
Translation Option = 0
DisableRULEHint = T
UserID =
StatementCache=F
CacheBufferSize=20
UseOCIDescribeAny=F
SQLTranslateErrors=F
MaxTokenSize=8192
AggregateSQLType=FLOAT
5.测试ODBC连接Oracle
[root@dmks ~]# isql  OracleODBC-12c system xxzx7817600 -v
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select * from v$version;
+---------------------------------------------------------------------------------+-----------------------------------------+
| BANNER                                                                          | CON_ID                                  |
+---------------------------------------------------------------------------------+-----------------------------------------+
| Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production    | 0                                       |
| PL/SQL Release 12.2.0.1.0 - Production                                          | 0                                       |
| CORE  12.2.0.1.0      Production                                                      | 0                                       
| TNS for Linux: Version 12.2.0.1.0 - Production                                  | 0                                       |
| NLSRTL Version 12.2.0.1.0 - Production                                          | 0                                       |
+---------------------------------------------------------------------------------+-----------------------------------------+

到此使用odbc连接Oracle的操作完成,还是很简单的。

18C RAC DBCA建库时找不到ASM磁盘

在Oracle Linux 7.1中使用dbca为Oracle 18C RAC创建数据库时,找不到ASM磁盘组;而grid用户使用asmca却又能看到ASM磁盘组。

解决方法
1. 检查创建ASM磁盘设备的权限,正确的权限为grid:asmadmin,通过下面输出可知权限正确

[root@18c1 ~]# ls -lrt /dev/asm*
brw-rw---- 1 grid asmadmin 8, 16 Mar 16 22:28 /dev/asmdisk01
brw-rw---- 1 grid asmadmin 8, 32 Mar 17 08:40 /dev/asmdisk02

[root@18c2 ~]# ls -lrt /dev/asm*
brw-rw---- 1 grid asmadmin 8, 32 Mar 17 08:41 /dev/asmdisk02
brw-rw---- 1 grid asmadmin 8, 16 Mar 17 08:41 /dev/asmdisk01

2.检查ASM实例是否启动

[grid@18c1 ~]$ 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  EXTERN  N         512             512   4096  4194304     61440    35868                0           35868              0             Y  CRS/
MOUNTED  EXTERN  N         512             512   4096  4194304     40960    36036                0           36036              0             N  DATA/

[grid@18c2 ~]$ 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  EXTERN  N         512             512   4096  4194304     61440    35868                0           35868              0             Y  CRS/
MOUNTED  EXTERN  N         512             512   4096  4194304     40960    36036                0           36036              0             N  DATA/

3. 检查GRID_HOME/bin下oracle是否有s权限,如果没有需要添加s权限,通过下面的输出可知GRID_HOME/bin目录下的oracle是没有s权限的,这里需要添加

[root@18c1 ~]# ls -lrt /u01/app/oracle/18.0.0/db/bin/oracle
-rwsr-s--x 1 oracle asmadmin 437038067 Mar 16 23:00 /u01/app/oracle/18.0.0/db/bin/oracle
[root@18c1 ~]# ls -lrt /u01/app/18.0.0/grid/bin/oracle
-rwxr-x--x. 1 grid oinstall 413877125 Mar 16 19:10 /u01/app/18.0.0/grid/bin/oracle
[root@18c2 /]# ls -lrt /u01/app/oracle/18.0.0/db/bin/oracle
-rwsr-s--x 1 oracle oinstall 437038067 Mar 16 23:07 /u01/app/oracle/18.0.0/db/bin/oracle
[root@18c2 /]# ls -lrt /u01/app/18.0.0/grid/bin/oracle
-rwxr-x--x. 1 grid oinstall 413877125 Mar 16 19:30 /u01/app/18.0.0/grid/bin/oracle

[root@18c1 ~]# chmod +s /u01/app/18.0.0/grid/bin/oracle
[root@18c1 ~]# ls -lrt /u01/app/18.0.0/grid/bin/oracle
-rwsr-s--x. 1 grid oinstall 413877125 Mar 16 19:10 /u01/app/18.0.0/grid/bin/oracle

[root@18c2 /]# chmod +s /u01/app/18.0.0/grid/bin/oracle
[root@18c2 /]# ls -lrt /u01/app/18.0.0/grid/bin/oracle
-rwsr-s--x. 1 grid oinstall 413877125 Mar 16 19:30 /u01/app/18.0.0/grid/bin/oracle

4.检查用户所有组

[root@18c1 ~]# id oracle
uid=1001(oracle) gid=1011(oinstall) groups=1007(asmdba),1009(dba),1010(oper),1012(backupdba),1013(dgdba),1014(kmdba),1015(racdba),1011(oinstall)
[root@18c1 ~]# id grid
uid=1002(grid) gid=1011(oinstall) groups=1006(asmadmin),1007(asmdba),1008(asmoper),1009(dba),1011(oinstall)
[root@18c1 ~]# gpasswd -a oracle asmadmin
Adding user oracle to group asmadmin
[root@18c1 ~]# id oracle
uid=1001(oracle) gid=1011(oinstall) groups=1006(asmadmin),1007(asmdba),1009(dba),1010(oper),1012(backupdba),1013(dgdba),1014(kmdba),1015(racdba),1011(oinstall)

[root@18c2 /]# id oracle
uid=1001(oracle) gid=1011(oinstall) groups=1007(asmdba),1009(dba),1010(oper),1012(backupdba),1013(dgdba),1014(kmdba),1015(racdba),1011(oinstall)
[root@18c2 /]# id grid
uid=1002(grid) gid=1011(oinstall) groups=1006(asmadmin),1007(asmdba),1008(asmoper),1009(dba),1011(oinstall)
[root@18c2 /]# gpasswd -a oracle asmadmin
Adding user oracle to group asmadmin
[root@18c2 /]# id oracle
uid=1001(oracle) gid=1011(oinstall) groups=1006(asmadmin),1007(asmdba),1009(dba),1010(oper),1012(backupdba),1013(dgdba),1014(kmdba),1015(racdba),1011(oinstall)

再执行dbca创建数据库时能正确找到磁盘组

Oracle Linux 7.1 Install Oracle 19C RAC

安装环境为Oracle Linux 7.1,Oracle版本为19C,下面是RAC环境的IP配置

ip地址          主机名                   类型     解析方式 
10.10.10.190  19c1                    public   DNS或etc/hosts 
10.10.10.191  19c2                    public   DNS或etc/hosts 
88.88.88.1    19c1-priv               private  DNS或etc/hosts 
88.88.88.2    19c2-priv               private  DNS或etc/hosts 
10.10.10.192  19c1-vip                virtual  DNS或etc/hosts 
10.10.10.193  19c2-vip                virtual  DNS或etc/hosts
10.10.10.194  hy-scan                 scan     DNS或etc/hosts
10.10.10.195  hy-scan                 scan     DNS或etc/hosts
10.10.10.196  hy-scan                 scan     DNS或etc/hosts

[root@19c1 /]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.10.10.190 19c1
10.10.10.191 19c2
88.88.88.1 19c1-priv
88.88.88.2 19c2-priv
10.10.10.192 19c1-vip
10.10.10.193 19c2-vip

10.10.10.194 hy-scan
10.10.10.195 hy-scan
10.10.10.196 hy-scan


[root@19c2 /]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.190 19c1
10.10.10.191 19c2
88.88.88.1 19c1-priv
88.88.88.2 19c2-priv
10.10.10.192 19c1-vip
10.10.10.193 19c2-vip

10.10.10.194 hy-scan
10.10.10.195 hy-scan
10.10.10.196 hy-scan

创建用户组

[root@19c1 /]# groupadd -g 1006 asmadmin
[root@19c1 /]# groupadd -g 1007 asmdba
[root@19c1 /]# groupadd -g 1008 asmoper
[root@19c1 /]# groupadd -g 1009 dba
[root@19c1 /]# groupadd -g 1010 oper
[root@19c1 /]# groupadd -g 1011 oinstall
[root@19c1 /]# groupadd -g 1012 backupdba
[root@19c1 /]# groupadd -g 1013 dgdba
[root@19c1 /]# groupadd -g 1014 kmdba
[root@19c1 /]# groupadd -g 1015 racdba

[root@19c2 /]# groupadd -g 1006 asmadmin
[root@19c2 /]# groupadd -g 1007 asmdba
[root@19c2 /]# groupadd -g 1008 asmoper
[root@19c2 /]# groupadd -g 1009 dba
[root@19c2 /]# groupadd -g 1010 oper
[root@19c2 /]# groupadd -g 1011 oinstall
[root@19c2 /]# groupadd -g 1012 backupdba
[root@19c2 /]# groupadd -g 1013 dgdba
[root@19c2 /]# groupadd -g 1014 kmdba
[root@19c2 /]# groupadd -g 1015 racdba

创建用户

[root@19c1 /]# useradd  -u 1001 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper,asmadmin oracle
[root@19c1 /]# useradd  -u 1002 -g oinstall -G asmadmin,asmdba,asmoper,dba grid


[root@19c2 /]# useradd  -u 1001 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper,asmadmin oracle
[root@19c2 /]# useradd  -u 1002 -g oinstall -G asmadmin,asmdba,asmoper,dba grid

[root@19c1 /]# passwd grid
Changing password for user grid.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

[root@19c1 /]# passwd oracle
Changing password for user grid.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

[root@19c2 /]# passwd grid
Changing password for user grid.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

[root@19c2 /]# passwd oracle
Changing password for user grid.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

配置ASM所需磁盘,编辑/etc/udev/rules.d/99-my-asmdevices.rules配置文件

[root@19c1 /]# cd /etc/udev/rules.d/
[root@19c1 rules.d]# ls -lrt
总用量 4
-rw-r--r--. 1 root root 709 3月   6 2015 70-persistent-ipoib.rules
[root@19c1 rules.d]# vi 99-my-asmdevices.rules
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block",  PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode",  RESULT=="36000c29e40b943ae6772ffb254910685", RUN+="/bin/sh -c 'mknod /dev/asmdisk01 b  $major $minor; chown grid:asmadmin /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=="36000c29a2bcbd0e7f1843df54da0baa6", RUN+="/bin/sh -c 'mknod /dev/asmdisk02 b  $major $minor; chown grid:asmadmin /dev/asmdisk02; chmod 0660 /dev/asmdisk02'"


[root@19c2 rules.d]# vi 99-my-asmdevices.rules
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block",  PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode",  RESULT=="36000c29e40b943ae6772ffb254910685", RUN+="/bin/sh -c 'mknod /dev/asmdisk01 b  $major $minor; chown grid:asmadmin /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=="36000c29a2bcbd0e7f1843df54da0baa6", RUN+="/bin/sh -c 'mknod /dev/asmdisk02 b  $major $minor; chown grid:asmadmin /dev/asmdisk02; chmod 0660 /dev/asmdisk02'" 

[root@19c1 rules.d]# /sbin/udevadm trigger --type=devices --action=change 
[root@19c2 rules.d]# /sbin/udevadm trigger --type=devices --action=change

[root@19c1 rules.d]#  ls -lrt /dev/asm*
brw-rw----. 1 grid asmadmin 8, 32 3月  16 19:16 /dev/asmdisk02
brw-rw----. 1 grid asmadmin 8, 16 3月  16 19:16 /dev/asmdisk01


[root@19c2 rules.d]#  ls -lrt /dev/asm*
brw-rw----. 1 grid asmadmin 8, 32 Mar 16 19:15 /dev/asmdisk02
brw-rw----. 1 grid asmadmin 8, 16 Mar 16 19:15 /dev/asmdisk01


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

[root@19c1 /]# mkdir -p /u01/app/oraInventory
[root@19c2 /]# mkdir -p /u01/app/oraInventory

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

[root@19c1 /]#  mkdir -p /u01/app/grid
[root@19c2 /]#  mkdir -p /u01/app/grid

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

[root@19c1 /]# mkdir -p /u01/app/19.0.0/grid
[root@19c2 /]# mkdir -p /u01/app/19.0.0/grid
[root@19c1 /]# chown -R grid:oinstall /u01
[root@19c1 /]# chmod -R 775 /u01
[root@19c2 /]# chown -R grid:oinstall /u01
[root@19c2 /]# chmod -R 775 /u01

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

[root@19c1 /]#  mkdir -p /u01/app/oracle
[root@19c2 /]#  mkdir -p /u01/app/oracle

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

[root@19c1 /]# mkdir -p /u01/app/oracle/19.0.0/db
[root@19c2 /]# mkdir -p /u01/app/oracle/19.0.0/db
[root@19c1 /]# chown -R oracle:oinstall /u01/app/oracle
[root@19c1 /]# chmod -R 775 /u01/app/oracle
[root@19c2 /]# chown -R oracle:oinstall /u01/app/oracle
[root@19c2 /]# chmod -R 775 /u01/app/oracle

创建一个tmp目录

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

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

设置环境变量

[grid@19c1 ~]$ 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/19.0.0/grid
export ORACLE_SID=+ASM1
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 

[grid@19c2 ~]$ 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/19.0.0/grid
export ORACLE_SID=+ASM2
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


[root@19c1 /]# su - oracle
[oracle@19c1 ~]$ 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/oracle
export ORACLE_HOME=/u01/app/oracle/19.0.0/db
export ORACLE_SID=hy1
export ORACLE_UNQNAME=hy
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

[root@19c2 /]# su - oracle
-bash: /home/oracle: 是一个目录
[oracle@19c2 ~]$ 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/oracle
export ORACLE_HOME=/u01/app/oracle/19.0.0/db
export ORACLE_SID=hy2
export ORACLE_UNQNAME=hy
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文件

[root@19c1 /]# vi /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

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
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304

[root@19c1 /]# 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
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304

[root@19c2 /]# vi /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

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
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304

[root@19c2 /]# 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
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304

修改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

解压GI安装压缩包:

[grid@jytest1 soft]cd /soft/
[grid@19c1 soft]$ unzip Oracle_Database_Grid_Infrastructure_19_2_0_0_0_for_Linux_x86-64.zip -d /u01/app/19.0.0/grid/

这里使用xshell与xmanager来执行安装

[root@19c1 ~]# xhost +
access control disabled, clients can connect from any host
[root@19c1 ~]# su - grid
??′ε??£o? 3? 16 19:55:59 CST 2020pts/0 ?
[grid@19c1 ~]$ cd $ORACLE_HOME
[grid@19c1 grid]$ export DISPLAY=10.138.130.242:0.0
[grid@19c1 grid]$ ./gridSetup.sh
 




















以root用户分别在两个节点上执行以下脚本,先在主节点执行。

[[root@19c1 /]# ./u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.

[root@19c2 /]# ./u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.

[root@19c1 /]# ./u01/app/19.0.0/grid/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= grid
    ORACLE_HOME=  /u01/app/19.0.0/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
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.
Relinking oracle with rac_on option
Using configuration parameter file: /u01/app/19.0.0/grid/crs/install/crsconfig_params
The log of current session can be found at:
  /u01/app/grid/crsdata/19c1/crsconfig/rootcrs_19c1_2020-03-16_10-18-52PM.log
2020/03/16 22:19:07 CLSRSC-594: Executing installation step 1 of 19: 'SetupTFA'.
2020/03/16 22:19:08 CLSRSC-594: Executing installation step 2 of 19: 'ValidateEnv'.
2020/03/16 22:19:08 CLSRSC-363: User ignored prerequisites during installation
2020/03/16 22:19:08 CLSRSC-594: Executing installation step 3 of 19: 'CheckFirstNode'.
2020/03/16 22:19:11 CLSRSC-594: Executing installation step 4 of 19: 'GenSiteGUIDs'.
2020/03/16 22:19:13 CLSRSC-594: Executing installation step 5 of 19: 'SetupOSD'.
2020/03/16 22:19:13 CLSRSC-594: Executing installation step 6 of 19: 'CheckCRSConfig'.
2020/03/16 22:19:13 CLSRSC-594: Executing installation step 7 of 19: 'SetupLocalGPNP'.
2020/03/16 22:19:44 CLSRSC-594: Executing installation step 8 of 19: 'CreateRootCert'.
2020/03/16 22:19:45 CLSRSC-4002: Successfully installed Oracle Trace File Analyzer (TFA) Collector.
2020/03/16 22:19:51 CLSRSC-594: Executing installation step 9 of 19: 'ConfigOLR'.
2020/03/16 22:20:06 CLSRSC-594: Executing installation step 10 of 19: 'ConfigCHMOS'.
2020/03/16 22:20:06 CLSRSC-594: Executing installation step 11 of 19: 'CreateOHASD'.
2020/03/16 22:20:15 CLSRSC-594: Executing installation step 12 of 19: 'ConfigOHASD'.
2020/03/16 22:20:16 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'
2020/03/16 22:20:46 CLSRSC-594: Executing installation step 13 of 19: 'InstallAFD'.
2020/03/16 22:20:56 CLSRSC-594: Executing installation step 14 of 19: 'InstallACFS'.
2020/03/16 22:21:06 CLSRSC-594: Executing installation step 15 of 19: 'InstallKA'.
2020/03/16 22:21:16 CLSRSC-594: Executing installation step 16 of 19: 'InitConfig'.

ASM has been created and started successfully.

[DBT-30001] Disk groups created successfully. Check /u01/app/grid/cfgtoollogs/asmca/asmca-200316PM102150.log for details.

2020/03/16 22:22:41 CLSRSC-482: Running command: '/u01/app/19.0.0/grid/bin/ocrconfig -upgrade grid oinstall'
CRS-4256: Updating the profile
Successful addition of voting disk dda88fad4f094f1cbf686f6a903d8f9c.
Successfully replaced voting disk group with +CRS.
CRS-4256: Updating the profile
CRS-4266: Voting file(s) successfully replaced
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   dda88fad4f094f1cbf686f6a903d8f9c (/dev/asmdisk01) [CRS]
Located 1 voting disk(s).
2020/03/16 22:24:13 CLSRSC-594: Executing installation step 17 of 19: 'StartCluster'.
2020/03/16 22:25:23 CLSRSC-343: Successfully started Oracle Clusterware stack
2020/03/16 22:25:23 CLSRSC-594: Executing installation step 18 of 19: 'ConfigNode'.
2020/03/16 22:27:29 CLSRSC-594: Executing installation step 19 of 19: 'PostConfig'.
2020/03/16 22:28:06 CLSRSC-325: Configure Oracle Grid Infrastructure for a Cluster ... succeeded

[root@19c2 /]# ./u01/app/19.0.0/grid/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= grid
    ORACLE_HOME=  /u01/app/19.0.0/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
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.
Relinking oracle with rac_on option
Using configuration parameter file: /u01/app/19.0.0/grid/crs/install/crsconfig_params
The log of current session can be found at:
  /u01/app/grid/crsdata/19c2/crsconfig/rootcrs_19c2_2020-03-16_10-28-54PM.log
2020/03/16 22:29:03 CLSRSC-594: Executing installation step 1 of 19: 'SetupTFA'.
2020/03/16 22:29:03 CLSRSC-594: Executing installation step 2 of 19: 'ValidateEnv'.
2020/03/16 22:29:03 CLSRSC-363: User ignored prerequisites during installation
2020/03/16 22:29:03 CLSRSC-594: Executing installation step 3 of 19: 'CheckFirstNode'.
2020/03/16 22:29:05 CLSRSC-594: Executing installation step 4 of 19: 'GenSiteGUIDs'.
2020/03/16 22:29:05 CLSRSC-594: Executing installation step 5 of 19: 'SetupOSD'.
2020/03/16 22:29:05 CLSRSC-594: Executing installation step 6 of 19: 'CheckCRSConfig'.
2020/03/16 22:29:06 CLSRSC-594: Executing installation step 7 of 19: 'SetupLocalGPNP'.
2020/03/16 22:29:08 CLSRSC-594: Executing installation step 8 of 19: 'CreateRootCert'.
2020/03/16 22:29:09 CLSRSC-594: Executing installation step 9 of 19: 'ConfigOLR'.
2020/03/16 22:29:13 CLSRSC-594: Executing installation step 10 of 19: 'ConfigCHMOS'.
2020/03/16 22:29:13 CLSRSC-594: Executing installation step 11 of 19: 'CreateOHASD'.
2020/03/16 22:29:17 CLSRSC-594: Executing installation step 12 of 19: 'ConfigOHASD'.
2020/03/16 22:29:17 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'
2020/03/16 22:29:36 CLSRSC-4002: Successfully installed Oracle Trace File Analyzer (TFA) Collector.
2020/03/16 22:29:44 CLSRSC-594: Executing installation step 13 of 19: 'InstallAFD'.
2020/03/16 22:29:47 CLSRSC-594: Executing installation step 14 of 19: 'InstallACFS'.
2020/03/16 22:29:50 CLSRSC-594: Executing installation step 15 of 19: 'InstallKA'.
2020/03/16 22:29:52 CLSRSC-594: Executing installation step 16 of 19: 'InitConfig'.
2020/03/16 22:30:02 CLSRSC-594: Executing installation step 17 of 19: 'StartCluster'.
2020/03/16 22:31:34 CLSRSC-343: Successfully started Oracle Clusterware stack
2020/03/16 22:31:34 CLSRSC-594: Executing installation step 18 of 19: 'ConfigNode'.
2020/03/16 22:31:57 CLSRSC-594: Executing installation step 19 of 19: 'PostConfig'.
2020/03/16 22:32:06 CLSRSC-325: Configure Oracle Grid Infrastructure for a Cluster ... succeeded



检查集群信息

[grid@19c1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
               ONLINE  ONLINE       19c1                     STABLE
               ONLINE  ONLINE       19c2                     STABLE
ora.chad
               ONLINE  ONLINE       19c1                     STABLE
               ONLINE  ONLINE       19c2                     STABLE
ora.net1.network
               ONLINE  ONLINE       19c1                     STABLE
               ONLINE  ONLINE       19c2                     STABLE
ora.ons
               ONLINE  ONLINE       19c1                     STABLE
               ONLINE  ONLINE       19c2                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.19c1.vip
      1        ONLINE  ONLINE       19c1                     STABLE
ora.19c2.vip
      1        ONLINE  ONLINE       19c2                     STABLE
ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)
      1        ONLINE  ONLINE       19c1                     STABLE
      2        ONLINE  ONLINE       19c2                     STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.CRS.dg(ora.asmgroup)
      1        ONLINE  ONLINE       19c1                     STABLE
      2        ONLINE  ONLINE       19c2                     STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       19c2                     STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       19c1                     STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       19c1                     STABLE
ora.asm(ora.asmgroup)
      1        ONLINE  ONLINE       19c1                     Started,STABLE
      2        ONLINE  ONLINE       19c2                     Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.asmnet1.asmnetwork(ora.asmgroup)
      1        ONLINE  ONLINE       19c1                     STABLE
      2        ONLINE  ONLINE       19c2                     STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       19c1                     STABLE
ora.qosmserver
      1        ONLINE  ONLINE       19c1                     STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       19c2                     STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       19c1                     STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       19c1                     STABLE
--------------------------------------------------------------------------------




[oracle@19c1 db]$ cd /soft
[oracle@19c1 soft]$ unzip -q Oracle_Database_19_2_0_0_0_for_Linux_x86-64.zip -d /u01/app/oracle/19.0.0/db

[root@19c1 ~]# xhost +
access control disabled, clients can connect from any host
[root@19c1 ~]# su – oracle
Last login: Mon Mar 16 22:51:15 CST 2020 on pts/3
[oracle@19c1 ~]$ cd $ORACLE_HOME
[oracle@19c1 db]$ export DISPLAY=10.138.130.242:0.0
[oracle@19c1 db]$ ./runInstaller











以 root用户在所有节点上执行以下脚本,先在主节点执行

[root@19c1 /]# ./u01/app/oracle/19.0.0/db/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/19.0.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.

[root@19c2 /]# ./u01/app/oracle/19.0.0/db/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/19.0.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.


创建磁盘组

[root@19c1 ~]# su - grid
Last login: Tue Mar 17 10:30:57 CST 2020
[grid@19c1 ~]$ export DISPLAY=10.138.130.242:0.0
[grid@19c1 ~]$ asmca



创建数据库hy

[root@19c1 ~]# xhost +
access control disabled, clients can connect from any host
[root@19c1 ~]# su - oracle
Last login: Mon Mar 16 23:09:23 CST 2020
[oracle@19c1 ~]$ export DISPLAY=10.138.130.242:0.0
[oracle@19c1 ~]$ dbca
 
















检查集群信息

[grid@jytest1 ~]$ 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.qosmserver
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       jytest2                  STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       jytest1                  STABLE
--------------------------------------------------------------------------------

到此19C RAC for Oracle Linux 7.1的安装完成!

Oracle Linux Install Oracle 18C RAC

安装环境为Oracle Linux 7.1,Oracle版本为18C,下面是RAC环境的IP配置

ip地址          主机名                   类型     解析方式 
10.10.10.171  18c1                    public   DNS或etc/hosts 
10.10.10.172  18c2                    public   DNS或etc/hosts 
88.88.87.1    18c1-priv               private  DNS或etc/hosts 
88.88.87.2    18c2-priv               private  DNS或etc/hosts 
10.10.10.175  18c1-vip                virtual  DNS或etc/hosts 
10.10.10.176  18c2-vip                virtual  DNS或etc/hosts
10.10.10.177  jycs-scan               scan     DNS或etc/hosts
10.10.10.178  jycs-scan               scan     DNS或etc/hosts
10.10.10.179  jycs-scan               scan     DNS或etc/hosts

[root@localhost soft]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.171 18c1
10.10.10.172 18c2
88.88.87.1 18c1-priv
88.88.87.2 18c2-priv
10.10.10.175 18c1-vip
10.10.10.176 18c2-vip

10.10.10.177 jycs-scan
10.10.10.178 jycs-scan
10.10.10.179 jycs-scan

[root@localhost ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.171 18c1
10.10.10.172 18c2
88.88.87.1 18c1-priv
88.88.87.2 18c2-priv
10.10.10.175 18c1-vip
10.10.10.176 18c2-vip

10.10.10.177 jycs-scan
10.10.10.178 jycs-scan
10.10.10.179 jycs-scan

创建用户组

[root@jytest1 ~]# groupadd -g 1006 asmadmin
[root@jytest1 ~]# groupadd -g 1007 asmdba
[root@jytest1 ~]# groupadd -g 1008 asmoper
[root@jytest1 ~]# groupadd -g 1009 dba
[root@jytest1 ~]# groupadd -g 1010 oper
[root@jytest1 ~]# groupadd -g 1011 oinstall
[root@jytest1 ~]# groupadd -g 1012 backupdba
[root@jytest1 ~]# groupadd -g 1013 dgdba
[root@jytest1 ~]# groupadd -g 1014 kmdba
[root@jytest1 ~]# groupadd -g 1015 racdba


[root@jytest2 ~]# groupadd -g 1006 asmadmin
[root@jytest2 ~]# groupadd -g 1007 asmdba
[root@jytest2 ~]# groupadd -g 1008 asmoper
[root@jytest2 ~]# groupadd -g 1009 dba
[root@jytest2 ~]# groupadd -g 1010 oper
[root@jytest2 ~]# groupadd -g 1011 oinstall
[root@jytest2 ~]# groupadd -g 1012 backupdba
[root@jytest2 ~]# groupadd -g 1013 dgdba
[root@jytest2 ~]# groupadd -g 1014 kmdba
[root@jytest2 ~]# groupadd -g 1015 racdba

创建用户
[root@jytest1 ~]#useradd -u 1001 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper,asmadmin oracle
[root@jytest1 ~]#useradd -u 1002 -g oinstall -G asmadmin,asmdba,asmoper,dba grid

[root@jytest2 ~]#useradd -u 1001 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper,asmadmin oracle
[root@jytest2 ~]#useradd -u 1002 -g oinstall -G asmadmin,asmdba,asmoper,dba grid

[root@jytest1 /]# 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.
You have new mail in /var/spool/mail/root
[root@jytest1 /]# 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@jytest2 /]# 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@jytest2 /]# 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.

配置ASM所需磁盘,编辑/etc/udev/rules.d/99-my-asmdevices.rules配置文件

[root@18c1 rules.d]# 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=="36000c29b61b89a10988ac7ee8d332517", RUN+="/bin/sh -c 'mknod /dev/asmdisk01 b  $major $minor; chown grid:asmadmin /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=="36000c29dfb622388fc0d35385109c4e9", RUN+="/bin/sh -c 'mknod /dev/asmdisk02 b  $major $minor; chown grid:asmadmin /dev/asmdisk02; chmod 0660 /dev/asmdisk02'"

[root@18c2 rules.d]# 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=="36000c29b61b89a10988ac7ee8d332517", RUN+="/bin/sh -c 'mknod /dev/asmdisk01 b  $major $minor; chown grid:asmadmin /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=="36000c29dfb622388fc0d35385109c4e9", RUN+="/bin/sh -c 'mknod /dev/asmdisk02 b  $major $minor; chown grid:asmadmin /dev/asmdisk02; chmod 0660 /dev/asmdisk02'"
[root@18c1 rules.d]#  /sbin/udevadm trigger --type=devices --action=change
[root@18c2 ~]#  /sbin/udevadm trigger --type=devices --action=change

[root@18c1 rules.d]#  ls -lrt /dev/asm*
brw-rw----. 1 grid asmadmin 8, 32 Mar 16 17:00 /dev/asmdisk01
brw-rw----. 1 grid asmadmin 8, 32 Mar 16 17:01 /dev/asmdisk02

[root@18c2 ~]#  ls -lrt /dev/asm*
brw-rw----. 1 grid asmadmin 8, 16 Mar 16 17:00 /dev/asmdisk01
brw-rw----. 1 grid asmadmin 8, 32 Mar 16 17:02 /dev/asmdisk02

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

[root@18c1 rules.d]# mkdir -p /u01/app/oraInventory
[root@18c1 rules.d]# chown -R grid:oinstall /u01/app/oraInventory
[root@18c1 rules.d]# chmod -R 775 /u01/app/oraInventory

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

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

[root@18c1 rules.d]# mkdir -p /u01/app/grid
[root@18c1 rules.d]# chown -R grid:oinstall /u01/app/grid
[root@18c1 rules.d]# chmod -R 775 /u01/app/grid

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

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

[root@18c1 rules.d]# mkdir -p /u01/app/18.0.0/grid
[root@18c1 rules.d]# chown -R grid:oinstall /u01/app/18.0.0/grid
[root@18c1 rules.d]# chmod -R 775 /u01/app/18.0.0/grid

[root@18c2 ~]# mkdir -p /u01/app/18.0.0/grid
[root@18c2 ~]# chown -R grid:oinstall /u01/app/18.0.0/grid
[root@18c2 ~]# chmod -R 775 /u01/app/18.0.0/grid

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

[root@18c1 rules.d]#  mkdir -p /u01/app/oracle
[root@18c1 rules.d]#  chown -R oracle:oinstall /u01/app/oracle
[root@18c1 rules.d]# chmod -R 775 /u01/app/oracle

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

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

[root@18c1 rules.d]# mkdir -p /u01/app/oracle/18.0.0/db
[root@18c1 rules.d]# chown -R oracle:oinstall /u01/app/oracle/18.0.0/db
[root@18c1 rules.d]# chmod -R 775 /u01/app/oracle/18.0.0/db

[root@18c2 ~]# mkdir -p /u01/app/oracle/18.0.0/db
[root@18c2 ~]# chown -R oracle:oinstall /u01/app/oracle/18.0.0/db
[root@18c2 ~]# chmod -R 775 /u01/app/oracle/18.0.0/db

创建一个tmp目录

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

[root@18c2 ~]# mkdir /u01/tmp
[root@18c2 ~]# chmod a+wr /u01/tmp

设置环境变量

[root@jytest1 ~]# su - grid

[grid@18c1 ~]$ 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/18.0.0/grid
export ORACLE_SID=+ASM1
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
[root@jytest2 ~]# su - grid
[grid@18c2 ~]$ 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/18.0.0/grid
export ORACLE_SID=+ASM2
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

[root@18c1 /]# su - oracle
[oracle@18c1 ~]$ 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/oracle
export ORACLE_HOME=/u01/app/oracle/18.0.0/db
export ORACLE_SID=jycs1
export ORACLE_UNQNAME=jycs
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

[root@18c2 ~]# su - oracle
[oracle@18c2 ~]$ 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/oracle
export ORACLE_HOME=/u01/app/oracle/18.0.0/db
export ORACLE_SID=jycs2
export ORACLE_UNQNAME=jycs
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文件

[root@18c1 /]# vi /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

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
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304



[root@18c1 /]# 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
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304

[root@18c2 ~]# vi /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
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
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304

~
[root@18c2 ~]# 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
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304

修改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

解压GI安装压缩包:

[grid@jytest1 soft]cd /soft/
[grid@18c1 soft]$ unzip LINUX.X64_180000_grid_home.zip -d /u01/app/18.0.0/grid

这里使用xshell与xmanager来执行安装

[root@18c1 ~]# xhost +
access control disabled, clients can connect from any host
[root@18c1 ~]# su - grid
Last login: Mon Mar 16 17:36:02 CST 2020 on pts/1
[grid@18c1 ~]$ cd /u01/app/18.0.0/grid
[grid@18c1 grid]$ export DISPLAY=10.138.130.242:0.0
[grid@18c1 grid]$ ./gridSetup.sh























以root用户分别在两个节点上执行以下脚本,先在主节点执行。

[root@18c1 /]# ./u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.

[root@18c2 /]# ./u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.


[root@18c1 /]# ./u01/app/18.0.0/grid/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= grid
    ORACLE_HOME=  /u01/app/18.0.0/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
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.
Relinking oracle with rac_on option
Using configuration parameter file: /u01/app/18.0.0/grid/crs/install/crsconfig_params
The log of current session can be found at:
  /u01/app/grid/crsdata/18c1/crsconfig/rootcrs_18c1_2020-03-16_07-10-52PM.log
2020/03/16 19:11:26 CLSRSC-594: Executing installation step 1 of 20: 'SetupTFA'.
2020/03/16 19:11:26 CLSRSC-4001: Installing Oracle Trace File Analyzer (TFA) Collector.
2020/03/16 19:12:15 CLSRSC-4002: Successfully installed Oracle Trace File Analyzer (TFA) Collector.
2020/03/16 19:12:15 CLSRSC-594: Executing installation step 2 of 20: 'ValidateEnv'.
2020/03/16 19:12:15 CLSRSC-363: User ignored prerequisites during installation
2020/03/16 19:12:15 CLSRSC-594: Executing installation step 3 of 20: 'CheckFirstNode'.
2020/03/16 19:12:19 CLSRSC-594: Executing installation step 4 of 20: 'GenSiteGUIDs'.
2020/03/16 19:12:24 CLSRSC-594: Executing installation step 5 of 20: 'SaveParamFile'.
2020/03/16 19:12:41 CLSRSC-594: Executing installation step 6 of 20: 'SetupOSD'.
2020/03/16 19:12:41 CLSRSC-594: Executing installation step 7 of 20: 'CheckCRSConfig'.
2020/03/16 19:12:41 CLSRSC-594: Executing installation step 8 of 20: 'SetupLocalGPNP'.
2020/03/16 19:13:25 CLSRSC-594: Executing installation step 9 of 20: 'CreateRootCert'.
2020/03/16 19:13:35 CLSRSC-594: Executing installation step 10 of 20: 'ConfigOLR'.
2020/03/16 19:13:58 CLSRSC-594: Executing installation step 11 of 20: 'ConfigCHMOS'.
2020/03/16 19:13:58 CLSRSC-594: Executing installation step 12 of 20: 'CreateOHASD'.
2020/03/16 19:14:13 CLSRSC-594: Executing installation step 13 of 20: 'ConfigOHASD'.
2020/03/16 19:14:14 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'
2020/03/16 19:15:02 CLSRSC-594: Executing installation step 14 of 20: 'InstallAFD'.
2020/03/16 19:16:10 CLSRSC-594: Executing installation step 15 of 20: 'InstallACFS'.
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on '18c1'
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on '18c1' has completed
CRS-4133: Oracle High Availability Services has been stopped.
CRS-4123: Oracle High Availability Services has been started.
2020/03/16 19:16:55 CLSRSC-594: Executing installation step 16 of 20: 'InstallKA'.
2020/03/16 19:17:10 CLSRSC-594: Executing installation step 17 of 20: 'InitConfig'.
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on '18c1'
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on '18c1' has completed
CRS-4133: Oracle High Availability Services has been stopped.
CRS-4123: Oracle High Availability Services has been started.
CRS-2672: Attempting to start 'ora.driver.afd' on '18c1'
CRS-2672: Attempting to start 'ora.evmd' on '18c1'
CRS-2672: Attempting to start 'ora.mdnsd' on '18c1'
CRS-2676: Start of 'ora.driver.afd' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on '18c1'
CRS-2676: Start of 'ora.cssdmonitor' on '18c1' succeeded
CRS-2676: Start of 'ora.mdnsd' on '18c1' succeeded
CRS-2676: Start of 'ora.evmd' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on '18c1'
CRS-2676: Start of 'ora.gpnpd' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.gipcd' on '18c1'
CRS-2676: Start of 'ora.gipcd' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.cssd' on '18c1'
CRS-2672: Attempting to start 'ora.diskmon' on '18c1'
CRS-2676: Start of 'ora.diskmon' on '18c1' succeeded
CRS-2676: Start of 'ora.cssd' on '18c1' succeeded

[INFO] [DBT-30161] Disk label(s) created successfully. Check /u01/app/grid/cfgtoollogs/asmca/asmca-200316PM071759.log for details.
[INFO] [DBT-30001] Disk groups created successfully. Check /u01/app/grid/cfgtoollogs/asmca/asmca-200316PM071759.log for details.


2020/03/16 19:19:59 CLSRSC-482: Running command: '/u01/app/18.0.0/grid/bin/ocrconfig -upgrade grid oinstall'
CRS-2672: Attempting to start 'ora.crf' on '18c1'
CRS-2672: Attempting to start 'ora.storage' on '18c1'
CRS-2676: Start of 'ora.storage' on '18c1' succeeded
CRS-2676: Start of 'ora.crf' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.crsd' on '18c1'
CRS-2676: Start of 'ora.crsd' on '18c1' succeeded
CRS-4256: Updating the profile
Successful addition of voting disk b1f6f23bbaef4ff2bf3cdfdec8a72881.
Successfully replaced voting disk group with +CRS.
CRS-4256: Updating the profile
CRS-4266: Voting file(s) successfully replaced
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   b1f6f23bbaef4ff2bf3cdfdec8a72881 (AFD:CRS1) [CRS]
Located 1 voting disk(s).
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on '18c1'
CRS-2673: Attempting to stop 'ora.crsd' on '18c1'
CRS-2677: Stop of 'ora.crsd' on '18c1' succeeded
CRS-2673: Attempting to stop 'ora.storage' on '18c1'
CRS-2673: Attempting to stop 'ora.crf' on '18c1'
CRS-2673: Attempting to stop 'ora.drivers.acfs' on '18c1'
CRS-2673: Attempting to stop 'ora.mdnsd' on '18c1'
CRS-2677: Stop of 'ora.crf' on '18c1' succeeded
CRS-2677: Stop of 'ora.storage' on '18c1' succeeded
CRS-2673: Attempting to stop 'ora.asm' on '18c1'
CRS-2677: Stop of 'ora.drivers.acfs' on '18c1' succeeded
CRS-2677: Stop of 'ora.mdnsd' on '18c1' succeeded
CRS-2677: Stop of 'ora.asm' on '18c1' succeeded
CRS-2673: Attempting to stop 'ora.cluster_interconnect.haip' on '18c1'
CRS-2677: Stop of 'ora.cluster_interconnect.haip' on '18c1' succeeded
CRS-2673: Attempting to stop 'ora.ctssd' on '18c1'
CRS-2673: Attempting to stop 'ora.evmd' on '18c1'
CRS-2677: Stop of 'ora.ctssd' on '18c1' succeeded
CRS-2677: Stop of 'ora.evmd' on '18c1' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on '18c1'
CRS-2677: Stop of 'ora.cssd' on '18c1' succeeded
CRS-2673: Attempting to stop 'ora.driver.afd' on '18c1'
CRS-2673: Attempting to stop 'ora.gipcd' on '18c1'
CRS-2673: Attempting to stop 'ora.gpnpd' on '18c1'
CRS-2677: Stop of 'ora.driver.afd' on '18c1' succeeded
CRS-2677: Stop of 'ora.gpnpd' on '18c1' succeeded
CRS-2677: Stop of 'ora.gipcd' on '18c1' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on '18c1' has completed
CRS-4133: Oracle High Availability Services has been stopped.
2020/03/16 19:22:35 CLSRSC-594: Executing installation step 18 of 20: 'StartCluster'.
CRS-4123: Starting Oracle High Availability Services-managed resources
CRS-2672: Attempting to start 'ora.evmd' on '18c1'
CRS-2672: Attempting to start 'ora.mdnsd' on '18c1'
CRS-2676: Start of 'ora.mdnsd' on '18c1' succeeded
CRS-2676: Start of 'ora.evmd' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on '18c1'
CRS-2676: Start of 'ora.gpnpd' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.gipcd' on '18c1'
CRS-2676: Start of 'ora.gipcd' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on '18c1'
CRS-2676: Start of 'ora.cssdmonitor' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.crf' on '18c1'
CRS-2672: Attempting to start 'ora.cssd' on '18c1'
CRS-2672: Attempting to start 'ora.diskmon' on '18c1'
CRS-2676: Start of 'ora.diskmon' on '18c1' succeeded
CRS-2676: Start of 'ora.crf' on '18c1' succeeded
CRS-2676: Start of 'ora.cssd' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.cluster_interconnect.haip' on '18c1'
CRS-2672: Attempting to start 'ora.ctssd' on '18c1'
CRS-2676: Start of 'ora.ctssd' on '18c1' succeeded
CRS-2676: Start of 'ora.cluster_interconnect.haip' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.asm' on '18c1'
CRS-2676: Start of 'ora.asm' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.storage' on '18c1'
CRS-2676: Start of 'ora.storage' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.crsd' on '18c1'
CRS-2676: Start of 'ora.crsd' on '18c1' succeeded
CRS-6023: Starting Oracle Cluster Ready Services-managed resources
CRS-6017: Processing resource auto-start for servers: 18c1
CRS-6016: Resource auto-start has completed for server 18c1
CRS-6024: Completed start of Oracle Cluster Ready Services-managed resources
CRS-4123: Oracle High Availability Services has been started.
2020/03/16 19:24:23 CLSRSC-343: Successfully started Oracle Clusterware stack
2020/03/16 19:24:23 CLSRSC-594: Executing installation step 19 of 20: 'ConfigNode'.
CRS-2672: Attempting to start 'ora.ASMNET1LSNR_ASM.lsnr' on '18c1'
CRS-2676: Start of 'ora.ASMNET1LSNR_ASM.lsnr' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.asm' on '18c1'
CRS-2676: Start of 'ora.asm' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.CRS.dg' on '18c1'
CRS-2676: Start of 'ora.CRS.dg' on '18c1' succeeded
2020/03/16 19:27:00 CLSRSC-594: Executing installation step 20 of 20: 'PostConfig'.
2020/03/16 19:29:03 CLSRSC-325: Configure Oracle Grid Infrastructure for a Cluster ... succeeded 

[root@18c2 /]# ./u01/app/18.0.0/grid/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= grid
    ORACLE_HOME=  /u01/app/18.0.0/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
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.
Relinking oracle with rac_on option
Using configuration parameter file: /u01/app/18.0.0/grid/crs/install/crsconfig_params
The log of current session can be found at:
  /u01/app/grid/crsdata/18c2/crsconfig/rootcrs_18c2_2020-03-16_07-30-27PM.log
2020/03/16 19:30:47 CLSRSC-594: Executing installation step 1 of 20: 'SetupTFA'.
2020/03/16 19:30:47 CLSRSC-4001: Installing Oracle Trace File Analyzer (TFA) Collector.
2020/03/16 19:32:12 CLSRSC-4002: Successfully installed Oracle Trace File Analyzer (TFA) Collector.
2020/03/16 19:32:12 CLSRSC-594: Executing installation step 2 of 20: 'ValidateEnv'.
2020/03/16 19:32:12 CLSRSC-363: User ignored prerequisites during installation
2020/03/16 19:32:12 CLSRSC-594: Executing installation step 3 of 20: 'CheckFirstNode'.
2020/03/16 19:32:15 CLSRSC-594: Executing installation step 4 of 20: 'GenSiteGUIDs'.
2020/03/16 19:32:15 CLSRSC-594: Executing installation step 5 of 20: 'SaveParamFile'.
2020/03/16 19:32:19 CLSRSC-594: Executing installation step 6 of 20: 'SetupOSD'.
2020/03/16 19:32:20 CLSRSC-594: Executing installation step 7 of 20: 'CheckCRSConfig'.
2020/03/16 19:32:20 CLSRSC-594: Executing installation step 8 of 20: 'SetupLocalGPNP'.
2020/03/16 19:32:22 CLSRSC-594: Executing installation step 9 of 20: 'CreateRootCert'.
2020/03/16 19:32:22 CLSRSC-594: Executing installation step 10 of 20: 'ConfigOLR'.
2020/03/16 19:32:27 CLSRSC-594: Executing installation step 11 of 20: 'ConfigCHMOS'.
2020/03/16 19:32:27 CLSRSC-594: Executing installation step 12 of 20: 'CreateOHASD'.
2020/03/16 19:32:29 CLSRSC-594: Executing installation step 13 of 20: 'ConfigOHASD'.
2020/03/16 19:32:29 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'
2020/03/16 19:33:05 CLSRSC-594: Executing installation step 14 of 20: 'InstallAFD'.
2020/03/16 19:33:58 CLSRSC-594: Executing installation step 15 of 20: 'InstallACFS'.
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on '18c2'
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on '18c2' has completed
CRS-4133: Oracle High Availability Services has been stopped.
CRS-4123: Oracle High Availability Services has been started.
2020/03/16 19:34:31 CLSRSC-594: Executing installation step 16 of 20: 'InstallKA'.
2020/03/16 19:34:33 CLSRSC-594: Executing installation step 17 of 20: 'InitConfig'.
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on '18c2'
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on '18c2' has completed
CRS-4133: Oracle High Availability Services has been stopped.
CRS-4123: Oracle High Availability Services has been started.
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on '18c2'
CRS-2673: Attempting to stop 'ora.drivers.acfs' on '18c2'
CRS-2677: Stop of 'ora.drivers.acfs' on '18c2' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on '18c2' has completed
CRS-4133: Oracle High Availability Services has been stopped.
2020/03/16 19:35:14 CLSRSC-594: Executing installation step 18 of 20: 'StartCluster'.
CRS-4123: Starting Oracle High Availability Services-managed resources
CRS-2672: Attempting to start 'ora.mdnsd' on '18c2'
CRS-2672: Attempting to start 'ora.evmd' on '18c2'
CRS-2676: Start of 'ora.mdnsd' on '18c2' succeeded
CRS-2676: Start of 'ora.evmd' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on '18c2'
CRS-2676: Start of 'ora.gpnpd' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.gipcd' on '18c2'
CRS-2676: Start of 'ora.gipcd' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on '18c2'
CRS-2676: Start of 'ora.cssdmonitor' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.crf' on '18c2'
CRS-2672: Attempting to start 'ora.cssd' on '18c2'
CRS-2672: Attempting to start 'ora.diskmon' on '18c2'
CRS-2676: Start of 'ora.diskmon' on '18c2' succeeded
CRS-2676: Start of 'ora.crf' on '18c2' succeeded
CRS-2676: Start of 'ora.cssd' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.cluster_interconnect.haip' on '18c2'
CRS-2672: Attempting to start 'ora.ctssd' on '18c2'
CRS-2676: Start of 'ora.ctssd' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.crsd' on '18c2'
CRS-2676: Start of 'ora.crsd' on '18c2' succeeded
CRS-2676: Start of 'ora.cluster_interconnect.haip' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.asm' on '18c2'
CRS-2676: Start of 'ora.asm' on '18c2' succeeded
CRS-6017: Processing resource auto-start for servers: 18c2
CRS-2673: Attempting to stop 'ora.LISTENER_SCAN1.lsnr' on '18c1'
CRS-2672: Attempting to start 'ora.ASMNET1LSNR_ASM.lsnr' on '18c2'
CRS-2672: Attempting to start 'ora.ons' on '18c2'
CRS-2677: Stop of 'ora.LISTENER_SCAN1.lsnr' on '18c1' succeeded
CRS-2673: Attempting to stop 'ora.scan1.vip' on '18c1'
CRS-2677: Stop of 'ora.scan1.vip' on '18c1' succeeded
CRS-2672: Attempting to start 'ora.scan1.vip' on '18c2'
CRS-2676: Start of 'ora.scan1.vip' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.LISTENER_SCAN1.lsnr' on '18c2'
CRS-2676: Start of 'ora.ASMNET1LSNR_ASM.lsnr' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.asm' on '18c2'
CRS-2676: Start of 'ora.ons' on '18c2' succeeded
CRS-2676: Start of 'ora.LISTENER_SCAN1.lsnr' on '18c2' succeeded
CRS-2676: Start of 'ora.asm' on '18c2' succeeded
CRS-2672: Attempting to start 'ora.proxy_advm' on '18c1'
CRS-2672: Attempting to start 'ora.proxy_advm' on '18c2'
CRS-2676: Start of 'ora.proxy_advm' on '18c1' succeeded
CRS-2676: Start of 'ora.proxy_advm' on '18c2' succeeded
CRS-6016: Resource auto-start has completed for server 18c2
CRS-6024: Completed start of Oracle Cluster Ready Services-managed resources
CRS-4123: Oracle High Availability Services has been started.
2020/03/16 19:38:09 CLSRSC-343: Successfully started Oracle Clusterware stack
2020/03/16 19:38:09 CLSRSC-594: Executing installation step 19 of 20: 'ConfigNode'.
2020/03/16 19:38:34 CLSRSC-594: Executing installation step 20 of 20: 'PostConfig'.
2020/03/16 19:39:07 CLSRSC-325: Configure Oracle Grid Infrastructure for a Cluster ... succeeded

检查集群信息

[root@18c1 /]# su - grid
Last login: Mon Mar 16 19:40:16 CST 2020
[grid@18c1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.CRS.GHCHKPT.advm
               OFFLINE OFFLINE      18c1                     STABLE
               OFFLINE OFFLINE      18c2                     STABLE
ora.CRS.dg
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.crs.ghchkpt.acfs
               OFFLINE OFFLINE      18c1                     volume /opt/oracle/r
                                                             hp_images/chkbase is
                                                             unmounted,STABLE
               OFFLINE OFFLINE      18c2                     STABLE
ora.helper
               OFFLINE OFFLINE      18c1                     STABLE
               OFFLINE OFFLINE      18c2                     IDLE,STABLE
ora.net1.network
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.ons
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.proxy_advm
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.18c1.vip
      1        ONLINE  ONLINE       18c1                     STABLE
ora.18c2.vip
      1        ONLINE  ONLINE       18c2                     STABLE
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       18c2                     STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       18c1                     STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       18c1                     STABLE
ora.MGMTLSNR
      1        OFFLINE OFFLINE                               STABLE
ora.asm
      1        ONLINE  ONLINE       18c1                     Started,STABLE
      2        ONLINE  ONLINE       18c2                     Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       18c1                     STABLE
ora.qosmserver
      1        ONLINE  ONLINE       18c1                     STABLE
ora.rhpserver
      1        OFFLINE OFFLINE                               STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       18c2                     STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       18c1                     STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       18c1                     STABLE
--------------------------------------------------------------------------------


安装数据库软件

[oracle@18c1 soft]$ unzip LINUX.X64_180000_db_home.zip -d /u01/app/oracle/18.0.0/db 

[root@18c1 ~]# xhost +
access control disabled, clients can connect from any host
[root@18c1 ~]# su - oracle
Last login: Mon Mar 16 17:20:14 CST 2020 on pts/0
[oracle@18c1 ~]$ cd  $ORACLE_HOME
[oracle@18c1  db]$ export DISPLAY=10.138.130.242:0.0
[oracle@18c1 db]$ ./runInstaller 











以 root用户在所有节点上执行以下脚本,先在主节点执行

[root@18c1 /]# ./u01/app/oracle/18.0.0/db/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/18.0.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.

[root@18c2 /]# ./u01/app/oracle/18.0.0/db/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/18.0.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.

创建数据库jycs

[oracle@jytest1 database]$ dbca
















检查数据库配置信息

[grid@18c2 18.0.0]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.CRS.GHCHKPT.advm
               OFFLINE OFFLINE      18c1                     STABLE
               OFFLINE OFFLINE      18c2                     STABLE
ora.CRS.dg
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.DATA.dg
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.chad
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.crs.ghchkpt.acfs
               OFFLINE OFFLINE      18c1                     STABLE
               OFFLINE OFFLINE      18c2                     STABLE
ora.helper
               OFFLINE OFFLINE      18c1                     IDLE,STABLE
               OFFLINE OFFLINE      18c2                     IDLE,STABLE
ora.net1.network
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.ons
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
ora.proxy_advm
               ONLINE  ONLINE       18c1                     STABLE
               ONLINE  ONLINE       18c2                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.18c1.vip
      1        ONLINE  ONLINE       18c1                     STABLE
ora.18c2.vip
      1        ONLINE  ONLINE       18c2                     STABLE
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       18c2                     STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       18c1                     STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       18c1                     STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       18c1                     169.254.11.99 88.88.
                                                             87.1,STABLE
ora.asm
      1        ONLINE  ONLINE       18c1                     Started,STABLE
      2        ONLINE  ONLINE       18c2                     Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       18c1                     STABLE
ora.jycs.db
      1        ONLINE  ONLINE       18c1                     Open,HOME=/u01/app/o
                                                             racle/18.0.0/db,STAB
                                                             LE
      2        ONLINE  ONLINE       18c2                     Open,HOME=/u01/app/o
                                                             racle/18.0.0/db,STAB
                                                             LE
ora.mgmtdb
      1        ONLINE  ONLINE       18c1                     Open,STABLE
ora.qosmserver
      1        ONLINE  ONLINE       18c1                     STABLE
ora.rhpserver
      1        OFFLINE OFFLINE                               STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       18c2                     STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       18c1                     STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       18c1                     STABLE
--------------------------------------------------------------------------------

到此18C RAC for Oracle Linux 7.1的安装完成!

Oracle 12c 使用SQL*Plus来创建与移动应用程序Seeds

可以使用多种方法来创建应用程序seeds,包括使用CDB seed,克隆现有的PDB或Non-CDB,与附加一个卸载的PDB。也可以从应用程序容器中删除应用程序seeds。

为了在应用程序容器中创建新的应用程序seed,可以执行带有as seed子句的create pluggable database语句。可以使用应用程序种子为应用程序提供一个应用程序容器。通常在应用程序seed创建之前应用程序容器的应用程序被安装在应用程序root中。在应用程序seed创建之后它将与应用程序root进行同步,因此应用程序被安装在应用程序seed中。当创建应用程序seed之后,使用应用程序seed创建的任何PDB都安装应用程序。当应用程序root中的应用程序被升级或打补丁后,应用程序seed必须使用应用程序root进行同步来应用这些改变。

通过执行带有as seed子句的create pluggable database语句来创建应用程序seed。

一个应用程序容器可以有零或一个应用程序seed。当使用as seed子句创建应程序seed时,不用指定它的名字。应用程序seed名字总是以application_container_name$SEED命名,其中application_container_name是应用程序seed的应用程序容器的名字。例如,在salesact应用程序容器中的应用程序seed它的名字必须是salesact$SEED。

当创建一个新的应用程序seed时,必须为在create pluggable database语句中为应用程序容器指定管理员。这个语句将在应用程序容器中创建一个本地用户的管理员,并且被授予pdb_dba角色。

创建应用程序seed的所需要满足的条件:
.CDB必须存在

.CDB必须处于读写模式

.应用程序seed所属的应用程序容器必须处于读写模式

.当前用户必须是一个公共用户,应用程序seed所属的应用程序root是当前容器

.当前用户有create pluggable database系统权限

.在应用程序容器中对于包含应用程序的应用程序seed,应用程序必须安装在应用程序root

创建应用程序seed
可以通过执行带有as seed子句的create pluggable database语句来创建应用程序。应用程序容器中的应用程序seed类似于CDB中的seed。一个应用程序seed能用来快速与简单的创建满足应用程序容器要求的应用程序PDB。创建应用程序seed的操作如下:
1.在SQL*Plus中,确保当前容器是应用程序root。

2.执行带有as seed子句的create pluggable database语句来创建应用程序seed。根据需要还可以指定其它子句。在创建完应用程序seed后,它处于mounted模式,状态为new。可以通过查询v$pdbs视图的open_mode列来检查应用程序seed的打开模式。可以通过查询cdb_pdbs或者dba_pdbs视图的status列来查看应用程序seed的状态。还会为应用程序seed创建缺省的服务名。服务名与应用程序seed同名并且可以被用来访问应用程序seed。

3.以读写模式来打开新的应用程序seed

4.为了将新应用程序seed集成到应用程序容器中必须以读写模式来打开新的应用程序seed。如果试图以只读模式来打开新的应用程序seed将会返回错误信息。在应用程序seed以读写模式打开后,它的状态将为normal。

5.执行一个或多个以下操作:
5.a 如果使用CDB seed中创建应用程序seed,那么将容器切换到应用程序seed,并且执行带有sync子句的alter pluggable database语句来同步应用程序seed。同步使用应用程序root来实例化应用程序seed中的一个或多个应用程序root的应用程序。

5.b 如果使用应用程序root中创建应用程序seed,那么将容器切换到应用程序seed,然后执行pdb_to_apppdb.sql脚本来将应用程序root转换为应用程序PDB。

当通过克隆一个应用程序PDB来创建应用程序seed时这些操作不需要执行。

6.关闭应用程序seed,然后以只读模式来打开它。

7.备份应用程序seed。

使用CDB seed来创建应用程序seed
这个例子假设满足以下条件:
.应用程序seed将被创建在名为salesact的应用程序容器中。

.对应用程序seed不使用存储限制,因此不指定storage子句。

.应用程序seed不创建缺省表空间。

.不指定path_prefix子句。

.不指定file_name_convert与create_file_dest子句。可以对CDB启用OMF或设置pdb_file_name_convert初始化参数。与CDB相关的文件将会基于OMF配置或参数设置被复制到新目录中。

.在目标目录中没有与新temp文件同名的文件存在,将会创建新的temp文件,因此不用指定tempfile reuse子句。

.不需要预先定义Oracle角色被授予给pdb_dba角色。

执行的语句如下:
先切换到应用程序容器salesact中

SQL> alter session set container=salesact;

Session altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE

执行语句来使用CDB seed来在应用程序容器salesact中创建应用程序seed,并打开应用程序seed。

SQL> create pluggable database as seed admin user actseedadm identified by "xxzx7817600";

Pluggable database created.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESACT$SEED                                                                                                                    MOUNTED

SQL> alter pluggable database salesact$seed open;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESACT$SEED                                                                                                                    READ WRITE

切换容器到应用程序seed(salesact$SEED)中,使用应用程序root中的所有应用程序来同步应用程序seed。

SQL> alter session set container=salesact$seed;

Session altered.

SQL>  select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT$SEED                                                                                                                    READ WRITE

SQL> alter pluggable database application all sync;

Pluggable database altered.

关闭应用程序seed(salesact$seed),然后以只读模式来打开应用程序seed。

SQL> alter pluggable database close immediate;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT$SEED                                                                                                                    MOUNTED

SQL> alter pluggable database  open read only;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT$SEED                                                                                                                    READ ONLY

因为应用程序容器名为salesact,所以应用程序seed名为salesact$seed。在创建应用程序seed时一起创建了一个本地管理用户并且被授予了pdb_dba公共角色。如果这个用户在创建应用程序seed时没有授予管理权限,那么使用sys与system公共用户来管理应用程序seed。当创建应用程序seed时,将使用应用程序root来同步应用程序seed。因此应用程序seed将包含安装在应用程序root中的应用程序与应用程序公共对象它们是这些应用程序的一部分。当使用应用程序seed来创建新的应用程序PDB时,应用程序PDB也会包含这些安装的应用程序与应用程序公共对象。

使用应用程序PDB创建应用程序seed
这个例子假设满足以下条件:
.在应用程序容器salesact中创建了应用程序seed。

.将在应用程序PBD(salesapppdb)所在的应用程序容器中创建应用程序seed。

.对应用程序seed不使用存储限制,因此不指定storage子句。

.应用程序seed不包含缺省表空间。

.不指定path_prefix子句。

.不指定file_name_convert与create_file_dest子句。可以启用OMF或设置pdb_file_name_convert初始化参数。与应用程序root相关的文件会基于OMF的配置或初始化参数设置被复制到新目录中。

.在目标目录中没有与新temp文件同名的文件存在,因此不需要使用tempfile reuse子句。

切换容器到应用程序容器(salesact),并执行以下命令来创建应用程序seed。

SQL> create pluggable database as seed from salesapppdb;

Pluggable database created.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESAPPPDB                                                                                                                      READ WRITE
SALESACT$SEED                                                                                                                    MOUNTED

然后打开应用程序seed,再关闭应用程序seed,最后再以只读方式打开应用程序seed。

SQL> alter pluggable database salesact$seed open;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESAPPPDB                                                                                                                      READ WRITE
SALESACT$SEED                                                                                                                    READ WRITE

SQL> alter pluggable database salesact$seed close immediate;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESAPPPDB                                                                                                                      READ WRITE
SALESACT$SEED                                                                                                                    MOUNTED

SQL> alter pluggable database salesact$seed open read only;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESAPPPDB                                                                                                                      READ WRITE
SALESACT$SEED                                                                                                                    READ ONLY

因为应用程序容器名为salesact,所以应用程序seed名字默认为salesact$seed。应用程序seed是使用应用程序pdb而创建的,因此应用程序seed就包含了安装在应用程序root中的应用程序与应用程序公共对象,它们是这些应用程序的一部分。当使用应用程序seed来创建新的应用程序pdb时,应用程序pdb也会包含安装的应用程序与应用程序公共对象。

使用应用程序root来创建应用程序seed
这个例子假设满足以下条件:
.应用程序seed将创建在应用程序容器(salesact)中。应用程序seed使用对应用程序容器的root进行克隆进行创建。

.对应用程序seed不使用存储限制,因此不使用storage子句。

.应用程序seed不包含缺省表空间。

.不使用path_prefix子句。

.不使用file_name_convert与create_file_dest子句。可以启用OMF或设置pdb_file_name_convert初始化参数。基于OMF配置或初始化参数的设置与应用程序root相关的文件会被复制到新目录中。

.在目标目录中没有与新temp文件同名的文件存在,因此不需要使用tempfile reuse子句。

切换到应用程序容器(salesact)中,执行下面的命令来创建应用程序seed。

SQL> create pluggable database as seed from salesact;

Pluggable database created.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESACT$SEED                                                                                                                    MOUNTED
SALESAPPPDB                                                                                                                      READ WRITE

打开应用程序seed,切换容器到应用程序seed,然后执行pdb_to_apppdb.sql脚本将应用程序root转换为应用程序pdb。

SQL> alter pluggable database salesact$seed open;

Warning: PDB altered with errors.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESACT$SEED                                                                                                                    READ WRITE
SALESAPPPDB                                                                                                                      READ WRITE

SQL> alter session set container=salesact$seed;

Session altered.

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

...
SQL> BEGIN
  2    execute immediate '&open_sql &restricted_state';
  3  EXCEPTION
  4    WHEN OTHERS THEN
  5    BEGIN
  6      IF (sqlcode <> -900) THEN
  7        RAISE;
  8      END IF;
  9    END;
 10  END;
 11  /

PL/SQL procedure successfully completed.

SQL> 
SQL> WHENEVER SQLERROR CONTINUE;



SQL> alter pluggable database close immediate instances=all;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT$SEED                                                                                                                    MOUNTED

1 row selected.

SQL> alter pluggable database open read only instances=all;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT$SEED                                                                                                                    READ ONLY

1 row selected.

因为应用程序容器名为salesact,所以应用程序seed名为salesact$seed。应用程序seed是使用应用程序root进行创建的。因此应用程序seed包含安装在应用程序root中的应用程序与应用程序公共对象,它们是这些应用程序的一部分。当使用应用程序seed来创建新应用程序PDB时,应用程序pdb也会包含安装的应用程序与应用程序公共对象。

从应用程序容器中拔出应用程序seed
拔出应用程序seed就是断开应用程序seed与应用程序容器的关联。当不再需要应用程序seed时可以将其删除。拔出应用程序seed类似于拔出PDB。为了拔出应用程序seed,连接到它的应用程序root并使用alter pluggable database语句来指定生成xml文件或.pdb文件。当指定xml文件后,在卸载完成后生成的xml文件会包含描述应用程序seed的元数据。

SQL> alter pluggable database salesact$seed close immediate instances=all;

Pluggable database altered.



SQL>  select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESACT$SEED                                                                                                                    MOUNTED
SALESAPPPDB                                                                                                                      READ WRITE

3 rows selected.



SQL> alter pluggable database salesact$seed unplug into '/tts/plug/salesact_seed.xml';

Pluggable database altered.

删除应用程序seed
当不再需要应用程序seed时,可以执行drop pluggable database语句来删除。当删除应用程序seed时,CDB的控制文件会被修改来删除与被删除应用程序seed的所有相关信息,但是归档重做日志与备份不会被删除,但可以使用RMAN来删除它们。

SQL> drop pluggable database salesapppdb including datafiles;

Pluggable database dropped.

创建应用程序PDB
可以在应用程序root容器中执行create pluggable database语句来创建应用程序PDB。创建应用程序pdb与在CDB root中创建PDB都是使用相同的SQL语句。当在应用程序root中执行create pluggable database语句时新创建的PDB为应用程序PDB。SQL语句必须在应用程序root中执行并且对应用程序root中所定义的应用程序数据库有显式依赖性。创建应用程序PDB的操作如下:

1.在SQL*Plus中,确保当前容器为应用程序root

2.执行create pluggable database语句。在应用程序PDB完成创建之后,它处于mounted模式并且状态为NEW。可以通过查询v$pdbs视图的open_mode列来查看应用程序pdb的打开模式,可以通过查询cdb_pdbs或dba_pdbs视图的status列来查看应用程序pdb的状态。对于新创建的应用程序PDB也会创建一个缺省的服务名,服务名与应用程序PDB同名并且可以被用来访问应用程序PDB。

3.以读写模式来打开应用程序PDB

4.为了将新的应用程序PDB集成到应用程序容器必须以读写模式来打开新的应用程序PDB。如果试图以只读模式来打开应用程序PDB将会返回错误信息。在应用程序PDB以读写模式打开后它的状态将变为NORMAL。

5.切换容器为应用程序PDB

6.执行alter pluggable database … sync来同步应用程序PDB。同步使用应用程序PDB来实例化应用程序PDB中的一个或多个应用程序root中的应用程序。

7.关闭应用程序PDB,然后以只读模式打开。

8.备份应用程序PDB。

SQL> alter session set container=salesact;

Session altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE

1 row selected.



SQL> create pluggable database salesapppdb admin user salesapppdbadm identified by "xxzx7817600";

Pluggable database created.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESAPPPDB                                                                                                                      MOUNTED

2 rows selected.

SQL> alter pluggable database salesapppdb open read write instances=all;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESACT                                                                                                                         READ WRITE
SALESAPPPDB                                                                                                                      READ WRITE

2 rows selected.

SQL> alter session set container=salesapppdb;

Session altered.


SQL> alter pluggable database application all sync; 

Pluggable database altered.

SQL> alter pluggable database salesapppdb close immediate instances=all;

Pluggable database altered.

SQL>  select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESAPPPDB                                                                                                                      MOUNTED

1 row selected.

SQL> alter pluggable database salesapppdb open read only instances=all;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
SALESAPPPDB                                                                                                                      READ ONLY

1 row selected.
Proudly powered by WordPress | Indrajeet by Sus Hill.