(原創)Install Postfix On CentOS 6.0(Minimal)

vi /etc/selinux/config
change
SELINUX=enforcing
to
SELINUX=disabled

reboot

update
yum -y update

useradd -u 1000 jason

passwd jason

vi /etc/ssh/sshd_config
Port 61093
AllowUsers jason

install mysql
yum -y install mysql-server
chkconfig --levels 2345 mysqld on

install apache + php
yum -y install httpd
chkconfig --levels 2345 httpd on
vi /etc/httpd/conf/httpd.conf
ServerName www.jason-tang.com:80

yum -y install php php-gd php-imap php-mbstring php-mysql php-pear php-xml

install named
yum -y install bind
chkconfig --levels 2345 named on
vi /etc/resolv.conf
change to
nameserver 127.0.0.1

vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 61093 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

reboot

install cyrus-sasl
yum -y install cyrus-sasl cyrus-sasl-plain

install Postfix
yum -y install postfix

cp -rp /etc/sasl2/smtpd.conf /etc/sasl2/smtpd.conf.bak
vi /etc/sasl2/smtpd.conf
pwcheck_method:authdaemond
log_level:3
mech_list: PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket

useradd vmail -u 500 -s /sbin/nologin -d /dev/null
mkdir /home/domains
chown -R vmail:vmail /home/domains
chmod -R ug+rwx,o-rwx /home/domains

mkdir /etc/postfix/TLS
cd /etc/postfix/TLS
openssl req -new -x509 -nodes -out smtpd.pem -keyout smtpd.pem -days 3650

Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:Hong Kong
Locality Name (eg, city) [Default City]:Hong Kong
Organization Name (eg, company) [Default Company Ltd]:Jason Tang Ltd
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:Jason Tang
Email Address []:Email住址會使用灌水程式保護機制。你需要啟動Javascript才能觀看它

cd /root

vi /etc/postfix/main.cf
myhostname = mail.jason-tang.com
mydomain = jason-tang.com
myorigin = $mydomain
mydestination = $myhostname localhost localhost.$mydomain
mynetworks = 127.0.0.1/32
inet_interfaces = all

virtual_mailbox_base = /home/domains/
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf

virtual_uid_maps = static:500
virtual_gid_maps = static:500

virtual_transport = maildrop
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1

message_size_limit = 51200000
virtual_mailbox_limit = 209715200
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes

virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes

broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner=$myhostname ESMTP $mail_name ($mail_version)

smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/postfix/TLS/smtpd.pem
smtpd_tls_cert_file = /etc/postfix/TLS/smtpd.pem
smtpd_tls_CAfile = /etc/postfix/TLS/smtpd.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

mime_header_checks = regexp:/etc/postfix/mime_header_checks.regexp

vi /etc/postfix/master.cf
smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

vi /etc/postfix/mysql_virtual_alias_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address
additional_conditions = AND active = '1'

vi /etc/postfix/mysql_virtual_domains_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = domain
select_field = domain
where_field = domain
additional_conditions = AND active = '1'

vi /etc/postfix/mysql_virtual_mailbox_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
additional_conditions = AND active = '1'

vi /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = quota
where_field = username
additional_conditions = AND active = '1'

vi /etc/postfix/mime_header_checks.regexp
/filename=\"?(.*)\.(bat|cmd|com|pif|exe)\"?$/ REJECT

chkconfig --levels 2345 postfix on

install Postfixadmin
yum -y install wget
wget http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-2.3.4/postfixadmin_2.3.4.tar.gz
tar -zxvf postfixadmin_2.3.4.tar.gz
mv postfixadmin-2.3.4 /var/www/html/postfixadmin
chown -R apache:apache /var/www/html/postfixadmin
rm -rf postfixadmin_2.3.4.tar.gz

1. Create the MySQL Tables
mysql -u root
CREATE DATABASE postfix;
GRANT ALL ON postfix.* TO postfix@localhost IDENTIFIED BY "postfix";
exit

2. Configure PostfixAdmin
vi /var/www/html/postfixadmin/config.inc.php
$CONF['configured'] = true;
$CONF['setup_password'] = '856d5eb384038a8bb9293adbd81ee487:8bd0475c6edee8aed00b6b5f336d74e45bc51276';
$CONF['postfix_admin_url'] = 'http://mail.jason-tang.com/postfixadmin';
$CONF['database_type'] = 'mysqli';
$CONF['database_password'] = 'postfix';

$CONF['admin_email'] = Email住址會使用灌水程式保護機制。你需要啟動Javascript才能觀看它';

$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';

$CONF['quota'] = 'YES';

$CONF['mailbox_postcreation_script']='/usr/bin/sudo -u vmail /usr/local/bin/postfixadmin-mailbox-postcreation.sh';
$CONF['mailbox_postdeletion_script']='/usr/bin/sudo -u vmail /usr/local/bin/postfixadmin-mailbox-postdeletion.sh';
$CONF['domain_postdeletion_script']='/usr/bin/sudo -u vmail /usr/local/bin/postfixadmin-domain-postdeletion.sh';

3.http://IP/postfixadmin/setup.php
You should see a list of 'OK' messages.

Setup password      postfixadmin   <-------- Input your Setup password
Admin:              <-------- Input your Email address(Just for postfixadmin)
Password:           <-------- Input your Password
Password (again):   <-------- Input your Password again

And then click "Add Admin"

Admin has been added!

mv /var/www/html/postfixadmin/setup.php /var/www/html/postfixadmin/setup.php.disabled
chmod 000 /var/www/html/postfixadmin/setup.php.disabled

4. Copy .sh files
cp -rp /var/www/html/postfixadmin/ADDITIONS/postfixadmin*.sh /usr/local/bin
chmod 755 /usr/local/bin/postfixadmin*.sh

vi /usr/local/bin/postfixadmin-mailbox-postcreation.sh
change
basedir=/var/spool/maildirs
to
basedir=/home/domains

change
maildirmake "$maildir"
to
/usr/lib/courier-imap/bin/maildirmake "$maildir"

vi /usr/local/bin/postfixadmin-mailbox-postdeletion.sh
change
basedir=/var/spool/maildirs
trashbase=/var/spool/deleted-maildirs
to
basedir=/home/domains
trashbase=/home/domains

vi /usr/local/bin/postfixadmin-domain-postdeletion.sh
change
basedir=/var/spool/maildirs
trashbase=/var/spool/deleted-maildirs
to
basedir=/home/domains
trashbase=/home/domains

5.install sudo
yum -y install sudo fprintd-pam
visudo
#Defaults    requiretty
apache ALL=(vmail) NOPASSWD: /usr/local/bin/postfixadmin-mailbox-postcreation.sh, /usr/local/bin/postfixadmin-mailbox-postdeletion.sh, /usr/local/bin/postfixadmin-domain-postdeletion.sh

