Monday, August 18, 2008

Membuat local repository Ubuntu

Pembuatan local repository akan sangat membantu mengirit bandwidth internet terutama jika komputer di jaringan lokal banyak dan menggunakan distro Ubuntu atau turunan Debian.


Ada banyak cara untuk membuat repository local.
Coba - coba googling, eh dapet yang seperti ini.

Pertama - tama siapkan aplikasi pendukungnya:

$ sudo apt-get install apache2 debmirror

Selanjutnya mulai mendownload package - package repositorinya..

$ sudo debmirror –nosource -m –passive –host=kambing.vlsm.org \
–root=ubuntu/ –method=ftp –progress –dist=breezy \
–section=main,multiverse,universe –arch=i386 /mnt/data/ubuntu/breezy/ –ignore-release-gpg

atau ambil scriptnya di sini.

Bila menggunakan script diatas, jalankan scriptnya:

$ sudo ./debmirror-ubuntu.sh

Maka debmirror akan mulai mendownload package - package.

Untuk penjelasan dari option debmirror yang lebih lengkap dan jelas bisa diliat pada man pagesnya.

Tapi mungkin yang perlu diperhatikan adalah option berikut:

–host=kambing.vlsm.org
Mendonwload package dari mirror. Kalo bisa yang tercepat dan terdekat, kalo ada!! )

–method=ftp
Proses download menggunakan ftp, bisa juga menggunakan http.

–dist=breezy
Package yang didownload adalah untuk breezy. Ganti dapper untuk mendownload package dapper.

–section=main,multiverse,universe
Download package - package pada section main, multiverse dan universe.

–arch=i386
Package yang didownload adalah untuk arsitektur i386.

/mnt/data/ubuntu/breezy/
Direktori tempat menaruh package yang didownload.

Nah, proses ini yang paling lama.
Setelah selesai, buatkan soft link kefolder document root http server Anda.

$ sudo ln -s /mnt/data/ubuntu/ /var/www/

Sampai tahap ini, Anda sudah selesai membuat repository lokal sendiri.
Sekarang tinggal mengkonfigurasi source.list pada /etc/apt/ untuk seluruh client ubuntu pada jaringan lokal agar menuju kepada server repository yang baru dibuat.

$ sudo gedit /etc/apt/source.list

Tambahkan baris berikut:

deb http://ip_server_repo/ubuntu/breezy breezy main multiverse universe

Simpan dan lanjutkan dengan perintah:

$ sudo apt-get update

Selesai. Anda sudah dapat mulai menginstall package - package yang diinginkan.

Tutorial singkat ini diperoleh dari Unofficial Ubuntu Linux Indonesia.


Friday, August 8, 2008

Instalasi Squirrelmail

Siapkan POP3, IMAP & SMTP Server

# apt-get install dovecot-common dovecot-imapd dovecot-pop3d postfix \
squirrelmail squirrelmail-decode

Pastikan dovecot mendukung imap

# vi /etc/dovecot/dovecot.conf
protocols = imap pop3



Restart Dovecot

# /etc/init.d/dovecot restart


Konfigurasi squirrelmail

# cp /etc/squirrelmail/apache.conf /etc/apache2/conf.d/squirrelmail.conf


Konfigurasi Domain Squirrelmail

# /usr/sbin/squirrelmail-configure
2 -> 1 -> domai.id -> R


Restart Squirrelmail

# /etc/init.d/apache2 restart


Webmail dapat di akses melalui

http://ip-address-server/squirrelmail

Konfigurasi IP Address

Edit file /etc/network/interfaces

# vi /etc/network/interfaces



Contoh isi :

Untuk LAN card
IP Dynamic

iface eth0 inet dhcp

IP Static

iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1

Untuk Wireless Card

IP Static
auto wlan0
iface wlan0 inet static
address 192.168.0.2
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
network 10.26.5.0
wireless-essid MYWifi
wireless-mode Managed

Setelah konfigurasi disimpan, lakukan restart network sevice

/etc/init.d/network restart

Checking and Repairing File system with FCSK

