|
Many times haproxy and apache does not reliable to serve the connections without tune or we say we need to set system as well some kernel parameters to work it better.
Here haproxy gives an errors to connect to apache, at that time it logs the errors into ‘dmesg | tail’ or in ‘/var/log/messages’ “kernel: ip_conntrack: table full, dropping packet” that is related to ip_conntrack kernel module.
Conntrack table is hash table (hash map) of fixed size (8192 entries by default), which is used for primary lookup. When the slot in the table is found it points to list of conntrack structures, so secondary lookup is done using list traversal. 65536/8192 gives 8 – the average list length. You may want to experiment with this value on heavily loaded systems.
If this error founds into /var/log/messages or dmesg you have to apply following steps to resolve.
Here I have done this to changes and added few settings in kernel also we will do it to set apache MPM and Haproxy tunning with sysctl.conf
Note: I have tried all this workaround and apply on CentOS-5.2, but don’t worry ip_conntrack module is default in kernel 2.6 +
1) To check ip_contrack is compiled with your kernel
[root@ravi.com ~]# modinfo ip_conntrack
filename: /lib/modules/2.6.18-128.el5/kernel/net/ipv4/netfilter/ip_conntrack.ko
license: GPL
srcversion: F1390E605BBFB05078B78E8
depends: nfnetlink
vermagic: 2.6.18-128.el5 SMP mod_unload gcc-4.1
module_sig: 883f350497747c575ed35fe9471dce112565509f4b58f4f3e440c6bcc05c2fba9bbdd224bdeb8209e293da385133a876e44a7b449ba59a882a8282b
2) Probe ip_conntrack kernel module or add it in /etc/modprobe.conf
[root@ravi.com ~]# modprobe ip_conntrack hashsize=131072
or
open /etc/modprobe.conf and add below lines at the end of file
options ip_conntrack hashsize=131072
3) before go to apply the 4th step, just check the ip_conntrack setting is into /etc/sysctl.conf
grep “ip_conntrack” /etc/sysctl.conf
if its found then apply 4th step or edit the /etc/sysctl.conf and add the given two lines at the end of file and save it then go for 4th step
(the value is compare to your RAM and set it to below)
net.ipv4.ip_conntrack_max = 16777216
net.ipv4.netfilter.ip_conntrack_max = 16777216
4) To apply the sysctl parameters run ’sysctl -p’
[root@ravi.com ~]# sysctl -p
5) Now check the ip_conntrack is logging the connections and check not dropping any more
[root@ravi.com ~]# cat /proc/slabinfo | grep conn
ip_conntrack_expect 0 0 136 28 1 : tunables 120 60 8 : slabdata 0 0 0
ip_conntrack 216053 231335 304 13 1 : tunables 54 27 8 : slabdata 17795 17795 216
6) Also you can check how much memory utilized by ip_conntrack module per connection.
[root@ravi.com ~]# grep ip_conntrack /var/log/messages
/var/log/messages.2:Jan 14 21:46:04 ravi kernel: ip_conntrack version 2.4 (8192 buckets, 65536 max) – 304 bytes per conntrack
1M connections would require 304MB of kernel memory.
Thanks
Ravi
Here I have used php version 5.2.11 and to jdk-6u18-linux-x64.bin
( from given JAVA download link)
[root@ravi.com ~]# yum -y install httpd php php-devel php-gd php-cli php-xml php-ldap php-common php-pear php-pdo
Install java jdk and set env in ~/.bashrc also run this on CLI to verify before next step.
export JAVA_HOME=//usr/java/jdk1.6.0_18
export PATH=/usr/java/jdk1.6.0_18/bin:$PATH
[root@ravi.com ~]# echo $JAVA_HOME
Now set the dynamic linker library path into /etc/ld.so.conf
/usr/java/jdk1.6.0_18/jre/lib/amd64
/usr/java/jdk1.6.0_18/jre/lib/amd64/server
[root@ravi.com ~]# ldconfig
Now download php-java-bridge source rpm
[root@ravi.com ~]# wget ftp://195.220.108.108/linux/sourceforge/p/project/ph/php-java-bridge/OldFiles/php-java-bridge-4.1.8-1.src.rpm
unpack the php-java-bridge rpm
[root@ravi.com ~]# rpm2cpio php-java-bridge-4.1.8-1.src.rpm | cpio -ivd
php-java-bridge.spec
php-java-bridge_4.1.8.tar.gz
16155 blocks
untar the php-java-bridge and configure the module
[root@ravi.com ~]# tar xzf php-java-bridge_4.1.8.tar.gz && cd php-java-bridge-4.1.8
[root@ravi.com ~]# phpize
[root@ravi.com ~]# ./configure –with-java=$JAVA_HOME && make && make install
[root@ravi.com ~]# echo “extension=java.so” > /etc/php.d/java.ini
open the php.ini and edit the at the end of file
[java]
java.class.path=/usr/lib64/php/modules/
java.library=/usr/java/jdk1.6.0_18/jre/lib/amd64/server/libjvm.so
Now restart apache
[root@ravi.com ~]# /etc/init.d/httpd restart
[root@ravi.com ~]# php -i | grep java
/etc/php.d/java.ini,
java
java support => Enabled
java bridge => 4.1.8
java.java_home =>
java.java => java
java.log_file => <stderr>
java.log_level => no value (use back-end’s default level)
java.security_policy => Off
java command => LD_LIBRARY_PATH=/usr/lib64/php/modules:/usr/lib/10.2.0.3/client64/lib java -Djava.library.path=/usr/lib64/php/modules -Djava.class.path=/usr/lib64/php/modules/JavaBridge.jar -Djava.awt.headless=true -Dphp.java.bridge.base=/usr/lib64/php/modules php.java.bridge.Standalone LOCAL:9267 1
java status => running
java server => 9267
PATH => /usr/java/jdk1.6.0_18/bin:/usr/java/jdk1.6.0_18/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
JAVA_HOME => /usr/java/jdk1.6.0_18
_SERVER["PATH"] => /usr/java/jdk1.6.0_18/bin:/usr/java/jdk1.6.0_18/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
_SERVER["JAVA_HOME"] => /usr/java/jdk1.6.0_18
_ENV["PATH"] => /usr/java/jdk1.6.0_18/bin:/usr/java/jdk1.6.0_18/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
_ENV["JAVA_HOME"] => /usr/java/jdk1.6.0_18
Test your code in test.php and run to check
<?php
// get instance of Java class java.lang.System in PHP
$system = new Java(‘java.lang.System’); // demonstrate property access
print ‘Java version=’.$system->getProperty(‘java.version’).’ ‘;
print ‘Java vendor=’ .$system->getProperty(‘java.vendor’).’ ‘;
print ‘OS=’.$system->getProperty(‘os.name’).’ ‘.
$system->getProperty(‘os.version’).’ on ‘.
$system->getProperty(‘os.arch’).’ ‘; // java.util.Date example
$formatter = new Java(‘java.text.SimpleDateFormat’,
“EEEE, MMMM dd, yyyy ‘at’ h:mm:ss a zzzz”); print $formatter->format(new Java(‘java.util.Date’));
?>
[root@ravi.com ~]# php test.php
Java version=1.6.0_18 Java vendor=Sun Microsystems Inc. OS=Linux 2.6.18-53.el5xen on amd64 Friday, January 22, 2010 at 4:44:48 AM Pacific Standard Time
Thanks
Ravi
To enable pdo_oci module you may need to install oracle client and oci8 module is require. I have installed oracle 10g client here.
[root@ravi.com ~]# export ORACLE_HOME=/usr/lib/oracle/10.2.0.3/client64/ ; export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.3/client64/
[root@ravi.com ~]# cd /tmp
[root@ravi.com tmp]# pecl download pdo_oci
[root@ravi.com tmp]# tar xvzf PDO_OCI-1.0.tar.gz
[root@ravi.com tmp]# cd PDO_OCI-1.0 && phpize
[root@ravi.com tmp]# ./configure
[root@ravi.com PDO_OCI-1.0]# make
/bin/sh /tmp/PDO_OCI-1.0/libtool –mode=compile gcc -I/usr/include/php/ext -I. -I/tmp/PDO_OCI-1.0 -DPHP_ATOM_INC -I/tmp/PDO_OCI-1.0/include -I/tmp/PDO_OCI-1.0/main -I/tmp/PDO_OCI-1.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /tmp/PDO_OCI-1.0/pdo_oci.c -o pdo_oci.lo
mkdir .libs
gcc -I/usr/include/php/ext -I. -I/tmp/PDO_OCI-1.0 -DPHP_ATOM_INC -I/tmp/PDO_OCI-1.0/include -I/tmp/PDO_OCI-1.0/main -I/tmp/PDO_OCI-1.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -DHAVE_CONFIG_H -g -O2 -c /tmp/PDO_OCI-1.0/pdo_oci.c -fPIC -DPIC -o .libs/pdo_oci.o
In file included from /tmp/PDO_OCI-1.0/pdo_oci.c:31:
/tmp/PDO_OCI-1.0/php_pdo_oci_int.h:21:17: error: oci.h: No such file or directory
In file included from /tmp/PDO_OCI-1.0/pdo_oci.c:31:
/tmp/PDO_OCI-1.0/php_pdo_oci_int.h:26: error: expected specifier-qualifier-list before ’sb4′
/tmp/PDO_OCI-1.0/php_pdo_oci_int.h:32: error: expected specifier-qualifier-list before ‘OCIServer’
/tmp/PDO_OCI-1.0/php_pdo_oci_int.h:48: error: expected specifier-qualifier-list before ‘OCIDefine’
/tmp/PDO_OCI-1.0/php_pdo_oci_int.h:62: error: expected specifier-qualifier-list before ‘OCIStmt’
/tmp/PDO_OCI-1.0/php_pdo_oci_int.h:73: error: expected specifier-qualifier-list before ‘OCIBind’
/tmp/PDO_OCI-1.0/php_pdo_oci_int.h:85: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PDO_OCI_INIT_MODE’
/tmp/PDO_OCI-1.0/php_pdo_oci_int.h:87: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/tmp/PDO_OCI-1.0/php_pdo_oci_int.h:89: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_oci_error’
/tmp/PDO_OCI-1.0/pdo_oci.c:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PDO_OCI_INIT_MODE’
/tmp/PDO_OCI-1.0/pdo_oci.c:87: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/tmp/PDO_OCI-1.0/pdo_oci.c: In function ‘zm_startup_pdo_oci’:
/tmp/PDO_OCI-1.0/pdo_oci.c:96: error: ‘pdo_oci_Env’ undeclared (first use in this function)
/tmp/PDO_OCI-1.0/pdo_oci.c:96: error: (Each undeclared identifier is reported only once
/tmp/PDO_OCI-1.0/pdo_oci.c:96: error: for each function it appears in.)
/tmp/PDO_OCI-1.0/pdo_oci.c:96: error: ‘PDO_OCI_INIT_MODE’ undeclared (first use in this function)
/tmp/PDO_OCI-1.0/pdo_oci.c: In function ‘zm_shutdown_pdo_oci’:
/tmp/PDO_OCI-1.0/pdo_oci.c:111: error: ‘dvoid’ undeclared (first use in this function)
/tmp/PDO_OCI-1.0/pdo_oci.c:111: error: expected expression before ‘)’ token
make: *** [pdo_oci.lo] Error 1
Is this the error that pdo does not connect to oci library and its find these into include subfolder, so you may need to copy all the files into include folder.
[root@ravi.com PDO_OCI-1.0]# cp -f /usr/include/oracle/10.2.0.3/client64/* /tmp/PDO_OCI-1.0/include/
Now run make & make install to compile and install the module.
[root@ravi.com PDO_OCI-1.0]# make && make install
enable the pdo_oci extension with php.
[root@ravi.com PDO_OCI-1.0]# echo “extension=pdo_oci.so” > /etc/php.d/pdo_oci.ini
[root@ravi.com PDO_OCI-1.0]# php -m | grep pdo_oci
To work pdo_oci properly you have to restart apache.
Thanks
Ravi
How to install VNCSERVER on CentOS
yum groupinstall “GNOME Desktop Environment”
yum install xterm vnc-server vnc
remove the existing file & edit with ‘/etc/sysconfig/vncservers‘ and put the following lines in it
VNCSERVERS=”2:root”
VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -nohttpd -localhost”
set the vnc password to open the vnc for user root (you have to login as a root)
vncpasswd
set the vnc password to open the vnc for user (you have to login as a normal user that way it will create the file xstartup in $home/.vnc)
vncpasswd
Now start the vncserver as root user
/etc/init.d/vncserver start
Now kill the vncserver proocesses using ‘ps aux | grep vnc | xargs kill -9′
and start vnc server by following command
vncserver
check the given path to open the vnc display as given in example
New ‘appserver.ravi.com:3 (root)’ desktop is appserver.ravi.com:3
before open the vncviewer remove the file ‘/tmp/.X1-lock’
Now open the vnc display you will get the default ‘xterm’ open on it.
How to install GeoIP and mod_geoip2 on centos for apache
1) yum install GeoIP GeoIP-devel GeoIP-data zlib-devel
2) mkdir /usr/local/share/GeoIP
3) Download the latest Country and City database files from maxmind
cd /usr/local/share/GeoIP
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoIP.dat.gz
gunzip GeoLiteCity.dat.gz
4) yum install httpd-devel apr-devel
5) wget http://geolite.maxmind.com/download/geoip/api/mod_geoip2/
6) tar xvzf mod_geoip2_1.2.5.tar.gz && cd mod_geoip2_1.2.5
7) apxs -i -a -L/usr/lib64 -I/usr/include -lGeoIP -c mod_geoip.c
Enabling mod-geoip
Nothing’s going to work unless mod-geoip is enabled in your apache configuration. You’ll need the following lines in your httpd.conf file (located on CentOS systems at /etc/httpd/conf/httpd.conf)
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat Standard
GeoIPDBFile /usr/local/share/GeoIP/GeoLiteCity.dat Standard
</IfModule>
9) Restart Apache so your changes will take effect by entering the following command.
#/etc/init.d/httpd restart
10) /usr/local/bin/geoipupdate
Introduction ~
—————————————–
Program (1) ~ array.sh
—————————————–
#!/bin/bash
echo “==============”
declare -a myarr[0]=”Arun”
declare -a myarr1
myarr1=(arun bagul bangalore mumbai raju santhosh)
myarr[1]=”Bagul”
echo “my name is ${myarr[0]} ${myarr[1]}”
echo “————————–”
echo “${myarr1[*]}”
echo ${myarr1[2]}
echo ${myarr1[@]}
echo “————————–”
echo “Total no of elements in array – ${#myarr1[*]}”
echo “Total no of elements in array – ${#myarr1[@]}”
echo “Size of word ‘${myarr1[2]}’ is – ${#myarr1[2]}”
echo ${#myarr1[1]}
echo ${#myarr1[0]}
echo “————————–”
#how to delete element in array
unset myarr[1]
echo “myarr is – ${myarr[*]}”
#how to assign element in array
myarr[1]=”- System Engineer!”
echo “myarr is – ${myarr[*]}”
echo ${myarr}
————————————————————————
Program (2) ~ command_line_arguments.sh
————————————————————————
#!/bin/bash
echo “Script/command name => $0″
echo “arg1 => $1″
echo “arg2 => $2″
echo “arg3 => $3″
echo “Total No of argument = $#”
echo “Script PID is => $$”
echo “Status of previous command – $?”
name=$myname
echo “Name – $name”
read n
————————————————-
Program (3) ~ default_value.sh
————————————————-
#!/bin/bash
#start=’123′
#start=${1:-$start}
start=${1:-’123′}
echo “Value of ’start’ variable is ==> $start”
—————————————————
Program (4) ~ echo_example.sh
—————————————————
#!/bin/bash
name=”Arun”
echo -e “My Name is $name_arun and \n”
echo -e “My Name is ${name}_arun and \n”
echo -e ‘My Name is $name and \n’
—————————————–
Program (5) ~ elif.sh
—————————————–
#! /bin/bash
if [ $1 -eq $2 ];then
echo “good”
elif [ $2 -eq $3 ];then
echo “Fine”
elif [ $1 -eq $3 ];then
echo “OK”
else
echo “NO”
fi
————————————————————
Program (6) ~ for_loop_example-1.sh
————————————————————
#!/bin/bash
i=1
while [ $i -le 512 ]
do
temp=$i
echo “What is => $i | $temp”
i=$(expr $i + 32)
for (( j=$temp; $j<=$i; j++ ))
do
echo -n ” $j”
done
done
———————————————————–
Program (7) ~ for_loop_example-2.sh
———————————————————–
#!/bin/bash
#for val in $(ls -1 /tmp)
sum=0
#for val in {1..5}
#for val in {$1..$2}
for((val=$1;$val<=$2;val++))
do
#echo “$val”
sum=$(expr $sum + $val )
#sum=`expr $sum + $val`
done
echo “$0 # Sum of $1 to $2 => $sum”
————————————————————
Program (8) ~ for_loop_example-3.sh
————————————————————
#!/bin/bash
for i in {1..9}
do
echo $i
done
—————————————–
Program (9) ~ function.sh
—————————————–
#!/bin/bash
function my_function()
{
name=”Arun Bagul”
echo “‘my_function’ body ~ $name”
return 1;
}
##########
myfunc()
{
echo “Another way of defining the function”
}
##########################
echo “Starting function program”
echo “——————————”
#calling function here
my_function
##
myfunc
echo -e “\n end of program”
—————————————————————————————
Program (10) ~ how_to_pass_argument_to_function.sh
—————————————————————————————
#!/bin/bash
function my_function()
{
echo “Total number of argument ~ $#”
echo “Arg1 => $1″
echo “Arg2 => $2″
echo “Arg3 => $3″
return 0;
}
##########
echo “Starting function program”
echo “——————————”
#calling function here
my_function arun bagul 1234
————————————————————————-
Program (11) ~ how_to_take_hidden_input.sh
————————————————————————-
#!/bin/bash
echo -n “Enter User Name :”
read username
echo -n “Enter Password :”
read -s mypwd
echo -e “\nI am $username and my password is – $mypwd”
——————————————————————————
Program (12) ~ how_to_take_input_from_user.sh
—————————————————————————–
#!/bin/bash
echo -ne “Enter the Name:- ”
read name
echo -n -e “Enter the Number:- ”
read num
echo “——————————”
add=$(expr $num + 10)
echo “Name is ~ $name”
echo “Number is ~ $add”
—————————————–
Program (13) ~ ifthen.sh
—————————————–
#!/bin/bash
if [ "arun" == "arun" ];then
echo “true!”
else
echo “false”
fi
echo “———————————-”
if [ 2 == 2 ];then
echo “true!”
else
echo “false”
fi
echo “———————————-”
if [ "arun" = "arun" ];then
echo “true!”
else
echo “false”
fi
echo “———————————-”
if [ 2 -eq 2 ];then
echo “true!”
else
echo “false”
fi
——————————————————
Program (14) ~ non-interactive.sh
——————————————————
#!/usr/bin/expect -f
spawn ssh arun@192.168.0.1
expect “password:”
sleep 1
send “pwd\r”
interact
—————————————————————-
Program (15) ~ read_file_line_by_line.sh
—————————————————————-
#!/bin/bash
file_name=”/etc/hosts”
while read myvar
do
echo “Line => $myvar”
done < $file_name
echo “#################################################”
for myvar1 in $(cat $file_name)
do
echo “Line => $myvar1″
done
——————————————————
Program (16) ~ reverse-number.sh
——————————————————
#!/bin/bash
declare -a date_array
num=$1
i=$(expr $(echo $num | wc -c) – 1 )
while [ $num -gt 10 ]
do
temp=$( expr $num % 10 )
num=$( expr $num / 10);
echo “Digit($i) => $temp”
date_array[$i]=”${temp}”
i=$(expr $i – 1)
done
echo “Digit($i) => $num”
date_array[$i]=”${num}”
echo ${date_array[*]}
——————————————————–
Program (17) ~ string-operation.sh
——————————————————–
#! /bin/bash
echo “Arun Bagul:-”
string=”/root/arun/bagul/image.gif”
echo “string=> $string”
echo “String=> ${string##/*/}”
echo “String=> ${string#/*/}”
echo “String=> ${string%.*}”
echo “String=> ${string%%.*}”
#str=”/home/y/conf/arunbagul/daily_market_0.conf”
str=”${str##/*conf/}”
echo “String=> ${str%/*}”
#done
mystr=”keyword_summary_exact_arunsb”
echo $mystr
echo ${mystr%_*}
echo “$*”
—————————————–
Program (18) ~ switch.sh
—————————————–
#!/bin/bash
echo ” Switch program | arg1 => $1″
echo ” ——————————-”
case $1 in
123)
echo “Case is 123″
;;
arun)
echo “Case is ‘arun’”
;;
pri*)
echo “Case is ‘pri*’”
;;
*)
echo ” * Usage: $0 ”
echo ” Default case (nothing is matched)”
exit 0;
;;
esac
—————————————————————–
Program (19) ~ while_loop_example-1.sh
——————————————————————
#!/bin/bash
mywait=wait
while [ "${mywait}" = "wait" ]
do
echo “arun”
done
——————————————————————-
Program (20) ~ while_loop_example-2.sh
——————————————————————–
#! /bin/bash
## on command line -> i=0 && while [ $i -le 10 ] ; do echo $i; i=$(expr $i + 1); done
i=0
while [ $i -le 10 ]
do
echo $i
i=$(expr $i + 1)
done
——————————————————————–
* Please download PDF file http://www.slideshare.net/arunbagul/bash-learning-by-examples/
Regards,
Arun
Introduction ~
I was planning to write article on Multi Master MySQL replication since long time; Finally started now!. Please refer the the article on “How to configure MySQL replication with one Master” URL ~ http://www.indiangnu.org/2007/mysql-replication-one-master-multiple-slave/
* Let me inform you all that Multi Master replication in MySQL is purely based on following two variables. It has nothing to do with replication technology used in MySQL replication….

mysql> show variables like ‘%increment_%’;
+—————————————+——-+
| Variable_name | Value |
+—————————————+——-+
| auto_increment_increment | 1 |
| auto_increment_offset | 1 |
+—————————————+—–+
2 rows in set (0.00 sec)
mysql>
** Requirements ~
a) Master Hosts (2 master in my case) ~
master-1 => 10.66.66.194
master-2 => 10.66.90.135
b) Replication Slave (1 slave) ~
slave => 10.66.75.137
c) MySQL server (with replication support)
** Let us understand how it works ?
* Master-1 Server =>
Set following variables…
mysql> set auto_increment_increment=5;
mysql> set auto_increment_offset=1;
mysql> show variables like ‘%increment_%’;
+————————–+——-+
| Variable_name | Value |
+————————–+——-+
| auto_increment_increment | 2 |
| auto_increment_offset | 1 |
+————————–+——-+
2 rows in set (0.00 sec)
mysql>
** Create Table ~
mysql> create table class ( rollno INT(5) NOT NULL PRIMARY KEY AUTO_INCREMENT , name VARCHAR(30) );
** Add Record now ~
mysql> INSERT INTO class VALUES (”,’Arun Bagul’);
mysql> INSERT INTO class VALUES (”,’Ravi Bhure’);
mysql> INSERT INTO class VALUES (”,’Karthik Appigita’);
mysql> INSERT INTO class VALUES (”,’Ameya Pandit’);
mysql> SELECT * FROM class;
+——–+——————+
| rollno | name |
+——–+——————+
| 1 | Arun Bagul |
| 3 | Ravi Bhure |
| 5 | Karthik Appigita |
| 7 | Ameya Pandit |
+——–+——————+
4 rows in set (0.00 sec)
mysql>
* Master-2 Server =>
Set following variables…
mysql> set auto_increment_increment=2;
mysql> set auto_increment_offset=2;
mysql> show variables like ‘%increment_%’;
+————————–+——-+
| Variable_name | Value |
+————————–+——-+
| auto_increment_increment | 2 |
| auto_increment_offset | 2 |
+————————–+——-+
2 rows in set (0.00 sec)
mysql>
** Create Table ~
mysql> create table class ( rollno INT(5) NOT NULL PRIMARY KEY AUTO_INCREMENT , name VARCHAR(30) );
** Add Record now ~
mysql> INSERT INTO class VALUES (”,’Nilkanth Parab’);
mysql> INSERT INTO class VALUES (”,’Nishit Shah’);
mysql> INSERT INTO class VALUES (”,’Ram Krishna’);
mysql> INSERT INTO class VALUES (”,’Suhail Thakur’);
mysql> SELECT * FROM class;
+——–+——————+
| rollno | name |
+——–+——————+
| 2 | Nilkanth Parab |
| 4 | Nishit Shah |
| 6 | Ram Krishna |
| 8 | Suhail Thakur |
+——–+——————+
4 rows in set (0.00 sec)
mysql>
** What is the importance of “auto_increment_increment” and “auto_increment_offset” ~
mysql> desc class;
+——–+————-+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+——–+————-+——+—–+———+—————-+
| rollno | int(5) | NO | PRI | NULL | auto_increment |
| name | varchar(30) | YES | | NULL | |
+——–+————-+——+—–+———+—————-+
auto_increment_offset => This is BASE value for column with “auto_increment” attribute (please refer the above example)
auto_increment_increment => This is the increment value for column with “auto_increment” attribute
** If you combine the both tables (master-1 and master-2) the final table will look like this ~
mysql> SELECT * FROM class;
+——–+——————+
| rollno | name |
+——–+——————+
| 1 | Arun Bagul |
| 2 | Nilkanth Parab |
| 3 | Ravi Bhure |
| 4 | Nishit Shah |
| 5 | Karthik Appigita |
| 6 | Ram Krishna |
| 7 | Ameya Pandit |
| 8 | Suhail Thakur |
+——–+——————+
8 rows in set (0.00 sec)
mysql>
** This is how Multi master replication works….
auto_increment_offset=Nth master server
auto_increment_increment=M
Where -
N => nth number of master server (on master-1 keep it 1 and on master-2 keep it 2 and so on..)
M => Total number of Master Server (2 in our case but better to keep this value high so that we can add new master server easily)
log-slave-updates => Slave server does not log to its own binary log any updates that are received from a Master server. This option tells the slave to log the updates performed by its SQL thread to its own binary log.
** Make sure that MySQL is running and up on all master servers and slave server-
How to setup Multi Master MySQL replication ? –
Step 1] Create Database/Tables on Master & Slave Servers –
You can create DB on all master & slave server or create on one server and export that DB on rest of all servers…
Master-1 => Create DB and Table
mysql> create database student;
mysql> use student;
mysql> create table class ( rollno INT(5) NOT NULL PRIMARY KEY AUTO_INCREMENT , name VARCHAR(30) );
mysql> show tables;
+——————-+
| Tables_in_student |
+——————-+
| class |
+——————-+
1 row in set (0.00 sec)
mysql> desc class;
+——–+————-+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+——–+————-+——+—–+———+—————-+
| rollno | int(5) | NO | PRI | NULL | auto_increment |
| name | varchar(30) | YES | | NULL | |
+——–+————-+——+—–+———+—————-+
2 rows in set (0.00 sec)
mysql> SELECT * FROM class;
Empty set (0.00 sec)
mysql>
* Now take dump of “student” DB and export it on all master and Slave server…
[root@master-1~]# mysqldump -u root -p -d student > /home/arunsb/student.sql
* SCP the dump file on master-2 and slave server ~
[root@master-1~]# scp /home/arunsb/student.sql arunsb@10.66.90.135:/tmp/student.sql
[root@master-1~]# scp /home/arunsb/student.sql arunsb@10.66.75.137:/tmp/student.sql
Login on master-2 and slave ~
mysql> create database student;
[root@master-2~]# mysql -u root -p student < /tmp/student.sql
Enter password:
[root@master-2~]#
[root@master-2~]# mysql -u root -p
Enter password:
mysql> use student
mysql> SELECT * FROM class;
Empty set (0.00 sec)
mysql>
** Please repeat the same steps on Slave server as well…
Step 2] Update “my.cnf” config file on master-1,master-2 and slave server –
[root@master-1~]# cat /etc/my.cnf
###########################
##MySQL replication setting
#Master setting(1)
server-id = 1
log-bin = /var/log/mysql/binary/mysql-bin.log
binlog-do-db = student
binlog-ignore-db = mysql
log = /var/log/mysql/mysql.log
auto_increment_offset=1
auto_increment_increment=5
log-slave-updates
##slave setting
master-port=3306
master-host=10.66.90.135
master-user=replication
master-password=mypwd
master-connect-retry=60
replicate-do-db=student
###########################
[root@master-1~]#
[root@master-2~]# cat /etc/mysql/my.cnf
###########################
##MySQL replication setting
#Master setting(2)
server-id = 2
log-bin = /var/log/mysql/binary/mysql-bin.log
binlog-do-db=student
binlog-ignore-db = mysql
log = /var/log/mysql/mysql.log
auto_increment_offset=2
auto_increment_increment=5
log-slave-updates
##slave setting
master-port=3306
master-host=10.66.66.194
master-user=replication
master-password=mypwd
master-connect-retry=60
replicate-do-db=student
###########################
[root@master-2~]#
* please create directory for binary log and set permission…
[root@master-1~]# mkdir -p /var/log/mysql/binary/
[root@master-1~]# chown mysql:adm /var/log/mysql/ /var/log/mysql/binary/
[root@master-2~]# mkdir -p /var/log/mysql/binary/
[root@master-2~]# chown mysql:adm /var/log/mysql/ /var/log/mysql/binary/
** MySQL Replication Slave ~
[root@slave~]# cat /etc/my.cnf
[mysqld]
########################################
##slave setting
server-id=4
master-port=3306
master-host=10.66.90.135
master-user=replication
master-password=mypwd
master-connect-retry=60
replicate-do-db=student
########################################
[root@slave~]#
Step 3] Give Replication permission on both masters ~
** Master (1 & 2) ~
mysql> GRANT REPLICATION SLAVE ON *.* TO ‘replication’@'10.66.%.%’ IDENTIFIED BY ‘mypwd’;
Query OK, 0 rows affected (0.00 sec)
mysql>
Step 4] Restart MySQL on both master as well as replication slave server ~
** Please verify setting on master-1 and master-2 server…
* Master-1
mysql> show variables like ‘%increment_%’;
+————————–+——-+
| Variable_name | Value |
+————————–+——-+
| auto_increment_increment | 5 |
| auto_increment_offset | 1 |
+————————–+——-+
2 rows in set (0.00 sec)
* Master-2
mysql> show variables like ‘%increment_%’;
+————————–+——-+
| Variable_name | Value |
+————————–+——-+
| auto_increment_increment | 5 |
| auto_increment_offset | 2 |
+————————–+——-+
2 rows in set (0.00 sec)
** Please verify ‘master’ & ’slave’ status on both masters(1 & 2) and slave -
mysql> show master status;
mysql> show slave status;
** Multi Master replication is started…
Step 5] Add few records on Master-1 & Master-2 server at same time ~
Add records on both master server at same time and check master and replication slave status as shown above….
** Add following on master-1
mysql> INSERT INTO class VALUES (”,’Arun Bagul’);
mysql> INSERT INTO class VALUES (”,’Ravi Bhure’);
mysql> INSERT INTO class VALUES (”,’Karthik Appigita’);
mysql> INSERT INTO class VALUES (”,’Ameya Pandit’);
** Add following on master-2
mysql> INSERT INTO class VALUES (”,’Nilkanth Parab’);
mysql> INSERT INTO class VALUES (”,’Nishit Shah’);
mysql> INSERT INTO class VALUES (”,’Ram Krishna’);
mysql> INSERT INTO class VALUES (”,’Suhail Thakur’);
** Please verify the numbers of records on both masters and slave….
mysql> SELECT * FROM class;
+——–+——————+
| rollno | name |
+——–+——————+
| 1 | Arun Bagul |
| 2 | Nilkanth Parab |
| 6 | Ravi Bhure |
| 11 | Karthik Appigita |
| 16 | Ameya Pandit |
| 17 | Nishit Shah |
| 22 | Ram Krishna |
| 27 | Suhail Thakur |
+——–+——————+
8 rows in set (0.00 sec)
mysql>
* So we all learned to configure multi-master MySQL replication. Enjoy!!
Regards,
Arun Bagul
Introduction -
* “rpmbuild” tool is used to build both…
1) Binary Package ~ used to install the software and supporting scripts. It contains the files that comprise the application, along with any additional information needed to install and erase it.
2) Source Package ~ contains the original compressed tar file of source code, patches and Specification File.
* What is RPM & RPM package Manager?
The RPM Package Manager (RPM) is a powerful command line package management system capable of installing, uninstalling, verifying, querying, and updating software packages.
RPM package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package.
* To build RPM package you need to specify three things ~
1) Source of application - In any case, you should not modify the sources used in the package building process.
2) Patches - RPM gives you the ability to automatically apply patches to them. The patch addresses an issue specific to the target system. This could include changing makefiles to install the application into the appropriate directories, or resolving cross-platform conflicts. Patches create the environment required for proper compilation.
3) Specification File - The specification file is at the heart of RPM package building process. It contains information required by RPM to build the package, as well as instructions telling RPM how to build it. The specification file also dictates exactly what files are a part of the package, and where they should be installed.
** Specification File ~ is divided in to 8 sections as shown below
a) Preamble ~ contains information that will be displayed when users request information about the package. This would include a description of the package’s function, the version number of the software etc.
b) Preparation ~ where the actual work of building a package starts. As the name implies, this section is where the necessary preparations are made prior to the actual building of the software. In general, if anything needs to be done to the sources prior to building the software, it needs to happen in the preparation section. The contents of this section are an ordinary shell script. However, RPM does provide two macros to make life easier. One macro can unpack a compressed tar file and cd into the source directory. The other macro easily applies patches to the unpacked sources.
c) Build ~ This section consists of a shell script. It is used to perform whatever commands are required to actually compile the sources like single make command, or be more complex if the build process requires it. There are no macros available in this section.
d) Install ~ This section also containing a shell script, the install section is used to perform the commands required to actually install the software.
e) Install and Uninstall Scripts ~ It consists of scripts that will be run, on the user’s system, when the package is actually installed or removed. RPM can execute a script pre/post installation/removal of package.
f) Verify Script ~ script that is executed on the user’s system. It is executed when RPM verifies the package’s proper installation.
g) Clean Section ~ script that can clean things up after the build. This script is rarely used, since RPM normally does a good job of clean-up in most build environments.
h) File List ~ consists of a list of files that will comprise the package. Additionally, a number of macros can be used to control file attributes when installed, as well as to denote which files are documentation, and which contain configuration information. The file list is very important.
*** RPM’s requirement for build environment ~
A] RPM requires a set of directories to perform the build. While the directories’ locations and names can be changed. Default layout is shown below -
root@arunsb:~# ls -l /usr/src/redhat/
drwxr-xr-x 2 root root 4096 Aug 25 2007 SOURCES => Contains the original sources, patches, and icon files
drwxr-xr-x 2 root root 4096 Aug 25 2007 SPECS => Contains the specification files
drwxr-xr-x 2 root root 4096 Aug 25 2007 BUILD => Directory in which the sources are unpacked, & software is built
drwxr-xr-x 8 root root 4096 May 28 2008 RPMS => Contains the binary package files created by the build process
drwxr-xr-x 2 root root 4096 Aug 25 2007 SRPMS => Contains the source package files created by the build process
root@arunsb:~#
B] Need to export few global variables used by RPM -
root@arunsb:~# export RPM_BUILD_DIR=/usr/src/redhat/BUILD/
root@arunsb:~# export RPM_SOURCE_DIR=/usr/src/redhat/SOURCES/
Step 1] Create Specification (spec) File ~
root@arunsb:~# head -n 50 /usr/src/redhat/SPECS/openlsm.spec
# Authority: Arun Bagul
#RPM_BUILD_DIR /usr/src/redhat/BUILD/
#RPM_SOURCE_DIR /usr/src/redhat/SOURCES/
%define MY_PREFIX /usr/local/openlsm/
## Preamble Section-
Name: openlsm
Version: 0.99
Vendor: IndianGNU.org & openlsm
Release: r45
Group: System Environment/Daemons
Packager: IndianGNU.org (http://www.indiangnu.org)
URL: http://openlsm.sourceforge.net/
Summary: openlsm Admin Server
License: GPL
%description
openlsm Admin Server is free & open source web based control panel for Linux,Unix systems.
## Preparation Section-
%prep
rm -rf ${RPM_BUILD_DIR}/openlsm-0.99-r45/
tar xvfz ${RPM_SOURCE_DIR}/openlsm-0.99-r45.tar.gz -C ${RPM_BUILD_DIR}
## Build Section-
%build
cd ./openlsm-0.99-r45/
./configure –prefix=/usr/local/openlsm –with-mysql=/usr/bin/mysql_config –enable-internal-pcre –with-geoip=/usr –with-ldap=/usr –enable-trace
make
## Install Section-
%install
cd ./openlsm-0.99-r45/
make install
## Files Section-
%files
/usr/local/openlsm
/usr/local/openlsm/etc/openlsm/openlsm.conf
/usr/local/openlsm/etc/openlsm/openlsm.conf.perf_sample
/usr/local/openlsm/etc/openlsm/ssl/
/usr/local/openlsm/bin/openlsm-config
….
…..
….. list of files installed by pkg
root@arunsb:~#
* How do you create the File List?
Creating the file list is manual process. What I did is I took the file list from my manual installed prefix directory with find command as shown below…
root@arunsb:~# find /usr/local/openlsm/ -type f -or -type d
Step 2] Starting the Build ~
root@arunsb:~# cd /usr/src/redhat/SPECS
root@arunsb:/usr/src/redhat/SPECS# ls -l openlsm.spec
-rw-r–r– 1 root root 12938 Dec 2 17:21 openlsm.spec
root@arunsb:/usr/src/redhat/SPECS#
root@arunsb:/usr/src/redhat/SPECS# rpmbuild -ba openlsm.spec
…
….
…..
Checking for unpackaged file(s): /usr/lib/rpm/check-files %{buildroot}
Wrote: /usr/src/redhat/SRPMS/openlsm-0.99-r45.src.rpm
Wrote: /usr/src/redhat/RPMS/i386/openlsm-0.99-r45.i386.rpm
root@arunsb:/usr/src/redhat/SPECS# echo $?
0
root@arunsb:/usr/src/redhat/SPECS# ls -l /usr/src/redhat/SRPMS/openlsm-0.99-r45.src.rpm
-rw-r–r– 1 root root 3206 Dec 2 17:50 /usr/src/redhat/SRPMS/openlsm-0.99-r45.src.rpm
root@arunsb:/usr/src/redhat/SPECS# ls -l /usr/src/redhat/RPMS/i386/openlsm-0.99-r45.i386.rpm
-rw-r–r– 1 root root 3052868 Dec 2 17:50 /usr/src/redhat/RPMS/i386/openlsm-0.99-r45.i386.rpm
root@arunsb:/usr/src/redhat/SPECS#
* Source and Binary package created !!
** Let’s see what happened in “/usr/src/redhat/” directory
root@arunsb:/usr/src/redhat# pwd
/usr/src/redhat
root@arunsb:/usr/src/redhat# ls
BUILD RPMS SOURCES SPECS SRPMS
root@arunsb:/usr/src/redhat# ls BUILD/
openlsm-0.99-r45 <== Source extracted here as part of build instructions from specification file ie “openlsm.spec”
root@arunsb:/usr/src/redhat# ls SOURCES/
openlsm-0.99-r45.tar.gz <== original ‘openlsm-0.99-r45.tar.gz’ source file copied by me
root@arunsb:/usr/src/redhat# ls RPMS/
athlon i386 i486 i586 i686 noarch
root@arunsb:/usr/src/redhat# ls RPMS/i386/
openlsm-0.99-r45.i386.rpm <== Binary rpm package created!
root@arunsb:/usr/src/redhat# ls SRPMS/
openlsm-0.99-r45.src.rpm <== Source rpm package created!
root@arunsb:/usr/src/redhat#
Step 3] Now install the package and test it ~
root@arunsb:/usr/src/redhat# cp RPMS/i386/openlsm-0.99-r45.i386.rpm /home/arunsb/
root@arunsb:/usr/src/redhat# cd /home/arunsb/
root@arunsb:~# ls
openlsm-0.99-r45.i386.rpm
root@arunsb:~# rpm -ivh openlsm-0.99-r45.i386.rpm
Preparing… ########################################### [100%]
1:openlsm ########################################### [100%]
root@arunsb:~# ls /usr/local/openlsm/
bin contrib etc include lib sbin scripts share var
root@arunsb:~#
** Starting the openlsm server ~
root@arunsb:~# /usr/local/openlsm/contrib/openlsm-redhat start
* Starting openlsm admin server: openlsm
. [ OK ]
root@arunsb:~#
root@arunsb:~# /usr/local/openlsm/contrib/openlsm-redhat status
openlsm (pid 21607) is running…
root@arunsb:~#
root@arunsb:~# rpm -q openlsm-0.99-r45
openlsm-0.99-r45
root@arunsb:~#
root@arunsb:~# rpm -ql openlsm-0.99-r45
..
…
root@arunsb:~# rpm -qiv openlsm-0.99-r45
Name : openlsm Relocations: (not relocatable)
Version : 0.99 Vendor: IndianGNU.org & openlsm
Release : r45 Build Date: Wed 02 Dec 2009 05:50:54 PM IST
Install Date: Wed 02 Dec 2009 06:06:23 PM IST Build Host: alongseveral-dr.eglbp.corp.yahoo.com
Group : System Environment/Daemons Source RPM: openlsm-0.99-r45.src.rpm
Size : 14877918 License: GPL
Signature : (none)
Packager : IndianGNU.org (http://www.indiangnu.org)
URL : http://openlsm.sourceforge.net/
Summary : openlsm Admin Server
Description :
openlsm Admin Server is free & open source web based control panel for Linux,Unix systems.
root@arunsb:~#
** NOTE ~ This article does not contain information on how to define micros,how to copy docs,man pages to default location, how to set permision and ownership etc. I will cover this topics in next article on RPM.
Regards,
Arun Bagul
|| How to create or build RPM Package ||
Introduction -
* “rpmbuild” tool is used to build both…
1) Binary Package ~ used to install the software and supporting scripts. It contains the files that comprise the application, along with any additional information needed to install and erase it.
2) Source Package ~ contains the original compressed tar file of source code, patches and Specification File.
* What is RPM & RPM package Manager?
The RPM Package Manager (RPM) is a powerful command line package management system capable of installing, uninstalling, verifying, querying, and updating software packages.
RPM package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file
attributes, and descriptive information about the package.
* To build RPM package you need to specify three things ~
1) Source of application – In any case, you should not modify the sources used in the package building process.
2) Patches – RPM gives you the ability to automatically apply patches to them. The patch addresses an issue specific to the target system. This could include changing makefiles to install the application into the appropriate directories, or resolving cross-platform conflicts. Patches create the environment required for proper compilation.
3) Specification File – The specification file is at the heart of RPM package building process. It contains information required by RPM to build the package, as well as instructions telling RPM how to build it. The specification file also dictates exactly what files are a part of the package, and where they should be installed.
** Specification File ~ is divided in to 8 sections as shown below
a) Preamble ~ contains information that will be displayed when users request information about the package. This would include a description of the package’s function, the version number of the software etc.
b) Preparation ~ where the actual work of building a package starts. As the name implies, this section is where the necessary preparations are made prior to the actual building of the software. In general, if anything needs to be done to the sources prior to building the software, it needs to happen in the preparation section. The contents of this section are an ordinary shell script. However, RPM does provide two macros to make life easier. One macro can unpack a compressed tar file and cd into the source directory. The other macro easily applies patches to the unpacked sources.
c) Build ~ This section consists of a shell script. It is used to perform whatever commands are required to actually compile the sources like single make command, or be more complex if the build process requires it. There are no macros available in this section.
d) Install ~ This section also containing a shell script, the install section is used to perform the commands required to actually install the software.
e) Install and Uninstall Scripts ~ It consists of scripts that will be run, on the user’s system, when the package is actually installed or removed. RPM can execute a script pre/post installation/removal of package.
f) Verify Script ~ script that is executed on the user’s system. It is executed when RPM verifies the package’s proper installation.
g) Clean Section ~ script that can clean things up after the build. This script is rarely used, since RPM normally does a good job of clean-up in most build environments.
h) File List ~ consists of a list of files that will comprise the package. Additionally, a number of macros can be used to control file attributes when installed, as well as to denote which files are documentation, and which contain configuration information. The file list is very important.
*** RPM’s requirement for build environment ~
A] RPM requires a set of directories to perform the build. While the directories’ locations and names can be changed. Default layout is shown below -
root@arunsb:~# ls -l /usr/src/redhat/
drwxr-xr-x 2 root root 4096 Aug 25 2007 SOURCES => Contains the original sources, patches, and icon files
drwxr-xr-x 2 root root 4096 Aug 25 2007 SPECS => Contains the specification files
drwxr-xr-x 2 root root 4096 Aug 25 2007 BUILD => Directory in which the sources are unpacked, and the software is built
drwxr-xr-x 8 root root 4096 May 28 2008 RPMS => Contains the binary package files created by the build process
drwxr-xr-x 2 root root 4096 Aug 25 2007 SRPMS => Contains the source package files created by the build process
root@arunsb:~#
B] Need to export few global variables used by RPM -
root@arunsb:~# export RPM_BUILD_DIR=/usr/src/redhat/BUILD/
root@arunsb:~# export RPM_SOURCE_DIR=/usr/src/redhat/SOURCES/
Step 1] Create Specification (spec) File ~
root@arunsb:~# head -n 50 /usr/src/redhat/SPECS/openlsm.spec
# Authority: Arun Bagul
#RPM_BUILD_DIR /usr/src/redhat/BUILD/
#RPM_SOURCE_DIR /usr/src/redhat/SOURCES/
%define MY_PREFIX /usr/local/openlsm/
## Preamble Section-
Name: openlsm
Version: 0.99
Vendor: IndianGNU.org & openlsm
Release: r45
Group: System Environment/Daemons
Packager: IndianGNU.org (http://www.indiangnu.org)
URL: http://openlsm.sourceforge.net/
Summary: openlsm Admin Server
License: GPL
%description
openlsm Admin Server is free & open source web based control panel for Linux,Unix systems.
## Preparation Section-
%prep
rm -rf ${RPM_BUILD_DIR}/openlsm-0.99-r45/
tar xvfz ${RPM_SOURCE_DIR}/openlsm-0.99-r45.tar.gz -C ${RPM_BUILD_DIR}
## Build Section-
%build
cd ./openlsm-0.99-r45/
./configure –prefix=/usr/local/openlsm –with-mysql=/usr/bin/mysql_config –enable-internal-pcre –with-geoip=/usr –with-ldap=/usr –enable-trace
make
## Install Section-
%install
cd ./openlsm-0.99-r45/
make install
## Files Section-
%files
/usr/local/openlsm
/usr/local/openlsm/etc/openlsm/openlsm.conf
/usr/local/openlsm/etc/openlsm/openlsm.conf.perf_sample
/usr/local/openlsm/etc/openlsm/ssl/
/usr/local/openlsm/bin/openlsm-config
….
…..
….. list of files installed by pkg
root@arunsb:~#
* How do you create the File List?
Creating the file list is manual process. What I did is I took the file list from my manual installed prefix directory with find command as shown below…
root@arunsb:~# find /usr/local/openlsm/ -type f -or -type d
Step 2] Starting the Build ~
root@arunsb:~# cd /usr/src/redhat/SPECS
root@arunsb:/usr/src/redhat/SPECS# ls -l openlsm.spec
-rw-r–r– 1 root root 12938 Dec 2 17:21 openlsm.spec
root@arunsb:/usr/src/redhat/SPECS#
root@arunsb:/usr/src/redhat/SPECS# rpmbuild -ba openlsm.spec
…
….
…..
Checking for unpackaged file(s): /usr/lib/rpm/check-files %{buildroot}
Wrote: /usr/src/redhat/SRPMS/openlsm-0.99-r45.src.rpm
Wrote: /usr/src/redhat/RPMS/i386/openlsm-0.99-r45.i386.rpm
root@arunsb:/usr/src/redhat/SPECS# echo $?
0
root@arunsb:/usr/src/redhat/SPECS# ls -l /usr/src/redhat/SRPMS/openlsm-0.99-r45.src.rpm
-rw-r–r– 1 root root 3206 Dec 2 17:50 /usr/src/redhat/SRPMS/openlsm-0.99-r45.src.rpm
root@arunsb:/usr/src/redhat/SPECS# ls -l /usr/src/redhat/RPMS/i386/openlsm-0.99-r45.i386.rpm
-rw-r–r– 1 root root 3052868 Dec 2 17:50 /usr/src/redhat/RPMS/i386/openlsm-0.99-r45.i386.rpm
root@arunsb:/usr/src/redhat/SPECS#
* Source and Binary package created !!
** Let’s see what happened in “/usr/src/redhat/” directory
root@arunsb:/usr/src/redhat# pwd
/usr/src/redhat
root@arunsb:/usr/src/redhat# ls
BUILD RPMS SOURCES SPECS SRPMS
root@arunsb:/usr/src/redhat# ls BUILD/
openlsm-0.99-r45 <== Source extracted here as part of build instructions from specification file ie “openlsm.spec”
root@arunsb:/usr/src/redhat# ls SOURCES/
openlsm-0.99-r45.tar.gz <== original ‘openlsm-0.99-r45.tar.gz’ source file copied by me
root@arunsb:/usr/src/redhat# ls RPMS/
athlon i386 i486 i586 i686 noarch
root@arunsb:/usr/src/redhat# ls RPMS/i386/
openlsm-0.99-r45.i386.rpm <== Binary rpm package created!
root@arunsb:/usr/src/redhat# ls SRPMS/
openlsm-0.99-r45.src.rpm <== Source rpm package created!
root@arunsb:/usr/src/redhat#
Step 3] Now install the package and test it ~
root@arunsb:/usr/src/redhat# cp RPMS/i386/openlsm-0.99-r45.i386.rpm /home/arunsb/
root@arunsb:/usr/src/redhat# cd /home/arunsb/
root@arunsb:~# ls
openlsm-0.99-r45 openlsm-0.99-r45.i386.rpm openlsm-0.99-r45.tar.gz thttpd-2.25b-3.dag.src.rpm thttpd-2.25b-dag.spec
root@arunsb:~# rpm -ivh openlsm-0.99-r45.i386.rpm
Preparing… ########################################### [100%]
1:openlsm ########################################### [100%]
root@arunsb:~# ls /usr/local/openlsm/
bin contrib etc include lib sbin scripts share var
root@arunsb:~#
** Starting the openlsm server ~
root@arunsb:~# /usr/local/openlsm/contrib/openlsm-redhat start
* Starting openlsm admin server: openlsm
. [ OK ]
root@arunsb:~#
root@arunsb:~# /usr/local/openlsm/contrib/openlsm-redhat status
openlsm (pid 21607) is running…
root@arunsb:~#
root@arunsb:~# rpm -q openlsm-0.99-r45
openlsm-0.99-r45
root@arunsb:~#
root@arunsb:~# rpm -lq openlsm-0.99-r45
..
…
root@arunsb:~# rpm -qiv openlsm-0.99-r45
Name : openlsm Relocations: (not relocatable)
Version : 0.99 Vendor: IndianGNU.org & openlsm
Release : r45 Build Date: Wed 02 Dec 2009 05:50:54 PM IST
Install Date: Wed 02 Dec 2009 06:06:23 PM IST Build Host: alongseveral-dr.eglbp.corp.yahoo.com
Group : System Environment/Daemons Source RPM: openlsm-0.99-r45.src.rpm
Size : 14877918 License: GPL
Signature : (none)
Packager : IndianGNU.org (http://www.indiangnu.org)
URL : http://openlsm.sourceforge.net/
Summary : openlsm Admin Server
Description :
openlsm Admin Server is free & open source web based control panel for Linux,Unix systems.
root@arunsb:~#
** NOTE ~ This article does not contain information on how to define micros,how to copy docs,man pages to default location, how to set permision and ownership etc. I will cover this topics in next article on RPM.
Regards,
Arun Bagul
Introduction ~
GNU Privacy Guard (GnuPG or GPG) is open source/free software encryption and signing tool, alternative to the Pretty Good Privacy (PGP) suite of cryptographic software. Enigmail is an extension for Mozilla Thunderbird and other Mozilla applications. It provides public key e-mail encryption. Actual cryptographic functionality is handled by GNU Privacy Guard (GnuPG,GPG).
Step 1] Install Gnupg or GPG –
* Ubuntu/Debian ~
root@arun:~# apt-get install gnupg gnupg2
* Redhat/Fedora ~
root@arun:~# yum install gnupg gnupg2
Step 2] How to Install Enigmail ?
I assume that Mozilla Thunderbird is already installed on your system. To install “Enigmail” follow following steps
a) Download “Enigmail” from url “http://enigmail.mozdev.org/download/”
Note ~ select OS and Thunderbird version properly.
b) In menu bar of the main Thunderbird window you will see “Tools”. Select this, and then “Add-ons” option. This will bring up a new window listing all of your Thunderbird plug-ins. In the lower left-hand corner of this new window you’ll see a button marked “Install”. Click this button. Tell Thunderbird where you saved the Enigmail .XPI file. and just say “Install” that’s it!!

* Once ‘Enigmail’ is installed restart the Thunderbird. Then you will see “OpenPGP” tab in main menu of Thunderbird.
Step 3] Setup private/public key ~
Enigmail uses public key cryptography to ensure privacy between you and your correspondents. To generate the public/private keys, there is two methods either generate them with the help of “gpg” command line tool or use “enigmail”….
* We will generate private/public cryptographic keys with the help of “enigmail” as shown below….
a) Click on “OpenPGP” in the menu bar of the Thunderbird main window. Select “Key Management”.
b) In Enigmail Key Manager ~ click on “Generate” tab in the menu bar and select “New key pair”.
c) At the very top of the window you will see a combo box showing all of your email addresses. GnuPG will associate your new key with an email address.
Enigmail is just asking you which address you want to use for this key. Select whichever account will be receiving encrypted mail.
NOTE ~ We can use same keys for multiple accounts.
d) You can use passphrase or just check “No passphrase” checkbox to generate keys without passphrase.
e) Create directory to save “Revocation Certificates”…
arunsb@arun:~$ mkdir /home/arunsb/.gpg_key/
f) Click on “Generate key” button to generate keys. done..
To share keys easily you can publish your keys with keyserver.
a) In “Key Management” window select your keys and then click on ‘Keyserver’ tab in main menu and then click on “Upload Public Keys”
Note ~ make sure to check “Display All Keys by Default” checkbox (to list all keys)
Step 4] Compose the mail and sign it ~
Compose the mail and tell Enigmail to sign it. At the top of your Compose window you will see a button reading “OpenPGP”. Click on this. Make sure that the “Sign” option, and only that, is checked. Finally “Send” the mail! (You will be asked for your passphrase. Once you enter it, Enigmail will sign your email and send it if you have generate keys with passphrase else it will not ask)
Enjoy!!
Regards,
Arun Bagul