Cloud Nine

Avatar

About IT things and others.

2月
21
PostgresSQL9.1.2の設定 in CentOS5.7
2月 21, 2012 0

基本設定部分

$ vi /var/lib/pgsql/9.1/data/postgresql.conf
#listen_addresses = 'localhost'
↓
listen_addresses = '*'
#port = 5432
↓
port = 5432

ログの名前
log_filename = 'postgresql-%Y-%m-%d_%H%M.log'
ログのローテーション
log_rotation_age = 1d
ログのサイズ
log_rotation_size = 2MB
同名のファイルが存在する時は上書きする。ローテーション用。
log_truncate_on_rotation = on
ログのレベル
log_min_error_statement = error

ログの細かい内容はこちらを参照してください。
http://lets.postgresql.jp/documents/technical/log_setting

セキュリティ設定部分

$ vi /var/lib/pgsql/9.1/data/pg_hba.conf
ローカル接続の許可
local    all             all                      peer
外部からの接続の設定
host    all             all             123.123.123.123/32(接続元のIP)            password

2月
13
CentOS5.7にPostgresSQL9.1.2をyumでインストール
2月 13, 2012 0

Postgresのサイトからrpmを取得
http://yum.postgresql.org/reporpms/

インストール

$ wget http://yum.postgresql.org/9.1/redhat/rhel-5-i386/pgdg-centos91-9.1-4.noarch.rpm
$ rpm -ivh pgdg-centos91-9.1-4.noarch.rpm
$ vi /etc/yum.repos.d/CentOS-Base.repo
[base]の中に下記のコメントを追加
exclude=postgresql*
[update]の中に下記のコメントを追加
exclude=postgresql*
$ yum -y install postgresql-server
Installed:
  postgresql91-server.i386 0:9.1.2-1PGDG.rhel5
Dependency Installed:
  postgresql91.i386 0:9.1.2-1PGDG.rhel5                    postgresql91-libs.i386 0:9.1.2-1PGDG.rhel5

初期設定

