linux

linux

Senin, 26 Maret 2012

RAID SOFTWARE LINUX

Hemmm...This is only my note.....
create raid software in linux  with mdadm
with this mdadm i can create raid 0,1,10,and 5

prepare the disks,
command for create :
mdadm --create /dev/md0 --verbose --level=[level] --raid-devices=[number of disk] [member disk]
example:
mdadm --create /dev/md0 --verbose --level=raid1 --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm --create /dev/md0 --verbose --level=raid5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

command for state raid :
cat /proc/mdstat
mdadm --detail /dev/md0

example :
root@totok:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md0 : active raid1 nbd1[1] nbd0[0]
1999936 blocks [2/2] [UU]
[=======>.............] resync = 38.7% (777152/1999936) finish=0.3min speed=59780K/sec

root@totok:/mnt# mdadm --detail /dev/md0
Version : 0.90
Creation Time : Sun Oct 31 19:53:26 2010
Raid Level : raid5
Array Size : 5860535808 (5589.04 GiB 6001.19 GB)
Used Dev Size : 1953511936 (1863.01 GiB 2000.40 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Sun Mar 27 21:18:45 2011
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 64K

UUID : 829aacd2:bf52a9d7:f190e036:dc0a4837
Events : 0.36

Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
2 8 33 2 active sync /dev/sdc1
3 8 49 3 active sync /dev/sdd1

 if one memberdisk on the array RAID is fail we can add the new member disk:
mdadm /dev/md0 -a /dev/sda1

this for boot loader  using lilo and grub :
===================
For LILO configuration:
 - When asked about LILO, choose the "simple" setup.
 - When asked about additional "append=" parameters, RAID 0 and
   RAID 5 users should type in "root=/dev/md0", to ensure that the proper
   array is mounted on / at bootup.
 - When asked about where to install LILO, choose MBR.
    Start by switching into your actual installation directory:
 - chroot /mnt

Let's make sure LILO boots from the RAID arrays properly.  Using your
favorite editor (vim/nano/pico), edit /etc/lilo.conf:
 - add a new line (add it anywhere, but don't indent it):
     raid-extra-boot = mbr-only
 - You will need to change the following line:
     boot = <something>
   RAID 0 and RAID 5 users, change it to:
     boot = /dev/md2
   RAID 1 users, change it to:
     boot = /dev/md0
 
 - Save the file and exit your editor.
 - run "lilo".
for Grub :
http://slackbuilds.org/repository/13.1/system/grub2/
download :ftp://alpha.gnu.org/gnu/grub/grub-1.98.tar.gz
          http://slackbuilds.org/slackbuilds/13.1/system/grub2.tar.gz

tar -xvf grub2.tar.gz
mv grub-1.98.tar.gz grub2/
cd grub2
./grub2.SlackBuild
cd /tmp
installpkg grub2-1.98-x86_64-2_SBo.tgz
cat /proc/mdstat
grub-install /dev/md0

berikut ini  pilihan bisa 2 cara :
1.grub-mkconfig -o /boot/grub/grub.cfg
  hasilnya masih kosong...
2.copy grub.cfg
  cp /usr/doc/grub2-1.98/grub.cfg /boot/grub2/
 
saya pilih yang no 2.
edit file grub.cfg jadi :
---------------------------------------------------------------
#
# Sample GRUB configuration file
#

# Boot automatically after 30 secs.
set timeout=10

# By default, boot the first entry.
set default=0

# Fallback to the second entry.
set fallback=1


# For booting GNU/Linux
menuentry "linuxslac_serever" {
        set root='(md0)'
        linux /boot/vmlinuz root=/dev/md0
        initrd
}

# Change the colors.
menuentry "Change the colors" {
        set menu_color_normal=light-green/brown
        set menu_color_highlight=red/blue
}

RAID 10
if you using raid 10 and the raid member are /dev/sda1,/dev/sdb1,/dev/sdc1,/dev/sdd1

for testting
if the fist fisical hdd remove from server the os still running and you can attach the new harddisk on server and then
check for new hdd with fdisk -l | grep dev
and compare with mdadm --detail /dev/md0
for new hdd
fdisk /dev/sdd  create for type is fd ( linux raid autodetect )

and then mdadm /dev/md0 -a /dev/sdd1

and you can see the /dev/md0 rebuild
if the system still rebuilding and you restart the server if the first hdd on bios is new hdd the system would not boot,
for boot up the system you must change the first bios for other old hdd.
when the system up the /dev/md0 will re-building from 0 % ( cat /proc/mdstat )

note : after replace with new disk you must type grub-install /dev/md0 to write
grub.conf to new disk

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