What is SNMP? how to use SNMP?

This is a brief documentation on using the google-provided MIBs for GSA (Google Search Appliance). This can also be used as a reference to monitor any SNMP enabled device.

Terminologies:
—————
SNMP: SNMP stands for Simple Network Management Protocol and consists of three key components: managed devices, agents, and network-management systems (NMSs). A managed device is a node that has an SNMP agent and resides on a managed network. These devices can be routers and access server, switches and bridges, hubs, computer hosts, or printers. An agent is a software module residing within a device. This agent translates information into a compatible format with SNMP. An NMS runs monitoring applications. They provide the bulk of processing and memory resources required for network management.

MIB: MIB stands for Management Information Base and is a collection of information organized hierarchically. These are accessed using a protocol such as SNMP. There are two types of MIBs: scalar and tabular. Scalar objects define a single object instance whereas tabular objects define multiple related object instances grouped in MIB tables.

OID: OIDs or Object Identifiers uniquely identify manged objects in a MIB hierarchy. This can be depicted as a tree, the levels of which are assigned by different organizations. Top level MIB object IDs (OIDs) belong to different standard organizations. Vendors define private branches including managed objects for their own products.

Tools required:
—————-
In order to get more information on the OID, or to get list of all available params/OID from a device, or to get OID from MIB or vice-versa, it would help if we have access to a linux box with snmp-utils installed. This can be checked using:
$ rpm -qa |grep -i snmp
net-snmp-5.1.2-13.el4
net-snmp-libs-5.1.2-13.el4
net-snmp-utils-5.1.2-13.el4

And if not available, installed from yum. You need to copy the vendor provided MIB file to you home directory under:
/home/username/.snmp/mibs/

For example:
[jayesh@MY_SERVER mibs]# pwd
/home/ram/.snmp/mibs
[jayesh@MY_SERVER mibs]# ls -la
total 24
drwxr-xr-x  2 jayesh jayesh 4096 Oct 28 18:04 .
drwxr-xr-x  3 jayesh jayesh 4096 Oct 28 18:03 ..
-rw-r–r–  1 jayesh jayesh 702 Oct 28 17:56 GOOGLE-MIB.txt
-rw-r–r–  1 jayesh jayesh 5032 Oct 28 17:56 GSA-MIB.txt

Setting up the monitor:
————————–
Your monitoring tool (sitescope) is normally capable of monitoring the usual/standard metrics from an SNMP capable device. The more famous and widely used the device is, the better support. (Cisco, Linux etc).

In case the OIDs are not available to the monitoring system, they can always be imported from the manufacturer provided MIBs.

Monitor can be setup using the MIB or OID for that particular system. In case of GSA, the MIBs that we need to monitor are:
system.temperature.temperatureHealth.0
system.gsaDisk.diskHealth.0
system.machine.machineHealth.0

Or (in terms of complete MIBs)
.iso.org.dod.internet.private.enterprises.google.gsa.system.temperature.temp
eratureHealth
.iso.org.dod.internet.private.enterprises.google.gsa.system.gsaDisk.diskHeal
th
.iso.org.dod.internet.private.enterprises.google.gsa.system.machine.machineH
ealth

Now, we can use the MIB directly to use for our monitoring or we can use the corresponding OID.

In order to get the list of OIDs corresponding to the MIBs, we can use the tools provided by the net-snmp-utils package.

Command:snmptranslate -m GSA-MIB -Ts
Function: to get the list of MIB trees

Command:snmptranslate -m GSA-MIB -To
Function: to get the list of OID

Using both the commands for GSA, we can get the following information:

OID                MIB
.1.3                .iso.org
.1.3.6                .iso.org.dod
.1.3.6.1            .iso.org.dod.internet
.1.3.6.1.1            .iso.org.dod.internet.directory
.1.3.6.1.2            .iso.org.dod.internet.mgmt
.1.3.6.1.2.1            .iso.org.dod.internet.mgmt.mib-2
.1.3.6.1.2.1.10
.iso.org.dod.internet.mgmt.mib-2.transmission
.1.3.6.1.3            .iso.org.dod.internet.experimental
.1.3.6.1.4            .iso.org.dod.internet.private
.1.3.6.1.4.1            .iso.org.dod.internet.private.enterprises
.1.3.6.1.4.1.11129
.iso.org.dod.internet.private.enterprises.google
.1.3.6.1.4.1.11129.1
.iso.org.dod.internet.private.enterprises.google.gsa
.1.3.6.1.4.1.11129.1.1
.iso.org.dod.internet.private.enterprises.google.gsa.crawl
.1.3.6.1.4.1.11129.1.1.1
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.crawlRunning
.1.3.6.1.4.1.11129.1.1.2
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status
.1.3.6.1.4.1.11129.1.1.2.1
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.docsServed
.1.3.6.1.4.1.11129.1.1.2.2
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.crawlingRa
te
.1.3.6.1.4.1.11129.1.1.2.3
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.docBytes
.1.3.6.1.4.1.11129.1.1.2.4
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.todayDocsC
rawled
.1.3.6.1.4.1.11129.1.1.2.5
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.docErrors
.1.3.6.1.4.1.11129.1.1.2.6
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.docsFound
.1.3.6.1.4.1.11129.1.1.2.7
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.batchCrawl
Running
.1.3.6.1.4.1.11129.1.1.2.8
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.batchCrawl
StartTime
.1.3.6.1.4.1.11129.1.1.2.9
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.batchCrawl
EndTime
.1.3.6.1.4.1.11129.1.1.2.10
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.status.batchCrawl
EndReason
.1.3.6.1.4.1.11129.1.1.3
.iso.org.dod.internet.private.enterprises.google.gsa.crawl.diagnostics
.1.3.6.1.4.1.11129.1.2
.iso.org.dod.internet.private.enterprises.google.gsa.serving
.1.3.6.1.4.1.11129.1.2.1
.iso.org.dod.internet.private.enterprises.google.gsa.serving.qpm
.1.3.6.1.4.1.11129.1.3
.iso.org.dod.internet.private.enterprises.google.gsa.system
.1.3.6.1.4.1.11129.1.3.1
.iso.org.dod.internet.private.enterprises.google.gsa.system.gsaDisk
.1.3.6.1.4.1.11129.1.3.1.1
.iso.org.dod.internet.private.enterprises.google.gsa.system.gsaDisk.diskHeal
th
.1.3.6.1.4.1.11129.1.3.1.2
.iso.org.dod.internet.private.enterprises.google.gsa.system.gsaDisk.diskErro
rs
.1.3.6.1.4.1.11129.1.3.2
.iso.org.dod.internet.private.enterprises.google.gsa.system.temperature
.1.3.6.1.4.1.11129.1.3.2.1
.iso.org.dod.internet.private.enterprises.google.gsa.system.temperature.temp
eratureHealth
.1.3.6.1.4.1.11129.1.3.2.2
.iso.org.dod.internet.private.enterprises.google.gsa.system.temperature.temp
eratureErrors
.1.3.6.1.4.1.11129.1.3.3
.iso.org.dod.internet.private.enterprises.google.gsa.system.machine
.1.3.6.1.4.1.11129.1.3.3.1
.iso.org.dod.internet.private.enterprises.google.gsa.system.machine.machineH
ealth
.1.3.6.1.4.1.11129.1.3.3.2
.iso.org.dod.internet.private.enterprises.google.gsa.system.machine.machineE
rrors
.1.3.6.1.4.1.11129.1.4
.iso.org.dod.internet.private.enterprises.google.gsa.search
.1.3.6.1.4.1.11129.1.4.1
.iso.org.dod.internet.private.enterprises.google.gsa.search.reports
.1.3.6.1.4.1.11129.1.4.2
.iso.org.dod.internet.private.enterprises.google.gsa.search.logs
.1.3.6.1.4.1.11129.1.5
.iso.org.dod.internet.private.enterprises.google.gsa.eventLogs
.1.3.6.1.5            .iso.org.dod.internet.security
.1.3.6.1.6            .iso.org.dod.internet.snmpV2
.1.3.6.1.6.1            .iso.org.dod.internet.snmpV2.snmpDomains
.1.3.6.1.6.2            .iso.org.dod.internet.snmpV2.snmpProxys
.1.3.6.1.6.3            .iso.org.dod.internet.snmpV2.snmpModules
.0.0                .ccitt.zeroDotZero

Now, we can use this information, to setup the monitor for the system. (we would need the IP address of the device, the community string, and of course, access to SNMP-readonly)

I would guess, SiteScope needs the OID, community string, and the IP address of the device to monitor.

Here is an example shell script, that uses snmp-utils (snmpget) and the GSA
MIBS:

#!/bin/bash
#set -o xtrace
DEVICE=”Yur_IP_HERE”
MIBS=”system.temperature.temperatureHealth.0 system.gsaDisk.diskHealth.0 system.machine.machineHealth.0″
# GSA-MIB::diskHealth.0 = INTEGER: green(0) for MIB in ${MIBS} do

RESULT=`snmpget -m GSA-MIB -v 2c -c public -t 5 ${DEVICE} ${MIB}| cut -f4 -d”:” | grep -E -o “[0-9]”`

