分類彙整: 技術小抄

CetnOS 5.5 postgresql 81換到 84的方法

參考: 這個網頁 

 su postgres

cd 

 cd backups/

 pg_dumpall –globals-only > globals.sql

 psql -d postgres

select * from pg_database  看看有那些資料庫

postgresql template0 template1 都是系統資料庫不用處理,其他的都

pg_dump --create --oids --format=c --verbose --file dbx dbx   這樣dump出來,如果編碼是 MUL_INTERNAL的,要
pg_dump -E big5 --create --oids --format=c --verbose --file dbx dbx 
 exit
 /etc/init.d/postgresql stop
 cd ~postgres
 mv data/ data.old
yum remove postgresql postgresql-server postgresql-devel
 yum install postgresql84 postgresql84-server postgresql84-devel
//信望愛站要處理一下soft link 
 /etc/init.d/postgresql initdb
 chkconfig --level 35 postgresql on
 cd ~postgres/data
 cp ../data.old/pg_hba.conf .
 /etc/init.d/postgresql start
su - postgres
cd  backups
 psql -f globals.sql
把剛剛備份出來的 db都
 pg_restore --create -d postgres dbX 
restore 進來 
 

如何使用Fedora 13的greylist 套件在CentOS上

1, wget http://software.virtualmin.com/gpl/centos/5/SRPMS/fedora-usermgmt-0.9-1.el5.src.rpm   and build the source rpm

rpm -ivh /usr/src/redhat/RPMS/noarch/fedora-usermgmt-0.9-1.noarch.rpm /usr/src/redhat/RPMS/noarch/fedora-usermgmt-core-0.9-1.noarch.rpm /usr/src/redhat/RPMS/noarch/fedora-usermgmt-default-fedora-setup-0.9-1.noarch.rpm /usr/src/redhat/RPMS/noarch/fedora-usermgmt-shadow-utils-0.9-1.noarch.rpm /usr/src/redhat/RPMS/noarch/fedora-usermgmt-devel-0.9-1.noarch.rpm

2, yum -y install sendmail-devel geoip-* –enablerepo dag

3, wget ftp://ftp.muug.mb.ca/mirror/fedora/linux/development/rawhide/source/SRPMS/milter-greylist-4.2.4-1400.fc14.src.rpm

4, rpm -ivh milter-greylist-4.2.3-1400.fc14.src.rpm –nomd5

vim /usr/src/redhat/SPECS/milter-greylist.spec

define the following variable

%global username        smmsp
%global vardir          %_var/%name
%global dbdir           %vardir
%global rundir          %_var/%name
%global __chkconfig     /sbin/chkconfig

delete
Requires:              init(%name)

delete
–enable-dnsrbl    \

delete the following (we want /var/milter-greylist/ path)

for i in `find -type f`; do
    sed -e ‘s!/var/milter-greylist/milter-greylist.sock!%rundir/milter-greylist.sock!g;
            s!/var/milter-greylist/greylist.db!%dbdir/greylist.db!g;
            s!/var/milter-greylist/milter-greylist.pid!%_var/run/milter-greylist.pid!g;
           ‘ "$i" >"$i.tmp"
    cmp -s "$i" "$i.tmp" || cat "$i.tmp" >"$i"
    rm -f "$i".tmp
done

change this line
touch $RPM_BUILD_ROOT%_var/run/milter-greylist.pid
to
touch $RPM_BUILD_ROOT%rundir/milter-greylist.pid

change this line
touch $RPM_BUILD_ROOT%_var/run/milter-greylist.sock
to
touch $RPM_BUILD_ROOT%rundir/milter-greylist.sock

change this line
%ghost %_var/run/milter-greylist.pid
to
%ghost %rundir/run/milter-greylist.pid

%ghost %rundir/milter-greylist.sock

%dir /usr/src/debug/%name-4.2.3/*
/usr/lib/debug/usr/sbin/%name.debug
%dir %vardir/%name.sock
%vardir/%name.pid

rpmbuild -ba /usr/src/redhat/SPECS/milter-greylist.spec

rpm -Uvh /usr/src/redhat/RPMS/noarch/milter-greylist-4.2.3-1400.noarch.rpm

edit /etc/mail/greylist.conf, adding the following

geoipdb "/usr/share/GeoIP/GeoIP.dat"
spamdsock inet "127.0.0.1:783"

dacl blacklist spamd > 7 msg "Your message is considered spam."
dacl greylist  spamd > 6  delay 6h autowhite 3h msg "greylist in action (6) , please come back later. call 886-921361388 for help!"
dacl greylist  spamd > 5  delay 1h autowhite 40h msg "greylist in action (5), please come back later. call 886-921361388 for help!"
dacl greylist  spamd > 4  delay 30m autowhite 110h msg "greylist in action (4), please come back later. call 886-921361388 for help!"
dacl greylist  spamd > 3  delay 10m autowhite 180h msg "greylist in action (3), please come back later. call 886-921361388 for help!"
racl whitelist default
racl greylist default  delay 5m autowhite 7d msg "greylist in action (4), please come back later. call 886-921361388 for help!"

now spamassassin must be starting
edit /etc/sysconfig/spamassassin

chkconfig –level 35 spamassassin on
service spamassassin start
service milter-greylist restart

Cent_OS lm_sensors 會動了

趕快紀錄下搞定的方法:

 rpm -Uvh http://elrepo.org/linux/elrepo/el5/i386/RPMS/elrepo-release-0.1-1.el5.elrepo.noarch.rpm

vi /etc/yum.repos.d/elrepo.repo

 enabled=1 把他enable起來

看kernel版本

yum install kmod-it87-PAE

yum install kmod-it87

都 yes 以後,就可以執行

 /usr/sbin/sensors-detect

偵測 sensors 。偵測完雖然有錯,但是只要

 
/etc/init.d/lm_sensors restart

即可用

 /usr/bin/sensors 查到資料

MailScanner與CentOS perl 之間的衝突

裝完MailScanner之後,發現一直發生yum update衝突,在網路上找到

 這一篇

有效解決問題。

指令 大概是,先移除套件

 rpm -e perl-bignum perl-Math-BigRat perl-Math-BigInt perl-IO perl-File-Temp perl-Sys-Syslog perl-Test-Harness perl-Test-Simple

自己補裝一套

perl -MCPAN -e shell

設定之後

install  bignum

install  IO

install  File::Temp

force install Scalar::Util

install Sys::Syslog

install Test::Harness

install Test::Simple

 exit

即可

解決CentOS中Apache導致loading 太高的問題

紀錄一下,免得忘記:

搞了半天,是 php 除錯信號紀錄太多的問題,只要把除錯信息拿掉一些,系統就輕鬆了。

 /etc/php.ini 中

把 

 error_reporting  =  E_ALL

改成

 error_reporting  =  E_ALL & ~E_NOTICE

立刻改善,差點就去買新機器了。

另外,如果還是需要監測太大的負載,底下這個 script 可以用:

系統 loading 大於 $thresh (此處是  50) 的負荷就會自動重新啟動 httpd

 #!/usr/bin/php -q
<?php
$load=(double) join(”,file(‘/proc/loadavg’));
$thresh=50;
if ($load >$thresh)
    exec(‘/etc/init.d/httpd restart’);
?>