August 27, 2010
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
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
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
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
feel free to surf my new photoshoot gallery at http://matnet.my
|