Showing posts with label Unix / Linux. Show all posts
Showing posts with label Unix / Linux. Show all posts

Tuesday, January 15, 2019

Disable Transparent Hugepages on Oracle Linux / Redhat Enterprise Linux 7.5

Transparent Hugepages (THP) are similar to standard HugePages. However, while standard HugePages allocate memory at startup, Transparent Hugepages memory uses the khugepaged thread in the kernel to allocate memory dynamically during runtime, using swappable HugePages.

They may cause delays in accessing memory that can result in node restarts in Oracle RAC environments, or performance issues or delays for Oracle Database single instances. Oracle recommends to disable Transparent HugePages on Oracle database servers.

Following discussion is based on Oracle Linux / Redhat Enterprise Linux 7.5, it may be different on other Linux distributions.

Thursday, March 1, 2018

How to delete archive log files using PL/SQL


Although RMAN is always the first choice for most DBAs to delete archive log files, PL/SQL could be easier for this scenario,

User wants to switch an existing database from NOARCHIVELOG mode to ARCHIVELOG mode in order to increase the database availability because the database backup job has to shut down database when running in NOARCHIVELOG mode.

Thursday, January 25, 2018

AIX Disk Only Visible to One ASM Instance of Grid Infrastructure

Oracle Grid Infrastructure 12.2.0.1
AIX 7.1