install courier-authlib courier-imap maildrop
yum -y install rpm-build make libtool openldap-devel mysql-devel postgresql-devel gdbm-devel pam-devel expect gcc-c++ redhat-rpm-config libtool-ltdl-devel libidn-devel gamin-devel pcre-devel
mkdir /home/jason/courier
cd /home/jason/courier
wget http://downloads.sourceforge.net/project/courier/authlib/0.63.0/courier-authlib-0.63.0.tar.bz2
wget http://downloads.sourceforge.net/project/courier/imap/4.9.3/courier-imap-4.9.3.tar.bz2
wget http://downloads.sourceforge.net/project/courier/maildrop/2.5.4/maildrop-2.5.4.tar.bz2
chown -R jason:jason /home/jason/courier
rpmbuild -ta /home/jason/courier/courier-authlib-0.63.0.tar.bz2
rpm -ivh /root/rpmbuild/RPMS/x86_64/courier-authlib-0.63.0-1.el6.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/courier-authlib-debuginfo-0.63.0-1.el6.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/courier-authlib-devel-0.63.0-1.el6.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/courier-authlib-mysql-0.63.0-1.el6.x86_64.rpm
su jason
rpmbuild -ta /home/jason/courier/courier-imap-4.9.3.tar.bz2
exit
rpm -ivh /home/jason/rpmbuild/RPMS/x86_64/courier-imap-4.9.3-1.x86_64.rpm
rpm -ivh /home/jason/rpmbuild/RPMS/x86_64/courier-imap-debuginfo-4.9.3-1.x86_64.rpm
rm -rf /home/jason/rpmbuild
rpmbuild -ta maildrop-2.5.4.tar.bz2
rpm -ivh /root/rpmbuild/RPMS/x86_64/maildrop-2.5.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/maildrop-devel-2.5.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/maildrop-debuginfo-2.5.4-1.x86_64.rpm

rm -rf /root/rpmbuild

chmod +x /var/spool/authdaemon

vi /etc/authlib/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"

vi /etc/authlib/authmysqlrc
MYSQL_SERVER            localhost
MYSQL_USERNAME          postfix
MYSQL_PASSWORD          postfix
MYSQL_SOCKET            /var/lib/mysql/mysql.sock
MYSQL_DATABASE          postfix
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD     password
MYSQL_UID_FIELD         '500'
MYSQL_GID_FIELD         '500'
MYSQL_LOGIN_FIELD       username
MYSQL_HOME_FIELD        '/home/domains/'
MYSQL_NAME_FIELD        name
MYSQL_MAILDIR_FIELD     maildir
MYSQL_QUOTA_FIELD       concat(quota,'S')
MYSQL_WHERE_CLAUSE      active='1'

chkconfig --levels 2345 courier-authlib on
chkconfig --levels 2345 courier-imap on

vi /etc/postfix/master.cf
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}

vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 465 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 995 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 993 -j ACCEPT

