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:
1 2 3 4 5 6 7 8 9 10 11 |
# 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 😉 (including version, edition, exit code, etc)
1 2 |
# [ oracle@ludodb01:/home/oracle [22:18:59] [18.4.0.0.0 [DBMS EE] SID=CDB] 0 ] # # |
- u : gets the status of the databases
1 2 3 4 5 |
# [ 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
1 2 3 4 5 |
# [ 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
1 2 3 4 5 6 7 8 |
# [ 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
1 2 3 4 5 |
# [ 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# [ 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)
1 2 3 4 5 6 7 |
# [ 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
1 2 3 4 5 6 7 |
# [ 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
1 2 3 4 |
# [ 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
Latest posts by Ludovico (see all)
- New views in Oracle Data Guard 23c - January 3, 2024
- New in Data Guard 21c and 23c: Automatic preparation of the primary - December 22, 2023
- Does FLASHBACK QUERY work across incarnations or after a Data Guard failover? - December 13, 2023
Thanks Ludo, good set of tools.
Regards.
Grzegorz
Thanks 🙂