New disks are added to both nodes of Grid Infrastructure, and the disk permission is configured properly,
[grid@host01]$ ls -l /dev/*hdisk[56]
brw-------      1 root      system         21, 26 Jan 22 10:58 /dev/hdisk5
brw-------      1 root      system         21, 25 Jan 22 10:58 /dev/hdisk6
crw-rw----    1 grid     asmadmin     21, 26 Jan 24 16:07 /dev/rhdisk5
crw-rw----    1 grid     asmadmin     21, 25 Jan 24 16:06 /dev/rhdisk6

[grid@host02]$ ls -l /dev/*hdisk2[56]
brw-------      1 root      system          21, 25 Jan 22 11:08 /dev/hdisk5
brw-------      1 root      system          21, 31 Jan 22 11:08 /dev/hdisk6
crw-rw----    1 grid     asmadmin     21, 25 Jan 22 11:08 /dev/rhdisk5
crw-rw----    1 grid     asmadmin     21, 31 Jan 24 14:49 /dev/rhdisk6

Wednesday, January 14, 2015

Automate Startup/Shutdown of OSWatcher with Oracle HAS (GridInfrastructure Standalone)

Grid Infrastructure Standalone 11.2.0.3
Operation system AIX 6.1

Download Oracle OSWatcher (oswbb732.tar, current version 7.3.2) from My Oracle Support. Install OSWatcher:
$ mkdir /u01/app/grid/product/7.3.2
$ cd /u01/app/grid/product/7.3.2
$ tar xvf /tmp/oswbb732.tar
  ... ...
$ ls -l oswbb/*OSWbb*
-rwxr-xr-x    1 grid  oinstall         2385 Oct 07 2013  oswbb/startOSWbb.sh
-rwxr-xr-x    1 grid  oinstall          558 Apr 17 2014  oswbb/stopOSWbb.sh

Create an Oracle HAS(Grid Infrastructure Standalone) Action Script file startOSWbb.sh:
#!/bin/sh
#
# ACTION_SCRIPT for Oracle HAS to manage OSWatcher
#
OSWBB_HOME=/u01/app/grid/product/7.3.2/oswbb
OSWBB_LOG=/u01/app/grid/local/logs/oswbb/alert_OSWbb.log
OSWBB_ARCHIVE_DEST=/u01/app/grid/local/logs/oswbb/archive
SNAPSHOT_INTERVAL=30   # in seconds
RETENTION_POLICY=720   # in hours
COMPRESS_COMMAND=NONE  # compress utility command such as zip, gzip, etc
#
case "$1" in
  'start')
     cd $OSWBB_HOME
     echo " " >> $OSWBB_LOG
     TMP=`ps -ef | grep OSWatcher  | grep -v grep |wc -l`
     if [ $TMP -eq 1 ]; then  # Only one process (OSWatcher or OSWatcherFM) running is not enough
        ./stopOSWbb.sh        # Stop orphan process
     fi
     echo "******************************************************" >> $OSWBB_LOG
     echo "...Starting OSWbb at `date` " >> $OSWBB_LOG
     ./startOSWbb.sh $SNAPSHOT_INTERVAL $RETENTION_POLICY $COMPRESS_COMMAND $OSWBB_ARCHIVE_DEST >> $OSWBB_LOG &
     if [ $? -eq 0 ]; then
        sleep 60    # Wait for all processes to be started
        exit 0
     else
        exit 1
     fi
     ;;
  'stop')
     cd $OSWBB_HOME
     echo "...Stopping OSWbb  at `date` " >> $OSWBB_LOG
     ./stopOSWbb.sh
     exit $?
     ;;
  'check')
    TMP=`ps -ef | grep OSWatcher  | grep -v grep |wc -l`
    if [ $TMP -eq 2 ]; then  # Both OSWatcher and OSWatcherFM (2 processes) running
       exit 0
    else
       exit 1
    fi
    ;;
  'clean')
     cd $OSWBB_HOME
     echo "...Cleaning/Stopping OSWbb  at `date` " >> $OSWBB_LOG
     ./stopOSWbb.sh
     exit $?
     ;;
esac

Note:
1. startOSWbb.sh has to be started in background by appending sign '&' at the end of the command line.
2. the output of startOSWbb.sh needs to be redirected to a file

Add a resource to HAS
crsctl add resource ora.OSWbb -type local_resource -attr "ACTION_SCRIPT=/u01/app/grid/local/bin/startOSWbb.sh,CHECK_INTERVAL=60,RESTART_ATTEMPTS=2"

Start resource ora.OSWbb
$ crsctl start resource ora.OSWbb
CRS-2672: Attempting to start 'ora.OSWbb' on 'host02'
CRS-2674: Start of 'ora.OSWbb' on 'host02' failed
CRS-4000: Command Start failed, or completed with errors.

Check OHASD agent log for errors:
$ tail /u01/app/grid/product/11.2.0/gi11204/log/host02/agent/ohasd/scriptagent_grid/scriptagent_grid.log
2015-01-14 10:00:49.240: [    AGFW][2057]{0:0:14962} Agent received the message: RESOURCE_START[ora.OSWbb host02 1] ID 4098:444107
2015-01-14 10:00:49.240: [    AGFW][2057]{0:0:14962} Preparing START command for: ora.OSWbb host02 1
2015-01-14 10:00:49.240: [    AGFW][2057]{0:0:14962} ora.OSWbb host02 1 state changed from: UNKNOWN to: STARTING
2015-01-14 10:00:49.242: [    AGFW][1543]{0:0:14962} Entering script entry point...
2015-01-14 10:00:49.242: [ora.OSWbb][1543]{0:0:14962} [start] Executing action script: /u01/app/grid/local/bin/startOSWbb.sh[start]
2015-01-14 10:00:49.304: [    AGFW][1543]{0:0:14962} Command: start for resource: ora.OSWbb host02 1 completed with status: SUCCESS
2015-01-14 10:00:49.305: [CLSFRAME][1] TM [MultiThread] is changing desired thread # to 3. Current # is 2
2015-01-14 10:00:49.306: [    AGFW][1543]{0:0:14962} Entering script entry point...
2015-01-14 10:00:49.306: [ora.OSWbb][1543]{0:0:14962} [check] Executing action script: /u01/app/grid/local/bin/startOSWbb.sh[check]
2015-01-14 10:00:49.307: [    AGFW][2057]{0:0:14962} Agent sending reply for: RESOURCE_START[ora.OSWbb host02 1] ID 4098:444107
2015-01-14 10:00:49.365: [    AGFW][2057]{0:0:14962} ora.OSWbb host02 1 state changed from: STARTING to: OFFLINE
2015-01-14 10:00:49.365: [    AGFW][2057]{0:0:14962} Agent sending last reply for: RESOURCE_START[ora.OSWbb host02 1] ID 4098:444107
2015-01-14 10:00:49.365: [    AGFW][2057]{0:0:14962} Agent has no resources to be monitored, Shutting down ..
2015-01-14 10:00:49.365: [    AGFW][2057]{0:0:14962} Agent sending message to PE: AGENT_SHUTDOWN_REQUEST[Proxy] ID 20486:25
2015-01-14 10:00:49.370: [    AGFW][2057]{0:0:14962} Agent is shutting down.
2015-01-14 10:00:49.370: [ USRTHRD][2057]{0:0:14962} Script agent is exiting..

Did not find helpful message, check OSWatcher log:
$ cat  /u01/app/grid/local/logs/oswbb/alert_OSWbb.log

******************************************************
The archive directory you specified for parameter 4 in startOSWbb.sh:/u01/app/grid/local/logs/oswbb/archive does not exist. Please create this directory and rerun ./startOSWbb.sh

******************************************************
...Starting OSWbb at Wed Jan 14 10:00:49 EST 2015
The archive directory you specified for parameter 4 in startOSWbb.sh:/u01/app/grid/local/logs/oswbb/archive does not exist. Please create this directory and rerun ./startOSWbb.sh

OSWatcher archive directory does not exist, manually create it:
$ mkdir /u01/app/grid/local/logs/oswbb/archive

Re-start resource ora.OSWbb
$ crsctl start resource ora.OSWbb
CRS-2672: Attempting to start 'ora.OSWbb' on 'host02'
CRS-2676: Start of 'ora.OSWbb' on 'host02' succeeded

Resource ora.OSWbb started successfully, make sure OSWatcher is running:
$ ps -ef | grep OSWatcher
 grid  7405596  5046352   0 10:13:16  pts/6  0:00 grep OSWatcher
 grid  7078198 11469280   0 10:11:23      -  0:00 /bin/sh ./OSWatcherFM.sh 720 /u01/app/grid/local/logs/oswbb/archive
 grid 11469280        1   0 10:10:54      -  0:00 /bin/sh ./OSWatcher.sh 30 720 NONE /u01/app/grid/local/logs/oswbb/archive

Note: Keyword 'OSWatcher' is reserved by OSWatcher stopping script to determine if the utility is running. DO NOT using string 'OSWatcher' anywhere (directory name, file name, command name, etc).

Test resource ora.OSWbb  stop function:
$ crsctl stop resource ora.OSWbb
CRS-2673: Attempting to stop 'ora.OSWbb' on 'host02'
CRS-2677: Stop of 'ora.OSWbb' on 'host02' succeeded
$ ps -ef | grep OSWatcher
 oragrid 12058682  5046352   0 15:15:50  pts/6  0:00 grep OSWatcher

Test resource ora.OSWbb  restart function (check & start functions):
$ ps -ef | grep OSWatcher
 oragrid 11010394  5046352   0 15:18:33  pts/6  0:00 grep OSWatcher
$ crsctl start resource ora.OSWbb
CRS-2672: Attempting to start 'ora.OSWbb' on 'host02'
CRS-2676: Start of 'ora.OSWbb' on 'host02' succeeded
$  ps -ef | grep OSWatcher
 oragrid  7864326        1   0 15:18:42      -  0:00 /bin/sh ./OSWatcher.sh 30 720 NONE /u01/app/grid/local/logs/oswbb/archive
 oragrid  8388952  7864326   0 15:19:10      -  0:00 /bin/sh ./OSWatcherFM.sh 720 /u01/app/grid/local/logs/oswbb/archive
 oragrid 11665602  5046352   0 15:19:53  pts/6  0:00 grep OSWatcher

OSWatcher is running, kill one of two running processes:
$ kill 8388952
$
$ ps -ef | grep OSWatcher
 oragrid  7405662  5046352   0 15:20:26  pts/6  0:00 grep OSWatcher
 oragrid  7864326        1   0 15:18:42      -  0:00 /bin/sh ./OSWatcher.sh 30 720 NONE /u01/app/grid/local/logs/oswbb/archive

Process OSWatcherFM.sh is killed. Now wait for 1 minute and see what happens:
$ ps -ef | grep OSWatcher
 oragrid 14614732  6816014   0 15:21:11      -  0:00 /bin/sh ./OSWatcherFM.sh 720 /u01/app/grid/local/logs/oswbb/archive
 oragrid  6816014        1   0 15:20:42      -  0:00 /bin/sh ./OSWatcher.sh 30 720 NONE /u01/app/grid/local/logs/oswbb/archive
 oragrid 10355082  5046352   0 15:22:23  pts/6  0:00 grep OSWatcher
$

Wow! The processes are restarted.

Saturday, June 6, 2009

Change Resolution of Red Hat Enterprise Linux Text Console

If Red Hat Enterprise Linux is installed without GUI (Gnome, KDE), or the system is running at runlevel 3, all the text appears big (low resolution) on local text-mode console as following,



Actually, this can be changed by adding 'vga=<resolution code>' option into grub boot loader configuration file '/boot/grub/grub.conf'.

Original grub.conf contains following line,

kernel /vmlinuz-2.6.9-89.EL ro root=LABEL=/ rhgb quiet


And we are going to set the resolution to 1024x768 24bit color and new file is changed as following,

kernel /vmlinuz-2.6.9-89.EL ro root=LABEL=/ rhgb quiet vga=792


Note: Resolution code (here is 792) really depends on hardware. It could be following values (come from Red Hat support),

   Depth      800×600     1024×768     1152×864     1280×1024     1600×1200
   8 bit         vga=771     vga=773        vga=353        vga=775         vga=796
   16 bit       vga=788     vga=791        vga=355        vga=794         vga=798
   24 bit       vga=789     vga=792        -------           vga=795         vga=799


After reboot, much more messages come up onto text console, the console becomes 'bigger',