Archives For November 30, 1999

while reading the 12c upgrade guide I noticed that the catupgrd.sql is deprecated:

“Oracle Database 12c introduces the new Parallel Upgrade Utility, catctl.pl. This utility replaces the catupgrd.sql script that was used in earlier releases. Although you can still use the catupgrd.sql script, it is deprecated starting with Oracle Database 12c and will be removed in future releases. Oracle recommends database upgrades be performed with the new Parallel Upgrade Utility, catctl.pl.”

so prepare for changing your upgrade process …

a question which pops up regulary is how one can find out which psu is installed on an oracle database. there are at least two possibilities.

if you have access to the server use opatch:

$ORACLE_HOME/OPatch/opatch lsinventory | grep "Database Patch Set Update"
Patch description:  "Database Patch Set Update : 11.2.0.2.8 (14275621)"
Sub-patch  13923804; "Database Patch Set Update : 11.2.0.2.7 (13923804)"
Sub-patch  13696224; "Database Patch Set Update : 11.2.0.2.6 (13696224)"

if you don’t have access to the server but can connect as sys:

col comments for a60
col version for a30
set lines 264
select version,comments from registry$history where comments like '%PSU%';

VERSION 		       COMMENTS
------------------------------ ------------------
11.2.0.2		       PSU 11.2.0.2.3
11.2.0.2		       PSU 11.2.0.2.4
11.2.0.2		       PSU 11.2.0.2.8

you may even check if the database was upgraded from a previous release:

select version,comments from registry$history where comments like '%Upgraded%';

VERSION 		       COMMENTS
------------------------------ ------------------------
11.2.0.3.0		       Upgraded from 11.2.0.2.0

nothing special but maybe this might help someone. this is a simple bash script which automates the installation of the oracle 12c binaries and creates an initial oracle database. all you have to do is to download the sources, adjust the parameters in the configuration section and execute the script. if you keep the script as it is (except for SOURCEPATH) you will get the following:

ORACLE_SID=orcl
ORACLE_BASE=/opt/oracle/product/base
ORACLE_HOME=/opt/oracle/product/base/12.1.0.1
oraInventory=/opt/oracle/oraInventory
/oradata/orcl/...    for the database files
standard oracle user and oracle groups

this is for redhat6 based distributions only (rhel6, ol6, centos6 (not supported, but works)).

as the script installs the required linux software you should have the yum repositories available somehow ( either you are connected to the internet or you have a local copy of the repositories ).

btw: the logs can be found in the home of the oracle user.
btw2: the script does not create the limits (ulimit) recommended by oracle as the defaults should be fine for testing

#!/bin/bash

##################################################
#         CONFIGURATION SECTION                  #
##################################################

# ** location of the database source files
SOURCEPATH=/home/daniel/Downloads
# ** name of the first source file
SOURCE1=linuxamd64_12c_database_1of2.zip
# ** name of the second source file
SOURCE2=linuxamd64_12c_database_2of2.zip
# ** working directory for extracting the source
WORKDIR=/opt/oracle/stage
# ** the oracle top directory
ORATOPDIR=/opt/oracle
# ** the oracle inventory
ORAINVDIR=${ORATOPDIR}/oraInventory
# ** the ORACLE_BASE to use
ORACLE_BASE=${ORATOPDIR}/product/base
# ** the ORACLE_HOME to use
ORACLE_HOME=${ORACLE_BASE}/12.1.0.1
# ** base directory for the oracle database files
ORABASEDIR=/oradata
# the ORACLE_SID to use
ORACLE_SID=orcl
# ** the owner of the oracle software
ORAOWNER=oracle
# ** the primary installation group
ORAINSTGROUP=oinstall
# ** the dba group
ORADBAGROUP=dba
# ** the oper group
ORAOPERGROUP=oper
# ** the backup dba group
ORABACKUPDBA=backupdba
# ** the dataguard dba group
ORADGBAGROUP=dgdba
# ** the transparent data encryption group
ORAKMBAGROUP=kmdba


##################################################
#        MAIN SECTION                            # 
##################################################

PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora

# print the header
_header() {
   echo "*** ---------------------------- ***"
   echo "*** -- starting oracle 12c setup ***"
   echo "*** ---------------------------- ***"
}

# print simple log messages to screen
_log() {
   echo "****** $1 "
}

# check for the current os user
_check_user() {
    if [ $(id -un) != "${1}" ]; then
        _log "you must run this as ${1}"
        exit 0
    fi

}