Fsck is a Unix utility for checking and repairing file system inconsistencies . File system can become inconsistent due to several reasons and the most common is abnormal shutdown due to hardware failure , power failure or switching off the system without proper shutdown . Due to these reasons the superblock in a file system is not updated and has mismatched information relating to system data blocks, free blocks and inodes .



Modes of operation :

fsck operates in two modes interactive and non interactive :

interactive : the fsck examines the file system and stops at each error it finds in the file system and gives the problem description and ask for user response usually whether to correct the problem or continue without making any change to the file system.

noninteractive :fsck tries to repair all the problems it finds in a file system without stopping for user response useful in case of a large number of inconsistencies in a file system but has the disadvantage of removing some useful files which are detected to be corrupt .

If file system is found to have problem at the booting time non interactive fsck fsck is run and all errors which are considered safe to correct are corrected. But if still file system has problems the system boots in single user mode asking for user to manually run the fsck to correct the problems in file system

Running fsck :

fsck should always be run in a single user mode which ensures proper repair of file system . If it is run in a busy system where the file system is changing constantly fsck may see the changes as inconsistencies and may corrupt the file system .

if the system can not be brought in a single user mode fsck should be run on the partitions ,other than root & usr , after unmounting them . Root & usr partitions can not be unmounted . If the system fails to come up due to root/usr files system corruption the system can booted with CD and root/usr partitions can be repaired using fsck.

command syntax:

fsck [ -F fstype] [-V] [-yY] [-o options] special

-F fstype type of file system to be repaired ( ufs , vxfs etc)

-V verify the command line syntax but do not run the command

-y or -Y Run the command in non interactive mode - repair all errors encountered without waiting for user response.

-o options Three options can be specified with -o flag

b=n where n is the number of next super block if primary super block is corrupted in a file system .

p option used to make safe repair options during the booting process.

f force the file system check regardless of its clean flag.

special - Block or character device name of the file system to be checked/repaired - for example /dev/rdsk/c0t3d0s4 .Character device should be used for consistencies check & repair

phases:

fsck checks the file system in a series of 5 pages and checks a specific functionality of file system in each phase.

** phase 1 - Check Blocks and Sizes

** phase 2 - Check Pathnames

** phase 3 - Check Connectivity

** phase 4 - Check Reference Counts

** phase 5 - Check Cylinder Groups



Error messages & Corrective action :

1.Corrupted superblock - fsck fails to run

If the superblock is corrupted the file system still can be repaired using alternate superblock which are formed while making new file system .

the first alternate superblock number is 32 and others superblock numbers can be found using the following command :

newfs -N /dev/rdsk/c0t0d0s6

for example to run fsck using first alternate superblock following command is used

fsck -F ufs -o b=32 /dev/rdsk/c0t0d0s6

2.Link counter adjustment : fsck finds mismatch between directory inode link counts and actual directory links and prompts for adjustment in case of interactive operation .Link count adjustments are considered to be a safe operation in a file system and should be repaired by giving 'y' response to the adjust ? prompt during fsck.

3.Free Block count salvage : During fsck the number of free blocks listed in a superblock and actual unallocated free blocks count does not match .fsck inform this mismatch and asks to salvage free block count to synchronize the superblock count. This error can be corrected without any potential problem to the file system or files.

4.Unreferenced file reconnection : While checking connectivity fsck finds some inodes which are allocated but not referenced -not attached to any directory . Answering y to reconnect message by fsck links these files to the lost+found directory with their inode number as their name .

To get more info about the files in lost+found 'file' command can be used to see the type of files and subsequently they can be opened in their applications or text editors to find out about their contents. If the file is found to be correct it can be used after copying to some other directory and renaming it.

Next Steps :

The fsck topic here paid a brief visit to some of general aspects of fsck but a detailed document on fsck is comming up to cover most of the error messages and there explanation so watch out if you are looking for more details.

fsck is covered in most of the sysadmin books and you can buy some of the books from amazon.com or besttechbooks.com which is a amazon affiliate site with focus obly on technical books.


Thursday, August 7, 2008

Instalasi FTP Server

Instalasi vsftp server

# apt-get install vsftpd
# chown -Rf root.root /home/ftp

Membuat public directory

# mkdir /home/ftp/pub
# chown -Rf ftp.nogroup /home/ftp/pub


