Saturday, October 22, 2011

Linux JDK Installation

Installation:
Once the file is copied on the Linux server (example: /usr/java).
JDK Installation Steps on Linux Operating System:
1. Change the file permission as follows.
chmod a+x jdk-xx-xxx.bin
                        
2. Run the bin file to start the installation.
./jdk-xx-xxx.bin
Unpacking...
Checksumming...
Extracting...
...
...

                        
A directory will be created under "/usr/java" with the JDK version name, which will consists of all the jdk files.
3. You can export the Java home to create it as an environment variable.
export JAVA_HOME=/usr/java/jdk1.6.x_xx
export PATH=$JAVA_HOME/bin:$PATH
                        
4. you can verify the JDK version installed on your system by issuing the following command.
which java
                        
Output:
/usr/java/jdk1.6.x_xx/bin/java
                        
java -version
                        
Output:
java version "1.6.x_xx"
Java(TM) SE Runtime Environment (build 1.6.x_xx-bxx)
Java HotSpot(TM) 32-Bit Server VM (build 11.0-bxx, mixed mode)
                        
5. Installation Completed

How to install java jdk

Installation Setup

1 ) Please visit sun java website to download any java jdk version you like.
http://java.sun.com/javase/downloads/index.jsp

2 ) Click download, select Linux platform, language and accept license and continue.

3 ) Select “Linux RPM in self-extracting file” and download jdk_filename-rpm.bin file (jdk-6u6-linux-i586-rpm.bin).

4 ) After downloaded, changed to the directory where you saved the file.

5 ) login to root user or su to root or sudo, and issue ‘chmod +x jdk_filename.-rpm.bin’ to make it executable.
chmod +x jdk_filename.bin
 
6 ) Execute it
./jdk_filename-rpm.bin
 
7 ) Press space bar , repeat until system prompt to enter yes or no, type y and enter to continue.

8 ) This will output a .rpm file in same directory

9 ) Issue ‘rpm -i jdk_filename.rpm’, this will install all jdk files on linux system /usr/java/jdk-version/
rpm -i jdk_filename.rpm
 
10 ) Create symbol links to make it execute anywhere
ln -s /usr/java/jdk1.6.0/bin/java /usr/bin/java
 ln -s /usr/java/jdk1.6.0/bin/javac /usr/bin/javac
 
11 ) type java -version, DONE !!

Post-Installation Setup

Set JAVA_HOME into environment variable

Copy following statement and append to /etc/profile or .bashrc file, make system set JAVA_HOME into system environment variable.
export JAVA_HOME="/usr/java/jdk1.6.0;"

Thursday, October 6, 2011

HeartBeat and build HA (High Availability) cluster environment

This example sets 2 systems as cluster servers. The environment of 2 systems are like below.
They have 2 NICs.
(1) www1.server-linux.info[eth0:192.168.0.21] [eth1:10.0.0.21]
(2) www2.server-linux.info[eth0:192.168.0.22] [eth1:10.0.0.22]

The package Heartbeat:-List of RPM files to download . e.g
1) heartbeat-2.1.3-3.el5.centos.i386.rpm
2) heartbeat-pils-2.1.3-3.el5.centos.i386.rpm
3) heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm


[1]Install HeartBeat first. It's necessary to do this on both systems.

[root@www1 ~]# yum -y install heartbeat

[root@www1 ~]# yum -y install heartbeat
 
# run again becaus of errors

[root@www1 ~]# vi /etc/ha.d/authkey

# create certificates
auth 1
1 crc

[root@www1 ~]# chmod 600 /etc/ha.d/authkeys
 
[2]Config for a server of (1)
 
[root@www1 ~]# vi /etc/ha.d/ha.cf

crm on
# debug log
debugfile /var/log/ha-debug
# log file
logfile /var/log/ha-log
# the way of output to syslog
logfacility local0
# keepalive
keepalive 2
# deadtime
deadtime 30
# deadping
deadping 40
# warntime
warntime 10
# initdead
initdead 60
# port
udpport 694
# interface and IP address of another Host
ucast eth1 10.0.0.22
# auto failback
auto_failback on|off
# node name (the name of "uname -n")
node www1.server-linux.info
node www2.server-linux.info
respawn root /usr/lib/heartbeat/pingd -m 100 -d 5s -a default_ping_set
 
[3]Config for a server of (2). The different point is only the section of ucast.
 
[root@www1 ~]# vi /etc/ha.d/ha.cf

crm on
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
deadping 40
warntime 10
initdead 60
udpport 694
# interface and IP address of another Hostucast eth1 10.0.0.21
auto_failback on
node www1.server-linux.info
node www2.server-linux.info
respawn root /usr/lib/heartbeat/pingd -m 100 -d 5s -a default_ping_set
[4]Start HeartBeat on both server
 
[root@www1 ~]# /etc/rc.d/init.d/heartbeat start
Starting High-Availability services:
[  OK  ]

[root@www1 ~]# chkconfig heartbeat on
[5] Run crm_mon on both server, then if following result is shown, it's OK, heartbeat running normally. These are Basical configuration of HeartBeat.

[root@www1 ~]# crm_mon -i 3

Defaulting to one-shot mode
You need to have curses available at compile time to enable console mode

============
Last updated: Sun Jun 15 05:04:34 2008
Current DC: www2.server-linux.info (f8719a77-70b4-4e5f-851b-dafa7d65d3a2)
2 Nodes configured.
0 Resources configured.
============