install squirrelmail
cd /home/jason/courier
wget http://downloads.sourceforge.net/project/squirrelmail/stable/1.4.22/squirrelmail-webmail-1.4.22.tar.gz
wget http://downloads.sourceforge.net/project/squirrelmail/locales/1.4.18-20090526/all_locales-1.4.18-20090526.tar.gz
tar -zxvf squirrelmail-webmail-1.4.22.tar.gz
rm -rf squirrelmail-webmail-1.4.22.tar.gz
mv squirrelmail-webmail-1.4.22 /var/www/html/webmail
tar -zxvf all_locales-1.4.18-20090526.tar.gz
rm -rf all_locales-1.4.18-20090526.tar.gz
./install
Please enter path to your squirrelmail installation:/var/www/html/webmail
cp: overwrite `/var/www/html/webmail/help/en_US/options.hlp'? y
cp: overwrite `/var/www/html/webmail/help/en_US/compose.hlp'? y
cp: overwrite `/var/www/html/webmail/help/en_US/search.hlp'? y
cp: overwrite `/var/www/html/webmail/help/en_US/addresses.hlp'? y
cp: overwrite `/var/www/html/webmail/help/en_US/read_mail.hlp'? y
cp: overwrite `/var/www/html/webmail/help/en_US/folders.hlp'? y
cp: overwrite `/var/www/html/webmail/help/en_US/main_folder.hlp'? y
cp: overwrite `/var/www/html/webmail/help/en_US/FAQ.hlp'? y
cp: overwrite `/var/www/html/webmail/help/en_US/basic.hlp'? y

chown -R apache:apache /var/www/html/webmail
/var/www/html/webmail/configure
10->1->zh_TW->2->big5->S->Q

mkdir -p /var/local/squirrelmail/data
mkdir -p /var/local/squirrelmail/attach
chown -R apache:apache /var/local/squirrelmail

rm -rf  /home/jason/courier

vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

reboot

test:
http://IP/postfixadmin
http://IP/webmail

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rm -rf rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

install clamav
yum -y install clamd clamav-milter
vi /etc/clamav-milter.conf
MilterSocketMode 666
AddHeader Replace

chkconfig --levels 2345 sendmail off
chkconfig --levels 2345 postfix on
chkconfig --levels 2345 clamd on
chkconfig --levels 2345 clamav-milter on

install SpamAssassin
yum -y install spamassassin spamass-milter
chkconfig --levels 2345 spamassassin on
chkconfig --levels 2345 spamass-milter on

vi /etc/mail/spamassassin/local.cf
required_hits 5
report_safe 0
rewrite_header Subject *****SPAM*****
use_bayes 1
bayes_auto_learn 1
ok_locales              en zh

vi /etc/postfix/main.cf
milter_connect_macros = b j _ {daemon_name} {if_name} {if_addr}
smtpd_milters =
      unix:/var/clamav/clmilter.socket
      unix:/var/run/spamass.sock
milter_default_action = accept

vi /etc/sysconfig/spamassassin
SPAMDOPTIONS="-u nobody -d -c -m5 -H"

sa-update

chown -R nobody:nobody /root/.spamassassin

vi /etc/rc.d/rc.local
chmod 777 /var/run/spamass.sock
su - root -c "/etc/init.d/spamassassin restart"

reboot

yum -y install perl-MIME-EncWords perl-Email-Valid perl-Mail-Sender perl-Log-Log4perl

wget http://download.fedora.redhat.com/pub/epel/6/i386/perl-MIME-Charset-1.006.2-3.el6.noarch.rpm
rpm -ivh perl-MIME-Charset-1.006.2-3.el6.noarch.rpm
rm -rf perl-MIME-Charset-1.006.2-3.el6.noarch.rpm

1. Create a local account
groupadd vacation -g 501
useradd vacation -u 501 -g 501 -s /sbin/nologin -d /nonexistent -c "Virtual Vacation"

2. Create a directory
mkdir /var/spool/vacation

3. Copy the files
cp -rp /var/www/html/postfixadmin/VIRTUAL_VACATION/vacation.pl /var/spool/vacation
vi /var/spool/vacation/vacation.pl
my $db_type = 'mysql';

my $db_username = 'postfix';
my $db_password = 'postfix';
my $db_name     = 'postfix';

our $vacation_domain = 'autoreply.jason-tang.com';

chown -R vacation:vacation /var/spool/vacation
chmod -R 700 /var/spool/vacation

4. Setup the transport type
vi /etc/postfix/master.cf
vacation  unix  -       n       n       -       -       pipe
  flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient}

vi /etc/postfix/main.cf
transport_maps = hash:/etc/postfix/transport

cp -rp /etc/postfix/transport /etc/postfix/transport.bak
vi /etc/postfix/transport
autoreply.jason-tang.com       vacation

postmap /etc/postfix/transport
/etc/init.d/postfix restart

5. Postfixadmin Setting
vi /var/www/html/postfixadmin/config.inc.php
$CONF['vacation'] = 'YES';
$CONF['vacation_domain'] = 'autoreply.jason-tang.com';
$CONF['vacation_control'] ='YES';
$CONF['vacation_control_admin'] = 'YES';

(原創)Drqueue + MAYA 2011 On CentOS 5.5

yum -y update

vi  /etc/hosts
192.168.10.242 master.jason-tang.com master
192.168.10.234 slave1.jason-tang.com slave1
192.168.10.244 slave2.jason-tang.com slave2

yum -y install mysql-devel pygtk2-devel libXp

wget http://downloads.sourceforge.net/project/scons/scons/1.3.1/scons-1.3.1-1.noarch.rpm
rpm -ivh scons-1.3.1-1.noarch.rpm

mkdir /usr/local/drqueue

vi /etc/exports
/usr/local/drqueue 192.168.10.0/255.255.255.0(rw,no_root_squash,sync)
/usr/autodesk 192.168.10.0/255.255.255.0(rw,no_root_squash,sync)

vi /etc/hosts.allow
ALL : ALL : allow
portmap: 192.168.10.0/255.255.0.0 : allow

/sbin/chkconfig --levels 235 nfs on
/sbin/chkconfig --levels 235 portmap on
/etc/init.d/nfs restart
/etc/init.d/portmap restart

service iptables stop
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
service iptables save
service iptables restart

reboot

cd /root
mkdir git
cd git
wget http://packages.sw.be/git/git-1.7.3-1.el5.rf.i386.rpm
wget http://packages.sw.be/git/git-1.7.3-1.el5.rf.x86_64.rpm
wget http://packages.sw.be/git/perl-Git-1.7.3-1.el5.rf.i386.rpm
wget http://packages.sw.be/git/perl-Git-1.7.3-1.el5.rf.x86_64.rpm
rpm -ivh *.rpm

cd /root
git clone https://ssl.drqueue.org/git/drqueue.git
cd ./drqueue
scons install

vi /usr/local/drqueue/etc/master.conf
logs=/usr/local/drqueue/logs
tmp=/usr/local/drqueue/tmp
db=/usr/local/drqueue/db
bin=/usr/local/drqueue/bin
etc=/usr/local/drqueue/etc

vi /usr/local/drqueue/etc/slave.conf
logs=/usr/local/drqueue/logs
tmp=/usr/local/drqueue/tmp
pool=Default,maya,blender

vi /usr/local/drqueue/etc/drqman.conf
logs=/usr/local/drqueue/logs
tmp=/usr/local/drqueue/tmp
db=/usr/local/drqueue/db

vi /root/.bashrc
PATH=${PATH}:/usr/local/drqueue/bin
export PATH

export DRQUEUE_ROOT=/usr/local/drqueue
export DRQUEUE_MASTER=192.168.10.242

vi /etc/rc.d/rc.local
PATH=${PATH}:/usr/local/drqueue/bin
export PATH

export DRQUEUE_ROOT=/usr/local/drqueue
export DRQUEUE_MASTER=192.168.10.242

/usr/local/drqueue/bin/master &

安裝 Maya license server
cd /root
wget http://images.autodesk.com/adsk/files/inux64_licenseserver_11.7.rpm
rpm -ivh inux64_licenseserver_11.7.rpm

用winscp upload file maya2011.lic 到 /opt/flexnetserver

改linux 的 MAC 跟 maya2011.lic 相同及boot機時 start Maya license service
vi /etc/rc.d/rc.local
ifconfig eth0 hw ether 00:30:48:9E:71:78
/etc/init.d/network restart
/opt/flexnetserver/lmgrd -c /opt/flexnetserver/maya2011.lic -L /var/log/debug.log

安裝 Maya 2011
安裝 Maya 2011 前,先看Maya license server是否正常運作,若沒有的話可用下一行使Maya license server正常運作.
/opt/flexnetserver/lmgrd -c /opt/flexnetserver/maya2011.lic -L /var/log/debug.log

用winscp upload Maya 2011(Linux 64 bit) 到 Master 及到安裝 Path
chmod 755 setup
./setup

vi /usr/local/drqueue/etc/maya_sg.py
改:
ENGINE_PATH="Render"
為:(不同版本的Maya path 可能不同)
ENGINE_PATH="/usr/autodesk/maya2011-x64/bin/Render"

安裝 DrQueueOnRails

cd /root
mkdir ruby
cd ruby
wget ftp://ftp.ruby-lang.org//pub/ruby/1.8/ruby-1.8.7-p302.tar.gz
tar -xvf ruby-1.8.7-p302.tar.gz
cd ruby-1.8.7-p302
./configure
make
make install

cd /root
mkdir rubygems
cd rubygems
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar -zxf rubygems-1.3.7.tgz
cd rubygems-1.3.7
ruby setup.rb

yum -y remove ImageMagick
yum -y install ghostscript-devel lcms-devel libtiff-devel freeglut
cd /root
mkdir ImageMagick
cd ImageMagick
wget http://dev.centos.org/centos/5/testing/x86_64/RPMS/jasper-1.900.1-2.el5.centos.x86_64.rpm
wget http://dev.centos.org/centos/5/testing/x86_64/RPMS/jasper-devel-1.900.1-2.el5.centos.x86_64.rpm
rpm -ivh jasper-*.rpm
wget http://www.imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-6.6.7-9.x86_64.rpm
wget http://www.imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-c++-6.6.7-9.x86_64.rpm
wget http://www.imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-c++-devel-6.6.7-9.x86_64.rpm
wget http://www.imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-debuginfo-6.6.7-9.x86_64.rpm
wget http://www.imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-devel-6.6.7-9.x86_64.rpm
wget http://www.imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-doc-6.6.7-9.x86_64.rpm
wget http://www.imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-perl-6.6.7-9.x86_64.rpm
rpm -ivh ImageMagick-*.rpm

ln -s /usr/lib64/libltdl.so.3.1.4  /usr/lib64/libltdl.so

gem sources -a http://gemcutter.org
gem sources -a http://gems.rubyforge.org
gem sources -a http://gems.github.com
gem update --system
gem install -v=2.3.8 rails
gem install ruby-net-ldap
gem install rmagick
gem install mislav-will_paginate
gem install mongrel
gem install DrQueueRubyBindings
gem install mysql

useradd drqueueonrails
rm -rf /home/drqueueonrails
cd /home
git clone https://ssl.drqueue.org/git/DrQueueOnRails.git DrQueueOnRails
mv /home/DrQueueOnRails /home/drqueueonrails
chown -R drqueueonrails:drqueueonrails /home/drqueueonrails
cd /home/drqueueonrails
ruby ./DrQueueOnRails_requirements_check.rb

/sbin/chkconfig --levels 235 mysqld on
/etc/init.d/mysqld restart
mysql
mysql>CREATE DATABASE drqueueonrails;
mysql>GRANT ALL ON drqueueonrails.* TO 'drqueueonrails'@'localhost' IDENTIFIED BY 'drqueueonrails';
mysql>quit

cp -rp /home/drqueueonrails/config/database.yml.example /home/drqueueonrails/config/database.yml
vi /home/drqueueonrails/config/database.yml
development:
  adapter: mysql
  database: drqueueonrails
  username: drqueueonrails
  password: drqueueonrails

cp -rp /home/drqueueonrails/config/environment.rb.example /home/drqueueonrails/config/environment.rb
vi /home/drqueueonrails/config/environment.rb
ENV['RAILS_ENV'] ||= 'development'

 

######## BEGIN DQOR CONFIG


# DrQueue variables
ENV['DRQUEUE_MASTER'] ||= 'MASTER'
ENV['DRQUEUE_TMP'] ||= '/usr/local/drqueue/tmp'
ENV['DRQUEUE_ETC'] ||= '/usr/local/drqueue/etc'
ENV['DRQUEUE_LOGS'] ||= '/usr/local/drqueue/logs'

# LDAP variables
#ENV['LDAP_TREEBASE'] ||= "dc=drqueue, dc=org"
#ENV['LDAP_HOST'] ||= "SERVER"
#ENV['LDAP_PORT'] ||= "389"
#ENV['LDAP_FILTER'] ||= "uid"
#ENV['LDAP_ATTRS'] ||= "mail,cn"

# protocol for webserver (HTTP, HTTPS)
ENV['WEB_PROTO'] ||= "http"

# user status, quota (disk space in GB), job priorities
ENV['USER_STATUS'] ||= "demo,student,advanced,admin"
ENV['USER_QUOTA'] ||= "0.5,5,15,35"
ENV['USER_PRIO'] ||= "100,500,750,1000"
ENV['USER_ADMIN_PW'] ||= "changeme"

# text for login dialog
ENV['LOG_SHOW_USER'] ||= "account name"
ENV['LOG_SHOW_PW'] ||= "password"

# owner and group of DrQueueOnRails instance
ENV['DQOR_USER'] ||= "drqueueonrails"
ENV['DQOR_GROUP'] ||= "drqueueonrails"

rake db:migrate

mkdir /usr/local/drqueue/tmp/user_filecache
mkdir /usr/local/drqueue/tmp/dist_filecache


vi /etc/rc.d/rc.local
su - drqueueonrails -c "/usr/local/bin/ruby /home/drqueueonrails/script/server >> /dev/null &"


reboot

其他節點 server
yum -y update
yum -y install libXp

vi /etc/hosts
192.168.10.242 master.jason-tang.com master
192.168.10.234 slave1.jason-tang.com slave1
192.168.10.244 slave2.jason-tang.com slave2

mkdir /usr/local/drqueue
mkdir /usr/autodesk

vi /root/.bashrc
PATH=${PATH}:/usr/local/drqueue/bin
export PATH

export DRQUEUE_ROOT=/usr/local/drqueue
export DRQUEUE_MASTER=192.168.10.242

vi /etc/rc.d/rc.local
mount 192.168.10.242:/usr/local/drqueue /usr/local/drqueue
mount 192.168.10.242:/usr/autodesk /usr/autodesk

PATH=${PATH}:/usr/local/drqueue/bin
export PATH

export DRQUEUE_ROOT=/usr/local/drqueue
export DRQUEUE_MASTER=192.168.10.242

/usr/local/drqueue/bin/slave &

reboot

(源自網絡)Linux Software RAID 1 實作

Linux Software RAID 1 實作
於單顆硬碟的系統加上另一顆硬碟, 做成 Software RAID 1
狀況測試:
指令熱插拔
摘除一顆硬碟
掛回摘除的硬碟
摘除其中一顆硬碟, 以另一顆全新硬碟取代
取消 Software RAID 1, 回到最原始的單顆硬碟環境
環境
Fedora Core 6 (on VMware Server)
/etc/sysconfig/selinux → SELINUX=disabled
fdisk -l
Disk /dev/sda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         456     3662788+  83  Linux
/dev/sda2             457         521      522112+  82  Linux swap / Solaris
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
(第二顆硬碟是空的, 尚未分割磁區)操作步驟
#安裝所需工具
yum -y install mkinitrd mdadm
#將第一顆硬碟的磁碟分割表複製給第二顆硬碟
sfdisk -d /dev/sda | sfdisk /dev/sdb
fdisk -l
Disk /dev/sda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         456     3662788+  83  Linux
/dev/sda2             457         521      522112+  82  Linux swap / Solaris
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1         456     3662788+  83  Linux
/dev/sdb2             457         521      522112+  82  Linux swap / Solarisfdisk /dev/sdb
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)
Command (m for help): w
#清除 RAID superblock
mdadm --zero-superblock /dev/sdb1
mdadm --zero-superblock /dev/sdb2
#Fedora Core 6 預設只有 /dev/md0, 但我們有兩個 partition, 所以手動再建一個 md1
mknod /dev/md1 b 9 1
#建立 RAID 1
mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb2
#查看 RAID 狀態: RAID 1 已經建立, 目前只有 /dev/sdb 掛入 ARRAY
cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb2[1]
      522048 blocks [2/1] [_U]
     
md0 : active raid1 sdb1[1]
      3662720 blocks [2/1] [_U]
     
unused devices: <none>#產生 RAID 設定檔
cp /usr/share/doc/mdadm-2.5.4/mdadm.conf-example /etc/mdadm.conf
mdadm --examine --scan >> /etc/mdadm.conf
#格式化第二顆硬碟的磁區, 並將第二顆硬碟的 root ( / ) 掛載到 /mnt/md0
mkfs.ext3 /dev/md0
mkswap /dev/md1
mkdir /mnt/md0
mount /dev/md0 /mnt/md0
#修改相關設定, 準備以第二顆硬碟 (/dev/md0) 開機
vi /etc/fstab
/dev/md0 / ext3 defaults 1 1
/dev/md1 swap swap defaults 0 0
vi /boot/grub/menu.lst
default=0
timeout=5
title Fedora Core (2.6.18-1.2798.fc6)
 root (hd1,0)
 kernel /boot/vmlinuz-2.6.18-1.2798.fc6 ro root=/dev/md0
 initrd /boot/initrd-2.6.18-1.2798.fc6-raid.img
#將 Software RAID Module 載入 initrd.img
mkinitrd --preload raid1 /boot/initrd-`uname -r`-raid.img `uname -r`
#將第一顆硬碟裡的資料全數複製到第二顆硬碟
cp -ax / /mnt/md0
#將 GRUB 寫入第二顆硬碟
grub
grub>root (hd1,0)
grub>setup (hd1)
grub>quit
reboot
#將第一顆硬碟的 Partition Type 改為 Linux RAID
fdisk /dev/sda
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)
Command (m for help): w
#把第一顆硬碟的磁區加入 RAID
mdadm --add /dev/md1 /dev/sda2
mdadm --add /dev/md0 /dev/sda1
#監看 RAID Recovery 的進度
watch cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda2[0] sdb2[1]
      522048 blocks [2/2] [UU]
     
md0 : active raid1 sda1[2] sdb1[1]
      3662720 blocks [2/1] [_U]
      [=>...................]  recovery =  9.7% (358400/3662720) finish=4.4min speed=12360K/sec
     
unused devices: <none>
完成後↓
Personalities : [raid1]
md1 : active raid1 sda2[0] sdb2[1]
      522048 blocks [2/2] [UU]
md0 : active raid1 sda1[0] sdb1[1]
      3662720 blocks [2/2] [UU]
unused devices: <none>
#修改 GRUB root device
#其實完成 RAID 1 後, 不管是 root (hd0,0) 還是 root (hd1,0) 都能開機, 但改成 hd0 較好, 因為若其中有一顆掛點, 只剩一顆硬碟開機的時候, 那顆硬碟就是 hd0 啦!
vi /boot/grub/menu.lst
default=0
timeout=5
title Fedora Core (2.6.18-1.2798.fc6)
 root (hd0,0)
 kernel /boot/vmlinuz-2.6.18-1.2798.fc6 ro root=/dev/md0
 initrd /boot/initrd-2.6.18-1.2798.fc6-raid.img
狀況測試
指令熱插拔:
mdadm --manage /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1
mdadm --add /dev/md0 /dev/sdb1
watch cat /proc/mdstat 觀察 recovery 進度
 
摘除其中一顆硬碟, 開機後一樣可以正常運作
 
掛回剛剛摘除的硬碟, 開機後查看 /proc/mdstat, 把缺少的那顆再掛載進來:
例如: mdadm --add /dev/md0 /dev/sda1
掛載後, cat /proc/mdstat 可看到系統正在進行 recovery
 
摘除其中一顆硬碟, 以另一顆全新硬碟取代 (新硬碟當第二顆), 開機後執行:
sfdisk -d /dev/sda | sfdisk /dev/sdb
mdadm --add /dev/md1 /dev/sdb2
mdadm --add /dev/md0 /dev/sdb1
watch cat /proc/mdstat 靜候 recovery 作業完成
附錄: 取消 RAID 1, 回到最原始的單顆硬碟環境
#設定以第二顆硬碟開機
vi /boot/grub/menu.lst
default=0
timeout=5
title Fedora Core (2.6.18-1.2798.fc6)
 root (hd1,0)
 kernel /boot/vmlinuz-2.6.18-1.2798.fc6 ro root=/dev/sdb1
 initrd /boot/initrd-2.6.18-1.2798.fc6.img (不是 -raid 那個)
vi /etc/fstab
/dev/sdb1 / ext3 defaults 1 1
/dev/sdb2 swap swap defaults 0 0
#刪除 Software RAID 設定檔
rm /etc/mdadm.conf
#所有的 partition 都改回 83 (linux)、82 (swap)
fdisk /dev/sda && fdisk /dev/sdb
reboot
#清除 RAID superblock
mdadm --zero-superblock /dev/sda1
mdadm --zero-superblock /dev/sda2
mount /dev/sda1 /mnt
chroot /mnt
#改回以第一顆硬碟開機
vi /etc/fstab
/dev/sda1 / ext3 defaults 1 1
/dev/sda2 swap swap defaults 0 0
vi /boot/grub/menu.lst
default=0
timeout=5
title Fedora Core (2.6.18-1.2798.fc6)
 root (hd0,0)
 kernel /boot/vmlinuz-2.6.18-1.2798.fc6 ro root=/dev/sda1
 initrd /boot/initrd-2.6.18-1.2798.fc6.img
exit

(源自網絡)P2V實體轉虛擬

參考
http://wiki.osslab.org.tw/實驗專案/Virtualization/VMware_Infrastructure_3/Advanced/P2V

P2V 是Physical-to-virtual縮寫,代表將實體機器轉換成虛擬機的方法

參考
http://www.vmware.com/products/converter/faqs.html

熱備份
不關機影響原有服務狀況下,對運作中OS做P2V轉換

冷備份
須脫離原有運作OS,從啟進入專用備份系統與軟體.

1.冷開機P2V 有下面種方法

  一. 以Besr 或Trueimage 正版做備份

  二. 啟動VMware P2V( VMware vCenter Converter ) BootCD 2.12   Boot ISO  (需要正版授權)

2.熱開機P2V

   一.使用免費Converter 軟體,可適用於 Linux/Windows OS。
       最新版本 Converter Installer for Windows Version 4.0.1 | 161434 - 05/21/09
        http://www.vmware.com/products/converter/get.html

   二.以試用版Besr 做轉換. 目前最佳方式
       方法
       本站相關介紹


FAQ
使用 Converter 做完 P2V 後,如何移除 Windows(guest os) 原先安裝的 HP Proliant Support Pack(PSP) 的那些 agent 工具
Ans:
請參考 VMware 討論串:Anyone have a script to remove all the HP/Compaq agents after conversion

原系統為 Linux + IDE 硬碟安裝,目的端為 ESX Server,做完 P2V 後無法開機
(用專業軟體 Linux Besr 軟體是否可以解決這問題 待測)

原因:這是因為 ESX 的 VM 只支援 SCSI 虛擬硬碟,當作完 P2V 程序後,原始的實體 IDE 硬碟會被轉換為虛擬的 SCSI 硬碟,但 Linux 仍是 IDE 的設定,所以若不作手動修改,是無法正常開機的。

解決:就 Linux 的標準開機流程,要修改 IDE 為 SCSI 的設定大致可分為兩個部份,一為 Boot Loader 也就是 Grub,另一個則是開機時的 SCSI 驅動。
要執行下列的操作,因為此時系統是無法開機的,所以請使用可開機的 Linux 系統光碟檔,例如 Ubuntu Live CD、Knoppix、SystemRescue CD,或者也可以用 RedHat 安裝光碟,以 Rescue 模式操作。本例是以 SystemRescue CD 為主要救援工具,此工具的取得及說明,請參考官網。

第一部份)
在 VM 設定掛上 SystemRescue CD 光碟檔,並使其由光碟開機,進入 Shell 模式後,

//找出系統目前的磁碟名稱
#>fdisk -l

//手動寫入 MRR
#>grub
grub>root (hd0,0)
grub>setup (hd0)
grub>quit

PS. 在 root (hd0,0) 設定,要選擇正確的 /boot 磁區位置。

第二部份)
如果完成第一部份後,仍無法正常開機,請繼續下一步。
在 VM 設定掛上 SystemRescue CD 光碟檔,並使其由光碟開機,進入 Shell 模式後,

//修改系統的設定為支援 SCSI 磁碟
//列出各磁區位置,並正確識別每個磁區的用途
#>fdisk -l

sda1 --> /boot
sda2 --> swap
sda3 --> /

//掛載系統的 / 及 /boot 磁區
#>mkdir /mnt/sda1
#>mkdir /mnt/sda3
#>mount /dev/sda3 /mnt/sda3
#>mount /dev/sda1 /mnt/sda3/boot

//執行 chroot 變換根目錄
#>chroot /mnt/sda3

//重建可支援 SCSI 的開機映像檔
#>vi /etc/modules.conf

*加上這一行
alias scsi_hostadapter mptscsih

#>cd /boot
#>mkinitrd initrd-x.x.x-x-vm.img x.x.x-x

PS. x.x.x-x 這是實際系統的核心版號。

//離開,重開機試試
#>sync;sync;sync
#>exit
#>reboot

系統做完 P2V 後,開機出現 Kernel panic - not syncing: Attempted to kill init!
解決方法:

- Virtual machine does not boot after being converted from a physical RedHat machine
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002402

- Troubleshooting the boot failure of a Linux virtual machine converted from a physical computer
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1010241

(源自網絡)Amanda(BackUp SoftWare)的安裝與設定

Amanda的安裝與設定(新版,用HardDisk):
================================

1) 設定Client
2) 設定Server
3) 取回data


 1.設定Client (需要做Backup的電腦):
==================================
1) 使用yum install
yum install amanda
yum install amanda-client
2) Setting
a.修改/etc/xinetd.d/中amanda,使其disable設為no,然後使xientd reload一次.
b.修改"/var/lib/amanda/.amandahosts ",使server可連接到本電腦進行backup.如可讓backup.abc.com server上的amanda user可以backup 本機,則在.amandahosts裡加上:
  backup.abc.com amada
c.使Server的ip地址和host name可相互對應,即可以ip地址找到其host name,以host nameip找到其地址.
d.iptables 中開通 1024-65534 端口


 2.設定Server:
1) 使用yum install
yum install amanda
yum install amanda-server
yum install amanda-devel
yum install amanda-client
2) Setting
a.修改/etc/amanda/DailySet1/amanda.conf.(可參考sample)
vi /etc/amanda/DailySet1/amanda.conf
#
# amanda.conf - sample Amanda configuration file.  This started off life as
#               the actual config file in use at CS.UMD.EDU.
#
# If your configuration is called, say, "csd", then this file normally goes
# in /etc/amanda/csd/amanda.conf.
#

org "ns1_DailySet1"  # your organization name for reports
mailto "Email住址會使用灌水程式保護機制。你需要啟動Javascript才能觀看它"  # space separated list of operators at your site
dumpuser "amanda" # the user to run dumps under

inparallel 4  # maximum dumpers that will run in parallel
netusage  600 Kbps # maximum net bandwidth for Amanda, in KB per sec

dumpcycle 1 days # the number of days in the normal dump cycle
runspercycle 1 days    # the number of amdump runs in dumpcycle days
tapecycle 3 tapes # the number of tapes in rotation
   # 4 weeks (dumpcycle) times 5 tapes per week (just
   # the weekdays) plus a few to handle errors that
   # need amflush and so we do not overwrite the full
   # backups performed at the beginning of the previous
   # cycle
### ### ###
# WARNING: don't use `inf' for tapecycle, it's broken!
### ### ###