# create the user and the groups
_create_user_and_groups() {
    _log "*** checking for group: ${ORAINSTGROUP} "
    getent group ${ORAINSTGROUP}
    if [ "$?" -ne "0" ]; then
        /usr/sbin/groupadd ${ORAINSTGROUP} 2> /dev/null || :
    fi
    _log "*** checking for group: ${ORADBAGROUP} "
    getent group ${ORADBAGROUP}
    if [ "$?" -ne "0" ]; then
        /usr/sbin/groupadd ${ORADBAGROUP} 2> /dev/null || :
    fi
    _log "*** checking for group: ${ORAOPERGROUP} "
    getent group ${ORAOPERGROUP}
    if [ "$?" -ne "0" ]; then
        /usr/sbin/groupadd ${ORAOPERGROUP} 2> /dev/null || :
    fi
    _log "*** checking for group: ${ORABACKUPDBA} "
    getent group ${ORABACKUPDBA}
    if [ "$?" -ne "0" ]; then
        /usr/sbin/groupadd ${ORABACKUPDBA} 2> /dev/null || :
    fi
    _log "*** checking for group: ${ORADGBAGROUP} "
    getent group ${ORADGBAGROUP}
    if [ "$?" -ne "0" ]; then
        /usr/sbin/groupadd ${ORADGBAGROUP} 2> /dev/null || :
    fi
    _log "*** checking for group: ${ORAKMBAGROUP} "
    getent group ${ORAKMBAGROUP}
    if [ "$?" -ne "0" ]; then
        /usr/sbin/groupadd ${ORAKMBAGROUP} 2> /dev/null || :
    fi
    _log "*** checking for user: ${ORAOWNER} "
    getent passwd ${ORAOWNER}
    if [ "$?" -ne "0" ]; then
        /usr/sbin/useradd -g ${ORAINSTGROUP} -G ${ORADBAGROUP},${ORAOPERGROUP},${ORABACKUPDBA},${ORADGBAGROUP},${ORAKMBAGROUP} \
                          -c "oracle software owner" -m -d /home/${ORAOWNER} -s /bin/bash ${ORAOWNER}
    fi
}

# create the directories
_create_dirs() {
    _log "*** creating: ${WORKDIR} "
    mkdir -p ${WORKDIR}
    chown ${ORAOWNER}:${ORAINSTGROUP} ${WORKDIR}
    _log "*** creating: ${ORATOPDIR} "
    mkdir -p ${ORATOPDIR}
    chown ${ORAOWNER}:${ORAINSTGROUP} ${ORATOPDIR}
    _log "*** creating: ${ORACLE_BASE} "
    mkdir -p ${ORACLE_BASE}
    chown ${ORAOWNER}:${ORAINSTGROUP} ${ORACLE_BASE}
    _log "*** creating: ${ORACLE_HOME} "
    mkdir -p ${ORACLE_HOME}
    chown ${ORAOWNER}:${ORAINSTGROUP} ${ORACLE_HOME}
    _log "*** creating: ${ORABASEDIR} "
    mkdir -p ${ORABASEDIR}
    chown ${ORAOWNER}:${ORAINSTGROUP} ${ORABASEDIR}
    _log "*** creating: ${ORABASEDIR}/${ORACLE_SID} "
    mkdir -p ${ORABASEDIR}/${ORACLE_SID}
    chown ${ORAOWNER}:${ORAINSTGROUP} ${ORABASEDIR}/${ORACLE_SID}
    _log "*** creating: ${ORABASEDIR}/${ORACLE_SID}/rdo1 "
    mkdir -p ${ORABASEDIR}/${ORACLE_SID}/rdo1
    _log "*** creating: ${ORABASEDIR}/${ORACLE_SID}/rdo2 "
    mkdir -p ${ORABASEDIR}/${ORACLE_SID}/rdo2
    _log "*** creating: ${ORABASEDIR}/${ORACLE_SID}/dbf "
    mkdir -p ${ORABASEDIR}/${ORACLE_SID}/dbf
    _log "*** creating: ${ORABASEDIR}/${ORACLE_SID}/arch "
    mkdir -p ${ORABASEDIR}/${ORACLE_SID}/arch
    _log "*** creating: ${ORABASEDIR}/${ORACLE_SID}/admin "
    mkdir -p ${ORABASEDIR}/${ORACLE_SID}/admin
    _log "*** creating: ${ORABASEDIR}/${ORACLE_SID}/admin/adump "
    mkdir -p ${ORABASEDIR}/${ORACLE_SID}/admin/adump
    _log "*** creating: ${ORABASEDIR}/${ORACLE_SID}/pdbseed "
    mkdir -p ${ORABASEDIR}/${ORACLE_SID}/pdbseed
    chown -R ${ORAOWNER}:${ORADBAGROUP} ${ORABASEDIR}/${ORACLE_SID}
}

