How to connect to PDB in Oracle 12c - database-connection

I'm running a fresh installation of Oracle 12c on Solaris 10 and I can connect to the CDB using toad just fine, please tell me how can I now connect to the PDB database named PDBORCL as mentioned in the guide: https://oracle-base.com/articles/12c/multitenant-connecting-to-cdb-and-pdb-12cr1
Following are the contents of my tnsnames.ora file:
# tnsnames.ora Network Configuration File: /bkofa/oracle/app/oracle
/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL12 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl12)
)
)
pdbORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdborcl)
)
)
Here are the contents of my listener.ora file:
# listener.ora Network Configuration File: /bkofa/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl12)
(SID_NAME = orcl12)
)
(SID_DESC =
(GLOBAL_DBNAME = pdborcl)
(SID_NAME = pdborcl)
)
)
These are the containers by the way:
SELECT name, pdb
FROM v$services
ORDER BY name;
NAME PDB
SYS$BACKGROUND CDB$ROOT
SYS$USERS CDB$ROOT
orcl12 CDB$ROOT
orcl12XDB CDB$ROOT
pdborcl PDBORCL
Still when I try to connect to PDB using any combination of commands this is what I get:
bash-3.2$ lsnrctl status
LSNRCTL for Solaris: Version 12.1.0.2.0 - Production on 13-APR-2016 15:42:28
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=afxortsts)(PORT=1523)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Solaris: Version 12.1.0.2.0 - Production
Start Date 12-APR-2016 13:56:56
Uptime 1 days 1 hr. 45 min. 36 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /bkofa/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /bkofa/oracle/app/oracle/diag/tnslsnr/afxortsts/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=afxortsts)(PORT=1523)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl12" has 1 instance(s).
Instance "orcl12", status UNKNOWN, has 1 handler(s) for this service...
Service "pdborcl" has 1 instance(s).
Instance "pdborcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
bash-3.2$ sqlplus '/ as sysdba'
SQL*Plus: Release 12.1.0.2.0 Production on Wed Apr 13 15:42:44 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> connect sys/oracle123#172.16.1.118:1523/pdborcl as sysdba
ERROR:
ORA-01017: invalid username/password; logon denied
Warning: You are no longer connected to ORACLE.
SQL> connect sys#pdborcl
Enter password:
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory
Additional information: 2581
Additional information: -2057892281
Process ID: 0
Session ID: 0 Serial number: 0
SQL> connect sys#172.16.1.118:1523/pdborcl as sysdba
ERROR:
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
SQL>
Oh I should make this clear that I'm using port 1523 because there is another instance of older Oracle 10g already running on the system that uses this port so I wanted to avoid any conflict with that.

You should not declare the services in the SID_LIST_LISTENER. Especially the pdborcl which is not an instance but a service within the instance. So remove this part:
(SID_DESC =
(GLOBAL_DBNAME = pdborcl)
(SID_NAME = pdborcl)
)
The instance should register itself to the listener. If not done, you should, when connected to the CDB:
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=afxortsts)(PORT=1523))) ';
alter system register;

Below my config which works:
listener.ora:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1525))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))
)
)
tnsnames.ora:
LISTENER_CATCDB =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1526))
# CDB
CATCDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1526))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = catcdb)
)
)
# PDB
CATDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1526))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = catdb)
)
)

Related

cannot connect to newly installed Oracle 19c single instance DB

