Thursday, November 6, 2014

How to Handle the Line with spaces in Shell for loop


One of the error that was faced while doing automation in Bash,ksh is that
when you use the for loop to loop a records that have spaces ,then it takes each word in a line and loops it.

This is due to the Setting of the Variable IFS

     
man bash


   IFS    The Internal Field Separator that is used for word splitting after expansion and to split lines into words with the  read  builtin  command.
              The default value is ‘‘<space><tab><newline>’’.

As it states above , the default IFS make it to happen that way.

How to overcome it, is by using the below where you can say to consider only the New Line as Internal Field separator.

  IFS=$'\n' 
  for BLIST in `cat $FileList`
   do
    echo "$BLIST"
    .
    .
    .
   done


Sample File :

  $cat FileList 
      A B C
      AA FF EE
      DD SS RR

Tuesday, November 26, 2013

ORA-12700: invalid NLS parameter value (nls_numeric_characters)

While practicing the Non-CDB to CDB Convert, got to the error

This Error came while opening the PDB after the successful PDB clone using the manifest file.

ORA-12700: invalid NLS parameter value (nls_numeric_characters)

The solution is to create a pfile out of spfile in the CDB .
Shutdown the CDB
 and start it with the pfile .
Then open the newly converted/cloned PDB.

Friday, July 26, 2013

orapwd and PDB

orapwd and PDB


The orapwd creates a password file which is used to authenticate the users.


The password provided for the orapwd and the password of sys can be different and Sys can login with the password locally .
And the password given for orapwd comes in only for the REMOTE Login (“@”) .

Changing the password of the orapwd (password file) will not affect the password of the local sys user,
But changing the password of the sys user syncs the password file also.

Lets see an example :

-          Login with the sys using the password “oracle3”

--> sqlplus sys/oracle3@sri12c as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Fri Jul 26 06:31:22 2013

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

SQL> show user
USER is "SYS"
SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL>

-          Create a password file with the password “oracle1”
--> orapwd file=orapwsri12c password=oracle
-          Now lets the passwords,

--> sqlplus sys/oracle3@sri12c as sysdba

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: sys/oracle1@sri12c as sysdba

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

SQL> conn sys/oracle3 as sysdba
Connected.

  The connection failed for the old password when connected using the Network (“@”) and it went fine when we used the password provided in the orapwd.

Also while using the old password and logged in locally, it worked.

-          Alter the sys password to oracle3 and let’s check if the password of the orapwd changes?

SQL> alter user sys identified by oracle3;

User altered.

SQL> conn sys/oracle3@sri12c as sysdba
Connected.

It got changed.


Now 12c PDB, the password file on 12c is for the CDB ,so when you change the password in the password file for the CDB , it goes the same for the PDB’s too.
Once the password is changed, the changed password file -password should be used to login from the next time.

And without the password file ,you will not be able to login to the PDB as we use to login to the PDB as a service “@” .



Thursday, July 25, 2013

Clone PDB (12c Pluggable Database)

Clone PDB
Note: The Clone is done on the same server.

1)  Shutdown  the pdb1
SQL> alter pluggable database pdb1 close;

Pluggable database altered.

2)  Open pdb1  in read only mode
SQL> alter pluggable database pdb1 open read only;

Pluggable database altered.

3) Clone using the below command
SQL> create pluggable database pdb2 from pdb1
FILE_NAME_CONVERT=('/12c/db/pdb1','/12c/db/pdb2');

Pluggable database created.

Elapsed: 00:01:00.23

4) Open the pdb2
SQL> alter pluggable database pdb2 open;

Pluggable database altered.

Elapsed: 00:00:08.95

5) Check the listener to make sure the pdb2 is listed and add the entry in oratab and tnsnames.ora (to use it in oraenv for setting the environment).

6) Connect to the pdb2 and play  ...
--> sqlplus srini/srini@pdb2

SQL*Plus: Release 12.1.0.1.0 Production on Thu Jul 25 07:23:10 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Last Successful login time: Thu Jul 15 2013 09:12:20 -05:00

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

SQL> show con_name

CON_NAME
------------------------------
PDB2


SQL> conn sys@pdb2 as sysdba
Enter password:
Connected.
SQL> select sum(bytes/1024/1024/1024) from dba_data_files;

