This is pretty old comic from geek&Poke . Enjoy 🙂
A User reported ORA-12514 error from JDBC application connecting to RAC database
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
To troubleshoot it,
a)I checked following things to ensure specified service is running
srvctl status service -d dbname -s serv_name
b) Ensured service is registered with listener
lsnrctl status
Note that if service has domain name like *.us.oracle.com then TNS entry should also have same service name.
Service "orcl.us.oracle.com" has 1 instance(s). Instance "orcl1", status READY, has 1 handler(s) for this service...
Please note that tnsping only helps to check what tns entry is being used (in case multiple entries are present ) and whether the listener is up. It doesn’t check if database being connected to is up/down.
Tip: In case tnsping utility hangs you can try doing telnet hostname port. If this hangs too, then it could be firewall issue
Coming back to issue. I decided to test if I can connect to database using same TNS entry. Tnsnames.ora has issues if there are extra spaces. I added tns entry in same db host and tested it and I was able to login.
Since user was still not able to connect I decided to use some other machine and check if I can connect to db ( I didnt had access on application host and we had already checked that it was not firewall issue)
Trying from different host gave me dreaded error “ORA-12514” 🙂
I did quick check of VIP address using ping/nslookup (nslookup node1-vip) utility and found that node1-vip ip was same as node2-vip in DNS. Service was running on node1-vip. Modifying the DNS resolved the connection issue.
In case you are wondering why I didn’t get this error earlier.This is because name resolution was being done by /etc/hosts on database host which had correct entries for node1-vip.
I was working on setting up monitoring for application team to monitor AQ and wanted html formatting of table data. On searching I found this link from Ittichai Chammavanijakul which makes use of css formatting to generate good visual reports.
EMPNO | ENAME | JOB | MGR | HIREDATE | SAL | COMM | DEPTNO |
---|---|---|---|---|---|---|---|
7369 | SMITH | CLERK | 7902 | 17-DEC-1980 00:00:00 | 800 | 20 | |
7499 | ALLEN | SALESMAN | 7698 | 20-FEB-1981 00:00:00 | 1600 | 300 | 30 |
7521 | WARD | SALESMAN | 7698 | 22-FEB-1981 00:00:00 | 1250 | 500 | 30 |
7566 | JONES | MANAGER | 7839 | 02-APR-1981 00:00:00 | 2975 | 20 | |
7654 | MARTIN | SALESMAN | 7698 | 28-SEP-1981 00:00:00 | 1250 | 1400 | 30 |
I used following code
set markup HTML ON HEAD "<style type='text/css'> - body { - font:10pt Arial,Helvetica,sans-serif; - color:blue; background:white; } - p { - font:8pt Arial,sans-serif; - color:grey; background:white; } - table,tr,td { - font:10pt Arial,Helvetica,sans-serif; - text-align:right; - color:Black; background:white; - padding:0px 0px 0px 0px; margin:0px 0px 0px 0px; } - th { - font:bold 10pt Arial,Helvetica,sans-serif; - color:#336699; - background:#cccc99; - padding:0px 0px 0px 0px;} - h1 { - font:16pt Arial,Helvetica,Geneva,sans-serif; - color:#336699; - background-color:White; - border-bottom:1px solid #cccc99; - margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;} - h2 { - font:bold 10pt Arial,Helvetica,Geneva,sans-serif; - color:#336699; - background-color:White; - margin-top:4pt; margin-bottom:0pt;} - a { - font:9pt Arial,Helvetica,sans-serif; - color:#663300; - background:#ffffff; - margin-top:0pt; margin-bottom:0pt; vertical-align:top;} - .threshold-critical { - font:bold 10pt Arial,Helvetica,sans-serif; - color:red; } - .threshold-warning { - font:bold 10pt Arial,Helvetica,sans-serif; - color:orange; } - .threshold-ok { - font:bold 10pt Arial,Helvetica,sans-serif; - color:green; } - </style> - <title>SQL*Plus Report</title>" - BODY "" - TABLE "border='1' width='90%' align='center'" - ENTMAP OFF SPOOL ON
So you can execute above code in sqlplus and spool the output to file. This file can be send using uuencode/sendmail function . You can use below code (note content-type is text/html)
_send_email() { /usr/lib/sendmail -t << EOF From: $FROMADDRESS To: $EMAIL Subject: $MESSAGE X-Priority: 1 Content-type: text/html `cat $LOGFILE |grep -v 'rows selected'` EOF }
Call the function _send_email in your script and ensure all variables are correctly set.
uuencode usage is also simple
uuencode emp.html emp.html|mailx [email protected]
Online patching is new feature introduced in 11.1.0.6 and oracle started delivering patches with 11.2.0.2.
This patch allows you to apply patch to live database i.e we do not need to shutdown database. This feature is only available for RDBMS home and can be installed/enabled using opatch.
RDBMS Online Patching Aka Hot Patching [ID 761111.1] explains internals of how this patching works.
I tested it while working on Database corruption issue caused by Bug 10205230 ORA-600 / corruption possible during shutdown in RAC. This bug is present in 11.2.0.2 database which causes corruption when you try to use shutdown immediate/normal/transactional option to shutdown RAC database. As per MOS note 1318986.1, Data corruption occurs around shutdown one or more of the RAC instances
* One of the following ORA-600 asserts:
– ORA-600 [kclchkblk_3]
– ORA-600 [kclwcrs_6]
– ORA-600 [ktubko_1]
– ORA-600 [kcratr_scan_lostwrt]
– ORA-600[3020] on the standby database
Workaround is to perform local check point and do shutdown abort. Patch 10205230 was available for our platform and I downloaded using below command directly to server
read mos_user_id read -s h_passwd wget --http-user="$mos_user_id" --http-password="$h_passwd" "https://updates.oracle.com/Orion/Services/download/p10205230_112020_Linux-x86-64.zip?aru=13671866&patch_file=p10205230_112020_Linux-x86-64.zip" -O p10205230_112020_Linux-x86-64.zip
mos_user_id – Metalink aka Mos user id (email id)
h_passwd – Password
To query if patch is online, go to patch directory and run following
$opatch query -all online Invoking OPatch 11.2.0.1.6 Oracle Interim Patch Installer version 11.2.0.1.6 Copyright (c) 2011, Oracle Corporation. All rights reserved. Oracle Home : /home/oracle/product/11.2 Central Inventory : /home/oracle/oraInventory from : /etc/oraInst.loc OPatch version : 11.2.0.1.6 OUI version : 11.2.0.2.0 Log file location : /home/oracle/product/11.2/cfgtoollogs/opatch/opatch2012-06-20_16-43-21PM.log -------------------------------------------------------------------------------- Patch created on 2 Apr 2011, 12:57:14 hrs PST8PDT Need to shutdown Oracle instances: false Patch is roll-backable: true Patch is a "Patchset Update": false Patch is a rolling patch: true Patch has sql related actions: false Patch is an online patch: true Patch is a portal patch: false Patch is an "auto-enabled" patch: false List of platforms supported: 226: Linux x86-64 List of bugs to be fixed: 10205230: TB_X64: HIT ORA-00600: [KCLWCRS_6] This patch is a "singleton" patch. This patch belongs to the "db" product family List of executables affected: ORACLE_HOME/bin/oracle List of optional components: oracle.rdbms: 11.2.0.2.0 List of optional actions: Patch the Database instances with Online Patch hpatch/bug10205230.pch Possible XML representation of the patch: <ONEOFF REF_ID="10205230" ROLLBACK="T" XML_INV_LOC="oneoffs/10205230/" ACT_INST_VER="11.2.0.2.0" INSTALL_TIME="2012.Jun.20 16:43:21 PDT"> <DESC></DESC> <REF_LIST> <REF NAME="oracle.rdbms" VER="11.2.0.2.0" HOME_IDX="0"/> </REF_LIST> <BUG_LIST> <BUG>10205230</BUG> </BUG_LIST> <FILE_LIST/> </ONEOFF> -------------------------------------------------------------------------------- OPatch succeeded.
“Patch is an online patch: true” indicates patch can be applied to live db.
To apply the patch, we can use following syntax
Non – RAC => opatch apply online -connectString <SID>:<USERNAME>:<PASSWORD>:<NODE>
RAC => opatch apply online -connectString <SID>:<USERNAME>:<PASSWORD>:<NODE1>,<SID2>:<USERNAME>:<PASSWORD>:<NODE2>,…
Since we are patching RAC database, we will use second syntax
$ opatch apply online -connectString orcl01d1:sys:oracle123:prod03,orcl01d2:sys:oracle123:prod04 Invoking OPatch 11.2.0.1.6 Oracle Interim Patch Installer version 11.2.0.1.6 Copyright (c) 2011, Oracle Corporation. All rights reserved. Oracle Home : /home/oracle/product/11.2 Central Inventory : /home/oracle/oraInventory from : /etc/oraInst.loc OPatch version : 11.2.0.1.6 OUI version : 11.2.0.2.0 Log file location : /home/oracle/product/11.2/cfgtoollogs/opatch/opatch2012-06-20_16-53-36PM.log The patch should be applied/rolled back in '-all_nodes' mode only. Converting the RAC mode to '-all_nodes' mode. Applying interim patch '10205230' to OH '/home/oracle/product/11.2' Verifying environment and performing prerequisite checks... Do you want to proceed? [y|n] y User Responded with: Y All checks passed. Backing up files... Patching component oracle.rdbms, 11.2.0.2.0... The patch will be installed on active database instances. Installing and enabling the online patch 'bug10205230.pch', on database 'orcl01d1'. Patching in all-node mode. Updating nodes 'prod04' Apply-related files are: FP = "/home/oracle/product/11.2/.patch_storage/10205230_Apr_2_2011_12_57_14/rac/copy_files.txt" DP = "/home/oracle/product/11.2/.patch_storage/10205230_Apr_2_2011_12_57_14/rac/copy_dirs.txt" MP = "/home/oracle/product/11.2/.patch_storage/10205230_Apr_2_2011_12_57_14/rac/make_cmds.txt" RC = "/home/oracle/product/11.2/.patch_storage/10205230_Apr_2_2011_12_57_14/rac/remote_cmds.txt" Instantiating the file "/home/oracle/product/11.2/.patch_storage/10205230_Apr_2_2011_12_57_14/rac/copy_files.txt.instantiated" by replacing $ORACLE_HOME in "/home/oracle/product/11.2/.patch_storage/10205230_Apr_2_2011_12_57_14/rac/copy_files.txt" with actual path. Propagating files to remote nodes... Instantiating the file "/home/oracle/product/11.2/.patch_storage/10205230_Apr_2_2011_12_57_14/rac/copy_dirs.txt.instantiated" by replacing $ORACLE_HOME in "/home/oracle/product/11.2/.patch_storage/10205230_Apr_2_2011_12_57_14/rac/copy_dirs.txt" with actual path. Propagating directories to remote nodes... Installing and enabling the online patch 'bug10205230.pch', on database 'orcl01d2' on node 'prod04'. Patch 10205230 successfully applied Log file location: /home/oracle/product/11.2/cfgtoollogs/opatch/opatch2012-06-20_16-53-36PM.log OPatch succeeded.
You can verify that patch is applied and enabled
SQL> oradebug patch list Patch File Name State ================ ========= bug10205230.pch ENABLED
If you have multiple ORACLE databases running out of same RDBMS Home, you can enable patch for other database using enableonlinepatch option
$ opatch util enableonlinepatch -connectString orcl02d1:sys:oracle123:prod03,orcl02d2:sys:oracle123:prod04 -id 10205230
In case of single instance home, below syntax is used
$ opatch util enableonlinepatch -connectString orcl:sys:oracle123 -id 10205230
Alert log is updated with following entries during patch application
Patch bug10205230.pch Installed - Update #1 Patch bug10205230.pch Enabled - Update #2 Thu Jun 21 02:13:17 2012 Online patch bug10205230.pch has been installed Online patch bug10205230.pch has been enabled
Online patching is very important feature introduced in 11.2.0.2 as this allows you to apply patches without any downtime. Note that if you apply patch using normal opatch apply, it will not be enabled. You can confirm this by oradebug patch list command.
If you don’t like crsctl status res –t output then try using below 🙂 Can also download here crsstat11g. I have tried this on linux
crsctl status res |grep -v "^$"|awk -F "=" 'BEGIN {print " "} {printf("%s",NR%4 ? $2"|" : $2"\n")}'|sed -e 's/ *, /,/g' -e 's/, /,/g'|\ awk -F "|" 'BEGIN { printf "%-40s%-35s%-20s%-50s\n","Resource Name","Resource Type","Target ","State" }{ split ($3,trg,",") split ($4,st,",")}{for (i in trg) {printf "%-40s%-35s%-20s%-50s\n",$1,$2,trg[i],st[i]}}'
In this post we discussed about GoldenGate(GG) concepts and setting GG without DataPump Process.
Now I will talk about DataPump process and show how to setup GG replication which also uses DataPump.
In GG environment, extract process will write the data to local trail files and then pump process reads from this local trail file and sends the data, over the network, to destination trail file where this will be read by replicat process to write the changes to destination database.
The advantage of using datapump process is to improve the performance of overall replication as it will free-up the extract process from sending the data to destination side.
To setup this, download and extract the GG software as discussed in earlier post(Step 1-7).
Once the GG software is extracted, go the directory where it is extracted, know as GG home directory.
In this case it will be /u01/app/GGS.
1. Configure and start Manager process:
GGSCI (gg1.company.com) 1> edit params mgr
It will open the parameter file for manager. Enter the following in the file:
PORT 7809
save and quit the file.
2. Start the Manager process:
GGSCI (gg1.company.com) 2> start mgr Manager started.
3.
GGSCI (gg1.company.com) 3> info all Program Status Group Lag Time Since Chkpt MANAGER RUNNING MANAGER RUNNING
4. Now add and configure extract process:
The syntax to be used is:
ADD EXTRACT <extract name>, TRANLOG, BEGIN NOW GGSCI (gg1.company.com) 2>add extract ext_gg1, tranlog, begin now Extract Added GGSCI (gg1.company.com) 1> info * EXTRACT EXT_GG1 Initialized 2012-06-10 16:15 Status STOPPED Checkpoint Lag 00:00:00 (updated 00:01:45 ago) Log Read Checkpoint Oracle Redo Logs 2012-06-10 16:15:20 Seqno 0, RBA 0
5. Configure the trail file to which extract will write the records:
Syntax:
ADD EXTTRAIL <extract trail path/two character trail id> ,EXTRACT <extract name>, Megabytes <n> GGSCI (gg1.company.com) 2> add exttrail /u01/app/GGS/dirdat/lt, extract ext_gg1, megabytes 50 EXTTRAIL added.
6. Create extract parameter file:
GGSCI (gg1.company.com) 1> edit params ext_gg1 extract ext_gg1 userid gggate, password oracle exttrail /u01/app/GGS/dirdat/lt
7. Configure Pump Process which will read the local extract trail file and send data to remote trail:
Syntax: ADD EXTRACT <pump name>, EXTTRAILSOURCE <extract trail Path/two character trail id> GGSCI (gg1.company.com) 1> add extract pump_gg1, exttrailsource /u01/app/GGS/dirdat/lt EXTRACT added. GGSCI (gg1.company.com) 2> info * EXTRACT EXT_GG1 Initialized 2012-06-10 16:15 Status STOPPED Checkpoint Lag 00:00:00 (updated 00:16:56 ago) Log Read Checkpoint Oracle Redo Logs 2012-06-10 16:15:20 Seqno 0, RBA 0 EXTRACT PUMP_GG1 Initialized 2012-06-10 16:32 Status STOPPED Checkpoint Lag 00:00:00 (updated 00:00:04 ago) Log Read Checkpoint File /u01/app/GGS/dirdat/lt000000 First Record RBA 0
8. Configure a remote trail file name with Pump process:
Syntax: ADD RMTTRAIL <pump trail path/two character trail id> ,EXTRACT <pump name>, Megabytes <n> GGSCI (gg1.company.com) 4> add rmttrail /u01/app/GGS/dirdat/rt, extract pump_gg1 RMTTRAIL added.
9. Add remote host information to Pump process:
— Remote host and remort manager port to write trail
RMTHOST <Remote hostname>, MGRPORT <Target manager port number>
— Remote trail info
RMTTRAIL <extract trail path/two character trail id> GGSCI (gg1.company.com) 1> edit params pump_gg1 [oracle@gg1 dirprm]$ cat pump_gg1.prm extract pump_gg1 passthru userid gggate, password oracle rmthost gg2.company.com, mgrport 7809 rmttrail /u01/app/GGS/dirdat/rt [oracle@gg1 dirprm]$ pwd /u01/app/GGS/dirprm
Target system:
==============
1. On target database, we need to configure Replicat process which will apply the changes
to target database after reading from remote trail file.
Syntax:
ADD REPLICAT <REPLICAT name>, EXTTRAIL <trail file path/two -- character trail id> Name of the replicat process. GGSCI (gg2.company.com) 8> add replicat rep_gg2, exttrail /u01/app/GGS/dirdat/rt ERROR: No checkpoint table specified for ADD REPLICAT.
2. Add checkpoint table.
A checkpoint table is a small table in the target database used by the Replicat
process to maintain checkpoints. A checkpoint records a known position in the trail from which
to start after an expected or unexpected shutdown. By default, a record of these checkpoints is maintained
in a file on disk in the GoldenGate directory. Optionally, the checkpoint record can also be maintained in a
checkpoint table in the target database.
More Information about check point table can be found in MOS note: 965698.1
GGSCI (gg2.company.com) 10> add checkpointtable chktbl Successfully created checkpoint table CHKTBL. GGSCI (gg2.company.com) 13> add replicat rep_gg2, exttrail /u01/app/GGS/dirdat/rt, checkpointtable gggate.chktbl REPLICAT added. GGSCI (gg2.company.com) 14> info * REPLICAT REP_GG2 Initialized 2012-06-10 16:58 Status STOPPED Checkpoint Lag 00:00:00 (updated 00:00:12 ago) Log Read Checkpoint File /u01/app/GGS/dirdat/rt000000 First Record RBA 0
Now start all the processes on Source system.
GGSCI (gg1.company.com) 11> start manager Manager started. GGSCI (gg1.company.com) 12> start extract ext_gg1 Sending START request to MANAGER ... EXTRACT EXT_GG1 starting GGSCI (gg1.company.com) 13> start extract pump_gg1 Sending START request to MANAGER ... EXTRACT PUMP_GG1 starting GGSCI (gg1.company.com) 15> info * EXTRACT EXT_GG1 Last Started 2012-06-10 17:02 Status RUNNING Checkpoint Lag 00:00:00 (updated 00:00:00 ago) Log Read Checkpoint Oracle Redo Logs 2012-06-10 17:02:20 Seqno 108, RBA 14447104 EXTRACT PUMP_GG1 Last Started 2012-06-10 17:02 Status RUNNING Checkpoint Lag 00:00:00 (updated 00:30:18 ago) Log Read Checkpoint File /u01/app/GGS/dirdat/lt000000 First Record RBA 0 [oracle@gg1 GGS]$ ls -ltr /u01/app/GGS/dirdat/lt000000 -rw-rw-rw- 1 oracle oinstall 983 Jun 10 17:02 /u01/app/GGS/dirdat/lt000000 GGSCI (gg1.company.com) 2> exit
Once the processes are strated, we will create the sample tables for replication using Oracle provided scripts.
These scripts can be found under /u01/app/GGS
[oracle@gg1 GGS]$ ls -ltr *demo* -r--r--r-- 1 oracle oinstall 2275 Oct 15 2010 demo_ora_misc.sql -r--r--r-- 1 oracle oinstall 4015 Oct 15 2010 demo_ora_lob_create.sql -r--r--r-- 1 oracle oinstall 821 Oct 15 2010 demo_ora_insert.sql -r--r--r-- 1 oracle oinstall 883 Oct 15 2010 demo_ora_create.sql -r--r--r-- 1 oracle oinstall 2520 Oct 15 2010 demo_ora_pk_befores_updates.sql -r--r--r-- 1 oracle oinstall 1227 Oct 15 2010 demo_ora_pk_befores_insert.sql -r--r--r-- 1 oracle oinstall 1269 Oct 15 2010 demo_ora_pk_befores_create.sql -r--r--r-- 1 oracle oinstall 967 Oct 15 2010 demo_more_ora_insert.sql -r--r--r-- 1 oracle oinstall 1217 Oct 15 2010 demo_more_ora_create.sql
we will create tables for mapping:
Source:
======
SQL> connect scott/tiger Connected. SQL> @demo_ora_create.sql DROP TABLE tcustmer * ERROR at line 1: ORA-00942: table or view does not exist Table created. DROP TABLE tcustord * ERROR at line 1: ORA-00942: table or view does not exist Table created. SQL>
Target:
=======
SQL> conn scott/tiger Connected. SQL> @demo_ora_create.sql DROP TABLE tcustmer * ERROR at line 1: ORA-00942: table or view does not exist Table created. DROP TABLE tcustord * ERROR at line 1: ORA-00942: table or view does not exist Table created. SQL> select count(*) from tcustmer; COUNT(*) ---------- 0 SQL>
Once the structure is created, we will tell the extract, pump and replicat process
to capture/apply the changes done under these tables. For that we need to configure
the respective parameter files and these should look like:
GGSCI (gg1.company.com) 13> edit params ext_gg1 extract ext_gg1 userid gggate, password oracle exttrail /u01/app/GGS/dirdat/lt Table SCOTT.TCUSTMER; Table SCOTT.TCUSTORD; GGSCI (gg1.company.com) 14> edit params pump_gg1 extract pump_gg1 passthru userid gggate, password oracle rmthost gg2.company.com, mgrport 7809 rmttrail /u01/app/GGS/dirdat/rt Table SCOTT.TCUSTMER; Table SCOTT.TCUSTORD; GGSCI (gg2.company.com) 4> edit params rep_gg2 REPLICAT rep_gg2 ASSUMETARGETDEFS userid gggate, password oracle discardfile /u01/app/GGS/discard/rep_gg2_discard.txt, append, megabytes 10 MAP SCOTT.TCUSTMER, Target SCOTT.TCUSTMER; MAP SCOTT.TCUSTORD, Target SCOTT.TCUSTORD;
Once the parameter files are updated with the table information, we can use the
Oracle provided scripts to test the replication i.e “demo_ora_insert.sql”
After running the insert on source, we can see the count(*) on both source and target,
which will confirm the changes applied at the target side.
Recent Comments