linux

linux

Selasa, 06 Maret 2012

install squid 3.1.19 at slackware 13.37

bellow resume for install squid 3.1.19 at slackware 13.37

download from http://www.squid-cache.org/Versions/v3/3.1/
#tar -xvf squid-3.1.19.tar.gz

#./configure
#make all
#make install
#groupadd proxy
#useradd proxy -g proxy -d /usr/local/squid -s /usr/bin/nologin
#mkdir /cache
#chown -R proxy.proxy /cache
# scp 192.168.1.191:/sdb/Docu/gudang/malang/squid.conf /usr/local/squid/etc/
you can create your own squid.conf  see the create squid.conf
#scp 192.168.1.191:/root/gudang/rc.squid /etc/rc.d/
 or create rc.squid bellow
#chown -R proxy.proxy /cache
#chmod a+w /cache
#useradd squid
#/usr/local/squid/sbin/squid -z
#cd /usr/local/squid/var/
#chmod -R a+w logs     
#cd logs
#chown squid cache.log
#/etc/rc.d/rc.squid start
#ps -ax | grep squid

create  rc.squid

#cd /etc/rc.d/
#nano rc.squid
copy this text at your rc.squid :
----------------------------------------------------------------------------------------------------------
#!/bin/sh
# Start/stop/restart/reload the Squid Internet Object Cache (squid)
# To make Squid start automatically at boot, make this
# file executable:  chmod 755 /etc/rc.d/rc.Squid
#
# Written for Slackware Linux by Erik Jan Tromp
# Modified by David Somero <xgizzmo@slackbuilds.org>

SQUIDCFG=/usr/local/squid/etc/squid.conf
SQUIDCMD=/usr/local/squid/sbin/squid

if [ ! -r $SQUIDCFG ]; then
  echo "Please set the correct path to $SQUIDCFG"
  exit 1
fi

if [ ! -x $SQUIDCMD ]; then
  echo "$SQUIDCMD not found"
  exit 1
fi

squid_start() {
  # Create cache directory hierarchy if needed
  ALL_DIRS=$(awk '/^cache_dir/ {print $3}' $SQUIDCFG)
  [ -z "$ALL_DIRS" ] && ALL_DIRS=/var/cache/squid

  for CACHE_DIR in $ALL_DIRS ; do
    if [ ! -d $CACHE_DIR/00 ] ; then
      echo "Creating swap directories:  $SQUIDCMD -z"
      $SQUIDCMD -z 2> /dev/null
      break
    fi
  done

  echo "Starting Squid:  $SQUIDCMD -SDYCF"
  $SQUIDCMD -SDYCF
}
squid_stop() {
  COUNTDOWN=$(awk '/^shutdown_lifetime/ {print $2}' $SQUIDCFG)
  [ -z "$COUNTDOWN" ] && COUNTDOWN=5

  echo -n "Shutting down Squid in $COUNTDOWN seconds:  "
  $SQUIDCMD -k shutdown 2> /dev/null
  while $SQUIDCMD -k check 2> /dev/null ; do
    sleep 1
    echo -n .
    COUNTDOWN=$[ $COUNTDOWN - 1 ]
    if [ $COUNTDOWN -le 0 ] ; then
      $SQUIDCMD -k interrupt 2> /dev/null
      sleep 1
      break
    fi
  done
  echo
}
squid_restart() {
  squid_stop
  sleep 1
  squid_start
}

squid_reload() {
  $SQUIDCMD -k reconfigure 2> /dev/null
}

case "$1" in
'start')
  squid_start
  ;;
'stop')
  squid_stop
  ;;
'restart')
  squid_restart
  ;;
'reload')
  squid_reload
  ;;
*)
  echo "usage: $0 start|stop|restart|reload"
esac
-----------------------------------------------------------------------------------------------------
#chmod a+x rc.squid
for start up squid at boot server linux
add this line at /etc/rc.d/rc.local
"/etc/rc.d/rc.squid start"
#nano /etc/rc.d/rc.local

/etc/rc.d/rc.squid start

to start your proxy
#/etc/rc.d/rc.squid start
to stop your proxy
#/etc/rc.d/rc.squid stop
to reload your proxy after reconfigure your squid.conf
#/etc/rc.d/rc.squid reload

===============================================
for any error see cache.log
#nano /usr/local/squid/var/logs/cache.log

