Friday, February 22, 2008

Linux TCP load balancing


Maybe some of us need to balance TCP connection through several server. This is a simple way to do so.

1. Download the package
wget http://www.inlab.de/balance-3.40.tar.gz
2. Extract, compile and install:
tar zxvf balance-3.40.tar.gz
cd balance-3.40
vi Makefile
Change this line of code: MANDIR=${BINDIR}/../man/man1
For Ubuntu users : MANDIR=/usr/share/man/man1
For RedHat users: MANDIR=/usr/local/share/man/man1
make
make install
3 Using the load balancer
Here is the network topology used


balance -f http 192.168.0.1 192.168.0.2 192.168.0.3
For http that requires http session we can use
balance -f http 192.168.0.1 192.168.0.2 192.168.0.3 %

We can also use this balancer to balance another tcp traffic such as ftp, etc

This article is taken from linux2.arinet.org

Tuesday, February 19, 2008

Simscan Instalation on QmailRocks

Here is some steps for installing simscan on Linux with QmailRocks Installed:
1. Edit configuration option based on your machine configuration, here is mine
./configure \
--enable-user=qscand \
--enable-clamav \
--enable-clamdscan=/usr/local/bin/clamdscan \
--enable-custom-smtp-reject=y \
--enable-per-domain=y \
--enable-attach=y \
--enable-dropmsg=n \
--enable-spam=y \
--enable-spam-hits=5 \
--enable-spam-passthru=y \
--enable-qmail-queue=/var/qmail/bin/qmail-queue \
--enable-ripmime=/usr/local/bin/ripmime \
--enable-sigtool-path=/usr/local/bin/sigtool \
--enable-received=y

and then run the above configure script

2. Run make && make install-strip

3. fix permissions on the /var/qmail/simscan/ directory
chmod g+s /var/qmail/simscan/

4. Set all mails to be scanned, machine wide by editing /var/qmail/supervise/qmail-smtpd/run
vi /var/qmail/supervise/qmail-smtpd/run

5.
Add the line
QMAILQUEUE="/var/qmail/bin/simscan"; export QMAILQUEUE

6.
Alternatively you can have much greater control by stating which actions to be performed on emails coming from different IP addresses: for instance mine is set to scan ALL mails and is probably the simplest setup.

Edit the /var/qmail/control/simcontrol file and place your options in there:
vi /var/qmail/control/simcontrol

As i said above mine scans ALL mails form ALL IP addrresses with:
:clam=yes,trophie=no,spam=no

7. Run /var/qmail/bin/simscanmk to convert the /var/qmail/control/simcontrol into the /var/qmail/control/simcontrol.cdb file
/var/qmail/bin/simscanmk
/var/qmail/bin/simscanmk -g

8. Restart qmail with
qmailctl restart

Thursday, February 14, 2008

Monitoring Oracle tablespace usage

Maybe some of us need to monitor Oracle tablespace usage on our DB Server. Here is some script that give a report about tablespace usage.

column "Tablespace" format a13
column "Used MB" format 99,999,999
column "Free MB" format 99,999,999
colimn "Total MB" format 99,999,999

select
fs.tablespace_name "Tablespace",
(df.totalspace - fs.freespace) "Used MB",
fs.freespace "Free MB",
df.totalspace "Total MB",
round(100 * (fs.freespace / df.totalspace)) "Pct. Free"
from
(select
tablespace_name,
round(sum(bytes) / 1048576) TotalSpace
from
dba_data_files
group by
tablespace_name
) df,
(select
tablespace_name,
round(sum(bytes) / 1048576) FreeSpace
from
dba_free_space
group by
tablespace_name
) fs
where
df.tablespace_name = fs.tablespace_name;

This script can be set to be run every day (with scheduler or crontab), and the result will be emailed to DBA.

Oracle 9i instalation on CentOS 4.4 Final Release

Here I post a quick tutorial to install Oracle 9i Release 2 on CentOS 4.4 (RHEL 4.4 Clone). You can download oracle 9i from Oracle Website (download.oracle.com) and for the Linux you can download it from official website www.centos.org or from local mirror (centos.cbn.net.id)

Before you can install Oracle, you need to check packets installed on your computer.
- CD 1
xorg-x11-deprecated-libs-6.8.2-1.EL.13.20.i386.rpm
xorg-x11-libs-6.8.2-1.EL.13.20.i386.rpm
xorg-x11-xfs-6.8.2-1.EL.13.20.i386.rpm

- CD 2
alsa-lib-devel-1.0.6-5.RHEL4.i386.rpm
fontconfig-devel-2.2.3-7.i386.rpm
freetype-devel-2.1.9-1.i386.rpm
libjpeg-devel-6b-33.i386.rpm
libtiff-devel-3.6.1-8.i386.rpm
libungif-devel-4.1.3-1.i386.rpm
xorg-x11-6.8.2-1.EL.13.20.i386.rpm
xorg-x11-deprecated-libs-devel-6.8.2-1.EL.13.20.i386.rpm
xorg-x11-devel-6.8.2-1.EL.13.20.i386.rpm

- CD 3
audiofile-devel-0.2.6-1.i386.rpm
esound-devel-0.2.35-2.i386.rpm
libaio-0.3.103-3.i386.rpm
libaio-devel-0.3.103-3.i386.rpm
openmotif21-2.1.30-11.RHEL4.4.i386.rpm

- CD 4
glib-devel-1.2.10-15.i386.rpm
gnome-libs-devel-1.4.1.2.90-44.1.i386.rpm
gtk+-devel-1.2.10-33.i386.rpm
imlib-devel-1.9.13-23.i386.rpm
ORBit-devel-0.5.17-14.i386.rpm

-- Additional packets from oracle
compat-libcwait-2.1-1.i386.rpm
compat-oracle-rhel4-1.0-5.i386.rpm


Here is some steps that I've done:

1. Unzip the oracle using gunzip and cpio
- gunzip ship_9204_linux_disk1.cpio.gz
- cpio -idmv < ship_9204_linux_disk1.cpio
2. Create oracle user and group
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba database
passwd database

3. Create folder in which Oracle will be installed
mkdir /data/oracle
mkdir /data/oracle/9.2.0
chown -R database:oinstall /data/oracle

4. Add this user environment variable on file .bashrc on user's home directory
ORACLE_SID=testdb
ORACLE_BASE=/data/oracle
ORACLE_HOME=/data/oracle/9.2.0
PATH=$ORACLE_HOME/bin:$PATH:.
LD_ASSUME_KERNEL=2.4.19
export ORACLE_SID ORACLE_BASE ORACLE_HOME PATH LD_ASSUME_KERNEL

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH

5. Edit /etc/sysctl.conf file and add those line
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000

after adding those line, check the parameter using this command
/sbin/sysctl -p

6. After those step, you can run runInstaller on the file that you have just extracted
./runInstaller

That is the step to install oracle 9i on CentOS 4.4

This tutorial is taken from http://www.puschitz.com/InstallingOracle9i.shtml