$ chkconfig postgresql-9.1 on
DBの初期化
$ service postgresql-9.1 initdb
データベースを初期化中: mkdir: ディレクトリ `/var/lib/pgsql/9.1/data/pg_log' を作成できません: ファイルが存在します
$ rm -rf /var/lib/pgsql/9.1/data/pg_log/
$ service postgresql-9.1 initdb
データベースを初期化中:                                    [  OK  ]
$ service postgresql-9.1.2 start
postgresql-9.1 サービスを開始中:                           [  OK  ]
$ su - postgres
$ psql -V
psql (PostgreSQL) 9.1.2

設定関連

基本関係
$ vi /var/lib/pgsql/9.1/data/postgresql.conf
セキュリティ関係
$ vi /var/lib/pgsql/9.1/data/pg_hba.conf

4月
03
CentOSにfastcgiの導入&mod_phpとの比較
4月 3, 2011 0

今週の木曜日に、Sydphpに行ってきました。
今回のお題は、Aimee-Maree Forsstromがmod_phpとfastcgiの比較、Phil Taylorがセキュリティについて話す予定でしたが、急遽が参加できなくなったので、@predominantがオープンソースの活用&運営について話してくれました。

せっかくだったので、自宅にかえって早速fastcgiを導入してみました。
fastcgiの存在は知っていたのですが、導入の経験がないので自宅サーバに導入(CentOS5.5,Apache2.0)検証してみました。

fastcgiについて

@aimee_mareeのスライドはこちらで確認ができます。

mod_phpとfastcgiを比較して、いかにfastcgiがが素晴らしいかを説いてくれました。
@aimee_mareeのまわりでも、圧倒的にmod_phpが一般的で、そのことがかなり腹立たしいとのことです。
要因としては、Apacheの標準であること、ホスティングサーバがmod_phpを使用していること、fastcgiの情報がまだまだ少ないことが原因のようです。
僕の英語力では、70%ほどしか理解できなかったのですが、こちらのページに日本語で詳細が記載してあるのでこちらをご確認ください。
FastCGI環境を構築する – ぱせらんメモ

CentOSにインストール

ちなみに、fastcgiには、mod_fastcgimod_fcgidの2種類があるようです。
今回は、mod_fcgidが早いとのことなので、mod_fcgidを導入しました。
検討に参考にさせてもらったサイト
Apache2 – mod_fcgid vs mod_fastcgi
Apache/FastCGI

すこし手間取ったので、そのトラブルと解決方法も記載しておきます。

最新mod_fcgidをcheckout、APXSのエラー

$ svn checkout http://svn.apache.org/repos/asf/httpd/mod_fcgid/trunk mod_fcgid
$ cd mod_fcgid
$ ./configure.apxs
.configure.apxs must be able to find apxs in your path,
or the environment variable APXS must provide the full path of APXS,
or you may specify it with:

httpd-develのインストール&APXSのパスを指定して再度インストール

$ yum install httpd-devel
$ APXS=/usr/sbin/apxs ./configure.apxs
$ make
$ make install

mod_fcgidの設定

ちなみに、mod_phpで構築してあるのですが、mod_fcgidとの共存が可能です。
下記のfcgid.confの中で場所を指定出来るようです。

参考サイト
Apache Module mod_fcgid

$vi /etc/httpd/conf.d/fcgid.conf
<IfModule mod_fcgid.c>
    AddHandler fcgid-script .php
    <Directory "/home/mizoshiri/work/www/test3.40">
#        SetHandler fcgid-script
        FCGIWrapper /usr/bin/php-cgi .php
#        DirectoryIndex index.php
        Options +ExecCGI
#        AllowOverride None
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</IfModule>
$ /etc/rc.d/init.d/httpd restart

インストール後は、phpinfo()でmodの中にmod_fcgidが表示されるようになります。

ベンチマークしてみる

せっかくなので、mod_phpとの比較したいので、ベンチマークをやっておきました。

phpのベンチマーク

PHPのベンチマークはPearのBenchmark
下記のコマンドでインストール

#pear install Benchmark

ベンチマークは、下記の参考サイトにある、フィボナッチ数列のベンチマークを使用しました。
僕の認識では、php自体の処理に関しては、変わらないはず。間違ってるかな???結果的には、やはりほぼ変わらず。
コードの最適化に役立つPHPスクリプトのベンチマーク

PHPのベンチマーク結果

導入前
beafore
beafore2
導入後
after1
after2

Apacheのベンチマーク

Apacheのベンチマークは、標準ではいっているabを使用しました。
apacheのベンチマークように、Wordpressをいれて、予め記事の中にいくつかの画像などを追加したものを準備しておきました。
下記のコマンドでベンチマークを取りました。

#ab -c 100 -n 1000 http://localhost/wp/?p=1

apacheのベンチマークは下記のサイトで詳細が確認できます。
@IT:Apacheパフォーマンス・チューニングのポイント(2/2)

Apacheのベンチマーク結果

導入前

$ab -c 100 -n 1000 http://localhost/wp/?p=1
Benchmarking test3.40 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests

Server Software:        Apache
Server Hostname:        localhost
Server Port:            80
Document Path:          /?p=1
Document Length:        103 bytes
Concurrency Level:      100
Time taken for tests:   0.648395 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      336336 bytes
HTML transferred:       103103 bytes
Requests per second:    1542.27 [#/sec] (mean)

Time per request:       64.840 [ms] (mean)
Time per request:       0.648 [ms] (mean, across all concurrent requests)
Transfer rate:          505.86 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   4.0      1      20
Processing:     9   58  10.0     61      66
Waiting:        5   56  10.0     58      64
Total:         11   60   8.5     62      82
Percentage of the requests served within a certain time (ms)
  50%     62
  66%     63
  75%     65
  80%     65
  90%     66
  95%     67
  98%     69
  99%     76
 100%     82 (longest request)

導入後

$ ab -c 100 -n 1000 http://localhost/wp/?p=1
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests

Server Software:        Apache
Server Hostname:        localhost
Server Port:            80
Document Path:          /?p=1
Document Length:        103 bytes

Concurrency Level:      100
Time taken for tests:   0.665636 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      336000 bytes
HTML transferred:       103000 bytes
Requests per second:    1502.32 [#/sec] (mean)
Time per request:       66.564 [ms] (mean)
Time per request:       0.666 [ms] (mean, across all concurrent requests)
Transfer rate:          492.76 [Kbytes/sec] received

Connection Times (ms)
             min  mean[+/-sd] median   max
Connect:        0    3   3.7      2      19
Processing:     9   59  10.1     62      66
Waiting:        3   56  10.2     59      65
Total:         10   62   9.2     64      85

Percentage of the requests served within a certain time (ms)
  50%     64
  66%     66
  75%     67
  80%     68
  90%     70
  95%     70
  98%     71
  99%     78
 100%     85 (longest request)

最後に

実際に導入してみたけど、上記の設定であっているのか不安でもありますので、
なにか間違っているところがありましたら、ご指摘いただけましたら幸いです。

11月
07
CentOSにemacs23.2をインストール
11月 7, 2010 0

最近設置した自宅サーバにemacsの23.3をインストールした際もメモ
yumでインストールすると、emacs21になるので、TrueTypeフォントの綺麗さに慣れているので、最新版をインストールしました。

# wget http://ftp.gnu.org/pub/gnu/emacs/emacs-23.2.tar.gz
# tar zxvf emacs-23.2.tar.gz
# cd ./emacs-23.2
# ./configure --without-x
# make
# make install
# emacs --version
GNU Emacs 23.2.1
Copyright (C) 2010 Free Software Foundation, Inc.

無事インストールは完了。
注意:事前にgcc、anthy-elなどの各種ライブラリはインストールしてある状況でのインストール方法です。

9月
06
CentOS5.5にopenssh-5.6をインストールのメモ
9月 6, 2010 0

CentOS5.5に標準で入っているsshdが、4.*だったような気がしたので最新のソースをダウンロードして、コンパイルしてインストールしました。

既存のsshdの削除

# /etc/rc.d/init.d/sshd stop
# yum -y remove openssh

最新のsshdをダウンロード

参考ページ:SSHサーバー構築(OpenSSH)

# wget http://ftp.jaist.ac.jp/pub/OpenBSD/OpenSSH/portable/openssh-5.6p1.tar.gz
# tar zxvf openssh-5.6p1.tar.gz
# vi openssh-5.6p1/contrib/redhat/openssh.spec
%define no_x11_askpass 0
↓
%define no_x11_askpass 1 ← x11_askpassの無効化
# Do we want to disable building of gnome-askpass? (1=yes 0=no)
%define no_gnome_askpass 0
↓
%define no_gnome_askpass 1 ← gnome_askpassの無効化

%configure \
        configure --without-zlib-version-check \ ← 追加(zlibのバージョンチェック無効化)
        --sysconfdir=%{_sysconfdir}/ssh \

# rm -rf openssh-5.6p1/contrib/aix/ ← 使わないディストリビューションは削除
# rm -rf openssh-5.6p1/contrib/hpux/
# rm -rf openssh-5.6p1/contrib/caldera/
# rm -rf openssh-5.6p1/contrib/suse/
# rm -rf openssh-5.6p1/contrib/cygwin/
# rm -rf openssh-5.6p1/contrib/solaris/

rpmの作成

rpmbuild -tb --clean openssh-5.6p1-final.tar.gz
パッケージ関係がはいっていないとのこと
# yum -y install pam-devel openssl-devel glibc-devel krb5-devel
# rpmbuild -tb --clean openssh-5.6p1-final.tar.gz
/var/tmp/rpm-tmp.78083 の不正な終了ステータス
# yum install rpm-build
# rpmbuild -tb --clean openssh-5.6p1-final.tar.gz
# rpm -Uvh /usr/src/redhat/RPMS/i386/openssh-5.6p1-1.i386.rpm
# rpm -Uvh /usr/src/redhat/RPMS/i386/openssh-server-5.6p1-1.i386.rpm
# rpm -Uvh /usr/src/redhat/RPMS/i386/openssh-clients-5.6p1-1.i386.rpm
# rm-f /usr/src/redhat/RPMS/i386/openssh-*
# rm -f openssh-5.6p1-final.tar.gz

SSHサーバー起動

# /etc/rc.d/init.d/sshd start
常時起動に設定
# chkconfgi sshd on

sshサーバ設定

# vi /etc/ssh/sshd_config
Protocol 2
PermitRootLogin no
SyslogFacility AUTHPRIV
PasswordAuthentication no
PermitEmptyPasswords no
RSAAuthentication yes
Match Group *,!wheel
        ChrootDirectory /home/%u/./
confの再読込
# /etc/rc.d/init.d/sshd reload

7月
08
CentOSで時間設定 in Sydney
7月 8, 2010 0

はじめは、NTPサーバで設定しようとしていたんですが、VPSのサーバの設定で変更が反映されないようなのでローカルタイムを設定して対応しました。
ちなみに、その際に使用したシドニーのNTPサーバです。
Thank miknight for telling this info!!

time.opusnet.com.au

今回の対応方法

dateのコマンドで無理やり設定してみる。。。。
でも権限がないとか言われる。

# date -s 'Fri Jul  2 11:18:19 MSD 2010'
date: cannot set date: Operation not permitted

とりあず、サーバのローカル時間をシドニーに設定してみる。

#cp -p /usr/share/zoneinfo/Australia/NSW/Sydney /etc/localtime
or
追記:2011/01/05
#cp -p /usr/share/zoneinfo/Australia/NSW/ /etc/localtime

上記の設定で、無事ぼくの環境は解決しました。

11月
08
configure: error: C++ preprocessor “/lib/cpp” fails sanity checkの対処法
11月 8, 2009 1

ファイル改ざん検知させるために、Tripwireを導入していた際に、下記のエラーがでました。

configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.

対処方法

(³ɤ…)

5月
09
I installed Cent OS 5
5月 9, 2007 0

I installed Cent OS 5.
It was very simple but I could enjoyed installed!!!
Thanks for developer about Cent OS.

centos2

Real Time Analytics