this step working  at my proxy server
Happy ...Slackware..... :)




create your squid.conf

for simple way you can edit the squid.conf
 
#cd /usr/local/squid/etc/
#nano squid.conf
find text bellow
======================================
# should be allowed
#acl localnet src 10.0.0.0/8    # RFC1918 possible internal network
#acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
#acl localnet src 192.168.0.0/16        # RFC1918 possible internal network
-------------------------------------------------------------
add your acl at your network
-------------------------------------------------------------
acl localnet src 192.168.23.0/24
acl admin1 src 192.168.23.7/32
acl ipblock src 192.168.23.21/32
---------------------------------------------------------------
 find text : # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
and add your acl site to block or allow
-----------------------------------------------------
acl company url_regex -i youtube.com
acl linux  url_regex -i linux.com

http_access allow admin1 all

http_access deny ipblock company
http_access allow ipblock linux

http_access deny localnet all

=============================================
this squid.conf mean :
allow admin1 to all internet
deny ipblock(192.168.23.21) to see youtube.com
allow ipblock to see linux.com

Selasa, 28 Februari 2012

test koneksi di linux

for tes conection use ping to destination server :
for monitoring connection :
1. the sequance number ( green colour )
2.time ( blue colour )
3.packet loss ( yellow colour )
4.packet error ( pink colour )

root@<o000o>:/# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.174 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.171 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.147 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.148 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.149 ms
^C
--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4000ms
rtt min/avg/max/mdev = 0.147/0.157/0.174/0.019 ms

64 bytes from 172.16.0.25: icmp_seq=65100 ttl=64 time=0.718 ms
64 bytes from 172.16.0.25: icmp_seq=65101 ttl=64 time=0.638 ms
64 bytes from 172.16.0.25: icmp_seq=65102 ttl=64 time=0.639 ms
64 bytes from 172.16.0.25: icmp_seq=65103 ttl=64 time=0.521 ms

--- 172.16.0.25 ping statistics ---
261711 packets transmitted, 261008 received, +198 errors, 0% packet loss, time 261709076ms
rtt min/avg/max/mdev = 0.356/0.498/468.511/1.706 ms, pipe 3
64 bytes from 172.16.0.25: icmp_seq=625 ttl=64 time=0.562 ms
64 bytes from 172.16.0.25: icmp_seq=626 ttl=64 time=0.546 ms
64 bytes from 172.16.0.25: icmp_seq=627 ttl=64 time=0.548 ms
64 bytes from 172.16.0.25: icmp_seq=628 ttl=64 time=0.971 ms

--- 172.16.0.25 ping statistics ---
628 packets transmitted, 602 received, 4% packet loss, time 626995ms
rtt min/avg/max/mdev = 0.540/1.079/53.770/3.836 ms

root@<o000o>:/# ping -c 9 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.186 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.166 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.164 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.165 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.173 ms
64 bytes from 192.168.1.1: icmp_seq=6 ttl=64 time=0.164 ms
64 bytes from 192.168.1.1: icmp_seq=7 ttl=64 time=0.173 ms
64 bytes from 192.168.1.1: icmp_seq=8 ttl=64 time=0.163 ms
64 bytes from 192.168.1.1: icmp_seq=9 ttl=64 time=0.163 ms

--- 192.168.1.1 ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 7999ms
rtt min/avg/max/mdev = 0.163/0.168/0.186/0.015 ms

ping for steess network :

root@<o000o>:/# ping -c 1000 -f -n 192.168.188.21
PING 192.168.188.21 (192.168.188.21) 56(84) bytes of data.

--- 192.168.188.21 ping statistics ---
1000 packets transmitted, 1000 received, 0% packet loss, time 661ms
rtt min/avg/max/mdev = 0.509/0.647/2.210/0.164 ms, ipg/ewma 0.661/0.613 ms


 stress network with large packet :

root@<o000o>:/# ping -s 512 -c 1000 -f -n 192.168.188.21
PING 192.168.188.21 (192.168.188.21) 512(540) bytes of data.

--- 192.168.188.21 ping statistics ---
1000 packets transmitted, 1000 received, 0% packet loss, time 1311ms
rtt min/avg/max/mdev = 1.242/1.292/1.664/0.068 ms, ipg/ewma 1.313/1.339 ms

for recording route :