case ${RESULT} in
0) STATUS=”Good”;;
1) STATUS=”Warning”;;
2) STATUS=”Critical”;;
*) STATUS=”Unreachable/Unknown”;;
esac

if [ ${STATUS} != “Good” ]
then
(
PARAM=`echo ${MIB}|cut -f3 -d”.”`
echo “From: MY_EMAIL_FROM@DOMAIN.COM”
echo “To: MY_EMAIL@DOMAIN.COM”
echo “Subject: [GSA] ${PARAM} ${STATUS}”
echo “GSA Device ${DEVICE} is in ${STATUS} state for ${PARAM}. Please investigate.”
)| sendmail -t
fi
Done

How to check the installed mod_jk version

2 ways you can do that.

1. Better approach is
# strings /PATH/TO/APACHE/modules/mod_jk.so |grep -i mod_jk
mod_jk.so
mod_jk.c
mod_jk/1.2.18 <-- There you go. 2. If you have that already installed then if you have enable mod_jk log then you can check from that log file or you can do http://Your_SERVER/ApplicationURL/SomeFOLDER/@#@#CS<>>$#$#$% You will get internal serever error over there at the bottom you will get the mod_jk version with apache version. e.g. Apache/2.0.59 (Unix) mod_jk/1.2.28

Steps to create SSL certificate

Change directory to conf/cert of your Apache SSL instance home

Generate key and CSR using the CN as the name of the web-site this apache instance will host. (Check the end of the doc to create csr)

Now you will have to give this CSR to the third party company and purchase the SSL certificate from them.

Steps to follow once we get the signed certificate:

Take the backup of previous certificate and then copy
EntrustSecureServerCA.crt
TrustedSecureCertificateAuthority.crt

ssl_home_ge_com.crt and replace the MY_SERVER1.key ( which gets created from step 3)

Restart the apachessl after all the changes. To use this certificate on other server2 , copy all the certificates there and rename MY_SERVER1.key to MY_SERVER2.key )

# openssl req -new -nodes -keyout MY_SERVER1.key -out MY_SERVER1csr

Crash in HotSpot Compiler Thread or Compiled Code

If the fatal error log indicates that the crash occurred in a compiler thread, then it is possible (but not always the case) that you have encountered a compiler bug. Similarly, if the crash is in compiled code then it is possible that the compiler has generated incorrect code.

In the case of the HotSpot Client VM (-client option), the compiler thread appears in the error log as CompilerThread0. With the HotSpot Server VM there are multiple compiler threads and these appear in the error log file as CompilerThread0, CompilerThread1, and AdapterThread.

Below is a fragment of an error log for a compiler bug that was encountered and fixed during the development of J2SE 5.0. The log file shows that the HotSpot Server VM is used and the crash occurred in CompilerThread1. In addition, the log file shows that the Current CompileTask was the compilation of the java.lang.Thread.setPriority method.

# An unexpected error has been detected by HotSpot Virtual Machine:
#
:
# Java VM: Java HotSpot(TM) Server VM (1.5-internal-debug mixed mode)
:
---------------  T H R E A D  ---------------

Current thread (0x001e9350): JavaThread "CompilerThread1" daemon [_thread_in_vm, id=20]

Stack: [0xb2500000,0xb2580000),  sp=0xb257e500,  free space=505k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xc3b13c]
:

Current CompileTask:
opto: 11      java.lang.Thread.setPriority(I)V (53 bytes)

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x00229930 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=21]
=>0x001e9350 JavaThread "CompilerThread1" daemon [_thread_in_vm, id=20]
 :

In this case there are two potential workarounds:

  • The brute force approach: change the configuration so that the application is run with the -client option to specify the HotSpot Client VM.
  • Assume that the bug only occurs during the compilation of the setPriority method and exclude this method from compilation.

The first approach (to use the -client option) might be trivial to configure in some environments. In others, it might be more difficult if the configuration is complex or if the command line to configure the VM is not readily accessible. In general, switching from the HotSpot Server VM to the HotSpot Client VM also reduces the peak performance of an application. Depending on the environment, this might be acceptable until the actual issue is diagnosed and fixed.

The second approach (exclude the method from compilation) requires creating the file .hotspot_compiler in the working directory of the application. Below is an example of this file:

exclude    java/lang/Thread    setPriority

In general the format of this file is exclude CLASS METHOD, where CLASS is the class (fully qualified with the package name) and METHOD is the name of the method. Constructor methods are specified as <init> and static initializers are specified as <clinit>.


Note – The .hotspot_compiler file is an unsupported interface. It is documented here solely for the purposes of troubleshooting and finding a temporary workaround.


