Database – Create Env


#!/bin/bash
#############################################################
# Created on: 2/17/09
# Last Updated: 07/09/09
# Version 2.1.6
#############################################################
#clear the screen
clear
#check for root user (this script must be run as root)
if [[ $EUID -ne 0 ]]; then
echo “This script must be run as root” 1>&2
exit 1
fi
# Confirm Start of Installation
echo -n “Are you sure that you want to continue? [y/n] “
read resp
if [ $resp != "Y" ] || [ $resp != "y" ]
then
echo “Exiting Installation”
exit
fi
# Create the Oracle User
echo “Creating ‘oracle’ user and groups”
echo “check if group oinstall exist:”
egrep “oinstall” /etc/group >/dev/null
if [ $? -eq 0 ]; then
echo “group: oinstall already exists”
else
groupadd oinstall
echo “group: oinstall added.”
fi
echo “check if dba group exists:”
egrep “dba” /etc/group >/dev/null
if [ $? -eq 0 ]; then
echo “group: dba already exists”
else
groupadd dba
echo “group: dba added.”
fi
echo “check to see if ‘oracle’ exists”
egrep “oracle” /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo “oracle already exists.”
else
useradd -g oinstall -G dba -d /home/oracle -m -s /bin/bash oracle
echo “user: oracle added.n”
passwd oracle
fi
# Creating Oracle Base Directory
echo “Create Oracle_Base directory”echo “Create Oracle_Base directory”
echo -e “Please enter the full of the Oracle Home”
read oh
mkdir -p $oh
chown -R oracle:oinstall $oh
# Kernel Parameter Modifications.
echo “Making kernel changes permanant by modifying /etc/sysctl.conf”
echo “# Kernel parameters required by Oracle” >> /etc/sysctl.conf
echo “kernel.msgmni = 2878″ >> /etc/sysctl.conf
echo “kernel.msgmax = 8192″ >> /etc/sysctl.conf
echo “kernel.msgmnb = 65535″ >> /etc/sysctl.conf
echo “kernel.sem = 256 32000 100 142″ >> /etc/sysctl.conf
echo “kernel.shmall = 2097152″ >> /etc/sysctl.conf
echo “kernel.shmmax = 4294967295″ >> /etc/sysctl.conf
echo “kernel.shmmni = 4096″ >> /etc/sysctl.conf
echo “fs.file-max = 131072″ >> /etc/sysctl.conf
echo “net.ipv4.ip_local_port_range = 20000 65000″ >> /etc/sysctl.conf
echo “Finished modifying /etc/sysctl.conf”
# Flush the sysctl.conf file after making the above changes.
/sbin/sysctl -p
# change to the oracle home directory
cd /home/oracle
echo “Create Environment source file:”
touch /home/oracle/infra.env
echo “ORACLE_BASE=/opt/oracle; export ORACLE_BASE” >> /home/oracle/infra.env
echo “ORACLE_HOME=$ORACLE_BASE/ias1; export ORACLE_HOME” >> /home/oracle/infra.env
echo “LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib:/user/local/bin; export LD_LIBRARY_PATH” >> /home/oracle/infra.env
echo “ORACLE_SID=orcl; export ORACLE_SID” >> /home/oracle/infra.env
echo “PATH=/usr/bin:$ORACLE_HOME/bin:$ORACLE_HOME/opmn/bin:$PATH; export PATH” >> /home/oracle/infra.env
# Change ownership of infra.env to oracle:oinstall
chown oracle:oinstall /home/oracle/infra.env
clear
echo -e “Oracle Environment Setup is Complete.”
exit 1

OUD Backup Script

Here is the output :


OUD Script Log Purge:: Purging the OUD Backup Script Logs older than 7 days
OUD Backup Purge:: Purging the OUD LDIF Backup older than 7 days
OUD Backup Purge:: Purging the OUD Binary Backup older than 7 days
OUD Backup:: Script Start -- 20160526_0854
Export task 20160526085425844 scheduled to start immediately
[26/May/2016:08:54:25 +0000] severity="NOTICE" msgCount=0 msgID=9896349 message="Export task 20160526085425844 started execution"
[26/May/2016:08:54:25 +0000] severity="INFORMATION" msgCount=1 msgID=10487422 message="Exporting to /tmp/oud-bkup/ldif/20160526_085421.ldif"
[26/May/2016:08:54:25 +0000] severity="INFORMATION" msgCount=2 msgID=8388850 message="The export will be done in Entry ID Order"
[26/May/2016:08:54:25 +0000] severity="NOTICE" msgCount=3 msgID=8847447 message="Exported 22 entries and skipped 0 in 0 seconds (average rate 1466.7/sec)"
[26/May/2016:08:54:25 +0000] severity="NOTICE" msgCount=4 msgID=9896350 message="Export task 20160526085425844 finished execution"
Export task 20160526085425844 has been successfully completed
+---  OUD LDIF Backup Verification:: Listing the backup ----+
-----
20160526_085421.ldif
-----
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend virtualAcis
[26/May/2016:08:54:33 +0000] category=JEB severity=NOTICE msgID=8847446 msg=Archived: 00000000.jdb
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend tasks
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend schema
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend userRoot
[26/May/2016:08:54:33 +0000] category=JEB severity=NOTICE msgID=8847446 msg=Archived: 00000000.jdb
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944792 msg=Starting backup for backend replicationChanges
[26/May/2016:08:54:33 +0000] category=JEB severity=NOTICE msgID=8847446 msg=Archived: 00000000.jdb
[26/May/2016:08:54:33 +0000] category=TOOLS severity=NOTICE msgID=10944795 msg=The backup process completed successfully
+--- OUD Binary Backup Verification:: Listing the backup ----+
-----
20160526_085421
-----
OUD Backup :: Script End -- 20160526_0854
Elapsed Time ::  00h:00m:12s

OUD – Script to check replication delay



#!/bin/bash

CMD="dsreplication --advanced status --hostname localhost --port 4444 --adminUID admin --adminPasswordFile /tmp/pwd.txt --trustAll --no-prompt -b cn=oraclecontext,dc=example,dc=com --dataToDisplay missing-changes"

if [[ "$($CMD | awk /4444/'{ print $3 }')" -gt 0 ]]; then
  echo " ==  Delay in Replication == "
  echo " == Please execute the following command for detailed replication status =="
  echo "dsreplication status --hostname localhost --port 4444 --adminUID admin --adminPasswordFile ~/pwd.txt --trustAll --no-prompt"
fi