root@<o000o>:/# ping -c 2  -R 192.168.21.8
PING 192.168.21.8 (192.168.21.8) 56(124) bytes of data.
64 bytes from 192.168.21.8: icmp_seq=1 ttl=62 time=8.65 ms
RR:     192.168.1.191
        172.16.0.57
        192.168.21.201
        192.168.21.8
        192.168.21.8
        172.16.0.58
        192.168.1.1
        192.168.1.191

64 bytes from 192.168.21.8: icmp_seq=2 ttl=62 time=8.66 ms      (same route)

Senin, 20 Februari 2012

konsole xterm setting

to create monitoring for many server use xterm





 create script like bellow with user non root
create file with name xtermtest

$nano xtermtest

#!/bin/sh
xterm -geometry  65x8 -title bandung -bg OliveDrab3 -e "ping 10.0.10.51"  &
sleep 1
xterm -geometry  65x8 -title surabaya -bg chartreuse4   -e "ping 10.0.10.52" &
sleep 1
xterm -geometry  65x8 -title semarang -bg DarkOliveGreen  -e "ping 10.0.10.53" &
sleep 1
xterm -geometry  65x8 -title makasar -bg SeaGreen4 -e "ping 10.0.10.54" &
sleep 1
xterm -geometry  65x8 -title medan -bg cyan4  -e "ping 10.0.10.55" &
sleep 1
xterm -geometry  65x8 -title solo -bg cyan4  -e "ping 10.0.10.56" &
sleep 1
xterm -geometry  65x8 -title bsd -bg SeaGreen4  -e "ping 10.0.10.57" &
sleep 1
xterm -geometry  65x8 -title puri -bg DarkOliveGreen -e "ping 10.0.10.58" &
sleep 1
xterm -geometry  65x8 -title malang -bg cyan4  -e "ping 10.0.10.59" &
sleep 1
xterm -geometry  65x8 -title pluit -bg chartreuse4 -e "ping 10.0.10.60" &
sleep 1
xterm -geometry  65x8 -title manado -bg OliveDrab3  -e "ping 10.0.10.61" &
sleep 1
xterm -geometry  65x8 -title pekanbaru -bg SeaGreen4  -e "ping 10.0.10.62" &
sleep 1
xterm -geometry  65x8 -title pontianak -bg DarkOliveGreen  -e "ping 10.0.10.63" &
sleep 1
xterm -geometry  65x8 -title balikpapan -bg SeaGreen4  -e "ping 10.0.10.64" &
sleep 1
xterm -geometry  65x8 -title kelapagading -bg cyan4  -e "ping 192.168.21.8" &

$su -
password:

#chmod a+x xtermtest

$./xtermtest

enjoy your new konsole :)

for detail color you can see at http://critical.ch/xterm/













Jumat, 17 Februari 2012

performance server

there are some item must be look at server performance
1.cpu
2.memory
3.Haddisk
4.ethernet

for first use nmon

Senin, 13 Februari 2012

Linux beginner / Pemula

melihat lokasi

#pwd

melihat isi direktori
#ls
#ls -a
#ls -l

masuk ke direktori

cd nama_direktori

membuat direktori
mkdir nama_file

increase size mdadm

This just my note  how to increase array raid from 54G to 80G
it was work without lost data
just follow this steps
 
root@HO-1-231:~# fdisk -l | grep dev                                                                                        
Disk /dev/md0 doesn't contain a valid partition table                                                                       
Disk /dev/sdc doesn't contain a valid partition table                                                                       
Disk /dev/sdd doesn't contain a valid partition table                                                                       
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes                                                                               
/dev/sda1               1      243201  1953512001   fd  Linux raid autodetect                                               
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes                                                                               
/dev/sdb1               1      243201  1953512001   fd  Linux raid autodetect                                               
Disk /dev/md0: 2000.4 GB, 2000396222464 bytes                                                                               
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes                                                                               
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes                                                                               
root@HO-1-231:~# fdisk /dev/sdc                                                                                             
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel                                          
Building a new DOS disklabel with disk identifier 0x5ce337a5.                                                               
Changes will remain in memory only, until you decide to write them.                                                         
After that, of course, the previous content won't be recoverable.                                                           

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted. 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to  
         sectors (command 'u').                                         

Command (m for help): p

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x5ce337a5                           

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action         
   e   extended        
   p   primary partition (1-4)
