Quantcast
Viewing all articles
Browse latest Browse all 119

First draft of a Common Oracle Environment… for the Cloud Database (and not only)

I have just published on GitHub a draft of a common Oracle environment scripts that make the shell environment a little bit smarter than what it is by default. It uses some function and aliases that I have published during the past years.

You can start playing with:

# Connect as oracle
sudo su - oracle

# Clone this repository
git clone https://github.com/ludovicocaldara/COE.git

# Enable the profile scripts
echo ". ~/COE/profile.sh" >> $HOME/.bash_profile

# Load the new profile
. ~/.bash_profile

Ideal for the Oracle Cloud Infrastructure

If you are new to the Oracle Cloud, probably you do not have environment scripts that makes it easy to interact with the database.

The environment scripts that I have published work out-of the box in the cloud (just make sure that you have rlwrap installed so that you can have a better CLI experience).

Actually, they work great as well on-premises, but I assume that you already have something automatic there.

Some examples

  • My famous Smart Prompt Image may be NSFW.
    Clik here to view.
    😉
    (including version, edition, exit code, etc)

# [ oracle@ludodb01:/home/oracle [22:18:59] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
#

  • u : gets the status of the databases

# [ oracle@ludodb01:/home/oracle [22:18:59] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# u
DB_Unique_Name           DB_Name  ludodb01       Oracle_Home
------------------------ -------- -------------- --------------------------------------------------
CDB_fra1cw               CDB      CDB            /u01/app/oracle/product/18.0.0.0/dbhome_1

  • pmon: just displays the running pmon processes

# [ oracle@ludodb01:/home/oracle [22:27:17] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# pmon
grid      8093     1  0 Mar25 ?        00:01:39 asm_pmon_+ASM1
grid     10293     1  0 Mar25 ?        00:01:43 apx_pmon_+APX1
oracle   11077     1  0 Mar25 ?        00:01:47 ora_pmon_CDB

  • db : sets the environment for a specific DB_NAME, DB_UNIQUE_NAME or SID

# [ oracle@ludodb01:/u01/app/oracle/diag/rdbms/cdb_fra1cw/CDB/trace [22:33:53] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# db CDB
DB_UNIQUE_NAME  = CDB_fra1cw
ORACLE_SID      = CDB
ROLE            = PRIMARY
VERSION         = 18.4.0.0.0
ORACLE_HOME     = /u01/app/oracle/product/18.0.0.0/dbhome_1
NLS_LANG        = AMERICAN_AMERICA.AL32UTF8

  • svcstat : shows the running services (and the corresponding pdb, host, etc) as I described in my previous post

# [ oracle@ludodb01:/home/oracle [22:28:03] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# svcstat
DB_Unique_Name           Service_Name                   PDB                            ludodb01
------------------------ ------------------------------ ------------------------------ --------------
cdb_fra1cw               pdb_service_test               PDB1                           ONLINE

  • s_ : smart alias for sqlplus: connects as sysdba/sysasm by default, or with any arguments that you pass:

# [ oracle@ludodb01:/home/oracle [22:29:14] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# s_

SQL*Plus: Release 18.0.0.0.0 - Production on Mon Apr 15 22:30:22 2019
Version 18.4.0.0.0

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


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> show user
USER is "SYS"
SQL> Disconnected from Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

# [ oracle@ludodb01:/home/oracle [22:30:30] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# s_ pippo/pippo

SQL*Plus: Release 18.0.0.0.0 - Production on Mon Apr 15 22:30:34 2019
Version 18.4.0.0.0

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

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


Enter user-name:

  • adr_, dg_ rman_, cm_, lsn_ : aliases for common oracle binaries
  • genpasswd : generates random passwords (default length 30)

# [ oracle@ludodb01:/home/oracle [22:32:35] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# genpasswd
+gagDCqVSgqHqsU+-IdeA0nx_-HVZ1

# [ oracle@ludodb01:/home/oracle [22:33:00] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# genpasswd 12
DiU9nHiwPB9y

  • lsoh: lists the Oracle Homes attached to the inventory

# [ oracle@ludodb01:/u01/app/oracle/diag/rdbms/cdb_fra1cw/CDB/trace [22:33:53] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# lsoh

HOME                        LOCATION                                                VERSION      EDITION
--------------------------- ------------------------------------------------------- ------------ ---------
OraGrid180                  /u01/app/18.0.0.0/grid                                  18.4.0.0.0   GRID
OraDB18000_home1            /u01/app/oracle/product/18.0.0.0/dbhome_1               18.4.0.0.0   DBMS EE

  • setoh: sets the Oracle Home given its name in the inventory

# [ oracle@ludodb01:/u01/app/oracle/diag/rdbms/cdb_fra1cw/CDB/trace [22:35:38] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] #
# setoh OraGrid180
VERSION         = 18.4.0.0.0
ORACLE_HOME     = /u01/app/18.0.0.0/grid

 

You might want to install the same environment for oracle, grid (if you have role separation, it should be the case for Cloud DB Systems) and (eventually) root.

I am curious to know if it works well for your environment.

Cheers

Ludo


Viewing all articles
Browse latest Browse all 119

Trending Articles