About

 

After a few years thinking of creating a blog about my personal notes collected throughout my professional life. Well, now it is the time.

When you are trying to implement new system or networking services, the normal rule is the emergence the troubles. When you have just successfully, all is well , just then you remember all steps performed, but when it takes a fews weeks or months and you have to implemnet the same service then you don’t remember. Sometimes you have luck finding old notes but not always.

This blog is created with the intention of posting some of my old personal notes found and the new fron now on. The post are related with my job as Systems Engineering.
You will find post about Linux Servers: DHCP/DNS, Database, Monitoring, High Availability, Virtualization, Storage,…  And post about Networking: Security, Routing, Switching, Cisco, VPN, VLANs, ….

Cisco LAB

GNS3 is a graphical network simulator that allows simulation of complex networks.  GNS3 is an excellent complementary tool to real labs for network engineers, administrators and people wanting to study for certifications such as Cisco CCNA, CCNP, CCIP and CCIE.

Install dependencies

$ sudo apt-get install python qt4-dev-tools pyqt4-dev-tools

Download  and unzip GNS3

$ cd  /opt
$ sudo  wget  http://downloads.sourceforge.net/project/gns-3/GNS3/0.8.3/GNS3-0.8.3-src.tar.bz2
$ sudo tar -xjvf GNS3-0.8.3-src.tar.bz2
$ sudo mv GNS3-0.8.3-src  GNS3

Preparing folders

$ cd GNS3  
$ sudo mkdir Dynamip  
$ sudo mkdir Images  
$ sudo mkdir Project 
$ sudo mkdir tmp 
$ sudo chmod o+rw -R ./Project

Download Dynamips

$ cd Dynamips
$ sudo wget http://downloads.sourceforge.net/project/gns-3/Dynamips/0.2.8-RC2/    \            dynamips-0.2.8-RC2-amd64.bin
$ sudo chmod +x dynamips-0.2.8-RC2-amd64.bin

start GNS3

$ gksu python “/opt/GNS3/gns3″

Set up  GNS3
Edit -> Preferences

General

Dynamips

Installing Nagios & Nagvis on Centos 6.2 (Part II)

NagVis is a visualization addon for the well known network managment system Nagios.
NagVis can be used to visualize Nagios Data, e.g. to display IT processes like a mail system or a network infrastructure.

Prerequisite: First you need to install Nagios
if you do not have Nagios installed, please look at this post :
Installing Nagios & Nagvis on Centos 6.2 (Part I)

Installing Nagvis

# yum install -y ndoutils mysql-server php-gd php-mbstring php-pdo php-mysql graphviz

Set MySQL service to start on boot

# chkconfig mysqld on

Start MySQL service

# service mysqld start

Create database and access permissions

# mysql
mysql> create database nagios;
mysql> GRANT ALL PRIVILEGES ON nagios.* TO ‘nagios’@'localhost’ IDENTIFIED BY ‘nagiossecret’;
mysql>flush privileges;

Initialize the database

# cd /usr/share/ndoutils
# ./installdb -u nagios -p nagiossecret -h localhost -d nagios

Set up “nagios.cfg” file

# nano /etc/nagios/nagios.cfg

Add line:  broker_module=/usr/libexec/ndomod-3x.o config_file=/etc/nagios/ndomod.cfg

event_broker_options=-1
broker_module=/usr/libexec/ndomod-3x.o  config_file=/etc/nagios/ndomod.cfg

Start NDOUtils service

# service ndoutils start

Restart Nagios service

# service nagios restart

 
Now check logs

# nano  /var/log/nagios/nagios.log

We can see is OK

[1348588492] Nagios 3.2.3 starting… (PID=4262)
[1348588492] Local time is Tue Sep 25 17:54:52 CEST 2012
[1348588492] LOG VERSION: 2.0
[1348588492] ndomod: NDOMOD 1.4b8 (07-16-2009) Copyright (c) 2009 Nagios Core Development Team and Community Contributors


Download
Nagvis last version (1.7.1)