bumpsize 20 Mb  # minimum savings (threshold) to bump level 1 -> 2
bumpdays 1  # minimum days at each level
bumpmult 4  # threshold = bumpsize * bumpmult^(level-1)

etimeout 300  # number of seconds per filesystem for estimates.
#etimeout -600  # total number of seconds for estimates.
# a positive number will be multiplied by the number of filesystems on
# each host; a negative number will be taken as an absolute total time-out.
# The default is 5 minutes per filesystem.
   

# Specify tape device and/or tape changer.  If you don't have a tape
# changer, and you don't want to use more than one tape per run of
# amdump, just comment out the definition of tpchanger.

# Some tape changers require tapedev to be defined; others will use
# their own tape device selection mechanism.  Some use a separate tape
# changer device (changerdev), others will simply ignore this
# parameter.  Some rely on a configuration file (changerfile) to
# obtain more information about tape devices, number of slots, etc;
# others just need to store some data in files, whose names will start
# with changerfile.  For more information about individual tape
# changers, read docs/TAPE.CHANGERS.

# At most one changerfile entry must be defined; select the most
# appropriate one for your configuration.  If you select man-changer,
# keep the first one; if you decide not to use a tape changer, you may
# comment them all out.

runtapes 1  # number of tapes to be used in a single run of amdump
#tpchanger "chg-manual" # the tape-changer glue script
tpchanger "chg-multi"
#tapedev "/dev/nst1" # the no-rewind tape device to be used
#rawtapedev "/dev/null" # the raw device to be used (ftape only)
#changerfile "/var/lib/amanda/DailySet1/changer"
#changerfile "/var/lib/amanda/DailySet1/changer-status"
changerfile "/etc/amanda/DailySet1/changer.conf"
#changerdev "/dev/null"