p                             
Partition number (1-4): 1     
First cylinder (1-243201, default 1): 
Using default value 1                 
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201): +50G

Command (m for help): p

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x5ce337a5                           

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1        6528    52436128+  83  Linux 
Partition 1 does not start on physical sector boundary.       

Command (m for help): t
Selected partition 1   
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x5ce337a5                           

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        6528    52436128+  fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.                      

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.                             
root@HO-1-231:~# fdisk /dev/sdd            
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x3c581631.                     
Changes will remain in memory only, until you decide to write them.               
After that, of course, the previous content won't be recoverable.                 

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted. 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to  
         sectors (command 'u').                                         

Command (m for help): p

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x3c581631                           

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action         
   e   extended        
   p   primary partition (1-4)
p                             
Partition number (1-4): 1     
First cylinder (1-243201, default 1): 
Using default value 1                 
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201): +50G

Command (m for help): p

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x3c581631                           

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        6528    52436128+  83  Linux 
Partition 1 does not start on physical sector boundary.       

Command (m for help): t
Selected partition 1   
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x3c581631                           

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        6528    52436128+  fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.                      

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.                             
root@HO-1-231:~# fdisk -l | grep dev
Disk /dev/md0 doesn't contain a Valid partition table
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes        
/dev/sda1               1      243201  1953512001   fd  Linux raid autodetect
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes                                
/dev/sdb1               1      243201  1953512001   fd  Linux raid autodetect
Disk /dev/md0: 2000.4 GB, 2000396222464 bytes                                
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes                                
/dev/sdc1               1        6528    52436128+  fd  Linux raid autodetect
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes                                
/dev/sdd1               1        6528    52436128+  fd  Linux raid autodetect
root@HO-1-231:~# mdadm --create /dev/md1 --verbose --level=raid1 --raid-devices=2 /dev/sdc1 /dec/sdd1
mdadm: Cannot open /dec/sdd1: No such file or directory                                              
mdadm: create aborted                                                                                
root@HO-1-231:~# mdadm --create /dev/md1 --verbose --level=raid1 --raid-devices=2 /dev/sdc1 /dev/sdd1
mdadm: size set to 52436032K                                                                         
mdadm: array /dev/md1 started.                                                                       
root@HO-1-231:~# cat /proc/mdstat                                                                    
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]                
md1 : active raid1 sdd1[1] sdc1[0]                                                                   
      52436032 blocks [2/2] [UU]                                                                     
      [>....................]  resync =  1.1% (599232/52436032) finish=7.2min speed=119846K/sec      
                                                                                                     
md0 : active raid1 sda1[1] sdb1[0]                                                                   
      1953511936 blocks [2/2] [UU]                                                                   
                                                                                                     
unused devices: <none>                                                                               
root@HO-1-231:~# cat /proc/mdstat                                                                    
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]                
md1 : active raid1 sdd1[1] sdc1[0]                                                                   
      52436032 blocks [2/2] [UU]                                                                     
      [>....................]  resync =  1.4% (755520/52436032) finish=9.1min speed=94440K/sec       
                                                                                                     
md0 : active raid1 sda1[1] sdb1[0]                                                                   
      1953511936 blocks [2/2] [UU]                                                                   
                                                                                                     
unused devices: <none>                                                                               
root@HO-1-231:~# cat /proc/mdstat                                                                    
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]                
md1 : active raid1 sdd1[1] sdc1[0]                                                                   
      52436032 blocks [2/2] [UU]                                                                     
      [>....................]  resync =  2.6% (1403328/52436032) finish=8.4min speed=100237K/sec     
                                                                                                     
md0 : active raid1 sda1[1] sdb1[0]                                                                   
      1953511936 blocks [2/2] [UU]                                                                   
                                                                                                     
unused devices: <none>                                                                               
root@HO-1-231:~# cat /proc/mdstat                                                                    
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]                
md1 : active raid1 sdd1[1] sdc1[0]                                                                   
      52436032 blocks [2/2] [UU]                                                                     
      [>....................]  resync =  3.2% (1691072/52436032) finish=9.5min speed=89003K/sec      
                                                                                                     
md0 : active raid1 sda1[1] sdb1[0]                                                                   
      1953511936 blocks [2/2] [UU]                                                                   
                                                                                                     