# cd /tmp
#  wget http://sourceforge.net/projects/nagvis/files/latest/download?source=files

Unzip

# tar zxvf nagvis-1.7.1.tar.gz


Install Nagvis

# cd nagvis-1.7.1
# ./install.sh

+——————————————————————————+
| Welcome to NagVis Installer 1.7.1                                            |
+——————————————————————————+
| This script is built to facilitate the NagVis installation and update        |
| procedure for you. The installer has been tested on the following systems:   |
| – Debian Etch, Hardy (4.0, 5.0)                                              |
| – Ubuntu Hardy, Intrepid, Jaunty, Karmic, Lucid (8.04 to 10.04)              |
| – SuSE Linux Enterprise Server 10 and 11                                     |
|                                                                              |
| Similar distributions to the ones mentioned above should work as well.       |
| That (hopefully) includes RedHat, Fedora, CentOS, OpenSuSE                   |
|                                                                              |
| If you experience any problems using these or other distributions, please    |
| report that to the NagVis team.                                              |
+——————————————————————————+
| Do you want to proceed? [y]:   y
+——————————————————————————+
| Starting installation of NagVis 1.7.1                                        |
+——————————————————————————+
| OS  : CentOS release 6.3 (Final)                                             |
|                                                                              |
+— Checking for tools ——————————————————-+
| Using packet manager /bin/rpm                                          found |
+— Checking paths ———————————————————–+
| Please enter the path to the nagios base directory [/usr]: /usr/share/nagios
|   nagios path /usr/share/nagios                                        found |
| Please enter the path to NagVis base [/usr/nagvis]: /usr/share/nagvis
+— Checking prerequisites —————————————————+
| PHP 5.3                                                                found |
|   PHP Module: gd php                                                   found |
|   PHP Module: mbstring php                                             found |
|   PHP Module: gettext compiled_in                                      found |
|   PHP Module: session compiled_in                                      found |
|   PHP Module: xml compiled_in                                          found |
|   PHP Module: pdo php                                                  found |
|   Apache mod_php                                                       found |


don not set up the backend, after set up from file

| Checking Backends. (Available: mklivestatus,ndo2db,ido2db,merlinmy)          |
| Do you want to use backend mklivestatus? [y]: n
| Do you want to use backend ndo2db? [n]: n
| Do you want to use backend ido2db? [n]: n
| Do you want to use backend merlinmy? [n]: n
| NO (valid) backend(s) specified                                      MISSING |