I just installed a new Oracle 19c single instance database and I cannot connect to it, and I'm not sure how to debug the problem.
I defined the SID to be "globaldb". The listener is started and is listening on port 1539. tnsping is happy. lsnrctl status shows output that makes me believe the DB is up. But I am not able to connect to this DB using either sqlplus or sqldeveloper. Can you advise me how to approach debugging this problem?
% tnsping globaldb
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 30-APR-2022 06:11:45
Copyright (c) 1997, 2019, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/19.0.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = LOCALHOST)(PORT = 1539)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = GLOBALDB)))
OK (0 msec)
I have, for temporary debug purposes, disabled the firewall:
[root#pca-flexcube-5 bin]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root#pca-flexcube-5 bin]#
% sqlplus 'system/Welcome1#(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1539)))(CONNECT_DATA=(SID=GLOBALDB)))'
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Apr 30 06:12:05 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12537: TNS:connection closed
Enter user-name:
listener.ora:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 100.111.161.49)(PORT = 1539))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
(SID_NAME = globaldb)
)
)
tnsnames.ora:
LISTENER_CDB =
(ADDRESS = (PROTOCOL = TCP)(HOST = LOCALHOST)(PORT = 1539))
globaldb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = LOCALHOST)(PORT = 1539))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = GLOBALDB)
)
)
CDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = LOCALHOST)(PORT = 1539))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CDB)
)
)
PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = LOCALHOST)(PORT = 1539))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB1)
)
)
[root#pca-flexcube-5 opc]# systemctl status dbora.service -l
● dbora.service - The Oracle Database Service
Loaded: loaded (/usr/lib/systemd/system/dbora.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2022-05-01 03:29:11 GMT; 8s ago
Main PID: 48553 (start_all.sh)
Tasks: 41 (limit: 99958)
Memory: 4.8G
CGroup: /system.slice/dbora.service
├─48553 /bin/bash /home/oracle/scripts/start_all.sh
├─48569 /bin/sh /u01/app/oracle/product/19.0.0/dbhome_1/bin/dbstart /u01/app/oracle/product/19.0.0/dbhome_1
├─48615 /bin/sh /u01/app/oracle/product/19.0.0/dbhome_1/bin/dbstart /u01/app/oracle/product/19.0.0/dbhome_1
├─48667 sqlplus
├─48672 ora_pmon_globaldb
├─48674 ora_clmn_globaldb
├─48676 ora_psp0_globaldb
├─48678 ora_vktm_globaldb
├─48709 ora_gen0_globaldb
├─48712 ora_mman_globaldb
├─48718 ora_gen1_globaldb
├─48721 ora_diag_globaldb
├─48723 ora_ofsd_globaldb
├─48726 ora_dbrm_globaldb
├─48728 ora_vkrm_globaldb
├─48730 ora_svcb_globaldb
├─48732 ora_pman_globaldb
├─48734 ora_dia0_globaldb
├─48736 ora_dbw0_globaldb
├─48738 ora_lgwr_globaldb
├─48740 ora_ckpt_globaldb
├─48742 ora_lg00_globaldb
├─48744 ora_smon_globaldb
├─48746 ora_lg01_globaldb
├─48748 ora_smco_globaldb
├─48750 ora_reco_globaldb
├─48752 ora_w000_globaldb
├─48754 ora_lreg_globaldb
├─48756 ora_w001_globaldb
├─48758 ora_pxmn_globaldb
├─48762 ora_mmon_globaldb
├─48764 ora_mmnl_globaldb
├─48766 ora_d000_globaldb
├─48768 ora_s000_globaldb
├─48770 ora_tmon_globaldb
├─48771 oracleglobaldb (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
├─48774 ora_m000_globaldb
└─48776 ora_m001_globaldb
May 01 03:29:11 pca-flexcube-5 systemd[1]: Started The Oracle Database Service.
May 01 03:29:11 pca-flexcube-5 bash[48553]: The Oracle base remains unchanged with value /u01/app/oracle
May 01 03:29:11 pca-flexcube-5 bash[48553]: Processing Database instance "globaldb": log file /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/log/startup.log
[root#pca-flexcube-5 opc]#
The key problem here was that my only experience with Oracle databases had taken place with their old products before they changed to the multitenant architecture of recent years. Under the multitenant architecture, the pluggable database does not automatically come up. So it was necessary to connect to the container database and request that it be brought up:
sqlplus / as sysdba
alter pluggable database YOUR_DATABASE_NAME open;
By default you have to do this after every machine restart. To avoid this burden you can do the following and make it automatic that the pluggable database comes up on reboot:
alter pluggable database YOUR_DATABASE_NAME save state;

I get connection error 8017 while trying to use Fast Load tool

I receive error message 8017:
The UserId, Password or account is invalid while trying to load data
using fast load.
Fast Load Script:
logon 10.61.59.93/796207,Wpwp123;
drop table DATAMDL_SNDBX.QA_FL_PD;
drop table DATAMDL_SNDBX.ERROR_TABLE_ucv;
drop table DATAMDL_SNDBX.ERROR_TABLE_TV;
CREATE SET TABLE DATAMDL_SNDBX.QA_FL_PD ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
NAME VARCHAR(10) CHARACTER SET LATIN NOT CASESPECIFIC,
INITIAL VARCHAR(10) CHARACTER SET LATIN NOT CASESPECIFIC)
PRIMARY INDEX CRO_FLIGHT_LEG_DEP_NUPI ( NAME );
SET RECORD VARTEXT'~';
DEFINE
NAME (VARCHAR(10)),
INITIAL (VARCHAR(10))
FILE = C:\Users\Scarlet\Desktop\FL_Data.TXT;
BEGIN LOADING DATAMDL_SNDBX.QA_FL_PD ERRORFILES teradata fastload.ERROR_TABLE_UCV, teradata fastload.ERROR_TABLE_TV;
INSERT INTO DATAMDL_SNDBX.QA_FL_PD
VALUES (:NAME,
:INITIAL);
END LOADING;
LOGOFF;
File containing data (with only 1 record):
NAME~INITIAL
PRASHANT~PD
Error Message:
C:\Windows\system32>cd\
C:\>fastload<C:\Users\Scarlet\Desktop\FL_Script.TXT
===================================================================
= =
= FASTLOAD UTILITY VERSION 14.10.00.03 =
= PLATFORM WIN32 =
= =
===================================================================
===================================================================
= =
= Copyright 1984-2013, Teradata Corporation. =
= ALL RIGHTS RESERVED. =
= =
===================================================================
**** 14:08:03 Processing starting at: Thu Mar 10 14:08:02 2016
===================================================================
= =
= Logon/Connection =
= =
===================================================================
0001 logon 10.61.59.93/796207,
**** 14:08:03 RDBMS error 8017: The UserId, Password or Account is
invalid.
**** 14:08:03 Unable to log on Main SQL Session
**** 14:08:03 FastLoad cannot continue. Exiting.
===================================================================
= =
= Exiting =
= =
===================================================================
**** 14:08:03 Total processor time used = '0.124801 Seconds'
. Start : Thu Mar 10 14:08:02 2016
. End : Thu Mar 10 14:08:03 2016
. Highest return code encountered = '12'.
**** 14:08:03 FDL4818 FastLoad Terminated
The problem was, I should have mentioned what mechanism I should be using to connect.
Adding below line at the top solved my problem
logmech LDAP;
Problem solved.. :)
I do not know how to close this thread.
Thanks
Prashant

Send sms using kannel & smmpsim

I'm trying to send sms using kannel & smppsim.
I use docker as container.
I use this kannel.conf:
group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
admin-allow-ip = "127.0.0.1;192.168.59.103"
box-allow-ip = "127.0.0.1;192.168.59.103"
group = smsc
smsc = smpp
smsc-id = SMPPSim
host = 192.168.59.103
port = 2775
transceiver-mode = 1
smsc-username = smppclient1
smsc-password = password
system-type = 'VMA'
#service-type = 'test'
interface-version = 34
#system-id = smppclient
preferred-smsc-id = SMPPSim
connect-allow-ip = 192.168.59.103
group = smsbox
bearerbox-host = bearerbox
sendsms-port = 13013
global-sender = 13013
group = sendsms-user
username = tester
password = foobar
group = sms-service
keyword = default
text = "No service specified"
when sending a request to send sms I get "0: Accepted for delivery"
I'm seeing these errors in smsbox log:
2015-03-21 20:20:52 [1] [3] DEBUG: Status: 202 Answer: <Sent.>
2015-03-21 20:20:52 [1] [3] DEBUG: Delayed reply - wait for bearerbox
2015-03-21 20:20:52 [1] [0] DEBUG: Got ACK (0) of 74f9cefe-db95-4b7d-aa99-f07395d32915
2015-03-21 20:20:52 [1] [0] DEBUG: HTTP: Resetting HTTPClient for `192.168.59.3'.
2015-03-21 20:20:52 [1] [1] ERROR: Error reading from fd 24:
2015-03-21 20:20:52 [1] [1] ERROR: System error 104: Connection reset by peer
2015-03-21 20:20:52 [1] [1] DEBUG: HTTP: Destroying HTTPClient area 0x7fe8d0000ad0.
Bearbox doesn't present any errors and seem to pass the message to smppsim, smppsim shows this in log:
21 Assessing state of 1 messages in the OutboundQueue
21 Message:2 state=DELIVERED
The sms is not sent, what could be wrong?
I think its a problem with your Kannel configuration file, specially with smsbox and later parts. I used following as smsbox
group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
global-sender = your sim number which you use in USB modem
sendsms-chars = "0123456789 +-"
log-file = "/var/log/kannel/smsbox.log"
log-level = 0
access-log = "/var/log/kannel/access.log"
and you can get my full configuration file from here. This worked fine for me.
This might be a problem of lоѕѕ оf thе соnnесtіоn оn thе rеmоtе ѕосkеt due tо а tіmеоut.
And SMPPSim is just a testing tool for kannel. It won't really send a message to your or mentioned mobile number. To send real messages you need to add either gsm modems or SMS operator details.
You can refer to userGuide from kannel.org.
To check your kannel status simply go to http://localhost:13000/status?password=password(password of your kannel)

Graphite carbon-relay not working

I have two graphite setup and I am trying to relay the traffic between the two, but somehow the carbon-relay is not working.
My cache runs on 2003/2004 and relay on 2013/2014
Following are the configurations done :
#carbon file
[cache:b]
LINE_RECEIVER_PORT = 2003
PICKLE_RECEIVER_PORT = 2004
CACHE_QUERY_PORT = 7012
[relay]
LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_PORT = 2013
PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_PORT = 2014
RELAY_METHOD = rules
REPLICATION_FACTOR = 1
DESTINATIONS = 127.0.0.1:2003:a, aa.bb.cc.dd:2003:b
#relay-rules file
[default]
default = true
destinations = 127.0.0.1:2003:a, aa.bb.cc.dd:2003:b
Any pointers will be helpful
As part of the recent project at work, I've figured out that carbon demons uses PICKLE protocol when sending data to the destinations.
So the destination of carbon-relay should be carbon-cache's pickle receiver port instead.
#carbon.conf
....
[relay]
LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_PORT = 2013
PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_PORT = 2014
RELAY_METHOD = rules
REPLICATION_FACTOR = 1
DESTINATIONS = 127.0.0.1:2004:a, aa.bb.cc.dd:2004:b
Also modify the relay-rules.conf with the same destinations specified in carbon.conf
relay-rules.conf
.....
[default]
default = true
destinations = 127.0.0.1:2004:a, aa.bb.cc.dd:2004:b

Grails errors switching to second DB with TNS string as Datasource

I use a TNS string as url of my Grails Datasource, with two oracle DBs (ora01, ora02). It connects to the db service ok during normal operation. Here is the config:
dbString = "jdbc:oracle:thin:#(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = ora01.foo)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = ora02.bar)(PORT = 1521))
)
(CONNECT_DATA = (SERVICE_NAME = orastage)))"
dataSource
{
pooled = true
driverClassName = "oracle.jdbc.OracleDriver"
username = foo
password = bar
url = dbString
logSql = false
}
When the DBAs switch off ora01 and restart ora02 as the active one, the Grails app doens't realise and throws JDBC errors:
2013-04-26 11:41:35,428 ERROR JDBCTransaction - JDBC commit failed
java.sql.SQLRecoverableException: No more data to read from socket
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1142)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1099)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:288)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C7Ocommoncall.doOCOMMIT(T4C7Ocommoncall.java:75)
at oracle.jdbc.driver.T4CConnection.doCommit(T4CConnection.java:565)
at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:3851)
at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:3857)
at org.apache.commons.dbcp.DelegatingConnection.commit(DelegatingConnection.java:334)
Does my config look ok? I'm assuming Grails can take a TNS string as datasource URL as it connects ok before we try failing a db - is this correct? It's like the app is still trying to connect to the dead db and not trying the other node. Do I need to get Grails to do anything specific to switch to the now-working node?
Try using (FAILOVER=ON) in the description.
dbString = "jdbc:oracle:thin:#(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = ON)
(FAILOVER=ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = ora01.foo)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = ora02.bar)(PORT = 1521))
)
(CONNECT_DATA = (SERVICE_NAME = orastage)))"

Resources