efficient dba part 1 scripting your logins “efficiency is intelligent laziness.” ~ david dunham...

22
Efficient DBA Part 1 Scripting Your Logins Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Upload: alexia-howard

Post on 16-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Efficient DBAPart 1

Scripting Your Logins“Efficiency is intelligent laziness.”

~ David Dunham

TCOUG

Page 2: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Start at the End

TCOUG

Page 3: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Set the SQL prompt

TCOUG

Page 4: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Always be aware of your environment

TCOUG

Page 5: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Script the environment variables for each instance

TCOUG

Page 6: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

rlwrap

TCOUG

• Gives capability to re-execute commands in sqlplus and rman• Command history program similar to bash’s history package• Installable as RPM or compile from source• Gives similar behavior to sqlplus in Windows• Will run in Cygwin• Very robust, but simple arrow up gives last command executed• http

://sysdba.wordpress.com/2006/10/08/how-to-use-rlwrap-to-get-a-command-history-in-sqlplus/• http://goo.gl/EfGOl

• http://utopia.knoware.nl/~hlub/rlwrap/#rlwrap• http://goo.gl/YdJN5

Page 7: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Put environment scripts in an easily accessible location and alias the most frequently used

TCOUG

Page 8: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Sudo prohibits and allows commands to be run

TCOUG

Page 9: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Sudo has a verification timeout before asking for your password again

TCOUG

Page 10: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Only requires password once, then loops and executes command once every 10 seconds

Note: Your company’s security department may not like this

TCOUG

Page 11: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Add this script to your profile scriptWill execute automatically on login

TCOUG

Page 12: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Will run as long as your login PID exists

TCOUG

Page 13: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

AD/LDAP user automatic login

TCOUG

Page 14: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Shared Key Authentication is enabled on the server by default

TCOUG

Page 15: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Generate private and public keys with PuttyKeyGen

TCOUG

Page 16: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Private key client authentication done by Pageant

TCOUG

Page 17: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

TCOUG

The key generated will look similar to thisFormatted like this will work with Linux SSHD

Page 18: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

$HOME/.ssh should be set to 700

TCOUG

$HOME/.ssh/authorized_keys should be set to 600

Page 19: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Once the public key is added, the server is ready to accept the paired keys

TCOUG

Page 20: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

Shared Key Authentication bypasses the need for a password on login

TCOUG

Page 21: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

TCOUG

• Desktop• Log into server using share-key authentication• Sudo keep-alive loop started• Switch User to Oracle• Set environment variables• Log into sqlplus

Review

Page 22: Efficient DBA Part 1 Scripting Your Logins “Efficiency is intelligent laziness.” ~ David Dunham TCOUG

When Time is Your Bottle NeckEvery Second Counts!

TCOUG

Become an Efficient DBASpend some time each week finding shortcuts

Thank You!

Seth [email protected]://sethmiller.org