Node: www2.server-linux.info (f8719a77-70b4-4e5f-851b-dafa7d65d3a2): online
Node: www1.server-linux.info (2bbd6408-ec01-4b8c-bb8e-207237af3a99): online

Install DRBD(Distributed Replicated Block Device) and set Disk mirroring

This example based on my environment below. I used hda6 that is empty partition for this config.
(1) www.server-linux.info[192.168.0.18]
(2) www2.server-linux.info[192.168.0.21]

Install and configure DRBD on both Host. Configure the same settings on them. For installing, Specify "kmod-drbd", the DRBD is also installed.The package that you need is e.g :-

1) drbd82-8.2.6-1.el5.centos.i386.rpm
2) kmod-drbd82-8.2.6-2.i686.rpm

[root@www ~]# yum -y install kmod-drbd-xen
[root@www ~]# vi /etc/drbd.conf
resource r0 {
# Specify A or B or C
protocol C;

syncer {
# band width
rate 300M;
}

disk {
on-io-error detach;
}

on www.server-linux.info {
# DRBD device
device /dev/drbd0;
# phisical device

disk /dev/hda6;

# IP address:port

address 192.168.0.18:7788;

meta-disk internal;

}

on www2.server-linux.info {

device /dev/drbd0;

disk /dev/hda6;

address 192.168.0.21:7788;

meta-disk internal;

}

}

[root@www ~]# modprobe drbd
# load module
[root@www ~]# lsmod | grep drbd
drbd      185096   0
# just loaded
[root@www ~]# dd if=/dev/zero of=/dev/hda6 bs=1M count=128
128+0 records in
128+0 records out
134217728 bytes (134 MB) copied, 2.39478 seconds, 56.0 MB/s
[root@www ~]#
drbdadm create-md r0
 
# create meta-data

v08 Magic number not found
v07 Magic number not found
v07 Magic number not found
v08 Magic number not found
Writing meta data...
initialising activity log
NOT initialized bitmap
New drbd meta data block sucessfully created.
--== Creating metadata ==--

As with nodes we count the total number of devices mirrored by DRBD at
at http://usage.drbd.org.

The counter works completely anonymous. A random number gets created for
this device, and that randomer number and the devices size will be sent.

http://usage.drbd.org/cgi-bin/insert_usage.pl?nu=5112098206248082396&ru=12990301505065341479&rs=1073741824
Enter 'no' to opt out, or just press [return] to continue:
success
[root@www ~]# /etc/rc.d/init.d/drbd start
[root@www ~]# cat /proc/drbd
# show status

version: 8.0.11 (api:86/proto:86)
GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b build by buildsvn@c5-i386-build, 2008-03-09 10:26:43
  0: cs:Connected st:Secondary/Secondary ds:Inconsistent/Inconsistent C r---
 
ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 
resync: used:0/31 hits:0 misses:0 starving:0 dirty:0 changed:0 
act_log: used:0/127 hits:0 misses:0 starving:0 dirty:0 changed:0
[2]Make a Host you set primary first. Then mirroring is started
[root@www ~]# drbdsetup /dev/drbd0 primary -o #make it primary
drbd0: Forced to consider local data as UpToDate!
[root@www ~]# cat  /proc/drbd

version: 8.0.11 (api:86/proto:86)
GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b build by buildsvn@c5-i386-build, 2008-03-09 10:26:43
0: cs:SyncSource st:Primary/Secondary ds:UpToDate/Inconsistent C r---  # changed
      ns:77968 nr:0 dw:0 dr:85524 al:0 bm:4 lo:111 pe:259 ua:1999 ap:0 
      [>...................] sync'ed: 7.5% (971572/1048508)K
      finish: 0:00:37 speed: 25,644 (25,644) K/sec
      resync: used:2/31 hits:40719 misses:6 starving:0 dirty:0 changed:6
      act_log: used:0/127 hits:0 misses:0 starving:0 dirty:0 changed:0

[root@www ~]# mkfs -t ext3 /dev/drbd0

[root@www ~]# mkdir /mnt/drbd

[root@www ~]# mount /dev/drbd0 /mnt/drbd

[root@www ~]# touch /mnt/drbd/test.txt # make test file

[root@www ~]# ll /mnt/drbd

total 16
drwx------ 2 root root 16384 May 11 02:18 lost+found
-rw-r--r-- 1 root root 0 May 11 02:22 test.txt
[3] If you'd like to mount DRBD device on secondary Host, unmount DRBD device on primary Host first and make primary Host secondary first. Next make secondary Host primary and mount DRBD devicet
########### on primary host ###########

[root@www ~]# umount  /mnt/drbd
[root@www ~]# drbdadm secondary r0 # make it secondary

########### on secondary host ###########

[root@www2 ~]# drbdadm primary r0 # make it primary
[root@www2 ~]# mkdir /mnt/drbd
[root@www2 ~]# mount /dev/drbd0 /mnt/drbd
[root@www2 ~]# ll /mnt/drbd
total 16
drwx------ 2 root root 16384 May 11 02:18 lost+found
-rw-r--r-- 1 root root 0 May 11 02:22 test.txt  


[4] Resolve the issue (split brain) been happen in  currently whereby drbd response status showing unknown status. to recover a split brain status in drbd here is the following steps need to be taken:-


under Slave drbd run the following command :-
#drbdadm disconnect all
# drbdadm -- --discard-my-data connect all

Primary drbd
# drbd connect all
# service drbd start