Wednesday, August 20, 2008

Load balancing by using Vmware and Linux

Here I will describe load balancing guide using linux with vmware workstation 6



First step is install 1 linux os(I chosed sles 10) and clone 2 more virtual machines of that machine .We will be using 1 virtual gateway and 2 virtual network members.

Then create 2 virtual switches named vmnet8 and bridged.
connect one of the gateway interface thru bridged switch-say eth1- and other to vmnet8.
Give ip address to eth1 as you connect to internet -dhcpd e.g.- and give static ip and netmask to eth0-10.0.0.2/24 e.g.Here eth0 will be our private 10.0.0.0 network's gateway and eth1 will be our wan door.When we generate http 80-or 8080- requests it should route us to the one of the internal zone member's 80.

After installation configure gateway with:

# echo net.ipv4.ip_forward = 1 >> sysctl.conf

and reload sysctl config with :

# sysctl -p
and double-check /proc/sys/net/ipv4/ip_forward it should be 1

Second step is configure our iptables nat rules.Remember we don't have to run iptables as a service if we only want iptables running our nat rules.

Here our basic nat rules:

# iptables -t nat -F // for flushing exising iptables nat rules
# iptables -t nat -I POSTROUTING -j MASQUERADE // create an postrouting masquerade
# iptables -t nat -I PREROUTING -d 136.10.195.84 -p tcp --dport 8080 -j DNAT --to 10.0.0.3:80
// finally route all packages which come from 136.10.195.84 iface(eth1) to 10.0.0.3:80 (our member 1 apache server) via our eth0 iface on the gateway

Test step; run apache server at 10.0.0.3(@ member 1) and try to load 136.10.195.84:8080 see if it's works

Wednesday, February 20, 2008

add a nice user

Add a nice unprivileged user to specific group..

First add a group called lfs

# groupadd lfs
then add a user with valid shell,home,member of group lfs called lfs
# useradd -s /bin/bash -g lfs -m -k /dev/null lfs
-m creates home directory..
-k give alternate /skel dir..if you specify it to /dev/null that means you won't use any preconfig value of user lfs
-g add user to group lfs

that's all..

Thursday, January 3, 2008

Unix kullaniminda hizi arttiran tavsiyeler

Unix kullaniminda konso ortaminda daha hizli ve tekili olmak amaciyla IBM su tavsiyeleri yapiyor(ozetin ozeti):

1-) Ornegin /tmp icerisinde /a/b/c dizinlerinin yaratilmasina ihtiyac duyuroruz.Bunu cd ve mkdir komutlariyla her defasinda bir dizin iceriye girip yeni bir dizin olusturmak yerine:

$mkdir -p tmp/a/b/c
komutuyla kisaca halledebiliriz.Ayrica bu yontemin scriplerdede oldukca etkili oldugundan bahsedilmis;

2-)Herhangibi dizindeki bir .tar arsivini baska bir dizine acmaya ihtiyacimiz var.Bunun icin oncelikle .tar dosyasini o dizine tasiyip, daha sonra .tar arsivini acmamiza gerek yok;

$tar xvf linux.tar -C /tmp/a/b/c

gibi bir komut bize hiz kazandirir.

3-)Bazi kontrol komutlariyla ( || && gibi) komutlar daha komplex ve daha etkili hale gelebilirler;

$ cd /tmp/a/b/c && tar xvf ~/archive.tar

Bu durumda aradaki && operatoru nedeniyle birinci komutun basarisizlikla sonulanmasi
durumunda tar komutu calistirilmaz.Buna benzer /tmp dizini altinda a/b/c dizinlerinin var olup olmadigini ogrenen, yoksa olusturan komut su sekilde olabilir;

$ cd /tmp/a/b/c || mkdir -p /tmp/a/b/c
Bu durumda ilk komut (0) dondurmezse, yani basarisiz olursa mkdir komutu calisir, aksi hakde tam tersi olur..

4-) Gercekten uzun bir komut yazmak durumundasiniz ve o anki kullandiginiz terminalle ilgili maymunluklar yapmak
istemiyorsaniz ifadenizi "\" operatoru ile satirlara bolebilir ve daha az acisin bir komutu gerceklemis olursunuz

$ cd /tmp/a/b/c || \
> mkdir -p /tmp/a/b/c && \
> tar xvf -C /tmp/a/b/c ~/archive.tar
5-) xargs kullanin.Ornegin bir dizindeki tum elemanlarin file komutunun ciktilarina ihtiyaciniz var;

$ls -laF | xargs file

simdilik bu kadar efendim

Registred Linux User

Registred Linux User

HitCounter