Tuesday, November 6, 2012

Improve system performance

Improve system performance
 
Tip: Find Linux major and minor page faults to improve system performance. Once the number of page faults gone down the performance of the daemons and entire Linux os will go up.

ps -o min_flt,maj_flt PID
ps -o min_flt,maj_flt,cmd,args,uid,gid PID-HERE
sar -B 1 10

Tuesday, October 30, 2012


INSTALL MYSQL-WORKBENCH ON UBUNTU


Steps are simple:

 
1wget ftp://ftp.gwdg.de/pub/misc/mysql/Downloads/MySQLGUITools/mysql-workbench-oss-5.2.11.tar.gz
2 tar -xzf mysql-workbench-oss-5.2.11.tar.gz
3 cd mysql-workbench-oss-5.2.11
4 apt-get install libzip-dev libzip1 libxml2-dev libsigc++-2.0-dev libcairomm-1.0-dev libglibmm-2.4-dev libpangomm-1.4-dev libglade2-dev libaudiofile-dev libavahi-client-dev libavahi-common-dev libavahi-glib-dev libbonobo2-dev libdbus-1-dev libesd0-dev libgconf2-dev libgcrypt11-dev libgnomevfs2-dev libgnutls-dev libgpg-error-dev libpopt-dev libselinux1-dev libsepol1-dev libtasn1-3-dev libsqlite3-dev libboost1.40-dev  libmysqlclient-dev libmysqld-dev uuid-dev liblua5.1-0-dev libncurses5-dev libreadline-dev libreadline6-dev libfribidi-dev libgl1-mesa-dev libglc-dev libglc0 libglu1-mesa-dev mesa-common-dev libpcre3-dev libpcrecpp0 python-paramiko
5 ./autogen.sh --prefix=/path/where/you/want/to/install/it
6 make
7 make install
8 /path/where/you/did/install/it/bin/mysql-workbench
For those guys who already tried it and got errors for missing packages, a python-error for missing import or a seg-faults, here my list of errors and the packages/action required to install/run:

No package 'libzip' found

01checking for ZIP... configure: error: Package requirements (libzip) were not met:
02
03No package 'libzip' found
04
05Consider adjusting the PKG_CONFIG_PATH environment variable if you
06installed software in a non-standard prefix.
07
08Alternatively, you may set the environment variables ZIP_CFLAGS
09and ZIP_LIBS to avoid the need to call pkg-config.
10See the pkg-config man page for more details.
libzip dev package is missing install it via apt-get:
1apt-get install libzip-dev libzip1

No package 'libxml-2.0' found

01checking for GLIB... configure: error: Package requirements (glib-2.0 gthread-2.0 gmodule-2.0 libxml-2.0 >= 2.6.2) were not met:
02
03No package 'libxml-2.0' found
04
05Consider adjusting the PKG_CONFIG_PATH environment variable if you
06installed software in a non-standard prefix.
07
08Alternatively, you may set the environment variables GLIB_CFLAGS
09and GLIB_LIBS to avoid the need to call pkg-config.
10See the pkg-config man page for more details.
libxml dev package is missing install it via apt-get:
1apt-get install libxml2-dev

No package 'sigc++-2.0' found

01checking for SIGC... configure: error: Package requirements (sigc++-2.0) were not met:
02
03No package 'sigc++-2.0' found
04
05Consider adjusting the PKG_CONFIG_PATH environment variable if you
06installed software in a non-standard prefix.
07
08Alternatively, you may set the environment variables SIGC_CFLAGS
09and SIGC_LIBS to avoid the need to call pkg-config.
10See the pkg-config man page for more details.
sigc++2.0 dev package is missing install it via apt-get:
1apt-get install libsigc++-2.0-dev

No package 'libglade-2.0' found / No package 'gtkmm-2.4' found/h3>

01checking for GNOME... configure: error: Package requirements (libglade-2.0 gtkmm-2.4) were not met:
02
03No package 'libglade-2.0' found
04No package 'gtkmm-2.4' found
05
06Consider adjusting the PKG_CONFIG_PATH environment variable if you
07installed software in a non-standard prefix.
08
09Alternatively, you may set the environment variables GNOME_CFLAGS
10and GNOME_LIBS to avoid the need to call pkg-config.
11See the pkg-config man page for more details.
libglade2 dev and libgtkmm 2 dev packages are missing install them via apt-get:
1apt-get install libcairomm-1.0-dev libglibmm-2.4-dev libpangomm-1.4-dev libglade2-dev libaudiofile-dev libavahi-client-dev libavahi-common-dev libavahi-glib-dev libbonobo2-dev libdbus-1-dev libesd0-dev libgconf2-dev libgcrypt11-dev libgnomevfs2-dev libgnutls-dev libgpg-error-dev libpopt-dev libselinux1-dev libsepol1-dev libtasn1-3-dev