SUM(BYTES/1024/1024/1024)
-------------------------
               9.21

7) The 9GB DB was cloned in a Minute .


Wednesday, July 24, 2013

Connecting to Pluggable Database (PDB)...

The PDB runs as a service in the CDB.

Below steps will guide to connect to the PDB,

  •  Check if the service is up  - lsnrctl status

lsnrctl status

LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 24-JUL-2013 02:49:59

Copyright (c) 1991, 2013, Oracle.  All rights reserved.
.
.
.

Service "pdb1" has 1 instance(s).
  Instance "pdb1", status READY, has 1 handler(s) for this service...
The command completed successfully
  • Check the if the TNS has the valid  entry for the PDB.

pdb1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Sri12c)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb1)
    )
  )

  • To set the PDB environment ,add the entry in oratab


           pdb1:/app/oracle/12c:N

  • Set the environment using oraenv and connect to the pdb,

sqlplus sys@pdb1 as sysdba

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

SQL> show con_name

CON_NAME
----------
PDB1

SQL> show con_id

CON_ID
-----------
3

  • The other way to connect to the pdb is :

             sqlplus pdbadmin/*****@Sri12c:1523/pdb1

             ==> Schema/Password@HOST:Port/Service_name


Saturday, June 29, 2013

Friday, June 14, 2013

ssh Password Less Login

Follow the below steps to perform the ssh passwordless login,

1.Login to the Server and run the below to generate the Key pair.

Sri> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sri/.ssh/id_rsa):
Created directory '/home/sri/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/sri/.ssh/id_rsa.
Your public key has been saved in /home/sri/.ssh/id_rsa.pub.
The key fingerprint is:
7y:74:10:98:25:06:17:d7:49:b7:u2:46:2i:jc:10:92 sri@beetle
The key's randomart image is:
+--[ RSA 2048]----+
|          ++B=oo=|
|         oE+..+.*|
|        . o  o = |
|         . o  . o|
|        S + .  . |
|         . o     |
|                 |
|                 |
|                 |
+-----------------+

2. The Private Keys gets genenrated .The Public Key gets created in the "/home/sri/.ssh/id_rsa.pub". 

Sri> cat /home/sri/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAouNqZ7+sK0P2zjf+y6pM1CY4jCZTD+CVzfjYyiAB7VhpIkn70MiPiNcbbrNCmIr4v+9U64Mm4ioAz9V4WJOhZ6+1/QLMhPpIhZcq7D1wfc26xU/b4moyzzygX8WaNd2D1XRX5JZMEcz/ir4C6wTFG9lL9Y9iKkKK2/sJHYGCDHJemxsw9wY4gH1fvrfdY/1M/rG4OOMrHsp9s6PB+1v+G7lEIHozDkPBDZx0ypSM4YNKZR6ddPt+GpcWU0RlS9X0eMeFljtWawmr1W90p/KeqwxQaVhl6YVZnQw1dJ0T5YUQIEhQcHJdJpbOfkN962D8dGJYGnjnTN2vJw83xoB/CQ== sri@beetle

3.To perform the Login without the Password copy the Public Key content (output is One line ) to the ".ssh/authorized_keys" on the remote System .
   The copy to the remote system can be done using scp or you can use the ssh as below

Sri> ssh remote -l sri "echo ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAouNqZ7+sK0P2zjf+y6pM1CY4jCZTD+CVzfjYyiAB7VhpIkn70MiPiNcbbrNCmIr4v+9U64Mm4ioAz9V4WJOhZ6+1/QLMhPpIhZcq7D1wfc26xU/b4moyzzygX8WaNd2D1XRX5JZMEcz/ir4C6wTFG9lL9Y9iKkKK2/sJHYGCDHJemxsw9wY4gH1fvrfdY/1M/rG4OOMrHsp9s6PB+1v+G7lEIHozDkPBDZx0ypSM4YNKZR6ddPt+GpcWU0RlS9X0eMeFljtWawmr1W90p/KeqwxQaVhl6YVZnQw1dJ0T5YUQIEhQcHJdJpbOfkN962D8dGJYGnjnTN2vJw83xoB/CQ== sri@beetle  >>~/.ssh/authorized_keys"

Enter the password when its prompted and the authorised_keys of Remote system is updated and now you can login without Password to the remote system.