August 27, 2010

NFS on centos

by Matnet @ 3:33 pm in BSD & *NIX

It's been a long time I'm not using NFS.

Today i need to generate a backup for web and mysql, so preferable i save this backup to another HDD on the others place.

Then NFS come out on my head. So here is the simple step to mount network drive for your CENTOS box using NFS


Server IP : 172.31.0.1
Client IP : 172.31.0.2

On the Server
1. Create backup folder

mkdir /backup


2. Edit /etc/exports
vi /etc/exports

add this line
/home/sharing 172.31.0.2/255.255.255.255(rw,sync)


3. Edit /etc/hosts.allow
vi /etc/hosts.allow

add this line
portmap: 172.31.0.0/255.255.255.0


4. Restart NFS and portmap
/etc/init.d/nfs restart
/etc/init.d/portmap restart


On the Client
1. Start portmap
/etc/init.d/portmap start[quote]


2. Edit /etc/fstab and add this line
vi /etc/fstab
172.31.0.1:/backup /mnt/backup nfs rw,hard,intr 0 0


3. mount the nfs
mount 172.31.0.1:/backup /mnt/backup


If you r using CSF as firewall make sure add your server ip address on /etc/csf/csf.allow.

That's all.

June 22, 2010

Postfixadmin autoreply / out of office on REDHAT / Centos

by Matnet @ 11:02 am in BSD & *NIX

Requirement :

# Requirements - the following perl modules are required:
# DBD::Pg or DBD::mysql
# Mail::Sender, Email::Valid MIME::Charset, Log::Log4perl, Log:ispatch, MIME::EncWords and GetOpt::Std

groupadd -r -g 65501 vacation
useradd -r -u 65501 -g vacation -d /var/spool/vacation -s /sbin/nologin vacation
mkdir /var/spool/vacation

cd /var/www/postfixadmin/VIRTUAL_VACATION
cp vacation.pl /var/spool/vacation/vacation.pl
chown -R vacation:vacation /var/spool/vacation
sudo chmod -R 700 /var/spool/vacation

nano /var/spool/vacation/vacation.pl

our $db_type = 'mysql';
our $db_username = 'postfix';
our $db_password = 'yourdbpasswd';
our $db_name = 'postfix';

our $vacation_domain = 'autoreply.yourdomain.com';

cd /var/www/postfixadmin

nano config.inc.php

$CONF['vacation'] = 'YES';
$CONF['vacation_domain'] = 'autoreply.yourdomain.com';


cd /etc/postfix
nano master.cf

Add (near the end of the file):

vacation unix - n n - - pipe
flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient}


nano main.cf

transport_maps = hash:/etc/postfix/transport

nano transport

autoreply.yourdomain.com vacation

postmap /etc/postfix/transport


/etc/init.d/postfix reload

Done.

June 15, 2010

Update multiple rows at once with different conditions.

by Matnet @ 9:59 am in WWW

sebagai contoh - sempena worldcup 2010

Table - gol

negara kekerapan_gol

brazil 10
portugal 11
japan 8


so now kita mau update table gol serentak, bley guna mysql case statement.

UPDATE gol SET

kekerapan_gol = CASE
WHEN negara = 'brazil' THEN '$jumgolbarubrazil'
WHEN negara = 'portugal' THEN '$jumgolbaruportugal'
WHEN negara = 'japan' THEN '$jumgolbarujapan'
ELSE kajian END

May 26, 2010

SQL Substring Function

by Matnet @ 4:56 pm in WWW

The Substring function in SQL is used to grab a portion of the stored data. This function is called differently for the different databases:

* MySQL: SUBSTR(), SUBSTRING()
* Oracle: SUBSTR()
* SQL Server: SUBSTRING()

Example :

Let say u have 2 table from old db.

Table1
userid
name


Table2
userid
password

userid in table1 and userid in table2 is identical but userid in table 1 start with letters T and userid in table 2 is not start with T

for example.

Table1
userid name
1 itik
2 ayam
3 kambing
4 bangau


Table2
userid password
T1 ******
T2 ******
T3 ******
T4 ******

so we need to use sql substring function to erase the T to make it identical.

The query :

Select table1.userid, table1.name, table2,password from table1, table2 WHERE table1.userid = SUBSTR(table2.userid, 2)




November 18, 2009

m.a.t.n.e.t v3 - released

by Matnet @ 5:19 pm in WWW

feel free to surf my new photoshoot gallery at http://matnet.my




:: Shout Me ::



:: About Me ::



They call me : Yachiru
Name : Yachiru Kusajishi
Birthday : February 12
Working Field : Shinigami lieutenant - 11th Division
E-mail : matnet80 [at] yahoo [dot] com


:: Calendar ::

February 2012
S M T W T F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29