Oracle 12C静默删除CDB

Oracle 12C引入了CDB与PDB的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库(PDB)。CDB全称为Container Database,中文翻译为数据库容器,PDB全称为Pluggable Database,即可插拔数据库。

在安装或者维护数据库的过程中,可以通过DBCA对CDB进行静默删除(别问我为什么知道:))。步骤如下:

#dbca -silent -deleteDatabase -sourceDB CDB数据库名

耐心等待至命令完成,正常情况下会出现以下提示:

 
Connecting to database
4% complete
9% complete
14% complete
19% complete
23% complete
28% complete
47% complete
Updating network configuration files
52% complete
Deleting instance and datafiles
76% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/condb0.log" for further details.

Oracle Database 12.2.0.1静默安装

一客户升级系统,准备把数据库升级到12C,操作系统切换到Redhat 7,而他们家系统管理员不但不熟Oracle数据库,还不熟Linux。只好请客户开了个Teamview连接,远程帮他们安装系统。因为连Linux都是供应商帮忙装了,没有装X window,只能选择静默安装了。开搞。

安装依赖包

要说安装包最方便的方式,莫过于利用Oracle官方的源了。

# cd /etc/yum.repos.d

# wget http://yum.oracle.com/public-yum-ol7.repo

#vim public-yum-ol7.repo

把文件按如下修改:

[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=0
enabled=1

然后运行oracle-database-server-12cR2-preinstall安装依赖包。

#yum install oracle-database-server-12cR2-preinstall

如果有问题可以采用以下方式。

#vim req-rpm.txt

在文件输入以下包名。

binutils
compat-libcap1
compat-libstdc++-33
gcc
gcc-c++
glibc
glibc-devel
ksh
libgcc
libstdc++
libstdc++-devel
libaio
libaio-devel
libXext
libXtst
libX11
libXau
libxcb
libXi
make
sysstat
libXmu
libXt
libXv
libXxf86dga
libdmx
libXxf86misc
libXxf86vm
xorg-x11-utils
xorg-x11-xauth

保存退出后,运行以下命令安装。

#yum install `awk ‘{print $1}’  req-rpm.txt`

配置系统参数

#vim /etc/sysctl.conf

增加以下内容:

–kernel parameters for 12C installation
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500

使用内核参数生效

#/sbin/sysctl -p

#vim /etc/security/limits.conf

–shell limits for users oracle 12C

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

#cat /etc/selinux/config

确认SELINUX设置如下:

SELINUX=permissive
setenforce Permissive

#service iptables stop

#chkconfig iptables off

创建oracle用户和组

#groupadd -g 54321 oinstall

#groupadd -g 54322 dba

#groupadd -g 54323 oper

#useradd –u 54321 –g oinstall –G dba,oracle,oper

#passwd oracle

#mkdir –p /u01
#chown oracle:dba /u01
#chmod 775 /u01

安装数据库

#su oracle

#unzip linuxx64_12201_database.zip

在解压文件夹的/database/response目录下,复制db_install.rsp文件到/home/oracle/oinstall/oracle/database目录下。

#vim db_install.rsp

oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=dba
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true

#./runInstaller -silent -responseFile
/home/oracle/oinstall/database/db_install.rsp

完成数据库软件安装,切到root用户,运行以下脚本。

# /u01/app/oraInventory/orainstRoot.sh

#/u01/app/oracle/product/12.2.0.1/dbhome_1/root.sh

完成数据库软件安装。

静默创建数据库

类似上面步骤,复制dbca.rsp到当前目录。

#vim dbca.rsp

gdbName=orcl
sid=orcl
databaseConfigType=SI
createAsContainerDatabase=false
templateName=General_Purpose.dbc
sysPassword=oracle12C
systemPassword=oracle12C
emConfiguration=NONE
datafileDestination=/u01/oradata
recoveryAreaDestination=/u01/recovery_area
storageType=FS
characterSet=AL32UTF8
sampleSchema=TRUE

#export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/dbhome_1

#export PATH=$ORACLE_HOME/bin:$PATH.

#dbca -silent -createDatabase -responseFile dbca.rsp

完成数据库创建。

创建监听器

类似上面步骤,复制netca.rsp到当前目录。

#netca -silent  -responseFile netca.rsp

完成安装后,验证监听器状态正常。

#lsnrctl status