tapetype HARD-DISK  # what kind of tape it is (see tapetypes below)
labelstr "^DailySet2[0-9][0-9]*$" # label constraint regex: all tapes must match

# Specify holding disks.  These are used as a temporary staging area for
# dumps before they are written to tape and are recommended for most sites.
# The advantages include: tape drive is more likely to operate in streaming
# mode (which reduces tape and drive wear, reduces total dump time); multiple
# dumps can be done in parallel (which can dramatically reduce total dump time.
# The main disadvantage is that dumps on the holding disk need to be flushed
# (with amflush) to tape after an operating system crash or a tape failure.
# If no holding disks are specified then all dumps will be written directly
# to tape.  If a dump is too big to fit on the holding disk than it will be
# written directly to tape.  If more than one holding disk is specified then
# they will all be used round-robin.

holdingdisk hd1 {
    comment "main holding disk"
    directory "/home/amanda/DailySet1" # where the holding disk is
    use -1 Gb  # how much space can we use on it
   # a negative value mean:
   #        use all space except that value
    chunksize 10 Gb  # size of chunk if you want big dump to be
   # dumped on multiple files on holding disks
   #  N Kb/Mb/Gb split disks in chunks of size N
   #  0          split disks in INT_MAX/1024 Kb chunks
   # -N Kb/Mb/Gb dont split, dump larger
   #             filesystems directly to tape
   #             (example: -2 Gb)
    }