| Graphviz 2.26                                                          found |
|   Graphviz Module dot 2.26.0                                           found |
|   Graphviz Module neato 2.26.0                                         found |
|   Graphviz Module twopi 2.26.0                                         found |
|   Graphviz Module circo 2.26.0                                         found |
|   Graphviz Module fdp 2.26.0                                           found |
| SQLite 3.6                                                             found |
|                                                                              |
+— Trying to detect Apache settings —————————————–+
| Please enter the web path to NagVis [/nagvis]: /nagvis
| Please enter the name of the web-server user [apache]: apache
| Please enter the name of the web-server group [apache]: apache
| create Apache config file [y]: y
+——————————————————————————+
| Summary                                                                      |
+——————————————————————————+
| NagVis home will be:           /usr/share/nagvis                             |
| Owner of NagVis files will be: apache                                        |
| Group of NagVis files will be: apache                                        |
| Path to Apache config dir is:  /etc/httpd/conf.d                             |
| Apache config will be created: yes                                           |
|                                                                              |
| Installation mode:             install                                       |
|                                                                              |
| Do you really want to continue? [y]: y
+——————————————————————————+
| Starting installation                                                        |
+——————————————————————————+
| Creating directory /usr/share/nagvis…                                done  |
| Creating directory /usr/share/nagvis/var…                            done  |
| Creating directory /usr/share/nagvis/var/tmpl/cache…                 done  |
| Creating directory /usr/share/nagvis/var/tmpl/compile…               done  |
| Creating directory /usr/share/nagvis/share/var…                      done  |
| Copying files to /usr/share/nagvis…                                  done  |
| Creating directory /usr/share/nagvis/etc/profiles…                   done  |
/usr/share/nagvis/share/frontend/nagvis-js/js
| Creating main configuration file…                                    done  |
| adding base=”/usr/share/nagvis”                                        done  |
|   Adding webserver group to file_group…                              done  |
| Creating web configuration file…                                     done  |
| Setting permissions for web configuration file…                      done  |
|                                                                              |
|                                                                              |
|                                                                              |
+— Setting permissions… —————————————————+
| /usr/share/nagvis/etc/nagvis.ini.php-sample                            done  |
| /usr/share/nagvis/etc                                                  done  |
| /usr/share/nagvis/etc/maps                                             done  |
| /usr/share/nagvis/etc/maps/*                                           done  |
| /usr/share/nagvis/etc/geomap                                           done  |
| /usr/share/nagvis/etc/geomap/*                                         done  |
| /usr/share/nagvis/etc/profiles                                         done  |
| /usr/share/nagvis/share/userfiles/images/maps                          done  |
| /usr/share/nagvis/share/userfiles/images/maps/*                        done  |
| /usr/share/nagvis/share/userfiles/images/shapes                        done  |
| /usr/share/nagvis/share/userfiles/images/shapes/*                      done  |
| /usr/share/nagvis/var                                                  done  |
| /usr/share/nagvis/var/*                                                done  |
| /usr/share/nagvis/var/tmpl                                             done  |
| /usr/share/nagvis/var/tmpl/cache                                       done  |
| /usr/share/nagvis/var/tmpl/compile                                     done  |
| /usr/share/nagvis/share/var                                            done  |
|                                                                              |
+——————————————————————————+
| Installation complete                                                        |
|                                                                              |
| You can safely remove this source directory.                                 |
|                                                                              |
| For later update/upgrade you may use this command to have a faster update:   |
| ./install.sh -n /usr/share/nagios -p /usr/share/nagvis -u apache -g apache -w /etc/httpd/conf.d -a y
|                                                                              |
| What to do next?                                                             |
| – Read the documentation                                                     |
| – Maybe you want to edit the main configuration file?                        |
|   Its location is: /usr/share/nagvis/etc/nagvis.ini.php                      |
| – Configure NagVis via browser                                               |
|   <http://localhost/nagvis/config.php>                                       |
| – Initial admin credentials:                                                 |
|     Username: admin                                                          |
|     Password: admin                                                          |
+——————————————————————————+


Set up NDO backend

# nano /usr/share/nagvis/etc/nagvis.ini.php


Set db_name, db_user and db_pass
created in Part I

; hostname for NDO-db
dbhost=”localhost”
; portname for NDO-db
dbport=3306
; database name for NDO-db
dbname=”nagios”
; username for NDO-db
dbuser=”nagios”
; password for NDO-db
dbpass=”nagiossecret”


 
Finally we access from:  http://Your_Server_Nagios_IP:/nagvis/
Default user/passwd: admin/admin



Installing Nagios & Nagvis on Centos 6.2 (Part I)

Nagios is an open source computer system monitor, network monitoring and infrastructure monitoring software application. Nagios offers monitoring and alerting for servers, switches, applications, and services. It watches hosts and services. It alerts users when things go wrong and alerts them again when those wrong things get better/resolved.

Installing RPMforge repository
Download the rpmforge-release package

For Centos 32-bits

# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

For Centos 64-bits

# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Install DAG’s GPG key

# rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt

Verify the package you have downloaded

# rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm

Install the package

# rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm

Set SELINUX=disabled on “/etc/selinux/config” file

# nano “/etc/selinux/config”
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted

and reboot system

# reboot

Install Nagios

# yum -y install nagios nagios-plugins nagios-plugins-nrpe

Set Apache and Nagios services to start on boot

# chkconfig httpd on
# chkconfig nagios on

Start Apache and Nagios services

# service httpd start
# service nagios start

We need also to open  port 80 from the firewall

# iptables -I INPUT -p tcp -m tcp –dport 80 -j ACCEPT

and save the changes

# service iptables save

Create user nagios to access

# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin

Now we can access to Nagios:   http://Your_Server_Nagios_IP:/nagios

Installing openERP 6 on Ubuntu 10.04 server

Create the OpenERP user

#  adduser –system –home=/opt/openerp –group openerp

Install and configure PostgreSQL

# apt-get install postgresql
# su – postgres
# createuser –createdb –username postgres –no-createrole –pwprompt openerp
Enter password for new role: <– ********
Enter it again: <– ********
Shall the new role be a superuser? (y/n) <– y
# exit

Install Python libraries

apt-get install python python-psycopg2 python-reportlab \
python-egenix-mxdatetime python-tz python-pychart python-mako \
python-pydot python-lxml python-vobject python-yaml python-dateutil \
python-pychart python-pydot python-webdav \
python-cherrypy3 python-formencode python-pybabel \
python-simplejson python-pyparsing

Install OpenERP server and web client

Download source code at home Directory

# wget http://www.openerp.com/download/stable/source/openerp-server-6.0.4.tar.gz
# wget http://www.openerp.com/download/stable/source/openerp-web-6.0.4.tar.gz

install the code at “/opt/openerp/” directory

# cd /opt/openerp
# tar xvf ~/openERP/openerp-server-6.0.4.tar.gz
# tar xvf ~/openERP/openerp-web-6.0.4.tar.gz
# chown -R openerp: *
# cp  -a  openerp-server-6.0.4   server
# cp  -a  openerp-web-6.0.4   web

copy  “/opt/openerp/server/doc/openerp-server.conf” at /etc/

#  cp /opt/openerp/server/doc/openerp-server.conf  /etc/

now edit this new file

# nano /etc/openerp-server.conf

and change the line db_password = FALSE to

db_password = paassword_your entered_openerp user_postgres

apply security changing ownership and access

# chown openerp:root  /etc/openerp-server.conf
# chmod 640  /etc/openerp-server.conf

creating the boot script

# nano  /etc/init.d/openerp-server

paste

#!/bin/sh### BEGIN INIT INFO
# Provides:             openerp-server
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Should-Start:         $network
# Should-Stop:          $network
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Enterprise Resource Management software
# Description:          Open ERP is a complete ERP and CRM software.
### END INIT INFOPATH=/bin:/sbin:/usr/bin
DAEMON=/opt/openerp/server/bin/openerp-server.py
NAME=openerp-server
DESC=openerp-server# Specify the user name (Default: openerp).
USER=openerp# Specify an alternate config file (Default: /etc/openerp-server.conf).
CONFIGFILE=”/etc/openerp-server.conf”# pidfile
PIDFILE=/var/run/$NAME.pid# Additional options that are passed to the Daemon.
DAEMON_OPTS=”-c $CONFIGFILE”[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0checkpid() {
    [ -f $PIDFILE ] || return 1
    pid=`cat $PIDFILE`
    [ -d /proc/$pid ] && return 0
    return 1
}case “${1}” in
        start)
                echo -n “Starting ${DESC}: “                start-stop-daemon –start –quiet –pidfile ${PIDFILE} \
                        –chuid ${USER} –background –make-pidfile \
                        –exec ${DAEMON} — ${DAEMON_OPTS}                echo “${NAME}.”
                ;;        stop)
                echo -n “Stopping ${DESC}: “                start-stop-daemon –stop –quiet –pidfile ${PIDFILE} \
                        –oknodo

                echo “${NAME}.”
                ;;

        restart|force-reload)
                echo -n “Restarting ${DESC}: “

                start-stop-daemon –stop –quiet –pidfile ${PIDFILE} \
                        –oknodo

                sleep 1

                start-stop-daemon –start –quiet –pidfile ${PIDFILE} \
                        –chuid ${USER} –background –make-pidfile \
                        –exec ${DAEMON} — ${DAEMON_OPTS}

                echo “${NAME}.”
                ;;

        *)
                N=/etc/init.d/${NAME}
                echo “Usage: ${NAME} {start|stop|restart|force-reload}” >&2
                exit 1
                ;;
esac

exit 0

owned by root and make it executable

# chown root: /etc/init.d/openerp-server
# chmod 755 /etc/init.d/openerp-server

set log directory

# mkdir /var/log/openerp
# chown openerp:root /var/log/openerp

automating OpenERP startup and shutdown

# update-rc.d openerp-server defaults

set web client

# cp  /opt/openerp/web/doc/openerp-web.cfg   /etc/openerp-web.conf
# chown  openerp:root  /etc/openerp-web.conf
# chmod  640  /etc/openerp-web.conf

creating web client boot script

# nano  /etc/init.d/openerp-web

paste

#!/bin/sh### BEGIN INIT INFO
# Provides:             openerp-web
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Should-Start:         $network
# Should-Stop:          $network
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    OpenERP Web – the Web Client of the OpenERP
# Description:          Open ERP is a complete ERP and CRM software.
### END INIT INFOPATH=”/sbin:/bin:/usr/sbin:/usr/bin”
DAEMON=”/opt/openerp/web/openerp-web.py”
NAME=”openerp-web”
DESC=”openerp-web”# Specify the user name (Default: openerp).
USER=openerp# Specify an alternate config file (Default: /etc/openerp-web.conf).
CONFIGFILE=”/etc/openerp-web.conf”# pidfile
PIDFILE=/var/run/$NAME.pid# Additional options that are passed to the Daemon.
DAEMON_OPTS=”-c $CONFIGFILE”

[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0

checkpid() {
    [ -f $PIDFILE ] || return 1
    pid=`cat $PIDFILE`
    [ -d /proc/$pid ] && return 0
    return 1
}

case “${1}” in
        start)
                echo -n “Starting ${DESC}: “

                start-stop-daemon –start –quiet –pidfile ${PIDFILE} \
                        –chuid ${USER} –background –make-pidfile \
                        –exec ${DAEMON} — ${DAEMON_OPTS}

                echo “${NAME}.”
                ;;

        stop)
                echo -n “Stopping ${DESC}: “

                start-stop-daemon –stop –quiet –pidfile ${PIDFILE} \
                        –oknodo

                echo “${NAME}.”
                ;;

        restart|force-reload)
                echo -n “Restarting ${DESC}: “

                start-stop-daemon –stop –quiet –pidfile ${PIDFILE} \
                        –oknodo

                sleep 1

                start-stop-daemon –start –quiet –pidfile ${PIDFILE} \
                        –chuid ${USER} –background –make-pidfile \
                        –exec ${DAEMON} — ${DAEMON_OPTS}

                echo “${NAME}.”
                ;;

        *)
                N=/etc/init.d/${NAME}
                echo “Usage: ${NAME} {start|stop|restart|force-reload}” >&2
                exit 1
                ;;
esac

exit 0

changing owner and permissions of execution

# chown root: /etc/init.d/openerp-web
# chmod 755 /etc/init.d/openerp-web

set to start and stop automatically

# update-rc.d openerp-web defaults

finally starts server and web client openERP

# service openerp-server start
# service openerp-web start

now you can access to the server from any browser

http://you_IP_server:8080

 

 

Posted in ERP |

Installing KVM on Centos 6.2 Desktop

Set SELINUX=disabled  on  “/etc/selinux/config” file

# nano  “/etc/selinux/config”
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing – SELinux security policy is enforced.
#     permissive – SELinux prints warnings instead of enforcing.
#     disabled – No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted – Targeted processes are protected,
#     mls – Multi Level Security protection.
SELINUXTYPE=targeted

and reboot system

# reboot

import the GPG keys for software packages

# rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*

install KVM and virtinst

# yum install kvm libvirt python-virtinst qemu-kvm

stop and set off on boot NetworkManger service

# service NetworkManager stop
# chkconfig NetworkManager off

install  “bridge-utils”  package

# yum install bridge-utils

configure a bridge creating “/etc/sysconfig/network-scripts/ifcfg-br0″ file

# nano /etc/sysconfig/network-scripts/ifcfg-br0

should modify IPADDR, PREFIX, GATEWAY, DNS1 and DNS2 values according to your network

DEVICE=”br0″
NM_CONTROLLED=”yes”
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=none
IPADDR=192.168.1.105
PREFIX=24
GATEWAY=192.168.1.1
DNS1=80.58.61.250
DNS2=80.58.61.254
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System br0″

edit “/etc/sysconfig/network-scripts/ifcfg-eth0 ” file

# nano /etc/sysconfig/network-scripts/ifcfg-eth0

and modify as follows (comment out BOOTPROTO, IPADDR, PREFIX, GATEWAY, DNS1, and DNS2 and add BRIDGE=br0)

DEVICE=”eth0″
NM_CONTROLLED=”yes”
ONBOOT=yes
HWADDR=00:16:0A:26:E6:D4
TYPE=Ethernet
#BOOTPROTO=none
#IPADDR=192.168.1.105
#PREFIX=24
#GATEWAY=192.168.1.1
#DNS1=192.168.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System eth0″
UUID=9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04
BRIDGE=br0

Restart the network

# service network restart

check the network bridge (br0)

# ifconfig
br0       Link encap:Ethernet  HWaddr 00:16:0A:26:E6:D4  
          inet addr:192.168.1.105  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::216:aff:fe26:e6d4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:28 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2002 (1.9 KiB)  TX bytes:7535 (7.3 KiB)eth0    Link encap:Ethernet  HWaddr 00:16:0A:26:E6:D4  
          inet6 addr: fe80::216:aff:fe26:e6d4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19247 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14826 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:25052924 (23.8 MiB)  TX bytes:1241868 (1.1 MiB)
          Interrupt:19 Base address:0x6c00 lo       Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2128 (2.0 KiB)  TX bytes:2128 (2.0 KiB)virbr0  Link encap:Ethernet  HWaddr 52:54:00:01:C5:58  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:3175 (3.1 KiB)

install virt-manager

# yum install virt-manager

Remove Volumes

Remove Logical Volume

# umount  /dev/vg00/lv00
# lvremove /dev/vg00/lv00
Do you really want to remove active logical volume lv00? [y/n]: y
Logical volume “lv00″ successfully removed

Remove Group Volume

# vgremove vg00
Do you really want to remove volume group “vg00″ containing 3 logical volumes? [y/n]: y
Volume group “vg00″ successfully removed

Remove Physical Volume

# pvremove /dev/sdc5
  Labels on physical volume “/dev/sdc5″ successfully wiped

Reducing a Logical Volume

check current size “lv00″

#  df -h
Filesystem                           Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lvrooC5
                                           19G  2,5G   16G  14% /
/dev/sda1                             244M   28M  203M  12% /boot
tmpfs                                   3,8G     0  3,8G   0% /dev/shm
/dev/mapper/vg00-lv00
                                           15G  154M   14G   2% /mnt

umount filesystem (can not be mounted)

# umount /dev/mapper/vg00-lv00

optional:  check filesystem (recommended)

# e2fsck -f /dev/mapper/vg00-lv00
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg00-lv00: 11/1966080 files (9.1% non-contiguous), 100898/3932160 blocks

reduce filesystem (new size 10G)

# resize2fs /dev/mapper/vg00-lv00 10G
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/mapper/vg00-lv00 to 2621440 (4k) blocks.
The filesystem on /dev/mapper/vg00-lv00 is now 2621440 blocks long.

mount  and check size filesystem

# mount /dev/mapper/vg00-lv00 /mnt/
# df -h
Filesystem                          Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lvrooC5
                                          19G  2,5G   16G  14% /
/dev/sda1                            244M   28M  203M  12% /boot
tmpfs                                  3,8G     0  3,8G   0% /dev/shm
/dev/mapper/vg00-lv00
                                          9,9G  151M  9,2G   2% /mnt

check size Logical Volume

# lvdisplay /dev/vg00/lv00 | grep Size
  LV Size                15,00 GB

Reduce size Logical Volumen

# lvreduce -L 10GB /dev/vg00/lv00
WARNING: Reducing active and open logical volume to 10,00 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv00? [y/n]: y
Reducing logical volume lv00 to 10,00 GB
Logical volume lv00 successfully resized

check new size

# lvdisplay /dev/vg00/lv00 | grep Size
LV Size                10,00 GB

Optional: Reduce Group Volume “vg00″

# vgreduce vg00 /dev/sdc5
  Removed “/dev/sdc5″ from volume group “vg00″

Setup iSCSI Target & Initiator (SAN ) on Centos 5.x

• Target

Install packages

#  yum -y groupinstall clustering cluster-storage
#  yum -y install scsi-target-utils
#  chkconfig tgtd on

Configure the target

# nano  /etc/tgt/target.conf
<target iqn.2010-12.localdomain.luci:diskDC>
backing-store /dev/mapper/vgstorage-lvdc
initiator-address 192.168.0.33
initiator-address 10.15.183.7
initiator-address 10.15.183.8
</target>

Display target available

# tgtadm –lld iscsi –op show –mode target

• Initiator

Install packages

#  yum -y groupinstall clustering cluster-storage
#  yum -y install iscsi-initiator-utils
#  chkconfig iscsi on
#  chkconfig iscsid on
#  service iscsid restart
#  service iscsi restart

Discover the iSCSI target

# iscsiadm -m discovery -t sendtargets -p 10.15.183.1

Log in to the target

# iscsiadm -m node -T iqn.2010-12.localdomain.luci:diskDC -p 10.15.183.1 -l

Delete iSCSI target

   /var/lib/iscsi/nodes/

   /var/lib/iscsi/send_targets/

Extending a Logical Volume

Situation a: Have enough free space on group volume vg00

check current size Logical Volume “lv00″

 # df -h
Filesystem                          Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lvrooC5
                                           19G  2,5G   16G  14% /
/dev/sda1                            244M   28M  203M  12% /boot
tmpfs                                  3,8G     0  3,8G   0% /dev/shm
/dev/mapper/vg00-lv00
                                          9,9G  151M  9,2G   2% /mnt

extend logical volume

# lvextend -L +5G /dev/vg00/lv00
  Extending logical volume lv00 to 15,00 GB
  Logical volume lv00 successfully resized

check size

 # df -h
Filesystem                          Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lvrooC5
19G  2,5G   16G  14% /
/dev/sda1                            244M   28M  203M  12% /boot
tmpfs                                  3,8G     0  3,8G   0% /dev/shm
/dev/mapper/vg00-lv00
                                          9,9G  151M  9,2G   2% /mnt

size does not change because we need further resize the File System

# resize2fs /dev/vg00/lv00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg00/lv00 is mounted on /mnt; on-line resizing required
Performing an on-line resize of /dev/vg00/lv00 to 3932160 (4k) blocks.
The filesystem on /dev/vg00/lv00 is now 3932160 blocks long.

check new size

# df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lvrooC5
                                       19G  2,5G   16G  14% /
/dev/sda1                         244M   28M  203M  12% /boot
tmpfs                               3,8G     0  3,8G   0% /dev/shm
/dev/mapper/vg00-lv00
                                       15G  154M   14G   2% /mnt

Situation b: Not have enough free space on group volume vg00

First, have to extend the volume group “vg00″
check current size “vg00″

# vgdisplay vg00 | grep “VG Size”
  VG Size               185,81 GB

create physical volume on another disk partition (/dev/sdc5)

# pvcreate /dev/sdc5
  Writing physical volume data to disk “/dev/sdc5″
  Physical volume “/dev/sdc5″ successfully created

then extend the volume group

# vgextend vg00 /dev/sdc5
  Volume group “vg00″ successfully extended

Finally check the new size

# vgdisplay vg00 | grep “VG Size”
  VG Size               465,25 GB

and now we are in the situation a