サーバとか」カテゴリーアーカイブ

CentOS5へのcrontabインストール

とあるプロジェクトにて、コンテンツバックアップ用のシェルを書いたので、それをcronに仕込もうとした時のお話。

バックアップシェルの動作検証も終わり、cron に仕込もうとしたところ・・・

[root@host ~]# crontab -l

-bash: crontab: command not found

。。。orz

他人が作ったサーバはキライです。

なので、crontab を使えるように。

[root@host ~]# yum install crontabs

Loading “installonlyn” plugin

Setting up Install Process

Setting up repositories

Reading repository metadata in from local files

Parsing package install arguments

Resolving Dependencies

–> Populating transaction set with selected packages. Please wait.

—> Downloading header for crontabs to pack into transaction set.

crontabs-1.10-8.noarch.rp 100% |=========================| 3.9 kB 00:00

—> Package crontabs.noarch 0:1.10-8 set to be updated

–> Running transaction check

Dependencies Resolved

=============================================================================

Package Arch Version Repository Size

=============================================================================

Installing:

crontabs noarch 1.10-8 base 5.0 k

Transaction Summary

=============================================================================

Install 1 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 5.0 k

Is this ok [y/N]: y

Downloading Packages:

(1/1): crontabs-1.10-8.no 100% |=========================| 5.0 kB 00:00

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing: crontabs ######################### [1/1]

Installed: crontabs.noarch 0:1.10-8

Complete!

もいっちょ。

[root@host ~]# yum install vixie-cron

Loading “installonlyn” plugin

Setting up Install Process

Setting up repositories

Reading repository metadata in from local files

Parsing package install arguments

Resolving Dependencies

–> Populating transaction set with selected packages. Please wait.

—> Package vixie-cron.i386 4:4.1-72.el5 set to be updated

–> Running transaction check

Dependencies Resolved

=============================================================================

Package Arch Version Repository Size

=============================================================================

Installing:

vixie-cron i386 4:4.1-72.el5 base 91 k

Transaction Summary

=============================================================================

Install 1 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 91 k

Is this ok [y/N]: y

Downloading Packages:

(1/1): vixie-cron-4.1-72. 100% |=========================| 91 kB 00:12

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing: vixie-cron ######################### [1/1]

Installed: vixie-cron.i386 4:4.1-72.el5

Complete!

確認。

[root@host ~]# crontab -l

no crontab for root

おk。

無事、crontab で、cron の設定が出来ましたとさ。

でわ。

postgreSQLでリストアエラー

postgreSQLのリストアで、こんなエラーが出る事があります。

# su – postgres

$ createdb testDB

$ psql -e testDB < testDB.dump

(snip)

ERROR: invalid byte sequence for encoding “UTF8”: 0xcbcc

HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by “client_encoding”.

このエラーの場合、バックアップする為にDumpした時のエンコードと、リストアする時のDBのエンコードが合っていない事が主な原因っぽいです。

バックアップとリストアの手順としては、

■バックアップ

# su – postgres

$ pg_dump DB名 > Dumpファイル名

■リストア

# su – postgres

$ createdb DB名

$ psql -e DB名 < Dumpファイル名

こんな感じです。

ここで、エンコードの絡みが出てくるのです。

今回、CentOS 5.2, postgreSQL8 で createdb した場合、デフォルトでエンコードは UTF8 になりました。

しかし、Dumpしたデータのエンコードが SQL_ASCII だった為、正常にリストアが出来ない状況でした。

それを回避する為には、リストアする際に、

# su – postgres

$ createdb -E SQL_ASCII DB名

$ psql -e DB名 < Dumpファイル名

と、エンコードを SQL_ASCII にしてあげれば、正常にリストアされます。

時々こういった事を忘れるので。。。

忘れないように書いておきます。

でわ。

Linuxのコマンドのrpmパッケージについて

自分でサーバ構築した時はよいのだが、他の人にサーバ構築した時に、使えないコマンドがあったりする。

今日は、whois と nslookup が使えなかったので、インストールした。

ただ、そのコマンドが入っているパッケージが分からない、と。

で、調べた結果、

nslookup:bind-util

whois:jwhois

という事が分かった。

なので、インスコ。

まずは、nslookup から。

# yum install bind-utils

Loading “installonlyn” plugin

Setting up Install Process

Setting up repositories

Reading repository metadata in from local files

Parsing package install arguments

Resolving Dependencies

–> Populating transaction set with selected packages. Please wait.

—> Downloading header for bind-utils to pack into transaction set.

bind-utils-9.3.4-6.0.2.P1 100% |=========================| 40 kB 00:00