#holdingdisk hd2 {
#    directory "/dumps2/amanda"
#    use 1000 Mb
#    }
#holdingdisk hd3 {
#    directory "/mnt/disk4"
#    use 1000 Mb
#    }


# If amanda cannot find a tape on which to store backups, it will run
# as many backups as it can to the holding disks.  In order to save
# space for unattended backups, by default, amanda will only perform
# incremental backups in this case, i.e., it will reserve 100% of the
# holding disk space for the so-called degraded mode backups.
# However, if you specify a different value for the `reserve'
# parameter, amanda will not degrade backups if they will fit in the
# non-reserved portion of the holding disk.

# reserve 30 # percent


# This means save at least 30% of the holding disk space for degraded
# mode backups. 

# Amanda needs a few Mb of diskspace for the log and debug files,
# as well as a database.  This stuff can grow large, so the conf directory
# isn't usually appropriate.  Some sites use /usr/local/var and some /usr/adm.
# Create an amanda directory under there.  You need a separate infofile and
# logdir for each configuration, so create subdirectories for each conf and
# put the files there.  Specify the locations below.

infofile "/var/lib/amanda/DailySet1/curinfo" # database filename
logdir   "/var/lib/amanda/DailySet1"  # log directory
indexdir "/var/lib/amanda/DailySet1/index" # index directory
#tapelist "/var/lib/amanda/DailySet1/tapelist" # list of used tapes
# tapelist is stored, by default, in the directory that contains amanda.conf


# tapetypes

# Define the type of tape you use here, and use it in "tapetype"
# above.  Some typical types of tapes are included here.  The tapetype
# tells amanda how many MB will fit on the tape, how big the filemarks
# are, and how fast the tape device is.

# A filemark is the amount of wasted space every time a tape section
# ends.  If you run `make tapetype' in tape-src, you'll get a program
# that generates tapetype entries, but it is slow as hell, use it only
# if you really must and, if you do, make sure you post the data to
# the amanda mailing list, so that others can use what you found out
# by searching the archives.

# For completeness Amanda should calculate the inter-record gaps too,
# but it doesn't.  For EXABYTE and DAT tapes this is ok.  Anyone using
# 9 tracks for amanda and need IRG calculations?  Drop me a note if
# so.

# If you want amanda to print postscript paper tape labels
# add a line after the comment in the tapetype of the form
#    lbl-templ "/path/to/postscript/template/label.ps"

# if you want the label to go to a printer other than the default
# for your system, you can also add a line above for a different
# printer. (i usually add that line after the dumpuser specification)

# dumpuser "operator"     # the user to run dumps under
# printer "mypostscript"  # printer to print paper label on

# here is an example of my definition for an EXB-8500

# define tapetype EXB-8500 {
# ...
#     lbl-templ "/usr/local/amanda/config/lbl.exabyte.ps"
# }

define tapetype HARD-DISK {
    comment "Hard disk instead of tape"
    length 130 gbytes
}

define tapetype HP-DAT24 {
    comment "HP SureStore DAT24, no compression"
    comment "DDS-3 125 meter tape"
    length 11703 mbytes         #12GB
    filemark 0 kbytes
    speed 1000 kbytes
}

define tapetype DAT40i {
    comment "just produced by tapetype program"
    length 19488 mbytes
    filemark 538 kbytes
    speed 3073 kbytes
}

define tapetype QIC-60 {
    comment "Archive Viper"
    length 60 mbytes
    filemark 100 kbytes  # don't know a better value
    speed 100 kbytes  # dito
}

define tapetype DEC-DLT2000 {
    comment "DEC Differential Digital Linear Tape 2000"
    length 15000 mbytes
    filemark 8 kbytes
    speed 1250 kbytes
}

# Email住址會使用灌水程式保護機制。你需要啟動Javascript才能觀看它
# in amanda-users (Thu Dec 26 01:55:38 MEZ 1996)
define tapetype DLT {
    comment "DLT tape drives"
    length 20000 mbytes  # 20 Gig tapes
    filemark 2000 kbytes # I don't know what this means
    speed 1536 kbytes  # 1.5 Mb/s
}

