Archive for the ‘Uncategorized’ Category

How to create bonding with bridge network ( Linux Kvm)

Thursday, November 21st, 2013

Package needed :

rpm -qa | grep bridge-utils
bridge-utils-1.2-10.el6.x86_64

Create Bondig :

cat /etc/sysconfig/network-scripts/ifcfg-bond0
 
DEVICE=bond0
ONBOOT=yes
BONDING_OPTS='mode=1 miimon=100'
BRIDGE=br0

Create Bride network:

DEVICE=br0
TYPE=Bridge
IPADDR=192.168.0.50
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=static
NM_CONTROLLED=no
DELAY=0

configure eth0:

DEVICE=eth0
HWADDR=00:1D:09:66:8A:7A
TYPE=Ethernet
UUID=5e76d7f6-7526-4b6e-baf3-cde82362a914
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
USERCTL=no
SLAVE=yes
MASTER=bond0

Configure eth1:

DEVICE=eth1
HWADDR=00:1D:09:66:8A:7C
TYPE=Ethernet
UUID=ef4ef437-73c7-4c42-8552-6777a789c5a6
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=no
USERCTL=no
SLAVE=yes
MASTER=bond0

Note : Please make sure that both eth0 and eth1 has HWADDR defined in the respective file , its needed for Virtualization and bridging.

Further Reading :NetWork Bridge

Screen commands

Sunday, April 21st, 2013

1) setup tab in screen
Edit .screenrc and Edit bellow :

caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-= @%H - %LD %d %LM - %c"

Ticket listing

Sunday, November 21st, 2010

You can view the list tickets on this page.

The frontend ticket listing feature is only available in the premium release. Don't hesitate to order the premium release on http://www.ticket-system.net/order-now/

Ticket submission form

Sunday, November 21st, 2010

You can submit tickets on this page.

The frontend submission form feature is only available in the premium release. Don't hesitate to order the premium release on http://www.ticket-system.net/order-now/

1 Ticket Submission Form

Sunday, November 21st, 2010

You can submit ticket on this page

The frontend submission form feature is only available in the premium release. Don't hesitate to order the premium release on http://www.ticket-system.net/order-now/

How to install Subversion

Thursday, February 25th, 2010

Ref:http://svnbook.red-bean.com/en/1.5/index.html

(A) To install Subversion : yum install mod_dav_svn subversion
(B) How to create a Repo :

svnadmin create /svn

So it will create a svn directory under / directory

[root@mail /]# pwd
/
[root@mail /]# ls
aquota.group  boot      dev   lib    opt   sbin     svn  usr
aquota.user   conffile  etc   media  proc  selinux  sys  var
bin           data      home  mnt    root  srv      tmp
[root@mail /]#

(C) How to import Directory in svn repos ?

 svn import directory/ file:///svn/directory

output :

[root@mail /]# svn import /root/script/ file:///svn/script
Adding         /root/script/checkmory.sh
 
Committed revision 1.

Note After typing the svn import command it will open a Vim editor ,and will ask you to write some comments about this import
Example: I would of write: I am adding the /root/script directory into svn repository.
Pic:

Svn Asking to input comments before adding directory to repository

Svn Asking to input comments before adding directory to repository

Note : if you see bellow error :

svn: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options
svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found

which means: you need to add “vim ” program path into bash_profile files

How to add vim programm path in .bash_profile file :

vi /root/.bash_profile
add this line :
export SVN_EDITOR="/bin/vi"

Now save the file and logoff and log on agian

(d) How to check list of projects in svn repo

[root@mail /]# svn list file:///svn

Output :

script/

Which means script directory has been added into svn repository.
Now if you want to see what is inside script directory

[root@mail /]# svn list file:///svn/script
checkmemory.sh

How to install/configure bind in linux

Friday, December 18th, 2009

a)yum install bind bind-chroot bin-utils