unused devices: <none>                                                                               
root@HO-1-231:~# cat /proc/mdstat                                                                    
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]                
md1 : active raid1 sdd1[1] sdc1[0]                                                                   
      52436032 blocks [2/2] [UU]                                                                     
      [>....................]  resync =  4.7% (2512256/52436032) finish=10.2min speed=81040K/sec     
                                                                                                     
md0 : active raid1 sda1[1] sdb1[0]                                                                   
      1953511936 blocks [2/2] [UU]                                                                   
                                                                                                     
unused devices: <none>                                                                               
root@HO-1-231:~# cat /proc/mdstat                                                                    
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]                
md1 : active raid1 sdd1[1] sdc1[0]                                                                   
      52436032 blocks [2/2] [UU]                                                                     
      [=========>...........]  resync = 46.1% (24198208/52436032) finish=8.0min speed=58504K/sec     
                                                                                                     
md0 : active raid1 sda1[1] sdb1[0]                                                                   
      1953511936 blocks [2/2] [UU]                                                                   
                                                                                                     
unused devices: <none>                                                                               
root@HO-1-231:~# cat /proc/mdstat                                                                    
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]                
md1 : active raid1 sdd1[1] sdc1[0]                                                                   
      52436032 blocks [2/2] [UU]                                                                     
      [===================>.]  resync = 96.2% (50460544/52436032) finish=0.4min speed=66731K/sec     
                                                                                                     
md0 : active raid1 sda1[1] Sdb1[0]                                                                   
      1953511936 blocks [2/2] [UU]                                                                   
                                                                                                     
unused devices: <none>                                                                               
root@HO-1-231:~# cat /proc/mdstat                                                                    
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]                
md1 : active raid1 sdd1[1] sdc1[0]                                                                   
      52436032 blocks [2/2] [UU]                                                                     
                                                                                                     
md0 : active raid1 sda1[1] sdb1[0]                                                                   
      1953511936 blocks [2/2] [UU]                                                                   
                                                                                                     
unused devices: <none>                                                                               
root@HO-1-231:~# ls /mnt                                                                             
README  cdrecorder/  cdrom/  dvd/  floppy/  hd/  memory/  tmp/  zip/                                 
root@HO-1-231:~# mkdir /mnt/md1                                                                      
root@HO-1-231:~# mount /dev/md1 /mnt/md1                                                             
mount: you must specify the filesystem type                                                          
root@HO-1-231:~# mkfs.xfs -f /dev/md1                                                                
warning: device is not properly aligned /dev/md1                                                     
meta-data=/dev/md1               isize=256    agcount=16, agsize=819313 blks                         
         =                       sectsz=512   attr=2                                                 
data     =                       bsize=4096   blocks=13109008, imaxpct=25                            
         =                       sunit=0      swidth=0 blks                                          
naming   =version 2              bsize=4096   ascii-ci=0                                             
log      =internal log           bsize=4096   blocks=6400, version=2                                 
         =                       sectsz=512   sunit=0 blks, lazy-count=1                             
realtime =none                   extsz=4096   blocks=0, rtextents=0                                  
root@HO-1-231:~# mount /dev/md1 /mnt/md1                                                                
root@HO-1-231:~# mc                                                                                     

root@HO-1-231:/mnt/md1# exit
exit                        

root@HO-1-231:~# cd /mnt/md1
root@HO-1-231:/mnt/md1# ls  
siapsrv/                    
root@HO-1-231:/mnt/md1# ls          
siapsrv/                            
root@HO-1-231:/mnt/md1# cd siapsrv/ 
root@HO-1-231:/mnt/md1/siapsrv# ls  
grub2/  grub2.tar.gz  monmdadm/  postgresql-9.0.4.tar.gz  rc.pg_reload*  rc.pg_start*  rc.pg_stop*
root@HO-1-231:/mnt/md1/siapsrv# mv rc.pg_reload testt                                             
root@HO-1-231:/mnt/md1/siapsrv# ls                                                                
grub2/  grub2.tar.gz  monmdadm/  postgresql-9.0.4.tar.gz  rc.pg_start*  rc.pg_stop*  testt*       
root@HO-1-231:/mnt/md1/siapsrv# md5                                                               
md5pass  md5sum                                                                                   
root@HO-1-231:/mnt/md1/siapsrv# ls                                                                
grub2/  grub2.tar.gz  monmdadm/  postgresql-9.0.4.tar.gz  rc.pg_start*  rc.pg_stop*  testt*       
root@HO-1-231:/mnt/md1/siapsrv# md5sum testt > md5sum                                             
root@HO-1-231:/mnt/md1/siapsrv# ls                                                                
grub2/  grub2.tar.gz  md5sum  monmdadm/  postgresql-9.0.4.tar.gz  rc.pg_start*  rc.pg_stop*  testt*
root@HO-1-231:/mnt/md1/siapsrv# mc                                                                 