Once the application is restarted, the compiler will not attempt to compile any of the methods listed as excluded in the .hotspot_compiler file. In some cases this can provide temporary relief until the root cause of the crash is diagnosed and the bug is fixed.

In order to verify that the HotSpot VM correctly located and processed the .hotspot_compiler file that is shown in the example above, look for the following log information at runtime. Note that the file name separator is a dot, not a slash.

### Excluding compile:    java.lang.Thread::setPriority

Script for oracle Database monitoring

shell script for DB monitoring.

[root@MY_SERVER1 monitor]#
#!/bin/bash
count=0;
SCRIPT_HOME=”/Your/folder/”
MONITOR_SCRIPT=”${SCRIPT_HOME}/MyEnv_db_monitor.pl”
LOCKFILE=/tmp/MyEnv_db_monitor.lock

if [ -f “${LOCKFILE}” ]
then
(
echo “${LOCKFILE} ALREADY EXISTS.. DB monitor will not run”
ls -la ${LOCKFILE}
) | mail -s “MY ENVIRONMENTDB Monitor is not running. Lock” MY_EMAIL@DOMAIN.com
else
touch ${LOCKFILE}
dblisteners=(IP2:PORT2 IP2:PORT1)
len=${#dblisteners[*]} #Num elements in array

#echo “dblisteners are $len members.They are:”
i=0
while [ $i -lt $len ]; do
#       echo “${dblisteners[$i]}”
server=`echo “${dblisteners[$i]}” | cut -d: -f1`
port=`echo “${dblisteners[$i]}” | cut -d: -f2`
#       echo $server $port
${MONITOR_SCRIPT} $server $port > /dev/null 2>&1
if [ $? -eq 0 ]
then
count=$((count+1))
fi

let i++
done
# ${MONITOR_SCRIPT} > /dev/null 2>&1
if  [ $count -eq 2 ]
then
rm ${LOCKFILE}
fi
fi

——————————————————————

[root@MY_SERVER1 monitor]# cat /Your/folder/MyEnv_db_monitor.sh
#!/bin/bash
count=0;
SCRIPT_HOME=”/Your/Folder”
MONITOR_SCRIPT=”${SCRIPT_HOME}/MyEnv_db_monitor.pl”
LOCKFILE=/tmp/MyEnv_db_monitor.lock

if [ -f “${LOCKFILE}” ]
then
(
echo “${LOCKFILE} ALREADY EXISTS.. DB monitor will not run”
ls -la ${LOCKFILE}
) | mail -s “MY ENVIRONMENTStage DB Monitor is not running. Lock” MY_EMAIL@DOMAIN.com
else
touch ${LOCKFILE}
dblisteners=(IP1:PORT1 IP2:PORT2)
len=${#dblisteners[*]} #Num elements in array

#echo “dblisteners are $len members.They are:”
i=0
while [ $i -lt $len ]; do
#       echo “${dblisteners[$i]}”
server=`echo “${dblisteners[$i]}” | cut -d: -f1`
port=`echo “${dblisteners[$i]}” | cut -d: -f2`
#       echo $server $port
${MONITOR_SCRIPT} $server $port > /dev/null 2>&1
if [ $? -eq 0 ]
then
count=$((count+1))
fi

let i++
done
# ${MONITOR_SCRIPT} > /dev/null 2>&1
if  [ $count -eq 2 ]
then
rm ${LOCKFILE}
fi
fi
[root@MY_SERVER1 monitor]# cat /Your/folder/MyEnv_db_monitor.pl
#!/usr/bin/perl -w

use warnings;
use strict;
use DBI;

BEGIN {
$ENV{ORACLE_HOME}=’/opt/oracle/product/9.2.0′;
$ENV{LD_LIBRARY_PATH}=’/opt/oracle/product/9.2.0/lib’;
}

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
my $timestamp = sprintf(“%4d-%02d-%02d %02d:%02d:%02dn”,$year+1900,$mon+1,$mday,$hour,$min,$sec);
chomp $timestamp;
print “The time is $timestampn”;

my $server = $ARGV[0];
my $appsport = $ARGV[1];
chomp $server; chomp $appsport;
print “The server is $server connecting to $appsport n”;
my $mail = “/usr/lib/sendmail -t”;
my $recipient = “MY_EMAIL@DOMAIN.COM”;
my $from = “MyEnv_db_monitor@DOMAIN.COM”;
my $timeOut = 60; # wait 60 seconds for connection
my $db = “DBNAME”;
my ($username, $password) = (‘DB_SCHEMA_NAME’,’DB_PASSWORD’);
#my $db_conn_dsn=”dbi:Oracle:host=DB_SERVER_NAME;port=PORT;sid=$db”;
my $db_conn_dsn=”dbi:Oracle:host=DB_SERVER_NAME;port=${appsport};sid=$db”;
my $flag = “/tmp/dbdbflag2.txt$server”;
my $qflag = “/tmp/dbtaskqueflag2.txt$server”;
my $rowcount = “”;
my $dummyflag = “/tmp/dbdummyflag2.txt$server”;

if ( -e $flag ) { # Check for DB status flag file
print “DB Flag exists.n”;
} else { # Create flag file
system “/bin/touch $flag”;
}

if ( -e $qflag ) { # Check for task que status flag file
print “Task que flag exists.n”;
} else { # Create flag file
system “/bin/touch $qflag”;
}

my $flagstatus = `/bin/cat $flag`;
chomp $flagstatus;
print “The status of the db flag is $flagstatusn”;

my $qflagstatus = `/bin/cat $qflag`;
chomp $qflagstatus;
print “The status of the task que flag is $qflagstatusn”;

if ( -e $dummyflag ) { # Check for Dummy status flag file
print “Dummy Flag exists.n”;
system “/bin/touch $dummyflag”;
} else { # Create flag file
system “/bin/touch $dummyflag”;
}

my $mtime_qflag = (stat($qflag))[9];
my $mtime_dflag = (stat($dummyflag))[9];

print “The mtime for qflag is $mtime_qflag secsn”;
print “The mtime for dflag is $mtime_dflag secsn”;

my $refresh_interval = ($mtime_dflag-$mtime_qflag)/3600;

print “The que flag has been refreshed since $refresh_interval hoursn”;

if (( $refresh_interval > 24 ) && ( $qflagstatus ne “LESS” )) {
system “echo BLANK > $qflag”;
} else {
print “The refresh interval is $refresh_interval hours and the flag status is $qflagstatusn”;
}

if ($db) {
print “checking $dbn”;
my $dbh=”;
eval {
#set alarm to timeout current operation
local $SIG{ALRM} = sub {die “connection timeoutn”};
alarm $timeOut;
print “Trying to connect to $db with $username and $passwordn”;
$dbh = DBI->connect($db_conn_dsn,$username,$password, { RaiseError => 1 } ) || die “Database connection not made: $DBI::errstr”;
};
alarm 0; # reset the alarm
if ($dbh) { # success
print “Connection succeeded for $dbn”;

my $sql = “select count(*) from vap_default.taskqueue”;
my $sth = $dbh->prepare($sql) or die “Cannot prepare sql statement” . $dbh->errstr(). “n”;
$sth->execute() or die “cannot execute sql query” . $sth->errstr() . “n”;
($rowcount) = $sth->fetchrow_array();
$sth->finish;
print “The task queue row count is $rowcountn”;

$dbh->disconnect;

print “DB is now up.n”;
if ( $flagstatus eq “DOWN” ) {
system “echo ‘RECOVERED’ > $flag”;
print “The DB has just recovered at $timestamp.n”;
&upmail;
} else {
print “Do nothing. DB was anyways up.n”;
}

print “Just outside failure blockn”;

} else { # failure
print “Inside failure blockn”;
if ( $flagstatus eq “DOWN” ) {
print “Do nothing. DB is still downn”;
} else {
print “Error connecting to $db at $timestampn”;
&downmail;
system “echo ‘DOWN’ > $flag”;
}
}
}

sub downmail {
open(MAIL, “|$mail”);
print MAIL “To: $recipientn”;
print MAIL “From: $fromn”;
print MAIL “Subject: MY ENVIRONMENTStage DATABASE_NAME on  Database Connection Failure $server $appsportn”;
print MAIL “$timestamp: FAILED CONNECTION TO MY ENVIRONMENT DATABASE.nnTurning Big-IP monitors OFF. $server $appsport”;
close MAIL;
system(“/Your/folder/disable_remote_tomcats.sh $server $appsport”);
}

sub upmail {
open(MAIL, “|$mail”);
print MAIL “To: $recipientn”;
print MAIL “From: $fromn”;
print MAIL “Subject: MY ENVIRONMENT DATABASE_NAME on  Database Connection Recovered $server $appsportn”;
#print MAIL “$timestamp: RECOVERED CONNECTION TO MY ENVIRONMENT DATABASE.nnTurning Big-IP monitors ON”;
print MAIL “$timestamp: RECOVERED CONNECTION TO MY ENVIRONMENTDATABASE.”;
close MAIL;
system(“/Your/folder/enable_remote_tomcats.sh $server $appsport”);
}

sub qmoremail {
open(MAIL, “|$mail”);
print MAIL “To: $recipientn”;
print MAIL “From: $fromn”;
print MAIL “Subject: MY ENVIRONMENTDATABASE_NAMEon  Vignette Task Queue Record Countn”;
print MAIL “$timestamp: TASK QUEUE RECORD COUNT = $rowcountnn”;
close MAIL;
}

sub qlessmail {
open(MAIL, “|$mail”);
print MAIL “To: $recipientn”;
print MAIL “From: $fromn”;
print MAIL “Subject: MY ENVIRONMENTDATABASE_NAMEon  Vignette Task Queue Record Countn”;
print MAIL “$timestamp: TASK QUEUE RECORD COUNT = $rowcountnn”;
close MAIL;
}

——————————————————————————————

Not Mendatary– but require in my environment thats why I added this.. In order to enable disaster recovery site.

[root@MY_SERVER1 monitor]# cat “/Your/folder/disable_remote_tomcats.sh”
#!/bin/bash

tomcat_user=”tomcat0″;
tomcat_node=$1;
#for tomcat_node in ${nodes}
#do
for tomcats in `seq 0 1`
do
ssh ${tomcat_user}@${tomcat_node} “mv /appl/tomcat${tomcats}/webapps/portal/Status/Status.jsp /appl/tomcat${tomcats}/webapps/portal/Status/Status.jsp.old”
done
#done

echo “${tomcat_node}  tomcat nodes are disabled in BigiP.” | mail -s “${tomcat_node} tomcat nodes are disabled” MY_EMAIL@DOMAIN.com
#echo “All tomcat nodes are disabled in BigiP. Enabling DR nodes” | mail -s “[DR Enabled] MY ENVIRONMENTApp Status Pages” YOUR_EMAIL@DOMAIN.COM
#/Your/folder/enable_dr.sh

[root@MY_SERVER1 monitor]#

[root@MY_SERVER1 monitor]# cat /Your/folder/enable_dr.sh
#!/bin/bash
drnodes=”MY_DR_NODE1 MY_DR_NODE2″

for dr_node in ${drnodes}
do
/usr/bin/ssh root@${dr_node} “mv /appl/webdocs/portal/Status/Status.jsp.down /appl/webdocs/portal/Status/Status.jsp”
done

echo “enabling DR nodes on `/bin/date`.” | /bin/mail -s “enabling DR nodes” YOUR_EMAIL@DOMAIN.COM MY_EMAIL@DOMAIN.COM

[root@MY_SERVER1 monitor]#

——————————————————————————————
[root@MY_SERVER1 monitor]# cat “/Your/folder/enable_remote_tomcats.sh”
#!/bin/bash

#nodes=”MY_SERVER1 MY_SERVER2″
tomcat_user=”tomcat0″;
tomcat_node=$1;

#for tomcat_node in ${nodes}
#do
for tomcats in `seq 0 1`
do
ssh ${tomcat_user}@${tomcat_node} “mv /appl/tomcat${tomcats}/webapps/portal/Status/Status.jsp.old /appl/tomcat${tomcats}/webapps/portal/Status/Status.jsp”
done
#done

#echo “${tomcat_node} All Tomcat Status pages are up. Trying to handle DR nodes…” | mail -s “[Restored] MY ENVIRONMENT App Status Pages” MY_EMAIL@DOMAIN.com
echo “${tomcat_node} All Tomcat Status pages are up.” | mail -s “[Restored] MY ENVIRONMENT App Status Pages” MY_EMAIL@DOMAIN.com
#/Your/folder/manage_dr.sh

[root@MY_SERVER1 monitor]#

[root@MY_SERVER1 monitor]# cat /Your/folder/manage_dr.sh
#!/bin/bash
#set -o xtrace
drnodes=”MY_DR_NODE2 MY_DR_NODE1″
poolcount1=0;
poolcount2=0;
STATUS_URI=”portal/Status/Status.jsp”
pool1=”URL1
URL2″
pool2=”URL3
URL4″

for MyEnv_node in ${pool1}
do
status=`/usr/bin/lynx –connect_timeout=3 –dump http://${MyEnv_node}.corporate.ge.com/${STATUS_URI} | grep “ITS_UP” | wc -l`
poolcount228=$((poolcount228+status))
done

for MyEnv_node in ${pool2}
do
status=`/usr/bin/lynx –connect_timeout=3 –dump http://${MyEnv_node}/${STATUS_URI} | grep “ITS_UP” | wc -l`
pool2count=$((pool2count+status))
done

#if [ $pool1count -ge 2 -a ${pool2count} -ge 2 ]
if [ $pool2count -ge 2 ]
then
for dr_node in ${drnodes}
do
/usr/bin/ssh root@${dr_node} “mv /appl/webdocs/portal/Status/Status.jsp /appl/webdocs/portal/Status/Status.jsp.down”
done
echo “disabling DR nodes on `date`. Will be re-enabled in 20 mins” | mail -s “Disabling DR nodes” YOUR_EMAIL@DOMAIN.COM MY_EMAIL@DOMAIN.COM
/usr/bin/at -f /Your/folder/enable_dr.sh  now + 20 min
else
echo -e “DR Nodes still kept UP, since dynamic nodes are not upnWill retry in 5 mins from now” | mail -s “DR nodes still UP” YOUR_EMAIL@DOMAIN.COM MY_EMAIL@DOMAIN.COM
/usr/bin/at -f /Your/folder/manage_dr.sh  now + 5 min
fi

[root@MY_SERVER1 monitor]#

Internet Explorer shortcut keys

Shortcut Keys Description
Alt + Left Arrow Back a page.
Backspace Back a page.
Alt + Right Arrow Forward a page.
F5 Refresh current page, frame, or tab.
F11 Display the current website in full screen mode. Pressing F11 again will exit this mode.
Esc Stop page or download from loading.
Ctrl + (- or +) Increase or decrease the font size, pressing ‘-‘ will decrease and ‘+’ will increase.
Ctrl + Enter Quickly complete an address. For example, type tcs in the address bar and press CTRL + ENTER to get http://www.tcs.com/
Ctrl + D Add a Favorite for the page currently opened.
Ctrl + I Display available bookmarks.
Ctrl + N Open New browser window.
Ctrl + P Print current page / frame.
Ctrl + T Opens a new tab.
Ctrl + F4 Closes the currently selected tab.
Ctrl + Tab Moves through each of the open tabs.
Spacebar Moves down a page at a time.
Shift + Spacebar Moves up a page at a time.
Alt + Down arrow Display all previous text entered in a text box and/or available options on drop down menu.
Alt + D Highlights the text in the address bar

Mysql master slave server database load balancing

Replication

1. Creating a User for Replication

Each Slave must connect to the Master using a standard username and password. The user that you use for this operation can be any user, providing they have been granted the REPLICATION SLAVE privilege.

You do not need to create a specific user for replication. However, you should be aware that the username and password will be stored in plain text within the master.info file. Therefore you may want to create a user that only has privileges for the replication process.

To create a user or grant an existing user the privileges required for replication use the GRANT statement. If you create a user solely for the purposes of replication then that user only needs the REPLICATION SLAVE privilege. For example, to create a user, repl, that allows all hosts within the domain mydomain.com to connect for replication:

mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';

2. Setting the Replication Master Configuration

For replication to work you must enable binary logging on the master. If binary logging is not enabled, replication will not be possible as it is the binary log that is used to exchange data between the master and slaves.

Each server within a replication group must have a unique server-id. The server-id is used to identify individual servers within the group, and must be positive integer between 1 and (232)-1). How you organize and select the numbers is entirely up to you.

To configure both these options you will need to shut down your MySQL server and edit the configuration of the my.cnf or my.ini file.

You will need to add the following options to the configuration file within the [mysqld] section. If these options already exist, but are commented out, uncomment the options and alter them according to your needs. For example, to enable binary logging, using a log filename prefix of mysql-bin, and setting a server ID of 1:

[mysqld]
log-bin=mysql-bin
server-id=1

3. Setting the Replication Slave Configuration

The only option you must configure on the slave is to set the unique server ID. If this option is not already set, or the current value conflicts with the value that you have chosen for the master server, then you should shut down your slave server, and edit the configuration to specify the server id. For example:

[mysqld]
server-id=2

If you are setting up multiple slaves, each one must have a unique server-id value that differs from that of the master and from each of the other slaves. Think of server-id values as something similar to IP addresses: These IDs uniquely identify each server instance in the community of replication partners.

If you do not specify a server-id value, it is set to 1 if you have not defined master-host; otherwise it is set to 2. Note that in the case of server-id omission, a master refuses connections from all slaves, and a slave refuses to connect to a master. Thus, omitting server-id is good only for backup with a binary log.

You do not have to enable binary logging on the slave for replication to be enabled. However, if you enable binary logging on the slave then you can use the binary log for data backups and crash recovery on the slave, and also use the slave as part of a more complex replication topology.

4. Obtaining the Master Replication Information

To configure replication on the slave you must determine the masters current point within the master binary log. You will need this information so that when the slave starts the replication process, it is able to start processing events from the binary log at the correct point.

If you have existing data on your master that you want to synchronize on your slaves before starting the replication process, then you must stop processing statements on the master, obtain the current position, and then dump the data, before allowing the master to continue executing statements. If you do not stop the execution of statements then the data dump, the master status information that you use will not match and you will end up with inconsistent or corrupted databases on the slaves.

To get the master status information, follow these steps:

1. Start the command line client and flush all tables and block write statements by executing the FLUSH TABLES WITH READ LOCK statement:

     mysql> FLUSH TABLES WITH READ LOCK;

2. Use the SHOW MASTER STATUS statement to determine the current binary log name and offset on the master:

      mysql > SHOW MASTER STATUS;
      +---------------+----------+--------------+------------------+
      | File          | Position | Binlog_Do_DB | Binlog_Ignore_DB |
      +---------------+----------+--------------+------------------+
      | mysql-bin.003 | 73       | test         | manual,mysql     |
      +---------------+----------+--------------+------------------+

The File column shows the name of the log and Position shows the offset within the file. In this example, the binary log file is mysql-bin.003 and the offset is 73. Record these values. You need them later when you are setting up the slave. They represent the replication coordinates at which the slave should begin processing new updates from the master.

If the master has been running previously without binary logging enabled, the log name and position values displayed by SHOW MASTER STATUS or mysqldump –master-data will be empty. In that case, the values that you need to use later when specifying the slave’s log file and position are the empty string () and 4.

You now have the information you need to enable the slave to start reading from the binary log in the correct place to start replication.

5. Creating a Data Snapshot Using Raw Data Files

If your database is particularly large then copying the raw data files may be more efficient than using mysqldump and importing the file on each slave.

To create a raw data snapshot of MyISAM tables you can use standard copy tools such as cp or copy, a remote copy tool such as scp or rsync an archiving tool such as zip or tar, or a file system snapshot tool such as dump, providing that your MySQL data files exist on a single filesystem. If you are only replicating certain databases then make su

re you only copy those files that related to those tables. (For InnoDB, all tables in all databases are stored in a single file unless you have the innodb_file_per_table option enabled.)

You may want to specifically exclude the following files from your archive:

  • Files relating to the mysql database.
  • The master.info file.
  • The master’s binary log files.
  • Any relay log files.

To get the most consistent results with a raw data snapshot you should shut down the server during the process, as below:

1. Acquire a read lock and get the master’s status. 2. In a separate session, shut down the MySQL server:

      shell> mysqladmin shutdown

3. Take a copy of the MySQL data files. Examples are shown below for common solutions – you need to choose only one of these solutions:

      shell> tar cf /tmp/db.tar ./data
      shell> zip -r /tmp/db.zip ./data
      shell> rsync --recursive ./data /tmp/dbdata

4. Start up the MySQL instance on the master.

If you are not using InnoDB tables, you can get a snapshot of the system from a master without shutting down the server as described in the following steps:

1. Acquire a read lock and get the master’s status. See Section 16.1.1.4, “Obtaining the Master Replication Information”. 2. Take a copy of the MySQL data files. Examples are shown below for common solutions – you need to choose only one of these solutions:

      shell> tar cf /tmp/db.tar ./data
      shell> zip -r /tmp/db.zip ./data
      shell> rsync --recursive ./data /tmp/dbdata

3. In the client where you acquired the read lock, free the lock:

      mysql> UNLOCK TABLES;

Once you have created the archive or copy of the database, you will need to copy the files to each slave before starting the slave replication process.

6. Setting the Master Configuration on the Slave

To set up the slave to communicate with the master for replication, you must tell the slave the necessary connection information. To do this, execute the following statement on the slave, replacing the option values with the actual values relevant to your system:

mysql> CHANGE MASTER TO
    ->     MASTER_HOST='master_host_name',
    ->     MASTER_USER='replication_user_name',
    ->     MASTER_PASSWORD='replication_password',
    ->     MASTER_LOG_FILE='recorded_log_file_name',
    ->     MASTER_LOG_POS=recorded_log_position;

7. Starting the slave threads

Start the slave using:

mysql> START SLAVE;

After you have performed this procedure, the slave should connect to the master and catch up on any updates that have occurred since the snapshot was taken. You also find error messages in the slave’s error log if it is not able to replicate for any other reason.

Once a slave is replicating, you can find in its data directory one file named master.info and another named relay-log.info. The slave uses these two files to keep track of how much of the master’s binary log it has processed. Do not remove or edit these files unless you know exactly what you are doing and fully understand the implications. Even in that case, it is preferred that you use the CHANGE MASTER TO statement to change replication parameters. The slave will use the values specified in the statement to update the status files automatically.