# extract the source files
_extract_sources() {
    cp ${SOURCEPATH}/${SOURCE1} ${WORKDIR}
    cp ${SOURCEPATH}/${SOURCE2} ${WORKDIR}
    chown ${ORAOWNER}:${ORAINSTGROUP} ${WORKDIR}/*
    _log "*** extracting: ${SOURCE1} "
    su - ${ORAOWNER} -c "unzip -d ${WORKDIR} ${WORKDIR}/${SOURCE1}"
    _log "*** extracting: ${SOURCE2} "
    su - ${ORAOWNER} -c "unzip -d ${WORKDIR} ${WORKDIR}/${SOURCE2}"
}

# install required software
_install_required_software() {
    _log "*** installing required software "
    yum install -y 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
}

# install oracle software
_install_oracle_software() {
    _log "*** installing oracle software"
    su -  ${ORAOWNER} -c "cd ${WORKDIR}/database; ./runInstaller oracle.install.option=INSTALL_DB_SWONLY \
    ORACLE_BASE=${ORACLE_BASE} \
    ORACLE_HOME=${ORACLE_HOME} \
    UNIX_GROUP_NAME=${ORAINSTGROUP}  \
    oracle.install.db.DBA_GROUP=${ORADBAGROUP} \
    oracle.install.db.OPER_GROUP=${ORAOPERGROUP} \
    oracle.install.db.BACKUPDBA_GROUP=${ORABACKUPDBA}  \
    oracle.install.db.DGDBA_GROUP=${ORADGBAGROUP}  \
    oracle.install.db.KMDBA_GROUP=${ORAKMBAGROUP}  \
    FROM_LOCATION=../stage/products.xml \
    INVENTORY_LOCATION=${ORAINVDIR} \
    SELECTED_LANGUAGES=en \
    oracle.install.db.InstallEdition=EE \
    DECLINE_SECURITY_UPDATES=true  -silent -ignoreSysPrereqs -ignorePrereq -waitForCompletion"
    ${ORAINVDIR}/orainstRoot.sh
    ${ORACLE_HOME}/root.sh
}

# create a very minimal pfile
_create_pfile() {
    _log "*** creating pfile "
    echo "instance_name=${ORACLE_SID}" > ${PFILE}
    echo "db_name=${ORACLE_SID}" >> ${PFILE}
    echo "db_block_size=8192" >> ${PFILE}
    echo "control_files=${ORABASEDIR}/${ORACLE_SID}/rdo1/control01.ctl,${ORABASEDIR}/${ORACLE_SID}/rdo2/control02.ctl" >> ${PFILE}
    echo "sga_max_size=512m" >> ${PFILE}
    echo "sga_target=512m" >> ${PFILE}
    echo "diagnostic_dest=${ORABASEDIR}/${ORACLE_SID}/admin" >> ${PFILE}
    echo "audit_file_dest=${ORABASEDIR}/${ORACLE_SID}/admin/adump" >> ${PFILE}
    echo "enable_pluggable_database=true" >> ${PFILE}
}

# create the database
_create_database() {
    _log "*** creating database "
    # escaping the dollar seems not to work in EOF
    echo "alter pluggable database pdb\$seed close;" > ${ORABASEDIR}/${ORACLE_SID}/admin/seedhack.sql
    echo "alter pluggable database pdb\$seed open;" >> ${ORABASEDIR}/${ORACLE_SID}/admin/seedhack.sql
    su - ${ORAOWNER} -c "export ORACLE_HOME=${ORACLE_HOME};export LD_LIBRARY_PATH=${LD_LIBRARY_PATH};export PATH=${ORACLE_HOME}/bin:${PATH};export ORACLE_SID=${ORACLE_SID};export PERL5LIB=${ORACLE_HOME}/rdbms/admin; sqlplus / as sysdba <<EOF 
shutdown abort
startup force nomount pfile=${PFILE} 
create spfile from pfile='${PFILE}';
startup force nomount
CREATE DATABASE \"${ORACLE_SID}\"
MAXINSTANCES 8
MAXLOGHISTORY 5
MAXLOGFILES 16
MAXLOGMEMBERS 5
MAXDATAFILES 1024
DATAFILE '${ORABASEDIR}/${ORACLE_SID}/dbf/system01.dbf' SIZE 1024m REUSE AUTOEXTEND ON NEXT 8m MAXSIZE 2g EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '${ORABASEDIR}/${ORACLE_SID}/dbf/sysaux01.dbf' SIZE 1024m REUSE AUTOEXTEND ON NEXT 8m MAXSIZE 2g
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '${ORABASEDIR}/${ORACLE_SID}/dbf/temp01.dbf' SIZE 1024m REUSE AUTOEXTEND ON NEXT 8m MAXSIZE 2g
UNDO TABLESPACE \"UNDOTBS1\" DATAFILE  '${ORABASEDIR}/${ORACLE_SID}/undotbs01.dbf' SIZE 1024m REUSE AUTOEXTEND ON NEXT 8m MAXSIZE 2g
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('${ORABASEDIR}/${ORACLE_SID}/rdo1/redo01_1.log', '${ORABASEDIR}/${ORACLE_SID}/rdo2/redo01_2.log') SIZE 64m,
        GROUP 2 ('${ORABASEDIR}/${ORACLE_SID}/rdo1/redo02_1.log', '${ORABASEDIR}/${ORACLE_SID}/rdo2/redo02_2.log') SIZE 64m,
        GROUP 3 ('${ORABASEDIR}/${ORACLE_SID}/rdo1/redo03_1.log', '${ORABASEDIR}/${ORACLE_SID}/rdo2/redo03_2.log') SIZE 64m
USER SYS IDENTIFIED BY \"sys\" USER SYSTEM IDENTIFIED BY \"system\"
enable pluggable database
seed file_name_convert=('${ORABASEDIR}/${ORACLE_SID}/dbf/system01.dbf', '${ORABASEDIR}/${ORACLE_SID}/pdbseed/system01.dbf'
                       ,'${ORABASEDIR}/${ORACLE_SID}/dbf/sysaux01.dbf', '${ORABASEDIR}/${ORACLE_SID}/pdbseed/sysaux01.dbf'
                       ,'${ORABASEDIR}/${ORACLE_SID}/dbf/temp01.dbf', '${ORABASEDIR}/${ORACLE_SID}/pdbseed/temp01.dbf'
                       ,'${ORABASEDIR}/${ORACLE_SID}/dbf/undotbs01.dbf', '${ORABASEDIR}/${ORACLE_SID}/pdbseed/undotbs01.dbf');
startup force
alter session set \"_oracle_script\"=true;
start ${ORABASEDIR}/${ORACLE_SID}/admin/seedhack.sql
host perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l /home/${ORAOWNER} -b catalog $ORACLE_HOME/rdbms/admin/catalog.sql;
host perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l /home/${ORAOWNER} -b catblock $ORACLE_HOME/rdbms/admin/catblock.sql;
host perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l /home/${ORAOWNER} -b catproc $ORACLE_HOME/rdbms/admin/catproc.sql;
host perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l /home/${ORAOWNER} -b catoctk $ORACLE_HOME/rdbms/admin/catoctk.sql;
host perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l /home/${ORAOWNER} -b pupbld -u SYSTEM/system $ORACLE_HOME/sqlplus/admin/pupbld.sql;
connect "SYSTEM"/"system"
host perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l /home/${ORAOWNER} -b hlpbld -u SYSTEM/system -a 1  $ORACLE_HOME/sqlplus/admin/help/hlpbld.sql 1helpus.sql;
connect / as sysdba
start $ORACLE_HOME/rdbms/admin/utlrp.sql
set lines 264 pages 9999
col owner for a30
col status for a10
col object_name for a30
col object_type for a30
col comp_name for a80
col PDB_NAME for a30
col PDB_ID for 999
select owner,object_name,object_type,status from dba_objects where status  'VALID';
select comp_name,status from dba_registry;
select pdb_id,pdb_name from dba_pdbs;
exit;
EOF"
}

# add oracle environment to .bash_profile
_create_env() {
    _log "*** adding environment to .bash_profile "
    echo "ORACLE_BASE=${ORACLE_BASE}" >> /home/${ORAOWNER}/.bash_profile
    echo "ORACLE_HOME=${ORACLE_HOME}" >> /home/${ORAOWNER}/.bash_profile
    echo "ORACLE_SID=${ORACLE_SID}" >> /home/${ORAOWNER}/.bash_profile
    echo "LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}" >> /home/${ORAOWNER}/.bash_profile
    echo "PATH=${ORACLE_HOME}/bin:${PATH}" >> /home/${ORAOWNER}/.bash_profile
    echo "export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH" >> /home/${ORAOWNER}/.bash_profile
}

_header
_check_user "root"
_create_user_and_groups
_create_dirs
_install_required_software
_extract_sources
_install_oracle_software
_create_pfile
_create_database
_create_env

once the script finished simply do:

su - oracle
sqlplus / as sysdba

… and start playing around.

here is a must read white paper from oracle decribing the multitenant architecture:
multitenant architecture

topics include basic concepts, upgrading, plugging/unplugging, cloning, common and local users and much more …

the previous post gave a little more information about the catcon.pl script. this time I will show how you may let work the script for you.

lets say you have a little script and you want to deploy this on two of your container databases. for this simple demonstration I created to PDBs ( dbs300_1 and dbs300_2 ):

set lines 264
col pdb_name for a30;
select PDB_ID,PDB_NAME,STATUS from dba_pdbs;

    PDB_ID PDB_NAME			  STATUS
---------- ------------------------------ -------------
	 2 PDB$SEED			  NORMAL
	 3 DBS300_1			  NORMAL
	 4 DBS300_2			  NORMAL

both pdbs have a tablespace called users:

select c.tablespace_name
     , v.name
  from v$containers v
     , cdb_tablespaces c
 where v.con_id = c.con_id
   and tablespace_name = 'USERS';

TABLESPACE_NAME 	       NAME
------------------------------ ------------------------------
USERS			       DBS300_2
USERS			       DBS300_1
USERS			       CDB$ROOT

i want a user, one table and a row for my two pdbs:

create user u1 identified by "u" container=current quota unlimited on users;
create table u1.t1 ( a number, b date);
insert into u1.t1 (a,b) values (1,sysdate);
commit;

lets pass this script to catcon.pl and see what happens:

export PERL5LIB=$ORACLE_HOME/rdbms/admin:$PERL5LIB
perl $ORACLE_HOME/rdbms/admin/catcon.pl -b mylog -d /home/oracle -l /home/oracle -e -c 'DBS300_1 DBS300_2' test_script.sql

how many logfile should be there now ? two:

ls -la mylog*
-rw-r----- 1 oracle oinstall 1511 27. Jun 03:58 mylog0.log
-rw-r----- 1 oracle oinstall 1511 27. Jun 03:58 mylog1.log

grep "ORA-" mylog*.log

looks fine. lets see if the user, table and row really got created:

SQL> show con_name

CON_NAME
------------------------------
DBS300_1
SQL> select * from u1.t1;

	 A B
---------- --------------------
	 1 27-JUN-2013 03:58:13

SQL> 

… and the second one ?

SQL> show con_name;

CON_NAME
------------------------------
DBS300_2
SQL> select * from u1.t1;

	 A B
---------- --------------------
	 1 27-JUN-2013 03:58:13

SQL> 

great…

but there is a side effect: if you want to drop the user in the pdb you’ll get:

SQL> drop user u1 cascade;
drop user u11 cascade
*
ERROR at line 1:
ORA-28014: cannot drop administrative users

this is a little bit strange as the test script did not create a user with “container=all”. what you need to know here is, that catcon.pl does this:

alter session set "_oracle_script"=true;

… and this somehow results in the created users to be considered administrative users although they are not. a workaround for this is:

alter session set "_oracle_script"=true;
drop user u1 cascade;

beside that catcon.pl may be a great way to deploy scripts to all or some of your pdbs, e.g. you might want to setup development pdbs which all look the same or want to do some maintenance tasks on all the pdbs.

oracle 12c: catcon.pl

June 28, 2013 — 4 Comments

the last post quickly mentioned a new perl script which is used to setup the catalog in 12c. first of all the script is officially document here. in summary it is used to execute sql scripts in one or more containers. it is even possible to execute scripts in parallel, e.g. if there are multiple containers to run the scripts against.

if you take a look at the script it seems there is not much in there. but if you are used to read perl scripts you’ll quickly notify that all the logic is packed into a perl module file called catcon.pm ( which is located in the same directory ). here is a simple flow diagram which rawly describes the path through the perl code:

flow of the container scripts

so, when for for example this is executed:

!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/lcsdb -b catalog /opt/oracle/product/base/12.1.0.1/rdbms/admin/catalog.sql;

… this actually executes the catalog.sql in all the containers databases as no “-c”-switch is given. this for sure is one reason why the setup of the catalog takes much more time than in 11g.

we can confirm this by looking where catconExec is called in catcon.pl:

$RetCode = catconExec(@Scripts, 0, 0, 0);

the header of catconExec explains the parameters:

  # catconExec - run specified sqlplus script(s) or SQL statements
  #
  # If connected to a non-Consolidated DB, each script will be executed
  # using one of the processes connected to the DB.
  #
  # If connected to a Consolidated DB and the caller requested that all
  # scripts and SQL statements be run against the Root (possibly in addition
  # to other Containers), each script and statement will be executed in the
  # Root using one of the processes connected to the Root.
  #
  # If connected to a Consolidated DB and were asked to run scripts and SQL
  # statements in one or more Containers besides the Root, all scripts and
  # statements will be run against those PDBs in parallel
  #
  # Parameters:
  #   - reference to an array of sqlplus script name(s) or SQL statement(s);
  #     script names are expected to be prefixed with @
  #   - an indicator of whether scripts need to be run in order
  #       TRUE => run in order
  #   - an indicator of whether scripts or SQL statements need to be run only
  #     in the Root if operating on a CDB (temporarily overriding whatever
  #     was set by catconInit)
  #       TRUE => if operating on a CDB, run in Root only
  #   - an indicator of whether per process initialization/completion
  #     statements need to be issued
  #     TRUE => init/comletion statements, if specified, will be issued

in short: run all the scripts referenced in the first parameter ( which is a perl array ), do not run it in order, do not run it only in the root container and do not issue per process initialization/completion.

at the end a little hardcoding in catconInit: “(default sys/knl_test7 AS SYSDBA)”. i wonder if this is a default password used at oracle development :) :

find . -type f | xargs grep "knl_test7"
./admin/catcon.pm:#     set connect string to 'sys/knl_test7 AS SYSDBA'
./admin/catcon.pm:    $connect = "sys/knl_test7"; 
./admin/catcon.pm:  #     undefined (default sys/knl_test7 AS SYSDBA)

update 2013-JUN-29: knl_test7 is also referenced in some older documentations:
10g Release 1 (10.1)
Oracle 8i Data Cartridge Developer’s Guide

as usual when oracle releases a new version of its database I start the dbca and generate the scripts to see what happens in the background. there are quite some interesting changes:

  • the create database statement contains new parameters: “enable pluggable database” and “seed file_name_convert”
  • there is a perl wrapper script to setup the database catalog (catcon.pl)
  • xdb is installed by catproc
  • a hidden parameter “_oracle_script” is used while setting up the catalog
  • there is a new parameter for the init.ora: enable_pluggable_database=true
  • files for the seed container get created, so you’ll need more space

I am sure there are much more changes but these are the ones that catched my eyes while looking at the scripts. here is the complete sample setup ( you’ll need to be patient, this will take much more time than you are used to in 11g ):

umask 0027
mkdir -p /oradata/dbs300/admin/adump
mkdir -p /oradata/dbs300/admin/dpdump
mkdir -p /oradata/dbs300/admin/audit
mkdir -p /oradata/dbs300/admin/pfile
mkdir -p /oradata/dbs300/appl
mkdir -p /oradata/dbs300/dbf
mkdir -p /oradata/dbs300/rdo1
mkdir -p /oradata/dbs300/rdo2
mkdir -p /oradata/dbs300/pdbseed
mkdir -p /oradata/dbs300/fast_recovery_area

orapwd file=/oradata/dbs300/admin/pfile/orapwdbs300 force=y format=12 password=oracle

echo "*.db_block_size=8192
*.control_file_record_keep_time=35
*.filesystemio_options='setall'
*.disk_asynch_io=TRUE
*.db_block_checksum=TYPICAL
*.db_block_checking=MEDIUM
*.db_cache_advice='ON'
*.db_keep_cache_size=0m
*.db_files=1024
*.db_recycle_cache_size=0m
*.fast_start_mttr_target=500
*.instance_name='dbs300'
*.open_cursors=300
*.db_domain='local'
*.db_name="dbs300"
*.log_archive_dest_1='location=/oradata/dbs300/fast_recovery_area'
*.log_archive_format='dummy_%r_%t_%S.arc'
*.job_queue_processes=2
*.control_files=('/oradata/dbs300/rdo1/control01.ctl', '/oradata/dbs300/rdo2/control02.ctl')
*.db_recovery_file_dest='/oradata/dbs300/fast_recovery_area'
*.db_recovery_file_dest_size=4815m
*.compatible=12.1.0.0.0
*.diagnostic_dest=/oradata/dbs300/admin/
*.enable_pluggable_database=true
*.processes=300
*.sga_target=256m
*.audit_file_dest='/oradata/dbs300/admin/adump/'
*.audit_trail=db
*.remote_login_passwordfile=EXCLUSIVE
*.pga_aggregate_target=80m
*.parallel_max_servers=5
*.query_rewrite_enabled='FALSE'
*.recovery_parallelism=4
*.star_transformation_enabled='FALSE'
*.statistics_level='typical'
*.timed_statistics=TRUE
*.recyclebin='OFF'
*.undo_management='auto'
*.undo_retention=10800
*.workarea_size_policy='auto'
*.optimizer_capture_sql_plan_baselines='FALSE'
*.optimizer_use_sql_plan_baselines='TRUE'
*.optimizer_dynamic_sampling=2
*.max_dump_file_size=50m
*.remote_login_passwordfile=EXCLUSIVE
*.undo_tablespace=UNDOTBS1" > /oradata/dbs300/admin/pfile/initdbs300.ora

PERL5LIB=$ORACLE_HOME/rdbms/admin:$PERL5LIB; export PERL5LIB

sqlplus / as sysdba
startup force nomount pfile='/oradata/dbs300/admin/pfile/initdbs300.ora';
create spfile='/oradata/dbs300/admin/pfile/spfiledbs300.ora' from pfile='/oradata/dbs300/admin/pfile/initdbs300.ora';
!ln -s /oradata/dbs300/admin/pfile/spfiledbs300.ora $ORACLE_HOME/dbs/
startup force nomount

CREATE DATABASE "dbs300"
MAXINSTANCES 8
MAXLOGHISTORY 5
MAXLOGFILES 16
MAXLOGMEMBERS 5
MAXDATAFILES 1024
DATAFILE '/oradata/dbs300/dbf/system_01.dbf' SIZE 1024m REUSE AUTOEXTEND ON NEXT 8m MAXSIZE 2g EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/oradata/dbs300/dbf/sysaux_01.dbf' SIZE 1024m REUSE AUTOEXTEND ON NEXT 8m MAXSIZE 2g 
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/oradata/dbs300/dbf/temp_01.dbf' SIZE 1024m REUSE AUTOEXTEND ON NEXT 8m MAXSIZE 2g
UNDO TABLESPACE "UNDOTBS1" DATAFILE  '/oradata/dbs300/dbf/undotbs_01.dbf' SIZE 1024m REUSE AUTOEXTEND ON NEXT 8m MAXSIZE 2g 
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('/oradata/dbs300/rdo1/redo01_1.log', '/oradata/dbs300/rdo2/redo01_2.log') SIZE 64m,
        GROUP 2 ('/oradata/dbs300/rdo1/redo02_1.log', '/oradata/dbs300/rdo2/redo02_2.log') SIZE 64m,
        GROUP 3 ('/oradata/dbs300/rdo1/redo03_1.log', '/oradata/dbs300/rdo2/redo03_2.log') SIZE 64m
USER SYS IDENTIFIED BY "oracle" USER SYSTEM IDENTIFIED BY "oracle"
enable pluggable database
seed file_name_convert=('/oradata/dbs300/dbf/system_01.dbf', '/oradata/dbs300/pdbseed/system_01.dbf'
                       ,'/oradata/dbs300/dbf/sysaux_01.dbf', '/oradata/dbs300/pdbseed/sysaux_01.dbf'
                       ,'/oradata/dbs300/dbf/temp_01.dbf', '/oradata/dbs300/pdbseed/temp_01.dbf'
                       ,'/oradata/dbs300/dbf/undotbs_01.dbf', '/oradata/dbs300/pdbseed/undotbs_01.dbf');

CREATE TABLESPACE "USERS" LOGGING DATAFILE '/oradata/dbs300/dbf/users_01.dbf' SIZE 16m REUSE AUTOEXTEND ON NEXT 8m MAXSIZE 2g EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
ALTER DATABASE DEFAULT TABLESPACE "USERS";

alter session set "_oracle_script"=true;
alter pluggable database pdb$seed close;
alter pluggable database pdb$seed open;

!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catalog /opt/oracle/product/base/12.1.0.1/rdbms/admin/catalog.sql;
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catblock /opt/oracle/product/base/12.1.0.1/rdbms/admin/catblock.sql;
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catproc /opt/oracle/product/base/12.1.0.1/rdbms/admin/catproc.sql;
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catoctk /opt/oracle/product/base/12.1.0.1/rdbms/admin/catoctk.sql;
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b pupbld -u SYSTEM/oracle /opt/oracle/product/base/12.1.0.1/sqlplus/admin/pupbld.sql;
connect system/oracle
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b hlpbld -u SYSTEM/oracle -a 1  /opt/oracle/product/base/12.1.0.1/sqlplus/admin/help/hlpbld.sql 1helpus.sql;

conn / as sysdba
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catclust /opt/oracle/product/base/12.1.0.1/rdbms/admin/catclust.sql;
grant sysdg to sysdg;
grant sysbackup to sysbackup;
grant syskm to syskm;

@?/rdbms/admin/utlrp

-- for java
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b initjvm /opt/oracle/product/base/12.1.0.1/javavm/install/initjvm.sql;
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b initxml /opt/oracle/product/base/12.1.0.1/xdk/admin/initxml.sql;
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b xmlja /opt/oracle/product/base/12.1.0.1/xdk/admin/xmlja.sql;
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catjava /opt/oracle/product/base/12.1.0.1/rdbms/admin/catjava.sql;
connect "SYS"/oracle as SYSDBA
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catxdbj /opt/oracle/product/base/12.1.0.1/rdbms/admin/catxdbj.sql;

-- for oracle text
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catctx -a 1  /opt/oracle/product/base/12.1.0.1/ctx/admin/catctx.sql 1change_on_install 1SYSAUX 1TEMP 1LOCK;
alter user CTXSYS account unlock identified by "CTXSYS";
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b dr0defin -u CTXSYS/CTXSYS -a 1  /opt/oracle/product/base/12.1.0.1/ctx/admin/defaults/dr0defin.sql 1\"AMERICAN\";
connect "SYS"/oracle as SYSDBA
alter user CTXSYS password expire account lock;

--for ord
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b ordinst -a 1  /opt/oracle/product/base/12.1.0.1/ord/admin/ordinst.sql 1SYSAUX 1SYSAUX;

-- for intermedia
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b iminst /opt/oracle/product/base/12.1.0.1/ord/im/admin/iminst.sql;

-- for olap
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b olap -a 1  /opt/oracle/product/base/12.1.0.1/olap/admin/olap.sql 1SYSAUX 1TEMP;

-- for spatial
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b mdinst /opt/oracle/product/base/12.1.0.1/md/admin/mdinst.sql;

-- for label security
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catols /opt/oracle/product/base/12.1.0.1/rdbms/admin/catols.sql;

-- for apex
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catapx -a 1  /opt/oracle/product/base/12.1.0.1/apex/catapx.sql 1change_on_install 1SYSAUX 1SYSAUX 1TEMP 1/i/ 1NONE;

-- for datavault
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catmac -a 1  /opt/oracle/product/base/12.1.0.1/rdbms/admin/catmac.sql 1SYSAUX 1TEMP 1oracle;

-- psu
!perl /opt/oracle/product/base/12.1.0.1/rdbms/admin/catcon.pl -n 1 -l /home/oracle -b catbundle -a 1  /opt/oracle/product/base/12.1.0.1/rdbms/admin/catbundle.sql 1psu 1apply;

select COMP_NAME,VERSION,STATUS from dba_registry

COMP_NAME				 VERSION			STATUS
---------------------------------------- ------------------------------ ------------------------------
Oracle XML Database			 12.1.0.1.0			VALID
Oracle Database Catalog Views		 12.1.0.1.0			VALID
Oracle Database Packages and Types	 12.1.0.1.0			VALID
Oracle Real Application Clusters	 12.1.0.1.0			OPTION OFF
shutdown immediate;
-- add to gi
!/opt/oracle/product/base/12.1.0.1/bin/srvctl add database -d dbs300 -o /opt/oracle/product/base/12.1.0.1 -n dbs300
!/opt/oracle/product/base/12.1.0.1/bin/srvctl start database -d dbs300;

more to come …

if you are used to use silent installation for the oracle database software you need to provide additional parameters: oracle.install.db.BACKUPDBA_GROUP, oracle.install.db.DGDBA_GROUP and oracle.install.db.KMDBA_GROUP

./runInstaller oracle.install.option=INSTALL_DB_SWONLY \
    ORACLE_BASE=/opt/oracle/product/base \
    ORACLE_HOME=/opt/oracle/product/base/12.1.0.1 \
    UNIX_GROUP_NAME=oinstall \
    oracle.install.db.DBA_GROUP=dba \
    oracle.install.db.OPER_GROUP=oper \
    oracle.install.db.BACKUPDBA_GROUP=dba \
    oracle.install.db.DGDBA_GROUP=dba \
    oracle.install.db.KMDBA_GROUP=dba \
    FROM_LOCATION=../stage/products.xml \
    INVENTORY_LOCATION=/opt/oracle/oraIventory \
    SELECTED_LANGUAGES=en \
    oracle.install.db.InstallEdition=EE \
    DECLINE_SECURITY_UPDATES=true  -silent -ignoreSysPrereqs -ignorePrereq -waitForCompletion

otherwise your installation will fail with:

[FATAL] [INS-35341] The installation user is not a member of the following groups: [null, null, null]
   CAUSE: The installation user account must be a member of all groups required for installation.
   ACTION: Ensure that the installation user is a member of the system privileges operating system groups you selected.

these are used to further improve seperation of duties: documentation

to be honest, I never was aware of this. there is a create schema command in oracle which can be used to populate a schema in a singe transaction:

create user u identified by u;
create user a identified by a;
grant create session, create table, create view to u;
alter user u quota 1m on users;
connect u/u
create schema authorization u
   create table t1 
      (a number, b varchar2(10))
   create view v1
      as select * from t1 where a = 1
   grant select on v1 to a;

this can be very handy if you want a script ( which creates some tables and views ) to be atomic. if there is an error in your create schema script like:

create schema authorization u
   create table t1
      (a number, b varchar2(10))
   create view v1
      as select **** from t1 where a = 1
   grant select on v1 to a;

… nothing will be created at all. you may fix the script and start over again ( without dropping anything as you would need to do it if you use single create commands ).

this is documented here.

there is a white paper which you definitely should read before you think about running an oracle database on zfs:

Configuring ZFS for an Oracle Database

fixing things afterwards might be tricky …