No package 'libgnome-2.0' found

01checking for LIBGNOME... configure: error: Package requirements (libgnome-2.0) were not met:
02
03No package 'libgnome-2.0' found
04
05Consider adjusting the PKG_CONFIG_PATH environment variable if you
06installed software in a non-standard prefix.
07
08Alternatively, you may set the environment variables LIBGNOME_CFLAGS
09and LIBGNOME_LIBS to avoid the need to call pkg-config.
10See the pkg-config man page for more details.
libgnome dev package is missing install it via apt-get:
1apt-get install libgnome2-dev

No package 'sqlite3' found

01checking for SQLITE3... configure: error: Package requirements (sqlite3) were not met:
02
03No package 'sqlite3' found
04
05Consider adjusting the PKG_CONFIG_PATH environment variable if you
06installed software in a non-standard prefix.
07
08Alternatively, you may set the environment variables SQLITE3_CFLAGS
09and SQLITE3_LIBS to avoid the need to call pkg-config.
10See the pkg-config man page for more details.
libsql3 dev package is missing install it via apt-get:
1apt-get install libsqlite3-dev

configure: error: "BOOST library is missing"

1checking for boost/foreach.hpp... no
2configure: error: "BOOST library is missing"
libboost dev package is missing install it via apt-get:
1apt-get install libboost1.40-dev

configure: error: Could not find mysql_config script. Make sure the mysql client libraries are installed

1checking for mysql headers and libraries... ./configure: line 16478: mysql_config: command not found
2./configure: line 16479: mysql_config: command not found
3configure: error: Could not find mysql_config script. Make sure the mysql client libraries are installed
libmysqlclient and libmysqld dev packages are missing install them apt-get:
1apt-get install libmysqlclient-dev libmysqld-dev

No package 'uuid' found

01checking for UUID... configure: error: Package requirements (uuid) were not met:
02
03No package 'uuid' found
04
05Consider adjusting the PKG_CONFIG_PATH environment variable if you
06installed software in a non-standard prefix.
07
08Alternatively, you may set the environment variables UUID_CFLAGS
09and UUID_LIBS to avoid the need to call pkg-config.
10See the pkg-config man page for more details.
uuid dev package is missing install it via apt-get:
1apt-get install uuid-dev

No package 'lua' found

01checking for LUA... configure: error: Package requirements (lua >= 5.1) were not met:
02
03No package 'lua' found
04
05Consider adjusting the PKG_CONFIG_PATH environment variable if you
06installed software in a non-standard prefix.
07
08Alternatively, you may set the environment variables LUA_CFLAGS
09and LUA_LIBS to avoid the need to call pkg-config.
10See the pkg-config man page for more details.
liblua5.1 dev package is missing install it via apt-get:
1apt-get install liblua5.1-0-dev libncurses5-dev libreadline-dev libreadline6-dev

configure: error: OpenGL headers not found

1checking for GL/gl.h... no
2configure: error: OpenGL headers not found
opengl dev packages are missing install them via apt-get:
1apt-get install liblua5.1-0-dev libncurses5-dev libreadline-dev libreadline6-dev

configure: error: Could not find pcre-config script. Make sure the pcre libraries are installed

1checking for pcre-config... no
2configure: error: Could not find pcre-config script. Make sure the pcre libraries are installed
libprce dev and libpcrecpp package are missing install them via apt-get:
1apt-get install libpcre3-dev libpcrecpp0

ImportError: No module named paramiko

1Traceback (most recent call last):
2  File "/opt/wb/share/mysql-workbench/sshtunnel.py", line 10, in
3    import paramiko
4ImportError: No module named paramiko
5terminate called after throwing an instance of 'std::runtime_error'
6  what():  Error starting tunnel manager:
7Aborted
python-paramiko is missing install it via apt-get:
1