define tapetype SURESTORE-1200E {
    comment "HP AutoLoader"
    length 3900 mbytes
    filemark 100 kbytes
    speed 500 kbytes
}

define tapetype EXB-8500 {
    comment "Exabyte EXB-8500 drive on decent machine"
    length 4200 mbytes
    filemark 48 kbytes
    speed 474 kbytes   
}

define tapetype EXB-8200 {
    comment "Exabyte EXB-8200 drive on decent machine"
    length 2200 mbytes
    filemark 2130 kbytes
    speed 240 kbytes   
}

define tapetype HP-DAT {
    comment "DAT tape drives"
    # data provided by Rob Browning <Email住址會使用灌水程式保護機制。你需要啟動Javascript才能觀看它>
    length 1930 mbytes
    filemark 111 kbytes
    speed 468 kbytes
}

define tapetype DAT {
    comment "DAT tape drives"
    length 1000 mbytes  # these numbers are not accurate
    filemark 100 kbytes  # but you get the idea
    speed 100 kbytes
}

define tapetype MIMSY-MEGATAPE {
    comment "Megatape (Exabyte based) drive through Emulex on Vax 8600"
    length 2200 mbytes
    filemark 2130 kbytes
    speed 170 kbytes  # limited by the Emulex bus interface, ugh
}


# dumptypes
#
# These are referred to by the disklist file.  The dumptype specifies
# certain parameters for dumping including:
#   auth - authentication scheme to use between server and client.
#    Valid values are "bsd" and "krb4".  Default: [auth bsd]
#   comment - just a comment string
#   comprate - set default compression rate.  Should be followed by one or
#    two numbers, optionally separated by a comma.  The 1st is
#    the full compression rate; the 2nd is the incremental rate.
#    If the second is omitted, it is assumed equal to the first.
#    The numbers represent the amount of the original file the
#    compressed file is expected to take up.
#    Default: [comprate 0.50, 0.50]
#   compress - specify compression of the backed up data.  Valid values are:
#    "none"        - don't compress the dump output.
#    "client best" - compress on the client using the best (and
#      probably slowest) algorithm.
#    "client fast" - compress on the client using fast algorithm.
#    "server best" - compress on the tape host using the best (and
#      probably slowest) algorithm.
#    "server fast" - compress on the tape host using a fast
#      algorithm.  This may be useful when a fast
#      tape host is backing up slow clients.
#    Default: [compress client fast]
#   dumpcycle - set the number of days in the dump cycle, ie, set how often a
#    full dump should be performed.  Default: from DUMPCYCLE above
#   exclude - specify files and directories to be excluded from the dump.
#    Useful with gnutar only; silently ignored by dump and samba.
#    Valid values are:
#    "pattern"       - a shell glob pattern defining which files
#        to exclude.
#        gnutar gets --exclude="pattern"
#    list "filename" - a file (on the client!) containing patterns
#        re's (1 per line) defining which files to
#        exclude.
#        gnutar gets --exclude-from="filename"
#    Note that the `full pathname' of a file within its
#    filesystem starts with `./', because of the way amanda runs
#    gnutar: `tar -C $mountpoint -cf - --lots-of-options .' (note
#    the final dot!)  Thus, if you're backing up `/usr' with a
#    diskfile entry like ``host /usr gnutar-root', but you don't
#    want to backup /usr/tmp, your exclude list should contain
#    the pattern `./tmp', as this is relative to the `/usr' above.
#    Please refer to the man-page of gnutar for more information.
#    Default: include all files
#   holdingdisk - should the holding disk be used for this dump.  Useful for
#    dumping the holding disk itself.  Default: [holdingdisk yes]
#   ignore - do not back this filesystem up.  Useful for sharing a single
#    disklist in several configurations.
#   index - keep an index of the files backed up.  Default: [index no]
#   kencrypt - encrypt the data stream between the client and server.
#    Default: [kencrypt no]
#   maxdumps - max number of concurrent dumps to run on the client.
#    Default: [maxdumps 1]
#   priority - priority level of the dump.  Valid levels are "low", "medium"
#    or "high".  These are really only used when Amanda has no
#    tape to write to because of some error.  In that "degraded
#    mode", as many incrementals as will fit on the holding disk
#    are done, higher priority first, to insure the important
#    disks are at least dumped.  Default: [priority medium]
#   program - specify the dump system to use.  Valid values are "DUMP" and
#    "GNUTAR".  Default: [program "DUMP"].
#   record - record the dump in /etc/dumpdates.  Default: [record yes]
#   skip-full - skip the disk when a level 0 is due, to allow full backups
#    outside Amanda, eg when the machine is in single-user mode.
#   skip-incr - skip the disk when the level 0 is NOT due.  This is used in
#    archive configurations, where only full dumps are done and
#    the tapes saved.
#   starttime - delay the start of the dump?  Default: no delay
#   strategy - set the dump strategy.  Valid strategies are currently:
#    "standard" - the standard one.
#    "nofull"   - do level 1 dumps every time.  This can be used,
#          for example, for small root filesystems that
#          only change slightly relative to a site-wide
#          prototype.  Amanda then backs up just the
#          changes.
#    "noinc"    - do level 0 dumps every time.
#          Unfortunately, this is not currently
#          implemented.  Use `dumpcycle 0'
#          instead.
#    "skip"     - skip all dumps.  Useful for sharing a single
#          disklist in several configurations.
#    Default: [strategy standard]
#
# Note that you may specify previously defined dumptypes as a shorthand way
# of defining parameters.

define dumptype global {
    comment "Global definitions"
    # This is quite useful for setting global parameters, so you don't have
    # to type them everywhere.  All dumptype definitions in this sample file
    # do include these definitions, either directly or indirectly.
    # There's nothing special about the name `global'; if you create any
    # dumptype that does not contain the word `global' or the name of any
    # other dumptype that contains it, these definitions won't apply.
    # Note that these definitions may be overridden in other
    # dumptypes, if the redefinitions appear *after* the `global'
    # dumptype name.
    # You may want to use this for globally enabling or disabling
    # indexing, recording, etc.  Some examples:
    # index yes
    # record no
}

define dumptype always-full {
    global
    comment "Full dump of this filesystem always"
    compress none
    priority high
    dumpcycle 0
}

define dumptype root-tar {
    global
    program "GNUTAR"
    comment "root partitions dumped with tar"
    compress none
    index
#    exclude list "/usr/local/lib/amanda/exclude.gtar"
    priority low
}

define dumptype user-tar {
    root-tar
    comment "user partitions dumped with tar"
    priority medium
}

define dumptype high-tar {
    root-tar
    comment "partitions dumped with tar"
    priority high
}

define dumptype comp-root-tar {
    root-tar
    comment "Root partitions with compression"
    compress client fast
}

define dumptype comp-user-tar {
    user-tar
    compress client fast
}

define dumptype holding-disk {
    global
    comment "The master-host holding disk itself"
    holdingdisk no # do not use the holding disk
    priority medium
}

define dumptype comp-user {
    global
    comment "Non-root partitions on reasonably fast machines"
    compress client fast
    priority medium
}

define dumptype nocomp-user {
    comp-user
    comment "Non-root partitions on slow machines"
    compress none
}

define dumptype comp-root {
    global
    comment "Root partitions with compression"
    compress client fast
    priority low
}

define dumptype nocomp-root {
    comp-root
    comment "Root partitions without compression"
    compress none
}