b) go to /usr/share/doc/bind-9.3.6/sample [ here all the sample files should be installed]

c)cp -R var/* /var/named/chroot/

d)cp -R etc/* /var/named/chroot/

cp /usr/share/doc/bind-9.3.6/sample/etc/named.conf /var/named/chroot/etc/

[note : if named.conf is not that location then type : locate named.conf, it will show you where is the named.conf]

Disclaimer

Tuesday, December 15th, 2009

Disclaimer: The information and content provided on this website is for reference and informational purpose only. I cannot guarantee for accuracy and completeness for any information or content published on this site. Use of the information and content on this site is at your own risk. I accept no responsibility for any loss or damage arising from the use of this website either directly or indirectly.

Fosiul Alam

Apache performace tunning

Monday, November 16th, 2009

Ref: http://httpd.apache.org/docs/2.2/mod/prefork.html

Ref:http://www.devside.net/articles/apache-performance-tuning

Ref:http://en.wikipedia.org/wiki/Slowloris

Sample Configuration for prefork setting

<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>

StartServers :

The StartServers directive sets the number of child server processes created on startup. So after restart the apache if we take a snapshot of how many process is running

[root@mail extra]# ps aux | grep -v grep | grep httpd
daemon 5384 0.0 0.7 15788 7532 ? S 17:45 0:00 /usr/local/apache/bin/httpd -k start
daemon 5385 0.0 0.7 15788 7532 ? S 17:45 0:00 /usr/local/apache/bin/httpd -k start
daemon 5386 0.0 0.7 15788 7532 ? S 17:45 0:00 /usr/local/apache/bin/httpd -k start
daemon 5387 0.0 0.7 15788 7532 ? S 17:45 0:00 /usr/local/apache/bin/httpd -k start
daemon 5388 0.0 0.7 15788 7532 ? S 17:45 0:00 /usr/local/apache/bin/httpd -k start
root 13326 0.0 0.8 15788 8596 ? Ss Nov07 0:00 /usr/local/apache/bin/httpd -k start
[root@mail extra]# ps aux | grep -v grep | grep httpd | wc -l
6

so after restart the server, its start of with 5 child process

MinSpareServer:

The MinSpareServers directive sets the desired minimum number of idle child server processes. An idle process is one which is not handling a request.

MaxSpareServers:

The MaxSpareServers directive sets the desired maximum number of idle child server processes. An idle process is one which is not handling a request. If there are more than MaxSpareServers idle, then the parent process will kill off the excess processes.

Extra Note :

Here By setting MinSpareServer and MaxSpareServer, we are telling apache how many child process would be idle at a time. According to the above configuration there would be always minimum of 5 Child process would be ide .So , now if 5 child process is busy,t hen apache will create another 5 child process so it would be 5+5=10 child process, 5 is busy and 5 is idle. Now if all of them 10 child process is busy, apache will create another 5 child process,so total child process would be 5+5+5=15. apache will create child process till 150 , because Maximum client is set to 150

How to compile php for GD library

Friday, November 13th, 2009

Install necessary software by yum or from source

yum install gd gd-devel yum install zlib zlib-devel

then

a) Download the php source from here : http://www.php.net/downloads.php
b) Download the source file in to /tmp directory
c) Here I am gussing the php version is php-5.3.0.tar.gz
d) Tar –xvzf php-5.3.0.tar.gz
e) Cd php-5.3.0
f)

 ./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --enable-mbstring –-with-gd –-with-zlib –-with-jpeg-dir-with-png-dir

g) make
h) make install
i) setup your php.ini : cp php.ini-dist /usr/local/lib/php.ini
j) Stop apache /usr/local/apache/bin/apachectl1 stop
k) Restart apache /usr/local/apache/bin/apachectl1 start

How to check :

create a file phpinfo.php

<?php
phpinfo();
?>

Open the file in your browser , http://localhost/phpinfo.php

and Look for 2 section , GD and ZLIB. You should see something like bellow pictures

How to configure master and slave replication in mysql server

Thursday, October 8th, 2009

All the contents of this article has taken from ” High Performance Mysql Server” For the simplicity I just added some extra visualize picture from my running server . For this reason the values(i.e time, log position) between pics and the book does not match.

Primary Server : 192.168.1.2

Slave Server : 192.168.1.3

In picture I used, Primary server(NODE2) Slave (Beaver)

Step -1

Create replication account on each server,Example user repl:

mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.*
-> TO repl@’192.168.0.%’ IDENTIFIED BY ‘p4ssword’;

Configure Master Server:

Edit my.cnf (/etc/my.cnf- For default mysql server setup) and insert bellow lines:

log_bin = mysql-bin
server_id = 10

Now restart mysql server ( service mysqld restart)

Now if you go to /var/lib/mysql/

you should see some files like bellow picture:

Log files created(Red circle)

Log files created(Red circle)

To verify that the binary log file is created on the master, run
SHOW MASTER STATUS as shown in bellow picture

Verifying if binary log is created.

Verifying if binary log is created.

Configure Slave Server:

Edit my.cnf and add bellow lines

log_bin = mysql-bin
server_id = 2
relay_log = mysql-relay-bin
log_slave_updates = 1

Now Restart Mysql server.

Starting the Slave:

Log into mysql server and execute the bellow commands

mysql> CHANGE MASTER TO MASTER_HOST=’server1′,
-> MASTER_USER=’repl’,
-> MASTER_PASSWORD=’p4ssword’,
-> MASTER_LOG_FILE=’mysql-bin.000001′,
-> MASTER_LOG_POS=0;

The MASTER_LOG_POS parameter is set to 0 because this is the beginning of the log.
After you run this, you should be able to inspect the output of SHOW SLAVE STATUS and
see that the slave’s settings are correct:

mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: server1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 4
Relay_Log_File: mysql-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: No
Slave_SQL_Running: No
…omitted…
Seconds_Behind_Master: NULL

Salve Server output should be something like this

Salve Server output should be something like this

The Slave_IO_State, Slave_IO_Running, and Slave_SQL_Running columns show that
the slave processes are not running,also notice that the log position
is 4 instead of 0. That’s because 0 isn’t really a log position; it just means “at the
start of the log file.” MySQL knows that the first event is really at position 4.*

To start replication, run the following command:
mysql> START SLAVE;

This command should produce no errors or output. Now inspect SHOW SLAVE STATUS
again:
mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: server1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 164
Relay_Log_File: mysql-relay-bin.000001
Relay_Log_Pos: 164
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
…omitted…
Seconds_Behind_Master: 0

Slave is awitting for master

Slave is awiting for master

Notice that the slave I/O and SQL threads are both running, and Seconds_Behind_
Master is no longer NULL. The I/
O thread is waiting for an event from the master, which means it has fetched all of the
master’s binary logs. The log positions have incremented, which means some events
have been fetched and executed (your results will vary). If you make a change on the
master, you should see the various file and position settings .

You will also be able to see the replication threads in the process list on both the master
and the slave. On the master, you should see a connection created by the slave’s I/O
thread:
mysql> SHOW PROCESSLIST\G
*************************** 1. row ***************************
Id: 55
User: repl
Host: slave1.webcluster_1:54813
db: NULL
Command: Binlog Dump
Time: 610237
State: Has sent all binlog to slave; waiting for binlog to be updated
Info: NULL

On the Master:

Server has sent all bin logs to slave

Server has sent all bin logs to slave

On the Slave :

On the slave, you should see two threads. One is the I/O thread, and the other is the
SQL thread:
mysql> SHOW PROCESSLIST\G
*************************** 1. row ***************************
Id: 1
User: system user
Host:
db: NULL
Command: Connect
Time: 611116
State: Waiting for master to send event
Info: NULL
*************************** 2. row ***************************
Id: 2
User: system user
Host:
db: NULL
Command: Connect
Time: 33
State: Has read all relay log; waiting for the slave I/O thread to update it
Info: NULL

Figure:

Slave is Updating binlog

Slave is Updating binlog

The sample output we’ve shown comes from servers that have been running for a
long time, which is why the I/O thread’s Time column on the master and slave has a
large value. The SQL thread has been idle for 33 seconds on the slave, which means
no events have been replayed for 33 seconds.

Pictures in Big size:

Linux performance tuning tools (vmstat tool)

Wednesday, September 23rd, 2009

Ref: Performance Tuning for Linux® Servers

Ref: System Performance Tuning, Second Edition

Ref: Optimizing Linux® Performance: A Hands-On Guide to Linux® Performance Tools

Linux Performance Tools:

Processor time is organized into four timed modes: system time, user time, I/O wait time, and idle time. The idle time consists of what’s left over when all other portions have had their fill. A program’s normal operating state is user mode, but as it runs, it may generate requests for services that the kernel provides, such as I/O. These requests require the attention of the operating system, so the program switches into system mode, then returns to user mode when the request is complete. The time spent in these two modes is tabulated independently to give the user time and system time values, respectively. These two figures account for the majority of a process’s execution time.

Note that vmstat reports only the user time, system time, and idle time (wait time is summed in with idle time). In order to get separated values for wait time and idle time, use mpstat.

When a process waits for a block device data request to complete, it incurs I/O wait time. This brings up an important fact: when a process is blocked in this fashion, all idle time becomes wait time. If your idle time is zero, as reported by vmstat, the first thing you should check is if your system has I/O throughput problems.

vmstat (Virtual Memory Statistics):

  • How many processes are running
  • How the CPU is being used
  • How many interrupts the CPU receives
  • How many context switches the scheduler performs
vmstat [-n] [-s] [delay [count]]
vmstat 2 5
Column Explanation
r This is the number of currently runnable processes. These processes are not waiting on I/O and are ready to run. Ideally, the number of runnable processes would match the number of CPUs available.

Performance hits: If the run queue is consistently at or more than four times the number of configured processors in the system, you should probably consider increasing the available processors.

b This is the number of processes blocked and waiting for I/O to complete.
forks The is the number of times a new process has been created. Command : vmstat -f
in This is the number of interrupts occurring on the system.
cs This is the number of context switches happening on the system.
us The is the total CPU time as a percentage spent on user processes (including “nice” time).
sy The is the total CPU time as a percentage spent in system code. This includes time spent in the system, irq, and softirq state.
wa The is the total CPU time as a percentage spent waiting for I/O.
id The is the total CPU time as a percentage that the system is idle.

Sample output:

[ezolt@scrffy tmp]$ vmstat
procs -----------memory---------- ---swap-- -----io---- --system--
----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
1  0 181024  26284  35292 503048    0    0     3     2    6      1  5  1 94  0

What to look for:

One key to focus on is the (wa), as consistent high numbers here is definitely a problem waiting on I/O. Usually seeing consistent (wa) in 10+ will show degradation of the system. Once it reaches 35+ you will not need to look at the statistics as your users will be complaining.

Look for high numbers in either system or user space. If you see consistent high numbers for user space it could be an application that has a process that is consuming too much resources. In this case look at top to see if you can identify the problem process. If you see consistent high numbers for system then you also need to look into what programs are taking the CPU resources and evaluate their status

To be continue…

How to install apache2-php-mysql from source

Thursday, September 10th, 2009

Prerequisite : yum install gcc-c++ gcc make ncurses-devel openssl-devel glibc* libc-*

Packages required for php: yum install libjpeg-devel libpng-devel curl-devel libmcrypt-devel krb5-devel

Apache Server Installation from Source:
Apache installation directory is : /usr/local/apache
a) Download the apache source file from : http://httpd.apache.org/download.cgi
b) Download the source file in to /tmp directory.
c) I am guessing the source file is httpd-2.2.13.tar.gz
d) Cd /tmp
e) tar –xvzf httpd-2.2.13.tar.gz
f) cd httpd-2.2.13

g)

 
./configure  --prefix=/usr/local/apache --with-included-apr --with-php --with-mysql --with-susexec --disable-info --with-mpm=prefork --enable-so --enable-cgi --enable-rewrite --enable-ssl --enable-mime-magic --enable-unique-id --enable-mods-shared="proxy cache ssl all"

h) make
i) make install
j)To restart apache : /usr/local/apache/bin/apachectl start

MySql Server Install from source:

Ref:http://dev.mysql.com/doc/refman/5.1/en/quick-install.html

a)Download my.version.tar.gz from
http://dev.mysql.com/downloads/mysql/5.1.html#source

b)shell> groupadd mysql
c)shell> useradd -g mysql mysql
d)shell> gunzip < mysql-VERSION.tar.gz | tar -xvf – e)shell> cd mysql-VERSION
f)

   ./configure --prefix=/usr/local/mysql --with-ssl --with-plugins=innobase

note:: for mysql 5.1 : to add innodb support its ” –with-plugins=innobase” but for 5.0 its “./configure –with-innodb”
g)shell> make
h)shell> make install
i)shell> cp support-files/my-medium.cnf /etc/my.cnf
j)shell> cd /usr/local/mysql
k)shell> chown -R mysql .
l)shell> chgrp -R mysql .
m)shell> bin/mysql_install_db -–user=mysql
n)shell> chown -R root .
o)shell> chown -R mysql var
p)shell> bin/mysqld_safe -–user=mysql &

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'

Php installation from source with GD library Support

http://www.php.net/manual/en/install.unix.apache2.php

a) Download the php source from here : http://www.php.net/downloads.php
b) Download the source file in to /tmp directory
c) Here I am gussing the php version is php-5.3.0.tar.gz
d) Tar –xvzf php-5.3.0.tar.gz
e) Cd php-5.3.0
f)

./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --enable-mbstring --with-gd --with-zlib --with-jpeg-dir --with-png-dir --with-openssl --with-curl --with-mcrypt --with-imap --with-imap-ssl --with-kerberos --with-mysqli=/usr/local/mysql/bin/mysql_config

g) make
h) make install
i) setup your php.ini : cp php.ini-dist /usr/local/lib/php.ini

j) In httpd.conf file.. check for bellow lines

LoadModule php5_module modules/libphp5.so

j) Add the bellow lines in httpd.conf file to allow .php extension.
add bellow lines under directive

Add php extension

 
<FilesMatch "\.phps$">
          SetHandler application/x-httpd-php-source
      </FilesMatch>
 
 <FilesMatch "\.ph(p[2-6]?|tml)$">
          SetHandler application/x-httpd-php
      </FilesMatch>

j) Stop apache /usr/local/apache/bin/apachectl1 stop
k) Restart apache /usr/local/apache/bin/apachectl1 start

Note :

(a) configure: error: xml2-config not found. Please check your libxml2 installation. : yum install libxml2-devel

(b) configure: error: libpng.(a|so) not found.
configure: error: libjpeg.(a|so) not found.
(c) Error : configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing
yum install libc-client-devel*
So it will try to find accurate rpm for your kernel(32/64)

(d) If you have older httpd daemon running , please stop that daemon,Other wise when you will start apache daemon, it will through an error .You can check by bellow command to make sure you don’t have any other httpd is running in background.

ps aux | grep -v grep | grep httpd

If this returns value that means another httpd daemon is running and you can stop it by executing

service httpd stop

Last Update : 14-09-2010

Hello world!

Tuesday, August 11th, 2009

Welcome to fosiul.co.uk.

This is my own knowledge base web site. This site is updated daily on computer related articles, new problem solving technique,”How to documents”.