—> Package bind-utils.i386 30:9.3.4-6.0.2.P1.el5_2 set to be updated

–> Running transaction check

–> Processing Dependency: libisccc.so.0 for package: bind-utils

–> Processing Dependency: libisc.so.11 for package: bind-utils

–> Processing Dependency: bind-libs = 30:9.3.4-6.0.2.P1.el5_2 for package: bind-utils

–> Processing Dependency: libbind9.so.0 for package: bind-utils

–> Processing Dependency: libdns.so.22 for package: bind-utils

–> Processing Dependency: libisccfg.so.1 for package: bind-utils

–> Processing Dependency: liblwres.so.9 for package: bind-utils

–> Restarting Dependency Resolution with new changes.

–> Populating transaction set with selected packages. Please wait.

—> Downloading header for bind-libs to pack into transaction set.

bind-libs-9.3.4-6.0.2.P1. 100% |=========================| 41 kB 00:00

—> Package bind-libs.i386 30:9.3.4-6.0.2.P1.el5_2 set to be updated

–> Running transaction check

Dependencies Resolved

=============================================================================

Package Arch Version Repository Size

=============================================================================

Installing:

bind-utils i386 30:9.3.4-6.0.2.P1.el5_2 updates 167 k

Installing for dependencies:

bind-libs i386 30:9.3.4-6.0.2.P1.el5_2 updates 846 k

Transaction Summary

=============================================================================

Install 2 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 1.0 M

Is this ok [y/N]: y

Downloading Packages:

(1/2): bind-utils-9.3.4-6 100% |=========================| 167 kB 00:01

(2/2): bind-libs-9.3.4-6. 100% |=========================| 846 kB 00:03

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing: bind-libs ######################### [1/2]

Installing: bind-utils ######################### [2/2]

Installed: bind-utils.i386 30:9.3.4-6.0.2.P1.el5_2

Dependency Installed: bind-libs.i386 30:9.3.4-6.0.2.P1.el5_2

Complete!

次に、whois。

# yum install jwhois

Loading “installonlyn” plugin

Setting up Install Process

Setting up repositories

Reading repository metadata in from local files

Parsing package install arguments

Resolving Dependencies

–> Populating transaction set with selected packages. Please wait.

—> Downloading header for jwhois to pack into transaction set.

jwhois-3.2.3-8.el5.i386.r 100% |=========================| 9.5 kB 00:00

—> Package jwhois.i386 0:3.2.3-8.el5 set to be updated

–> Running transaction check

–> Processing Dependency: libidn.so.11 for package: jwhois

–> Restarting Dependency Resolution with new changes.

–> Populating transaction set with selected packages. Please wait.

—> Downloading header for libidn to pack into transaction set.

libidn-0.6.5-1.1.i386.rpm 100% |=========================| 9.6 kB 00:00

—> Package libidn.i386 0:0.6.5-1.1 set to be updated

–> Running transaction check

Dependencies Resolved

=============================================================================

Package Arch Version Repository Size

=============================================================================

Installing:

jwhois i386 3.2.3-8.el5 base 94 k

Installing for dependencies:

libidn i386 0.6.5-1.1 base 194 k

Transaction Summary

=============================================================================

Install 2 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 289 k

Is this ok [y/N]: y

Downloading Packages:

(1/2): libidn-0.6.5-1.1.i 100% |=========================| 194 kB 00:00

(2/2): jwhois-3.2.3-8.el5 100% |=========================| 94 kB 00:00

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing: libidn ######################### [1/2]

Installing: jwhois ######################### [2/2]

Installed: jwhois.i386 0:3.2.3-8.el5

Dependency Installed: libidn.i386 0:0.6.5-1.1

Complete!

以上。

でわ。

Apacheへのmod_rewrite組み込み

apxsが組み込まれている前提でお話を進めます。

■ 前提

Apacheインストール先:/usr/local/apache2

Apacheソース:/usr/local/src/httpd-2.0.63

# cd /usr/local/src/httpd-2.0.63/modules/mappers

ビルド

# /usr/local/apache2/bin/apxs -c mod_rewrite.c

インストール

# /usr/local/apache2/bin/apxs -i -a -n rewrite mod_rewrite.la

終了。

httpd.conf に、

LoadModule rewrite_module modules/mod_rewrite.so

が、勝手に書き加えられるので、念の為、事前にバックアップ取っておいて下さいな。

でわ。

Plone その2

Plone妥協。。。

とりあえず、Ploneを動かす事を優先した。

なので、インストール済のZopeを消して、Ploneのinstall.shで全てを完了する形とする。

# cd /usr/local/src

