1. Logon as the oracle user.
su - oracle
2. Setup the OE schema in the database.
a. By default the TWO_TASK is set to the PDB. Unset the TWO_TASK to connect to the CDB.
[oracle@source ~]$ echo $TWO_TASK pdb1 [oracle@source ~]$ unset TWO_TASK
b. Logon to the database )CDB) as sysdba.
[oracle@source ~]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.1.0 Production on Thu Jul 31 23:25:18 2014 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options CDB$ROOT@ORCL>
c. Connect to the PDB.
CDB$ROOT@ORCL> ALTER SESSION SET container = pdb1;
d. Unlock and alter the OE schema. Run the following SQL.
ALTER USER oe IDENTIFIED BY oe; ALTER USER oe ACCOUNT UNLOCK; GRANT ALTER SESSION, CONNECT, CREATE MATERIALIZED VIEW, CREATE VIEW, QUERY REWRITE, RESOURCE TO oe; GRANT EXECUTE ON DBMS_LOCK TO oe; ALTER USER OE QUOTA UNLIMITED ON USERS;
e. Logout of the database.
SQL> exit
3. Setup the correct TNS alias. Edit /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
vi /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
Add the following to the end of the file:
TTORCL_SRC = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = source-int)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = pdb1) ) ) TTORCL_TRG = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = target-int)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = pdb1) ) )
Test if the TNS alias is working:
$ tnsping ttorcl_src TNS Ping Utility for Linux: Version 11.2.0.2.0 - Production on 11-JAN-2014 13:39:13 Copyright (c) 1997, 2010, Oracle. All rights reserved. Used parameter files: Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = source-int)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl))) OK (0 msec)
4. Bring the database in archivelog mode. This is a requirement for Dbvisit Replicate.
a. By default the TWO_TASK is set to the PDB. Unset the TWO_TASK to connect to the CDB.
[oracle@source ~]$ unset TWO_TASK
b. Shutdown the database.
sqlplus / as sysdba CDB$ROOT@ORCL> shutdown immediate;
c. Start up the database in no mount mode.
CDB$ROOT@ORCL> startup mount; ORACLE instance started. Total System Global Area 413372416 bytes Fixed Size 2289016 bytes Variable Size 322962056 bytes Database Buffers 79691776 bytes Redo Buffers 8429568 bytes Database mounted.
d. Turn on archivelog mode.
CDB$ROOT@ORCL> alter database archivelog; Database altered.
e. Open the database.
CDB$ROOT@ORCL> alter database open; Database altered.
f. Check the archivelog mode.
CDB$ROOT@ORCL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 104 Next log sequence to archive 106 Current log sequence 106
g. Logout of the database.
SQL> exit
5. Ensure the archive log files are managed and not filling up and stopping the database. Install a script that manages the archive logs.
a. Logon as root.
su -
change directory to /usr/local/bin
cd /usr/local/bin
b. Download an archive management script from the dbvisit.com website named del_arch.sh
[root@source bin]# wget http://ww2.dbvisit.com/download/files/external/del_arch.sh --2013-12-23 01:13:17-- http://ww2.dbvisit.com/download/files/external/del_arch.sh Resolving ww2.dbvisit.com... 67.222.54.241 Connecting to ww2.dbvisit.com|67.222.54.241|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1822 (1.8K) [application/x-sh] Saving to: `del_arch.sh' 100%[================================================================================================================>] 1,822 --.-K/s in 0s 2013-12-23 01:13:18 (104 MB/s) - `del_arch.sh' saved [1822/1822]
c. Make the script executable and change ownership to oracle.
[root@source bin]# chmod 750 del_arch.sh
[root@source bin]# chown oracle:dba del_arch.sh
[root@source bin]# exit
d. As user oracle, add the script to the oracle crontab.
su - oracle
crontab -e
e. Add the following line to crontab and then save and exit (:wq) This runs the script every 15 minutes and deletes all archives older than 4.8 hours (0.2 days).
*/15 * * * * /usr/local/bin/del_arch.sh orcl 0.2 > /tmp/del_arch.txt 2>&1
In a production environment a proper RMAN backup procedure would be used to backup the archive log files before removing them.
Add Comment