define dumptype comp-high {
    global
    comment "very important partitions on fast machines"
    compress client best
    priority high
}

define dumptype nocomp-high {
    comp-high
    comment "very important partitions on slow machines"
    compress none
}

define dumptype nocomp-test {
    global
    comment "test dump without compression, no /etc/dumpdates recording"
    compress none
    record no
    priority medium
}

define dumptype comp-test {
    nocomp-test
    comment "test dump with compression, no /etc/dumpdates recording"
    compress client fast
}

define dumptype comp-root-no-tar {
    root-tar
    compress client best
}

define dumptype comp-root-no-shadow {
    root-tar
    compress client best
    exclude "./shadow*"
}

define dumptype comp-root-tar-a-d {
    root-tar
    comment "Root partitions with compression"
    compress client best
    exclude "./[e-z0-9]*"
}

define dumptype comp-root-tar-e-h {
    root-tar
    comment "Root partitions with compression"
    compress client best
    exclude "./[a-di-z0-9]*"
}

define dumptype comp-root-tar-i-l {
    root-tar
    comment "Root partitions with compression"
    compress client best
    exclude "./[a-hm-z0-9]*"
}

define dumptype comp-root-tar-m-p {
    root-tar
    comment "Root partitions with compression"
    compress client best
    exclude "./[a-lq-z0-9]*"
}

define dumptype comp-root-tar-q-t {
    root-tar
    comment "Root partitions with compression"
    compress client best
    exclude "./[a-pu-z0-9]*"
}
define dumptype comp-root-tar-u-z {
    root-tar
    comment "Root partitions with compression"
    compress client best
    exclude "./[a-t0-9]*"
}

define dumptype comp-root-tar-other {
    root-tar
    comment "Root partitions with compression"
    compress client best
    exclude "./[a-z]*"
}

# network interfaces
#
# These are referred to by the disklist file.  They define the attributes
# of the network interface that the remote machine is accessed through.
# Notes: - netusage above defines the attributes that are used when the
#          disklist entry doesn't specify otherwise.
#        - the values below are only samples.
#        - specifying an interface does not force the traffic to pass
#          through that interface.  Your OS routing tables do that.  This
#          is just a mechanism to stop Amanda trashing your network.
# Attributes are:
# use  - bandwidth above which amanda won't start
#     backups using this interface.  Note that if
#     a single backup will take more than that,
#     amanda won't try to make it run slower!

define interface local {
    comment "a local disk"
    use 1000 kbps
}

define interface eth0 {
    comment "10 Mbps ethernet"
    use 400 kbps
}

# You may include other amanda configuration files, so you can share
# dumptypes, tapetypes and interface definitions among several
# configurations.

#includefile "/usr/local/amanda.conf.main"


b.修改/etc/amanda/DailySet1/disklist,增加要backup的資料路徑.(可參考sample)
vi /etc/amanda/DailySet1/disklist
# sample Amanda2 disklist file, derived from CS.UMD.EDU's disklist
#
# If your configuration is called, say, "csd2", then this file normally goes
# in /etc/amanda/csd2/disklist.
#
# File format is:
#
# hostname diskdev dumptype
#
# where the dumptypes are defined by you in amanda.conf.


# At our site, root partitions have a different dumptype because they
# are of lower priority; they don't contain user data, and don't change
# much from the department prototype.  In a crunch, they can be left for
# last or skipped.

## A SPARCstation 1+
#salty sd0a comp-root
#salty sd0g comp-user
#salty sd1g comp-user
#salty sd2a comp-root
#salty sd2g comp-user
#salty sd3c comp-user
#
## A DECstation 3100
#slithy rz1a comp-root
#slithy rz1g comp-user
#slithy rz3a comp-root
#slithy rz3g comp-user
#
## We don't run compression on the master host since it is going to be
## busy enough running amanda.
#master sd0a nocomp-root -1 local
#master sd0g nocomp-user -1 local
## note: -1 is a placeholder for the spindle number
## the holding disk can't be dumped to itself, it uses a disktype that
## specifies the "no-hold" option (see amanda.conf).
#master sd1c holding-disk -1 local
#
## The chairman's disk is high priority to make sure it gets done.
#bigwig sd0a comp-root
#bigwig sd0g comp-high
## Likewise the named databases in the root partition on our primary
## nameserver.  Also, compression is turned off because we don't want
## to create any unnecessary load on this baby (it's only a Sun3).
#bozo        sd0a nocomp-high
#bozo        sd0g nocomp-user
#bozo        sd4c nocomp-user
#
## Dump Joe's NetBSD machine, with the mounted MS-DOS partition dumped
## using tar.
#joespc  wd0a comp-root
#joespc  wd0e comp-user
#joespc /msdos comp-user-tar
#
## Some really slow machines, like Sun2's and some Vaxstations, take
## forever to compress their dumps: it's just not worth it.
#
## A Sun2
#cleo     sd0a nocomp-root
#cleo     sd0g nocomp-user
## A VaxStation
#susie         rz8a nocomp-root
#susie         rz8g nocomp-user
#
## and so on ... well, you get the idea

#ns1
ns1.jason-tang.com /etc comp-root-no-shadow
ns1.jason-tang.com /var/named comp-root-no-tar
ns1.jason-tang.com /home/jason comp-root-tar-a-d
ns1.jason-tang.com /home/jason/ comp-root-tar-e-h
ns1.jason-tang.com /home/jason/. comp-root-tar-i-l
ns1.jason-tang.com /home/jason/./ comp-root-tar-m-p
ns1.jason-tang.com /home/jason/./. comp-root-tar-q-t
ns1.jason-tang.com /home/jason/././ comp-root-tar-u-z
ns1.jason-tang.com /home/jason/././. comp-root-tar-other
ns1.jason-tang.com /var/spool/mail comp-root-no-tar


c.建立changer.conf (可參考sample)
vi /etc/amanda/DailySet1/changer.conf
multieject 0
gravity 0
needeject 0
ejectdelay 0
statefile /var/lib/amanda/DailySet1/changer-status

firstslot 1
lastslot 3

slot 1 file:/home/amanda/DailySet1/tape01
slot 2 file:/home/amanda/DailySet1/tape02
slot 3 file:/home/amanda/DailySet1/tape03
d.建立虛擬tape的目錄
mkdir  -p  /home/amanda/DailySet1/tape01/data
mkdir  -p  /home/amanda/DailySet1/tape02/data
mkdir  -p  /home/amanda/DailySet1/tape03/data
chown -R amanda.disk /home/amanda
chmod -R 770 /home/amanda
e.標記label
轉換成amanda 身份.
su amanda
amlabel DailySet1 DailySet101 slot 1
amlabel DailySet1 DailySet102 slot 2
amlabel DailySet1 DailySet103 slot 3
f.測試是否正常.
轉換成amanda 身份.
su amanda
/usr/sbin/amcheck DailySet1
g.排除問題後,則可以定時運行 /usr/sbin/amdump DailySet1,作定時BackUp
crontab -e
0 0 * * * /usr/sbin/amdump DailySet1


 3.取回data:
=====================
到适當的位置,用root的身份運行"/usr/sbin/amrestore backupfiles" 即可得到backup,再用tar -xvf 解開所有files
如取回ns100.newsbook.net中的etc
1.)去相應的位置找到文件 "00007.ns100.newsbook.net._etc.0"
2.)/usr/sbin/amrestore 00007.ns100.newsbook.net._etc.0 生成文件ns100.newsbook.net._etc.20060326.0
3.)tzr -xvf ns100.newsbook.net._etc.20060326.0 則得到所有files