Restart ftp server

# /etc/init.d/vsftpd restart




Wednesday, August 6, 2008

Script buat nge-dump ma restore Database Postgree di linux

Masuk ke konsole linux trus ketikkan script di bawah ini :
- Untuk ngedump database :
pg_dump -Fc -U username dbname > file.sql
- Untuk ngerestorenya :
pg_restore -U username -d dbname file.sql


Membagi dan Menggabungkan File Berukuran Besar Melalui Portal

Ukuran upload file terkadang dibatasi oleh proxy atau hal lain. Jika masalah ini terjadi, salah satu cara yang bisa dilakukan adalah dengan membagi file yang ingin di-upload menjadi beberapa bagian. Secara umum yang dilakukan adalah sebagai berikut:

* Membagi file pada komputer klien dan kemudian meng-uploadnya melalui portal
* Membuat script untuk menggabungkan file
* Menggabungkan kembali file yang sudah dibagi-bagi dengan menggunakan script yang baru saja dibuat



Membagi file dengan perintah ‘split’ dan kemudian meng-upload hasilnya ke portal

1.Cara mudah untuk membagi file dalam lingkungan UNIX adalah dengan menggunakan perintah ‘split’. Pada contoh berikut ini kita akan melakukan pembagian terhadap file berukuran 70mb dengan nama ‘dump.dat’. File dibagi dengan ukuran 20mb masing-masing. Nama file hasil dari pembagian akan memiliki pola ‘partxx’

split -b 20m dump.dat part

2.Login ke portal, kemudian klik tab “Data Manager”. Dari halaman ini upload file-file yang sudah terbagi ke server. Untuk mempermudah proses penggabungan file nantinya, sebaiknya file-file tersebut di-upload ke root directory home pengguna (misal: /export/home/xxx).

Membuat script untuk menggabungkan file

1.Untuk menggabungkan file yang sudah dibagi menggunakan perintah ‘split’ dapat dilakukan dengan menggunakan perintah ‘cat’. Namun sayangnya pemanggilan perintah ‘cat’ melalui portal inGRID tidak bisa disertai dengan simbol ‘>’ untuk redirect output. Oleh karena itu, kita harus membuat script yang bisa melakukan hal ini tanpa memasukkan simbol ‘>’ di portal. Berikut ini adalah contoh script sederhana yang dapat digunakan:

#!/bin/sh
if [ -e joined ]
then
rm joined
fi
while [ $# -gt 0 ]
do
cat $1 >> joined
shift
done

Script ini akan menggabungkan file-file yang dimasukkan sebagai parameter ke dalam sebuah file baru yang bernama “joined”.
2.Simpan script di atas dengan nama gabung.sh kemudian upload ke server melalui portal. Login ke portal, masuk ke halaman “Data Management” dan lakukan seperti ketika kita meng-upload file-file sebelumnya.
3.Ubah permission supaya script gabung.sh ini bisa kita panggil melalui portal. Masuk ke halaman “Data Management”. Pilih file gabung.sh, kemudian klik “Change Permissions”. Beri izin untuk “Execute” bagi “User”.

Menggabungkan kembali file-file yang sudah dibagi-bagi

1.Untuk menggabungkan file yang sudah dibagi-bagi, dapat dilakukan dengan cara mengeksekusi scrpit gabung.sh melalui portal. Masuk ke tab “Job Services”, klik halaman “Generic Jobs”. Kemudian masukkan detail sebagai berikut:

Job Name: gabung
Executables: gabung.sh
Arguments: partaa partab partac partad

Perhatikan bahwa nama executable pada contoh di atas tidak perlu ditambahkan absolute pathnya, karena secara default, direktori kerjanya adalah direktori home dari masing-masing pengguna. Sedangkan untuk arguments, yang dimasukkan adalah nama-nama file yang sudah dibagi sebelumnya.
2.Klik tombol submit, kemudian buka halaman “Job Status”. Perhatikan kondisi pekerjaan “gabung” yang baru saja di-submit. Jika sudah selesai (Done), maka dalam direktori home akan terdapat file baru bernama “joined” yang merupakan hasil gabungan dari file-file yang sudah dipecah sebelumnya.