Thursday, December 1, 2016

Configuration Baseline Collector Script For Linux OS & Oracle Databases

Have you ever performed a change on your OS or DB and later you figured out that you need to revert back to the previous setting but you struggled a lot to do so?
It happened to me before! but the good lesson I've learned was to keep a configuration baseline for all important settings and keep it somewhere, so when the time come to revert back any change, the configuration baseline will be the reference.

Creating a configuration baseline for each and every OS & database in your environment is definitely a daunting job, unless you do it through a script. In this post I'm sharing a Linux shell script to make such task a piece of cake one for you.

Download the configuration baseline script from this link:
https://www.dropbox.com/s/vf527mb46l2iivp/configuration_baseline.sh?dl=0

This shell script should run by the Oracle software owner (e.g. oracle), it will write one log for the OS configuration baseline and one log for each up and running oracle database. It can also send you the output logs via E-mail if you set MAIL_LIST="youremail@yourcompany.com" parameter to your E-mail address.

The script will do the following:
DATABASE Configuration Baseline: [For each database]
- Gather Instances & Database general info.
- Gather NON-DEFAULT Initialization Parameters.
- Gather DATABASE ENABLED FEATURES.
- Gather DATABASE FEATURES USAGE HISTORY.
- Gather DATABASE SETTINGS [Default tablespaces, Characterset, ...]
- Gather SERVICES details.
- Gather CLUSTERWARE INTERCONNECT details.
- Gather PATCHING history.
- Gather DATABASE LINKS.
- Gather DIRECTORIES info.
- Gather ACLs.
- Gather AUDIT settings.
- Gather USERS AND PROFILES details.
- Gather NUMBER OF OBJECTS in each schema.
- Gather the SIZE of each schema.
- Gather PRIVILEGED USERS details.
- Gather DATABASE PHYSICAL STRUCTURE information:
- CONTROLFILES.
- REDOLOG FILES AND GROUPS.
- TABLESPACES AND DATAFILES [+Utilization].
- ASM DISK GROUPS AND ASM FILES [+Utilization].
- FLASH RECOVERY AREA DETAILS [+Utilization].
- Gather RMAN NON-DEFAULT CONFIGURATIONS.
- Gather ACTIVE INCIDENTS information.
- Gather OUTSTANDING BUILT-IN ALERTS.
- Gather SCHEDULED JOBS details.
- Gather AUTO-TASK MAINTENANCE WINDOW details.
- Gather ADVISORS STATUS.
- Gather HARDWARE STATISTICS details.
- Gather RECYCLEBIN information.
- Gather FLASHBACK RESTORE POINTS details.
- Gather FOREIGN KEY COLUMNS HAVING NO INDEXES information.
- Gather DISABLED CONSTRAINTS details.
- Gather MONITORED INDEXES details.
- Gather COMPRESSED TABLES details.
- Gather PARTITIONED TABLES details.

OPERATING SYSTEM Configuration Baseline:
      - Gather RUNNING DATABASES & LISTENERS names.
      - Gather CLUSTERWARE CONFIGURATIONS.
      - Gather LISTENERS STATUS details.
      - Gather SERVER NAME AND OS/KERNEL VERSION information.
      - Gather BOOT CONFIGURATION.
      - Gather ORACLE FILES details:
- oratab
- listener.ora
- tnsnames.ora
- sqlnet.ora
      - Gather INSTALLED OPATCH PATCHES details.
      - Gather FILESYSTEM details.
      - Gather FILSYSTEM configurations.
- LOCAL FILESYSTEM.
- NFS SHARES.
- RAW DEVICES.
- MULTIPATH CONFIGURATIONS.
- ORACLE ASM CONFIGURATIONS.
      - Gather USERS AND GROUPS details.
      - Gather ACCOUNTS SETTINGS details.
      - Gather USERS RESOURCES LIMITS details.
      - Gather ORACLE USER CRONTAB JOBS details.
      - Gather ORACLE USER PROFILE.
      - Gather GENERIC/bashrc PROFILE.
      - Gather SECURITY CONFIGURATIONS:
- FIREWALL RULES. [hashed]
- PAM configurations.
- LOGINS default configurations.
- SELINUX configurations.
- INTRO MESSAGE.
      - Gather SERVICES CONFIGURATIONS.
      - Gather KERNEL PARAMETERS SETTINGS.
      - Gather NETWORK CONFIGURATIONS:
- GENERAL NETWORK SETTINGS.
- DNS SETTINGS.
- NICS CONFIGURATIONS.
- NICS BONDING ALIASES.
- LOCAL/ALLOWED/DENIED HOSTS SETTINGS.
      - Gather TIME AND DATE CONFIGURATIONS:
- LOCAL TIME CONFIGURATIONS.
- NTP STATUS & SETTINGS.
      - Gather LOGGING SETTINGS:
- SYSLOG SETTINGS.
- KEEP LOG SETTINGS.
- LOG ROTATE SETTINGS.
      - Gather HARDWARE INFORMATION:
- ALL ATTACHED HARDWARE.
- ATTACHED PCI DEVICES.
- CPU details.
- MEMORY details.
      - Gather INSTALLED PACKAGES information.

Please note that this shell script is tested on Linux Redhat & Oracle distributions, I didn't test it on other Linux distributions, nevertheless, you need to test it first on a test environment and use it on your own risk.
Even Oracle Support is saying the same in their scripts, I'm not that arrogant to claim that I'm smarter than Oracle:-))

This script is part of DBA BUNDLE, you can download the whole bundle from here:
http://dba-tips.blogspot.ae/2014/02/oracle-database-administration-scripts.html

Finally, your suggestions are always welcome.

4 comments:

Zeeshan Christy said...

Hi Adel,

I am getting similar errors when i execute the script.

INSTANCE INFO:
^^^^^^^^^^^^^
select INST_ID,instance_name INS_NAME,STATUS,DATABASE_STATUS DB_STATUS,VERSION,INSTANCE_ROLE,LOGINS,BLOCKED,to_char(STARTUP_TIME,"DD-MON-YY HH24:MI:SS") STARTUP_TIME from gv$instance
*
ERROR at line 1:
ORA-00904: "DD-MON-YY HH24:MI:SS": invalid identifier


I am not sure whats wrong with it. Any help regarding it

Mahmmoud ADEL said...

Hi Zeeshan,
Actually I don't think this format with double quotation mark is included in this script! may be you need to download it again.
But it's obvious that the double quotation mark " need to be replaced with single quotation mark '

select INST_ID,instance_name INS_NAME,STATUS,DATABASE_STATUS DB_STATUS,VERSION,INSTANCE_ROLE,LOGINS,BLOCKED,to_char(STARTUP_TIME,'DD-MON-YY HH24:MI:SS') STARTUP_TIME from gv$instance;

Zeeshan Christy said...

Hi Adel,

I guess this is something to do with the solaris vs linux. Your script is for linux environment. The actual queries in yoru script are correct with single quotes but when they are executed on solaris platform they are executed as double quotes. Wonder if you have a solaris environment that you can test them on.

Thanks
Zee

Mahmmoud ADEL said...

Thank you Zee for your comment. Actually I don't have a Solaris environment to test the script on, but I'm sure it will throw out errors if it runs on Unix platforms, especially the OS configuration baseline part. It's not easy to run a full cycle of test to get the script compatible with Solaris, mentioning in the post a short clause like "the script was tested on Linux Redhat & Oracle" took me too much time of testing on various Linux platforms and versions, I wish I could have it work on all environments but the lack of time is a major constraint on doing so!.