# tar zxvf ./Plone-3.1.5.1-UnifiedInstaller.tgz

# cd Plone-3.1.5.1-UnifiedInstaller

# ./install.sh standalone

これで、Zope/Python/Plone のインストールは完了。

最後の方に、Zopeの管理コンソールへログインする為のID/PWが表示されるので注意。

Zopeを起動。

# cd /opt/

# ln -s Plone-3.1 plone

# cd plone

# cd zinstance

# cd bin

# ./zopectl start

次に、Zopeの管理コンソールより、PloneSiteを追加する。

http://192.168.100.100:8080/manage/

へアクセス。

右上のComboBoxより、「PloneSite」を選択。

Idには「plone」と入力。

あとは適当w

以下URLへアクセスし、正常に表示されればおk。

http://192.168.100.100:8080/plone/

これで、PloneSiteの追加は完了。

サイトのユーザ作成には、メールでの認証フローが必須との事。

現状、メールサーバ入れてないので、postfix でも入れてみようかと。

それはまたの機会に。

でわ。

Ruby と Gem と Rails を入れてみた

Plone からちょっと脱線。

動かしたいプロジェクト管理ツールがあったので、

Ruby + Rails のインストールやってみました。

面倒だったので、ちょっとズルイ方法でw

まずは、Rubyのインストール

# yum -y install ruby*

次に、gem のインストール

# cd /usr/local/src

# wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz

# tar zxvf ./rubygems-0.9.2.tgz

# cd rubygems-0.9.2

# ruby setup.rb

でもって、Rails のインストール

# gem install –remote rails –include-dependencies

完了

ちなみに、動かしたかったのは、「9arrows」です。

上記だけでは動きませんので、あしからず。

設定諸々は、Plone が一段落したらやろうと思います。

でわ。

Plone その1

Plone準備からの続き。

まずは、Ploneをダウンロード。

$ cd /usr/local/src

$ wget http://launchpad.net/plone/3.1/3.1.5.1/+download/Plone-3.1.5.1-UnifiedInstaller.tgz

次に、展開して install.sh を実行

$ tar zxvf ./Plone-3.1.5.1-UnifiedInstaller.tgz

$ cd Plone-3.1.5.1-UnifiedInstaller

$ ./install.sh

どうやら、Python / Zope / Plone をセットで入れてくれるみたい。

そんなのヤダなぁ・・・

と思ったので、なんとか、Ploneのコアだけを既存のZopeに入れられないかと試行錯誤。

が、うまくいかず。。。orz

まだまだ、色々やってみます。

でわ。

Plone準備( Python-2.4.5 + Zope-2.10.6インストール )

その1その2のやり直し。

前の後始末はファイルとかディレクトリとか消すだけだから省略。

Python-2.4.5+Zope-2.10.6 にて、再構築。

  • まずは、Pythonから。

$ cd /usr/local

$ mkdir python_2.4.5

$ cd /usr/local/src

$ wget http://www.python.org/ftp/python/2.4.5/Python-2.4.5.tgz

$ tar zxvf ./Python-2.4.5.tgz

$ cd Python-2.4.5

$ ./configure –prefix=/usr/local/python_2.4.5

$ make

# su –

# cd /usr/local/src/Python-2.4.5

# make install

  • 次にZope

$ cd /usr/local

$ mkdir zope_2.10.6

$ cd /usr/local/src

$ tar zxvf ./Zope-2.10.6-final.tgz

$ cd Zope-2.10.6-final

$ ./configure –prefix=/usr/local/zope_2.10.6 –with-python=/usr/local/python_2.4.5

$ make

# su –

# cd /usr/lcoal/src/Zope-2.10.6-final

# make install

  • Zopeの初期設定は前と同じ

# cd /usr/local/zope/bin

# ./mkzopeinstance.py

Please choose a directory in which you’d like to install

Zope “instance home” files such as database files, configuration

files, etc.

Directory: /usr/local/zope → Zopeインストールディレクトリ

Please choose a username and password for the initial user.

These will be the credentials you use to initially manage

your new Zope instance.

Username: admin → 管理者アカウント

Password: → 管理者パスワード

Verify password: → もう一回パスワード

して、

# cd /usr/local/zope/etc

# vi zope.conf

default-zpublisher-encoding utf-8

さて、ちゃんと動くかな?

# su – zope

$ cd /usr/local/zope/bin

$ ./zopectl start

. daemon process started, pid=16886

おk。

http://XXX.XXX.XXX.XXX:8080/

で、ちゃんとZopeの画面も見れたので、それもおk。

ようやく、Ploneに入れます。

続く。