root@HO-1-231:/mnt/md1/siapsrv# exit
exit                                

root@HO-1-231:/mnt/md1/siapsrv# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] 
md1 : active raid1 sdd1[1] sdc1[0]                                                    
      52436032 blocks [2/2] [UU]                                                      
                                                                                      
md0 : active raid1 sda1[1] sdb1[0]                                                    
      1953511936 blocks [2/2] [UU]                                                    
                                                                                      
unused devices: <none>                                                                
root@HO-1-231:/mnt/md1/siapsrv# mdadm /dev/md1 --fail /dev/sdc1 --remove /dev/sdc1    
mdadm: set /dev/sdc1 faulty in /dev/md1                                               
mdadm: hot remove failed for /dev/sdc1: Device or resource busy                       
root@HO-1-231:/mnt/md1/siapsrv# cd /                                                  
root@HO-1-231:/# mdadm /dev/md1 --fail /dev/sdc1 --remove /dev/sdc1                   
mdadm: set /dev/sdc1 faulty in /dev/md1                                               
mdadm: hot removed /dev/sdc1                                                          
root@HO-1-231:/# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] 
md1 : active raid1 sdd1[1]                                                            
      52436032 blocks [2/1] [_U]                                                      
                                                                                      
md0 : active raid1 sda1[1] sdb1[0]                                                    
      1953511936 blocks [2/2] [UU]                                                    
                                                                                      
unused devices: <none>                                                                
root@HO-1-231:/# fdisk -l | grep dev                                                  
Disk /dev/md0 doesn't contain a valid partition table                                 
Disk /dev/md1 doesn't contain a valid partition table                                 
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes                                         
/dev/sda1               1      243201  1953512001   fd  Linux raid autodetect         
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes                                         
/dev/sdb1               1      243201  1953512001   fd  Linux raid autodetect         
Disk /dev/md0: 2000.4 GB, 2000396222464 bytes                                         
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes                                         
/dev/sdc1               1        6528    52436128+  fd  Linux raid autodetect         
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes                                         
/dev/sdd1               1        6528    52436128+  fd  Linux raid autodetect         
Disk /dev/md1: 53.7 GB, 53694496768 bytes                                             
root@HO-1-231:/# fdisk /dev/sdc                                                       

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted. 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to  
         sectors (command 'u').                                         

Command (m for help): p

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x5ce337a5                           

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        6528    52436128+  fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.                      

Command (m for help): d
Selected partition 1   

Command (m for help): p

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x5ce337a5                           

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action         
   e   extended        
   p   primary partition (1-4)
p                             
Partition number (1-4): 1
First cylinder (1-243201, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201): +84G

Command (m for help): p

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x5ce337a5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       10968    88092396+  83  Linux
Partition 1 does not start on physical sector boundary.

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x5ce337a5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       10968    88092396+  fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
root@HO-1-231:/# fdisk -l | grep dev
Disk /dev/md0 doesn't contain a valid partition table
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
/dev/sda1               1      243201  1953512001   fd  Linux raid autodetect
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
/dev/sdb1               1      243201  1953512001   fd  Linux raid autodetect
Disk /dev/md0: 2000.4 GB, 2000396222464 bytes
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
/dev/sdc1               1       10968    88092396+  fd  Linux raid autodetect
Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
/dev/sdd1               1        6528    52436128+  fd  Linux raid autodetect
Disk /dev/md1: 53.7 GB, 53694496768 bytes
root@HO-1-231:/#
root@HO-1-231:/# df -h                                                       
Filesystem            Size  Used Avail Use% Mounted on                       
/dev/root             1.9T  165G  1.7T   9% /                                
tmpfs                 7.9G     0  7.9G   0% /dev/shm                         
/dev/md1               50G   25M   50G   1% /mnt/md1                         
root@HO-1-231:/# mdadm /dev/md1 -a /dev/sdc1                                 
mdadm: added /dev/sdc1                                                       
root@HO-1-231:/# cat /proc/mdstat                                            
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] 
md1 : active raid1 sdc1[2] sdd1[1]                                                    
      52436032 blocks [2/1] [_U]                                                      
      [>....................]  recovery =  0.8% (460928/52436032) finish=13.1min speed=65846K/sec