segmentation fault ./mysql-workbench-bin

1[2]    20800 segmentation fault  ./mysql-workbench-bin
Dont start mysql-workbench-bin, use mysql-workbench instead

Monday, October 29, 2012

Recover MySQL root Password

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop
Output:
Stopping MySQL database server: mysqld.

Step # 2: Start to MySQL server w/o password:

# mysqld_safe --skip-grant-tables &
Output:
[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client:

# mysql -u root
Output:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop
Output:
Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended
[1]+  Done                    mysqld_safe --skip-grant-tables

Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p

Tuesday, October 23, 2012

"Server does not use any supported authentication method" in pidgin

 "Server does not use any supported authentication method" in pidgin

     /etc/hostname doesn't match /etc/hosts and comment ipv6 address

Sunday, October 21, 2012

Varnish Cache for Centos.

 Varnish Cache for Centos.

Add EPEL repository to Yum

#rpm -ivh http://mirror.nus.edu.sg/Fedora/epel//5/i386/epel-release-5-4.noarch.rpm

# yum install jemalloc-2.1.3-2.el5.x86_64.rpm

#rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm
#yum install varnish

Now to edit the varnish configuration file. It’s located at: etc/varnish/default.vcl. Insert the following code in the file. Explanation of the different constructs follows:


======================================================================================
backend default {
  .host = "your.primary.domainname.com";
  .port = "80";
}
sub vcl_recv {
  if (req.http.Accept-Encoding) {
    if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|lzma|tbz)(\?.*|)$") {
      remove req.http.Accept-Encoding;
    } elsif (req.http.Accept-Encoding ~ "gzip") {
      set req.http.Accept-Encoding = "gzip";
    } elsif (req.http.Accept-Encoding ~ "deflate") {
      set req.http.Accept-Encoding = "deflate";
    } else {
      remove req.http.Accept-Encoding;
    }
  }
  if (req.url ~ "^/[^?]+\.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.*|)$") {
    unset req.http.cookie;
  }
  if (req.request == "GET" && req.url ~ "cron_job" ||         req.url ~ "something_else"        ) {
    return ( pass );
  }
}
======================================================================================



To start the varnish process 
 


# varnishd -f /etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:6081 -a 0.0.0.0:80



To redirect http traffic to varnish port 
 =========================
 iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 6081

 =========================

Wednesday, October 17, 2012

Proxy for Curl.

Proxy Setting for Curl.

You can make a alias in your ~/.bashrc file :

=================
alias curl="curl -x :"
=================
Exp:  vi .bashrc
alias curl="curl -x http://172.16.101.87:80"
 
source .bashrc
aswathy@AcerPower:~$ alias curl
alias curl='curl -x http://172.16.101.87:8080'
 
 
 =================

 
 
Another solution is to use (maybe the better solution) the ~/.curlrc file (create it if it does not exist) :
proxy = :
 
aswathy@AcerPower:~$ cat .curlrc 
proxy = http://172.16.101.87:8080
aswathy@AcerPower:~$ =================

Thursday, October 4, 2012

Password for '(null)' GNOME keyring:




 Password for '(null)' GNOME keyring:  While doing SVN.


 =======================
sanitha@ubuntu1:~ svn co https://xxxxxxxxxxxxxxxxxx/trunk
Password for '(null)' GNOME keyring:

svn: OPTIONS of 'https://xxxxxxxxxxxxx/trunk': authorization failed: Could not authenticate to server: rejected Basic challenge (https://xxxxxxxxxxx)
=======================

The fix is..
 ==========================

sanitha@ubuntu1:~$ rm -rf .gnome2/keyrings/login.keyring
 ==========================

Thursday, September 6, 2012

FTP file Fetch script


 FTP file Fetch script

===========================
#!/bin/bash
export SSHPASS=******(ftp passwd
sshpass -e sftp -oBatchMode=no -b -  test@sftp2.urserver.com << !
   cd inbound
   mget *.zip
   rename *.zip archive/*.zip
   bye
!
===========================

Connect SFTP using Private Key.

Connect SFTP using Private Key.


sftp -oIdentityFile=/home/xxxx.key user@servername

Saturday, September 1, 2012

Create an apt-mirror with ubuntu 12.04

create an apt-mirror with ubuntu 12.04 

If you run several ubuntu machines on your network, you may want to mirror the ubuntu repositories locally to both save bandwidth, and increase the overall download rate at which you can update your machines, you don't want to be going out to the internet to download the same update file time and time again now do you?

The following describes how to setup an apt mirror on an ubuntu server (12.04 LTS) to mirror the main ubuntu repositories (main, multiverse, restricted and universe), security repository, as well as the puppet apt repository.

Server Setup - install and configure apt-mirror

For this setup I had an ubuntu 12.04 server with a 200GB partition mounted at /var/spool/apt-mirror. Step one is to install apt-mirror :
# sudo apt-get install apt-mirror
The default configuration file can be found at /etc/apt/mirror.list :
############# config ##################
#
# set base_path    /var/spool/apt-mirror
#
# set mirror_path  $base_path/mirror
# set skel_path    $base_path/skel
# set var_path     $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch  
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads     20
set _tilde 0
#
############# end config ##############

deb http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse

deb-src http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse

clean http://archive.ubuntu.com/ubuntu
You can add extra mirrors to the list, change the default directory into which the mirror is created, change the number of threads used for downloading packages etc. For example, to download only 64 bit architecture, change the deb section for each line to read deb-amd64 (or deb-i386 for 32 bit packages).

Once edited, my configuration looked as such :
############# config ##################
#
# set base_path    /var/spool/apt-mirror
#
# set mirror_path  $base_path/mirror
# set skel_path    $base_path/skel
# set var_path     $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch  
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads     20
set _tilde 0
#
############# end config ##############

# Precise 64Bit Mirror
deb-amd64 http://gb.archive.ubuntu.com/ubuntu precise main restricted universe multiverse
deb-amd64 http://gb.archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
deb-amd64 http://gb.archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
deb-amd64 http://gb.archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
deb-amd64 http://gb.archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse

# Precise 32Bit Mirror
deb-i386 http://gb.archive.ubuntu.com/ubuntu precise main restricted universe multiverse
deb-i386 http://gb.archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
deb-i386 http://gb.archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
deb-i386 http://gb.archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
deb-i386 http://gb.archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse

#deb-src http://gb.archive.ubuntu.com/ubuntu precise main restricted universe multiverse
#deb-src http://gb.archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
#deb-src http://gb.archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
#deb-src http://gb.archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
#deb-src http://gb.archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse

# Puppet mirror
deb-amd64 http://apt.puppetlabs.com/ precise main
deb-i386 http://apt.puppetlabs.com/ precise main

clean http://gb.archive.ubuntu.com/ubuntu
clean http://apt.puppetlabs.com/
You can see that I am mirroring both the 32bit and 64bit architectures for 12.04 (precise) as well as the precise mirror from puppetlabs. Since I'm not often recompiling packages from the source, I haven't mirrored the source packages.

Another change to make from the default file is to change the mirror that your are downloading your packages from in order to download from a closer, faster mirror. This should be done by adding the country code to the beginning of archive.ubuntu.com for example here, gb.archive.ubuntu.com.

At this point in time, my mirror is using 67GB of space to help calculate how much space to use.

To perform the first manual update of the mirror, run the following command (warning, depending on your connection, this could take quite a while, go get a coffee, or five!) :
# sudo apt-mirror /etc/apt/mirror.list
If you have a problem with your configuration and apt-mirror quits unexpectedly, or you break out it (with a ctrl-c for example) you may need to remove the lockfile at /var/spool/apt-mirror/var/apt-mirror.lock
In order to keep the mirror up-to-date automatically, the apt-mirror installs a cron job at /etc/cron.d/apt-mirror :
#
# Regular cron jobs for the apt-mirror package
#
#0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
Removing the comment (#) from the start of the last line will make your mirror update daily at 4am, you may wish to change this to a more convenient time, but I would advise against running it too often, and putting unnecessary strain on the remote mirror.

Every once in a while you may wish to clean up your mirror to save space, this can be done by running the following command :
# sudo /var/spool/apt-mirror/var/clean.sh
Server Setup - install and configure apache for http access

Ubuntu clients normally access their mirrors over http, we can setup our mirror for access using apache2. Firstly install apache :
# sudo apt-get install apache2
This will install apache2 and any other necessary dependancies. The quickest (but not necessarily best) way to set up apache to serve the mirror out to clients is as follows :
# sudo ln -s /var/spool/apt-mirror/mirror/gb.archive.ubuntu.com/ubuntu/ /var/www/ubuntu
# sudo ln -s /var/spool/apt-mirror/mirror/apt.puppetlabs.com /var/www/puppet
Remember to change the relevant directory names if your using a different mirror to download from!

Client Setup

Finally we have to update our clients to point to the mirror, this is a simple as editing the file /etc/apt/sources.list and changing the URLs to point to our local mirror, below is an example of an update sources.list file
# deb cdrom:[Ubuntu 11.10 _Oneiric Ocelot_ - Release i386 (20111012)]/ oneiric main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://apt-mirror.localdomain/ubuntu/ precise main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ precise main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://apt-mirror.localdomain/ubuntu/ precise-updates main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ precise-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://apt-mirror.localdomain/ubuntu/ precise universe
deb-src http://gb.archive.ubuntu.com/ubuntu/ precise universe
deb http://apt-mirror.localdomain/ubuntu/ precise-updates universe
deb-src http://gb.archive.ubuntu.com/ubuntu/ precise-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://apt-mirror.localdomain/ubuntu/ precise multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://apt-mirror.localdomain/ubuntu/ precise-updates multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ precise-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://apt-mirror.localdomain/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse

deb http://apt-mirror.localdomain/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://apt-mirror.localdomain/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://apt-mirror.localdomain/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu oneiric partner
deb-src http://archive.canonical.com/ubuntu oneiric partner

## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
Once you've updated the sources.list file, run the following command on the client to download the catalogs from your new mirror and update your software :
# sudo apt-get update $$ sudo apt-get upgrade
 
 
 
 
                                                                thanx:unixrob
 
 
 
 

Friday, August 17, 2012

Time Zone In redhat/Centos

Time Zone In redhat/Centos

1. To enable  UTC in server
        
   /etc/sysconfig/clock
     |-UTC=false

Otherwise we can use #setup and enable utc

Set timezone using /etc/localtime configuration file [any Linux distro]

Often /etc/localtime is a symlink to the file localtime or to the correct time zone file in the system time zone directory.

Generic procedure to change timezone

Change directory to /etc
# cd /etc

Create a symlink to file localtime:
# ln -sf /usr/share/zoneinfo/EST localtime

OR some distro use /usr/share/zoneinfo/dirname/zonefile format (Red hat and friends)
# ln -sf /usr/share/zoneinfo/EST localtime

OR if you want to set up it to IST (Asia/Calcutta):
# ln -sf /usr/share/zoneinfo/Asia/Calcutta localtime

Monday, August 6, 2012

To Flush Memcached Cache.

$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
flush_all

Monday, July 30, 2012

Dnstracer


You can trace a chain of DNS servers to the source and troubleshooting dns issues with dnstracer command.

dnstracer www.google.com

OR try old good dig :)

dig +trace www.google.com


Trace using IPv4 and IPv6 root servers:

dnstracer -4 -s . www.google.com
dnstracer -6 -s . www.google.com


                                                                                                                                          ============
                                                                                                                                                                                                                            Thnx Nixcraft
                                                                                                                                                                                                                             ============

Wednesday, July 18, 2012

LINUX BOOTING SEQUENCE TROUBLESHOOTING

LINUX BOOTING SEQUENCE TROUBLESHOOTING
Case 1: No boot loader splash screen or prompt appears
Cause:
1) Grub.conf miss configures
2) Initrd misplaced or deleted
3) MBR cruuppet
4) /boot partition miss
Grub.conf miss configures
Remedy: try to pass boot location initrd location & kernel module location as follows
Step a) Grub > root (hd0,0)
Note: here hd0,0 means boot partition is in 1st partition of 1st hdd.(please use hd for SATA & SCSI hdd also )
Step b) grub > kernel /vmlinuz-$(uname -r) root=LABEL=/ rhgb quiet
Step c) grub > initrd /initrd-$(uname -r).img
Step d) grub > boot
Then after rebooting try to recreate grub.conf file
Initrd misplaced or deleted
Case a) system is up
This is the most fortunate situation for system admins who are managing the server remotely because now once the system will down it will not be up without rescue mode
Remedy:
[root@dh-localhost ~]# mkinitrd /boot/ initrd-$(uname -r).img $(uname -r)
Case b) system is down
Then boot from system via DVD & start it by rescue mode
Remedy:
Step 1) Boot: linux recue
After some process & ittrective prompt you will be on sh prompt
Step 2) chroot /mnt/sysimage
cd /boot
mkinitrd /boot/ initrd-$(uname -r).img $(uname -r)
Then reboot the system by HDD
Note: - in case of fstab is also misconfigured (ie / & other partition will not mount after boot) then chroot command will not work. So in this case your 1st step would be to correct fstab then perform above steps as follows
Step a) boot from DVD or other bootable media
Step b) chroot /mnt/sysimage (you will find chroot error here )
Step c) mkdir /test
e2label /dev/sda1 (if it will show boot them mount it otherwise try to search by e2label /dev/sda2 ownwards)
mount /dev/sda1 /test
cd /test
cd grub
vi grub.conf (please make it correct)
mkdir /data
mount /dev/sda2 /data (mounting / partition on /data )
cd /data
cd /etc
vi fstab (please correct it )
Then reboot the system & follow previous step
Mbr corrupt
Case a) system is up
Method 1
[root@dh-localhost ~]# /sbin/grub-install /dev/sda
Method 2
[root@dh-localhost ~]# grub
grub> root (hd0,0)
grub > setup (hd0)
grub > quit
Case b) system is down
Boot system by rescue mode
Sh #Chroot /mnt/sysimage
Sh # /sbin/grub-install /dev/sda
Note : A smart system admin always take backup of MBR as follows
[root@dh-localhost ~]# dd if=/home/mbr of=/home/mbr bs=1 count 500
&
For restoration for MBR
[root@dh-localhost ~]# dd if=/home/mbr of=/home/mbr bs=1 count 500
/boot partition miss
In this case if you have backup of /boot then you can recover it otherwise you need to rebuild the server again.

Recover LVM from Corrupted physical volume/Disk

Recover LVM from Corrupted physical volume

I had Volume Group /dev/vg1 that consist two physical volumes /dev/sdb1 and /dev/sdc1 . One of physical volume /dev/sdc1, corrupted due to disk problem , now the challenge was to recover LVM. I decided to use pvremove command, in following way
    root#pvremove /dev/sdc1
Above command displayed error couldn't find device uuid 'xxxxxxx'
Then issue tried forcefully
   root#pvremove -ff /dev/sdc1
After some warning, it removed that physical volume.
Then i issued pvdisplay command
 root#pvdisplay
This display message  ' Couldn't find device with uuid xxxxxx'

Now what you need to do is to create a physical volume with new disk with missing uuid .
For that following command can be used
root# pvcreate --uuid=xxxxxx /dev/sdd1 --restorefile=/etc/lvm/archive/vg0_0.vg
Where /dev/sdd1 is new hard disk in replace of /dev/sdc1
Then restore the vg metadata with following command
root# vgcfgrestore -f /etc/lvm/archive/vg0_0.vg tvg0
Note: check archive of vg in /etc/lvm/archive

How to restore accidently removed LVM


Following command can be helpful in this scenario
   vgcfgrestore
Also look at your /etc/lvm/archive/ for all archived metadata.
You should be able to use '--list' optio

Team multiple network interface into single interface /NIC Bonding

Team multiple network interface into single interface


Linux allows binding multiple network interfaces into a single channel/NIC using special kernel module called bonding.

Step #1: Create a bond0 configuration file

First, create bond0 config file in /etc/sysconfig/network-scripts/
# vi /etc/sysconfig/network-scripts/ifcfg-bond0Append following lines to it:DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes


Step #2: Modify eth0 and eth1 config files:

Open both configuration using vi text editor and make sure file read as follows for eth0 interface# vi /etc/sysconfig/network-scripts/ifcfg-eth0 Modify/append directive as follows:DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

And do same for /etc/sysconfig/network-scripts/ifcfg-eth1

Step # 3: Load bond driver/module

Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. One need to modify kernel modules configuration file:# vi /etc/modprobe.conf Append following two lines:alias bond0 bonding
options bond0 mode=balance-alb miimon=100

Save file and exit to shell prompt.

Step # 4: Test configuration

First, load the bonding module:

# modprobe bonding
Restart networking service in order to bring up bond0 interface
# service network restart
Verify everything is working:# less /proc/net/bonding/bond0Output:
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:59
 
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:63
List all interfaces:# ifconfig