12c Beq Connection As Sysdba PDF
12c Beq Connection As Sysdba PDF
12c Beq Connection As Sysdba PDF
In Oracle 12c you can run Oracle processes as operating system threads, lowering the number of OS processes. But you cant use OS authentification: you need to
provide a password. Here is a way to set an environment so that you can still connect / as sysdba to a multithreaded instance.
Windows
I start with Windows because Oracle has always been multithreaded on windows. Are you able to use operating system authentication then? You think so because
you can connect / as sysdba. But look at your sqlnet.ora:
1 SQLNET.AUTHENTICATION_SERVICES = (NTS)
You need NTS to connect locally without a password, the same authentication as when you connect remotely. If you dont set NTS then both local and remote
connections need a password.
Threaded execution
Back to Linux, Ive set my instance with multithreading:
1 NAME TYPE VALUE
2 ERROR:
by default on Unix/Linux the AUTHENTICATION_SERVICES is not set, which allows operating system suthentication for Bequeath connections.
When multithreaded, I can only connect with a password:
1 SQL> connect sys as sysdba
2 Enter password:
3 Connected.
But I dont want that. I want to keep she same scripts and procedures as I had before going to multithread instance. I can put the password in an external password
file (wallet) and then connect without typing the password. But then I have to use a network service name. I can use TWO_TASK environment variable to add that
network service name to connections transparently, but for waterver reason I dont want to connect through the listener. So lets see how to set it up.
TNS_ADMIN
Ill setup my own SQL*Net files in a custom directory and use TNS_ADMIN to use them.
1 $ mkdir /home/franck/tns
2 $ export TNS_ADMIN=/home/franck/tns
2 ORACLE_SID=DEMO11
3 ORACLE_BASE=/u01/app/oracle
4 ORACLE_HOME=/u01/app/oracle/product/12102EE
this as created the wallet containing my user (SYS) and password for the network service name BEQ_DEMO111_SYS
1 $ ls -l
2 -rwxrwx---. 1 root vboxsf 589 Jun 23 23:29 cwallet.sso
2 WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/home/franck/tns)))
3 SQLNET.WALLET_OVERRIDE=TRUE
$ cat tnsnames.ora
BEQ_DEMO11_SYS=(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=/u01/app/oracle/product/12102EE/bin/oracle)(ARGV0=oracleDEMO11)(ARGS='(DESCRIPT
ION=(LOCAL=YES)(ADDRESS=(PROTOCOL=BEQ)))')(ENVS='ORACLE_HOME=/u01/app/oracle/product/12102EE,ORACLE_SID=DEMO11'))
Here is how a beaqueath (PROTOCOL=BEQ) connection is defined. You need to define the PROGRAM to be run (the oracle binary) and the ARGS. You need to
pass the environement variables at least ORACLE_HOME and ORACLE_SID
The ARGV0 is the name that will be displayed by the ps CMD command, but you can put whatever you want in it (just saying have fun but not in prod please).
The convention is to add the ORACLE_SID to the binary name oracle.
Then I can connect:
1 SQL> connect /@BEQ_DEMO11_SYS as sysdba
2 Connected.
TWO_TASK
Finally, I dont want to add the network service name in my scripts, then I can set the TWO_TASK environment variable to it. I definitely dont want to set it for all
my environment because it can be misleading (you think you use the ORACLE_SID but you are not, you change environement with oraenv but TWO_TASK
remains,). So i set it locally when I run sqlplus.
Here is an example where I set TNS_ADMIN and TWO_TASK only when calling sqlplus:
1
6 Connected to:
8 With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
2 Connected.
but you should now that if the script is connecting with another user, TWO_TASK is still used:
1 SQL> connect scott/tiger
2 Connected.
Note that those sessions are multithreaded even if you dont set DEDICATED_THROUGH_BROKER for the listener, because youre not connecting through the
listener here. More information about it in Martin Bachs post.
Here is how to check it process and thread id from v$process:
SQL> select spid, stid, program, execution_type from v$process where addr=(select paddr from v$session where sid=sys_context('userenv','sid'));
TWO_TASK is coming from very old version but will be useful to run old scripts in 12c. Here is an example with threaded instance. You can use it also to connect
directly to a PDB (but through listener then you need a service).
But
There is one thing that doesnt work as I want with external password files. DGMGRL keeps the password provided and uses it to connect to the remote instance
which is why you need same password for sys on standby. But lets see if it works with external password file:
1 $ TNS_ADMIN=$PWD TWO_TASK=BEQ_DEMO11_SYS dgmgrl /
5 Connected as SYSDG.
12
13 Warning: You are no longer connected to ORACLE.
14
17
18
I have to finish the switchover manually because the password retreived from the wallet is not used here. Same behaviour than OS authentication here. Tip: if you
connect to the primary to do the switchover, then the connection to remote is detected at the begining.
Final note
This is not best practice. Using external password file is a good practice of course because we should never put passwords in our scripts or in command line.
Passwords are something to be only typed by human fingers. TWO_TASK and BEQ connection string are not a good practice, but only a workaround to keep old
scripts compatible with new features.