root@HO-1-231:/# cat /proc/mdstat                                                                  
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]              
md1 : active raid1 sdc1[2] sdd1[1]                                                                 
      52436032 blocks [2/1] [_U]                                                                   
      [============>........]  recovery = 61.8% (32446976/52436032) finish=5.1min speed=65110K/sec 
                                                                                                   
md0 : active raid1 sda1[1] sdb1[0]                                                                 
      1953511936 blocks [2/2] [UU]                                                                 
                                                                                                   
unused devices: <none>                                                                             
root@HO-1-231:/# cat /proc/mdstat                                                                  
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]              
md1 : active raid1 sdc1[0] sdd1[1]                                                                 
      52436032 blocks [2/2] [UU]                                                                   
                                                                                                   
md0 : active raid1 sda1[1] sdb1[0]                                                                 
      1953511936 blocks [2/2] [UU]                                                                 
                                                                                                   
unused devices: <none>                                                                             
root@HO-1-231:/# mdadm /dev/md1 --fail /dev/sdd1 --remove /dev/sdd1
mdadm: set /dev/sdd1 faulty in /dev/md1                            
mdadm: hot removed /dev/sdd1                                       
root@HO-1-231:/# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] 
md1 : active raid1 sdc1[0]                                                            
      52436032 blocks [2/1] [U_]                                                      
                                                                                      
md0 : active raid1 sda1[1] sdb1[0]                                                    
      1953511936 blocks [2/2] [UU]                                                    
                                                                                      
unused devices: <none>                                                                
root@HO-1-231:/# fdisk /dev/sdd                                                       

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted. 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to  
         sectors (command 'u').                                         

Command (m for help): p

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x3c581631                           

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        6528    52436128+  fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.                      

Command (m for help): d
Selected partition 1   

Command (m for help): p

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x3c581631                           

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action         
   e   extended        
   p   primary partition (1-4)
p                             
Partition number (1-4): 1     
First cylinder (1-243201, default 1): 
Using default value 1                 
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201): +84G

Command (m for help): p

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x3c581631                           

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       10968    88092396+  83  Linux 
Partition 1 does not start on physical sector boundary.       

Command (m for help): t
Selected partition 1   
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x3c581631                           

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       10968    88092396+  fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.                      

Command (m for help): t
Selected partition 1   
Hex code (type L to list codes): fd

Command (m for help): p

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes   
Disk identifier: 0x3c581631                           

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       10968    88092396+  fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.                      

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.                             
root@HO-1-231:/# mdadm /dev/md1 -a /dev/sdd1
mdadm: added /dev/sdd1 
root@HO-1-231:/# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] 
md1 : active raid1 sdd1[2] sdc1[0]                                                    
      52436032 blocks [2/1] [U_]                                                      
      [===============>.....]  recovery = 76.3% (40046528/52436032) finish=3.1min speed=66193K/sec
                                                                                                  
md0 : active raid1 sda1[1] sdb1[0]                                                                
      1953511936 blocks [2/2] [UU]                                                                
                                                                                                  
unused devices: <none>                                                                            
root@HO-1-231:/# cat /proc/mdstat                                                                 
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]             
md1 : active raid1 sdd1[2] sdc1[0]                                                                
      52436032 blocks [2/1] [U_]                                                                  
      [===================>.]  recovery = 97.1% (50961088/52436032) finish=0.3min speed=68716K/sec
                                                                                                  
md0 : active raid1 sda1[1] sdb1[0]                                                                
      1953511936 blocks [2/2] [UU]                                                                
                                                                                                  
unused devices: <none>                                                                            
root@HO-1-231:/# cat /proc/mdstat                                                                 
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]             
md1 : active raid1 sdd1[1] sdc1[0]                                                                
      52436032 blocks [2/2] [UU]                                                                  
                                                                                                  
md0 : active raid1 sda1[1] sdb1[0]                                                                
      1953511936 blocks [2/2] [UU]                                                                
                                                                                                  
unused devices: <none>                                                                            
root@HO-1-231:/# mdadm --detail /dev/md0 | grep -e 'Array Size' -e 'Device Size'                  
     Array Size : 1953511936 (1863.01 GiB 2000.40 GB)                                             
root@HO-1-231:/# mdadm --detail /dev/md1 | grep -e 'Array Size' -e 'Device Size'                  
     Array Size : 52436032 (50.01 GiB 53.69 GB)                                                   
root@HO-1-231:/# mdadm --detail /dev/md1                                                          
/dev/md1:                                                                                         
        Version : 0.90                                                                            
  Creation Time : Thu Feb  2 20:07:41 2012                                                        
     Raid Level : raid1                                                                           
     Array Size : 52436032 (50.01 GiB 53.69 GB)                                                   
  Used Dev Size : 52436032 (50.01 GiB 53.69 GB)                                                   
   Raid Devices : 2                                                                               
  Total Devices : 2                                                                               
Preferred Minor : 1                                                                               
    Persistence : Superblock is persistent                                                        

    Update Time : Thu Feb  2 21:09:54 2012
          State : clean                   
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : d2a575b9:b98dd42f:473eda47:d8152018
         Events : 0.122

    Number   Major   Minor   RaidDevice State
       0       8       33        0      active sync   /dev/sdc1
       1       8       49        1      active sync   /dev/sdd1
root@HO-1-231:/# mdadm --detail /dev/md1 | grep -e 'Array Size' -e 'Used Dev Size'
     Array Size : 52436032 (50.01 GiB 53.69 GB)
  Used Dev Size : 52436032 (50.01 GiB 53.69 GB)
root@HO-1-231:/# mdadm --grow /dev/md1 -z max
root@HO-1-231:/# mdadm --detail /dev/md1 | grep -e 'Array Size' -e 'Used Dev Size'
     Array Size : 88092288 (84.01 GiB 90.21 GB)
  Used Dev Size : 88092288 (84.01 GiB 90.21 GB)
root@HO-1-231:/# mount
/dev/root on / type xfs (rw,relatime,attr2,noquota)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/md1 on /mnt/md1 type xfs (rw)
root@HO-1-231:/# resize2fs /dev/md1
resize2fs 1.41.11 (14-Mar-2010)
resize2fs: Bad magic number in super-block while trying to open /dev/md1
Couldn't find valid filesystem superblock.
root@HO-1-231:/# mc

root@HO-1-231:/mnt/md1/siapsrv# exit
exit

root@HO-1-231:/# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/root             1.9T  165G  1.7T   9% /
tmpfs                 7.9G     0  7.9G   0% /dev/shm
/dev/md1               50G   25M   50G   1% /mnt/md1
root@HO-1-231:/# xfs_growfs /mnt/md1
meta-data=/dev/md1               isize=256    agcount=16, agsize=819313 blks
         =                       sectsz=512   attr=2
data     =                       bsize=4096   blocks=13109008, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13109008 to 22023072
root@HO-1-231:/# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/root             1.9T  165G  1. T   9% /
tmpfs                 7.9G     0  7.9G   0% /dev/shm
/dev/md1               84G   26M   84G   1% /mnt/md1
root@HO-1-231:/#md5sum -c md5sum

ok

Kamis, 19 Januari 2012

compress

How can I compress a whole directory under Linux / UNIX using a shell prompt?A. It is very easy to compress a Whole Linux/UNIX directory. It is useful to backup files, email all files, or even to send software you have created to friends. Technically, it is called as a compressed archive. GNU tar command is best for this work. It can be use on remote Linux or UNIX server. It does two things for you:
=> Create the archive
=> Compress the archive
You need to use tar command as follows (syntax of tar command):
tar -zcvf archive-name.tar.gz directory-name
Where,
  • -z: Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose i.e display progress while creating archive
  • -f: Archive File name
For example, you have directory called /home/jerry/prog and you would like to compress this directory then you can type tar command as follows:
$ tar -zcvf prog-1-jan-2005.tar.gz /home/jerry/prog
Above command will create an archive file called prog-1-jan-2005.tar.gz in current directory. If you wish to restore your archive then you need to use following command (it will extract all files in current directory):
$ tar -zxvf prog-1-jan-2005.tar.gz
Where,
  • -x: Extract files
If you wish to extract files in particular directory, for example in /tmp then you need to use following command:
$ tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
$ cd /tmp
$ ls -