トップページ | 2008年8月 »

2008年7月

LPI IRA、I/Oアドレス、DMA、SCSI、PCIの設定

LPIを取得しようかと・・・それで勉強のメモ書きを。

IRQ(Interrupt ReQuest):割り込み要求のこと。各種デバイスがCPUとデータをやり取り
際に発生し、CPUがどのデバイスからの要求なのか識別するために用いられる。

通常、IRQは自動的に割り当てられますが、手動で割り当てる時には重複しないよう
注意する。IRQが重複すると、デバイスが動作しなかったり、動作しても不安定になる
要素なる。

IRQの割り当ては、# cat /proc/interrupts で確認が出来る。

I/Oアドレスは、CPUのメモリマップ上のアドレスで入出力を行うデバイスの為に
割り当てられる。
I/Oアドレスの割り当ては # cat /proc/ioports で確認が出来る。

DMA(Direct Memory Access):CPUを使わずに、デバイスとメインメモリとの間で高速な
データ転送を行うために使う。

CPUが他の処理を実行中でも、ハードディスクなどのデバイスとメモリとのデータを
DMAコントローラが制御する為、CPUの負荷軽減となり、処理速度が向上する。
DMAチャネルの割り当ては、# cat /proc/dma で確認が出来る。

IRQ I/Oアドレス DMA の値は競合しないようにする

# lsdev コマンドにより、デバイスごとのDMA、IRQ、I/Oアドレス一覧を確認できる。

SCSI(Small Computers System Interface):コンピュータと周辺機器を接続する為の
インターフェイスの国際標準規格。

SCSIは、SCSI IDで識別されることと、SCSI IDは重複しない事が重要。
/proc/scsi ディレクトリ以下に情報がある。

SCSI接続されたハードディスクやCD-ROMドライブのデバイスファイル名は、
________________________________________________________________
1番目のデバイス | /dev/sda
------------------------------------
2番目のデバイス | /dev/sdb
------------------------------------
    :       |  :
------------------------------------
 
SCSI接続されたテープドライブのデバイスファイル名は、
________________________________________________________________
1番目のテープドライブ | /dev/st0
------------------------------------
2番目のテープドライブ | /dev/st1
------------------------------------

その他、PCIデバイス情報は # cat /proc/pci もしくは、# lspci にて確認ができる。

| | コメント (0) | トラックバック (0)

MovaleType 初期設定

Webブラウザより『http://サーバアドレス/cgi-bin/mt.cgi』でアクセスする
各項目に以下の値を入力(選択)して『インストールを続行』ボタンをクリック。

 
 
  • ユーザー名
            --> admin     :作成したユーザ名    
  • 表示する名前
            --> 管理者名   :ご自身の環境に合わせて設定    
  • メールアドレス
            --> 管理者のメールアドレス :ご自身の環境に合わせて設定    
  • 使用言語
            --> 日本語を選択    
  • パスワード
            --> password   :作成したユーザ名のパスワード    
  • パスワードを再入力
            --> password   :上記と同じパスワードを入力(確認用)    
  • パスワード再設定用のフレーズ
            --> 適当値を入力 :パスワードを忘れた時に入力する設定値
  • ブログ名:ブログのタイトルを指定    
  • ブログURL:ブログを公開するURL名
  • 公開パス:公開する自サーバのhtmlディレクトリ
  • 時間帯(タイムゾーン):UTC+9(日本標準時)

データベース初期化中画面が表示される。

『Movable Typeにサインイン』をクリック。

Webブラウザより『http://サーバアドレス/cgi-bin/mt.cgi』でアクセスすると
管理者ページのログイン画面となります。

インストール完了。

Movable Type標準ハンドブック Movable Typeで今すぐできるウェブログ入門 改訂版

      
Movable Type標準ハンドブック Movable Typeで今すぐできるウェブログ入門 改訂版

著者:平田 大治,関根 元和

Movable Type標準ハンドブック Movable Typeで今すぐできるウェブログ入門 改訂版

| | コメント (0) | トラックバック (0)

障害切り分けコマンド

運用中のLinuxサーバが重いなぁーと感じたら、以下確認する。

1. CPU使用率
2. メモリ使用量
3. ディスクI/O
4. TCPコネクション数

■「top」,「w」,「free」コマンドで
  CPU、メモリ使用率を確認する。

# top
151 processes: 150 sleeping, 1 running, 0 zombie, 0 stopped
CPU0 states:  0.4% user,  0.5% system,  0.0% nice, 98.1% idle
Mem:   513596K av,  442136K used,   71460K free,       0K shrd,   77992K
buff
Swap: 1044184K av,   14120K used, 1030064K free                  208420K
cached

idle値が98%以上(2%未満)なのでCPUは正常。

# w
12:08pm  up 171 days,  1:20,  1 user, 
load average: 1.22, 1.02, 1.97
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU  WHAT
hoge     pts/0    192.168.5.1      11:09am  0.00s  0.33s  0.01s  w

load averageは処理待ちの平均プロセス数。
3以上の場合はかなり重たい状態となる。
その他の情報は、
「FROM」は接続元ホスト名(IPアドレス)である。
「LOGIN@」はログインした時刻である。
「JCPU」は使用した総CPU時間である。
「PCPU」現在のプロセスが使用したCPU時間である。
「WHAT」フィールドはユーザが実行しているコマンドである。

Linuxでは空きメモリがあると、それをすべてCacheにまわすらしい。
それがtopに出てくる数字。Cacheに回された分を差し引く必要があるので
freeコマンドを実行。

# free
             total       used       free     shared    buffers     cached
Mem:        513596     443556      70040          0      78340     209196
-/+ buffers/cache:    
156020     357576
Swap:      1044184      14120    1030064

この場合は実際使用している
メモリが156MBで余裕がある状態です。

次にディスクI/O。

$ vmstat 2
procs -----------memory---------- ---swap-- -----io---- --system--
----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id
wa
1  0   4268  21500 161164 546304    0    0     3     2    3     3 32  3 65
0
6  0   4268  22204 161164 546304    0    0    2   108    0   624 80  6 14
0

見る箇所はbi/bo。
アプリ側で過大なメモリを要求した結果、仮想メモリを使用して
処理を捌こうとします。
つられるようにswapも上昇し最終的にサーバが応答しなくなります。

最後にTCPコネクション数。
netstatコマンドで確認します。

-------------------------
# netstat -an | wc -l
3050
-------------------------

ポートは65535個しかないので数万個のTCPコネクションが
あった場合はサーバを分散化する等の対応が必要になります。

| | コメント (0) | トラックバック (0)

Movable Typeの設定

MySQLへログイン
# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.1.16

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

「mt」というデータベースを作成
mysql> create database mt;
Query OK, 1 row affected (0.01 sec)

管理DBをデフォルト(管理をカレント)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
Movable Typeがログインするユーザー名とパスワードを設定
以下は例として「ユーザー名:admin」「パスワード:password」としています。 
mysql> grant usage on mt.* to admin@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)

「mt」に対してすべての権限を「admin」に許す
mysql> grant all on mt.* to admin@localhost;
Query OK, 0 rows affected (0.00 sec)

終了
mysql> exit
Bye

Movable Type設定ファイルのコピー
# cp -p /var/www/html/cgi-bin/mt-config.cgi-original /var/www/html/cgi-bin/mt-config.cgi

設定ファイルの編集
# vi /var/www/html/cgi-bin/mt-config.cgi
##          Movable Type configuration file                   ##
##                                                            ##
## This file defines system-wide settings for Movable Type    ##
## In total, there are over a hundred options, but only those ##
## critical for everyone are listed below.                    ##
##                                                            ##
## Information on all others can be found at:                 ##
## http://www.sixapart.jp/movabletype/manual/config

################################################################
##################### REQUIRED SETTINGS ########################
################################################################

# The CGIPath is the URL to your Movable Type directory
Movable TypeのCGI実行パスを設定
CGIPath    http://se-memo.nifty.com/cgi-bin/

# The StaticWebPath is the URL to your mt-static directory
# Note: Check the installation documentation to find out
# whether this is required for your environment.  If it is not,
# simply remove it or comment out the line by prepending a "#".
StaticWebPathパスを設定
StaticWebPath    http://se-memo.nifty.com/cgi-bin/mt-static

#================ DATABASE SETTINGS ==================
#   REMOVE all sections below that refer to databases
#   other than the one you will be using.

##### MYSQL #####
使用データベース「MySQL」の各種設定
ObjectDriver DBI::mysql
データベース名
Database mt
オール権限のユーザー名
DBUser admin
上記ユーザーのパスワード
DBPassword password
自サーバのホストDB使用
DBHost localhost

##### POSTGRESQL #####
すべてコメントアウト
#ObjectDriver DBI::postgres
#Database DATABASE_NAME
#DBUser DATABASE_USERNAME
#DBPassword DATABASE_PASSWORD
#DBHost localhost

##### SQLITE #####
すべてコメントアウト
#ObjectDriver DBI::sqlite
#Database /path/to/sqlite/database/file

##### BERKELEYDB #####
すべてコメントアウト
#DataSource  /path/to/database/directory

基本からしっかりわかる Movable Type 4.1 カスタマイズブック Movable Type 4.1/MTOS 4.1対応 (Web Designing BOOKS)

      
基本からしっかりわかる Movable Type 4.1 カスタマイズブック Movable Type 4.1/MTOS 4.1対応 (Web Designing BOOKS)

著者:大藤 幹

基本からしっかりわかる Movable Type 4.1 カスタマイズブック Movable Type 4.1/MTOS 4.1対応 (Web Designing BOOKS)

| | コメント (0) | トラックバック (0)

MovableType インストール

私の場合、自分のPCにMovableTypeのパッケージをDLしておき、
MovableTypeサーバにFTPで転送しておいた。

パッケージの展開

# unzip MT-4_0-ja.zip
Archive:  MT-4_0-ja.zip
   creating: MT-4.0-ja/
   creating: MT-4.0-ja/tmpl/
   creating: MT-4.0-ja/tmpl/feeds/
  inflating: MT-4.0-ja/tmpl/feeds/feed_entry.tmpl
               :
               :
               :
  inflating: MT-4.0-ja/mt-config.cgi-original
  inflating: MT-4.0-ja/mt-feed.cgi
  inflating: MT-4.0-ja/mt-xmlrpc.cgi
  inflating: MT-4.0-ja/index.html
  inflating: MT-4.0-ja/mt-upgrade.cgi


展開したモジュールをCGI実行パスへ移動
# mv ./MT-4.0-ja/* /var/www/html/cgi-bin/


apacheプロセスで読み書き・実行できる様にオーナ・グループ変更
# chown -R apache:apache /var/www/html/cgi-bin/

生成するブログの公開先がドキュメントルート「/var/www/html/」
にある場合は「html」のオーナも「apache」である必要があります。
(下記コマンドの方が無難かもしれません。との事で私は実行しておいた)

# chown -R apache:apache /var/www/html/
ドキュメントルート「/var/www/html」直下に生成させる為、パーミッション変更
# chmod 777 /var/www/html

apacheの再起動
# /etc/rc.d/init.d/httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]

Webブラウザより『http://サーバアドレス/cgi-bin/mt-check.cgi』で
アクセスすると下記画面が表示されます
2




































これで9割は終了。

| | コメント (0) | トラックバック (0)

MovableType インストール apache設定編

MovableTypeは、webサーバが利用可能である事が必須。
早速、Apacheの設定をここを参考に。
MySQLでてこずったけど、Apacheはスムーズに設定できた。

設定ファイルのバックアップを取る
# cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/OLG_httpd.conf

設定ファイルの編集
# vi /etc/httpd/conf/httpd.conf

管理者のメールアドレスを設定する
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin webmaster@se-memo.nifty.com


サーバ名を設定する
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
ServerName se-memo.nifty.com :80


ドキュメントルートの指定
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html" (自分の環境に併せる)


ドキュメントルートの設定
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
SSIの許可(コマンドExec含む)、CGIの許可、シンボリックリンク許可
    Options Includes ExecCGI FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
.htaccessの許可
    AllowOverride All

</Directory>
設定ファイルの編集は、ここまで。

次は、apache(httpd)を起動する

# /etc/rc.d/init.d/httpd start
httpd を起動中:                                            [  OK  ]

起動時にapache(httpd)を起動する
# chkconfig httpd on
設定内容を確認
# chkconfig --list httpd
httpd           0:オフ  1:オフ  2:オン  3:オン  4:オン  5:オン  6:オフ

クライアントより[http://サーバのアドレス/]でアクセスして
Apacheのテストページが表示されていればOK。

Apacheハンドブック

      
Apacheハンドブック

著者:Ben Laurie,Peter Laurie,大川 佳織,田辺 茂也

Apacheハンドブック

| | コメント (0) | トラックバック (0)

MovableType インストール事前準備 MySQL編

職場で社内情報共有ツールとして使えるものを選出
してくれ。との要望が。。。
それも、出来ればお金をかけない方向性でとの事。
思いつくものは、MovableType、XOOPS、WordPress。
とりあえず、要望として第一に挙がったのが
MovableTypeだったので、インストールを試みた。
MovableTypeを使うには事前準備として、以下が必要だ。

■Webサーバー(Apacheなど)が利用可能な事
■MySQLなどのデータベースが利用可能な事
■プログラム実行環境(PerlやPHPなど)が必要(#whereis perlで確認しておく)

「インストール環境」
■OS:CentOS4
■DB:MySQL
■MT:MovableType4.13

今回は、CentOSをインストールする事から始めた。
CDからのインストールだったので楽々インストール完了。
(ただ、MySQLのチェックボックスをONにしてインストール
したが、MySQLが起動しない。
しかも、何故かMYSQLSERVERがインストールされていない。)
再度、CDからソフトウエアのインストールを試す。
詳細インストールを覗くと、
MYSQLSERVERがデフォルトでは
チェックが入っていないのでインストールされない。という
情けないお粗末な結果が判明。

MYSQLSERVERにチェックを入れ、無事インストールが完了。

# /etc/init.d/mysqld start #MySQLの起動コマンド
# /etc/init.d/mysqld stop #MySQLの停止コマンド

無事、MySQLの起動コマンドで起動した〜。

次は、データベースの作成と自動実行の登録。
サーバ再起動する度に起動コマンド実行するのは大変
ですからねー。

その後のMySQLの設定は、ここを参考にした。

# mysql -u root
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 3.23.58

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

インストール直後のデータベース表示
mysql> show databases;
+-----------+
| Databases |
+-----------+
| mysql     |
| test      |
+-----------+
データベースが「mysql」と「test」の2つが存在している。


「mysql」データベースのテーブル名表示
mysql> show tables from mysql;
+-----------------+
| Tables_in_mysql |
+-----------------+
| columns_priv    |
| db              |
| func            |
| host            |
| tables_priv     |
| user            |
+-----------------+
6 rows in set (0.00 sec)
columns_priv    :フィールドについてのアクセス制限
db              :各データベースについてのアクセス制限
func            :システムテーブル(ユーザ定義関数)
host            :ホストによる制限
tables_priv     :テーブルについてのアクセス制限
user            :ユーザによりアクセスを制限


MySQLアカウントのrootが自動的に作成されているがパスワードが
設定されていないので設定する。

rootにパスワードを設定する(パスワードを"se-heigi"とする場合)
mysql> SET PASSWORD FOR root@localhost=PASSWORD('se-heigi');
Query OK, 0 rows affected (0.00 sec)

MySQL monitorの終了
mysql> exit
Bye


MySQL monitorにrootで接続する
(この時、"-p"オプションを指定しパスワード入力をする)

# mysql -u root -p
上記で設定したパスワード"se-heigi"を入力
Enter password:se-heigi(通常は表示されません)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 3.23.58

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

「use」コマンドで「mysql」データベースに切り替える。
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

データベースが変更された
Database changed

MySQLに接続できるユーザの表示
mysql> select host,user,password from user;
+------------------------+------+------------------+
| host                   | user | password         |
+------------------------+------+------------------+
| localhost              | root | 451b483e5c7325d5 |
| se-memo.nifty.com     | root |                  |
| se-memo.nifty.com   |      |                  |
| localhost              |      |                  |
+------------------------+------+------------------+
4 rows in set (0.00 sec)

パスワード無しのユーザ(匿名ユーザ)の削除(セキュリティの為)
mysql> delete from user where user="";
Query OK, 2 rows affected (0.00 sec)

MySQLに接続できるユーザの表示
mysql> select host,user,password from user;
+------------------------+------+------------------+
| host                   | user | password         |
+------------------------+------+------------------+
| localhost              | root | 451b483e5c7325d5 |
| se-memo.nifty.com    | root |                  |
+------------------------+------+------------------+
2 rows in set (0.00 sec)


パスワード無しのユーザが削除されたホスト「se-memo.nifty.com
にもパスワードを設定する

mysql> SET PASSWORD FOR root@se-memo.nifty.com=PASSWORD('se-heigi');
Query OK, 0 rows affected (0.00 sec)

MySQLに接続できるユーザの表示
mysql> select host,user,password from user;
+------------------------+------+------------------+
| host                   | user | password         |
+------------------------+------+------------------+
| localhost              | root | 451b483e5c7325d5 |
| se-memo.nifty.com   | root | 451b483e5c7325d5 |
+------------------------+------+------------------+
2 rows in set (0.00 sec) 


MySQL monitorの終了
mysql> exit
Bye

 

基礎からのMySQL [基礎からのシリーズ] (プログラマの種シリーズ)

      
基礎からのMySQL [基礎からのシリーズ] (プログラマの種シリーズ)

著者:西沢 夢路

基礎からのMySQL [基礎からのシリーズ] (プログラマの種シリーズ)

 

| | コメント (0) | トラックバック (0)

複数の DNS サーバ製品におけるキャッシュポイズニングの脆弱

JPCERT/CC 2008-07-24のアラートメールで
複数の DNS サーバ製品におけるキャッシュポイズニングの
脆弱が見つかったとのこと・・・。おいおい。

内容は、
DNS プロトコルと複数の DNS サーバ製品には
キャッシュポイズニング攻撃を許す脆弱性があります。
この脆弱性が使用された場合、遠隔の第三者によって
DNS キャッシュサーバが偽の DNS 情報で汚染される
可能性があります。とのこと。

キャッシュポイズニング攻撃って??
第三者によりDNSキャッシュサーバのキャッシュデータを
嘘のDNS情報に書き換えてしまう攻撃法とのこと。

なるほどね。

今回の脆弱は、
海外のセキュリティ研究者により2008年8月に公表される
予定でしたが、2008年7月22日当初の予定より早く
攻撃手法が公開されました。
さらに、2008年7月24日に本脆弱性を狙った攻撃ツールが
公開されました。
このため、近日中に本脆弱性を狙った攻撃が発生する
可能性が高まりました。だって。

この為に対策を取らないといけない人々には、はた迷惑な
話だよねーーー。

対策として、
各製品ベンダが提供する修正済ソフトウエアに製品を
アップデート。

注意1:
  Debian GNU/Linux や Fedora などで BIND を使用している場合、
  named.conf に以下のような DNS クエリーのソースポートを固定する設定が
  行われている場合があります。

    query-source    port 53;
    query-source-v6 port 53;

  このような場合、BIND をバージョンアップ後に設定を変更しないとキャッ
  シュポイズニング対策として不十分です。変更方法につきましては各ベンダ
  からの情報を参照してください。

  注意2:
  対策後には DNS サーバからのクエリーのソースポートがランダムになりま
  す。このため、ファイアウォールなどで DNS サーバからの通信が制限され
  る可能性があります。設定変更の際には、事前にファイアウォールなどの設
  定を確認することを推奨いたします。

  注意3:
  DNS サーバをルータ等のゲートウェイ機器の内側に設置している場合、
  NAT/NAPT 機能によってソースポートがランダムでなくなり、パッチによる
  効果が無くなる可能性があります。ゲートウェイ機器などの NAT/NAPT 機能
  を確認したり、DMZ に設置するなどの DNS サーバの設置環境の見直しをご検
  討ください。

IV. 参考情報

    JVNVU#800113
    複数の DNS 実装にキャッシュポイズニングの脆弱性
    http://jvn.jp/cert/JVNVU800113/index.html

| | コメント (0) | トラックバック (2)

バージョン情報を調べる

まぁ、SE的な仕事をしていると・・・何かとバージョン情報
を確認する必要があり、そんな時に限って、バージョン情報
を調査するコマンドが出てこなかったりする訳で。。。
そんな訳で、覚え書きです。

■BIND(digとかnamedコマンド)
# dig @nameserver chaos txt version.bind

(ex.) dig @se-memo.cocolog-nifty.com chaos txt version.bind
         version.bind. 0 CH TXT "9.2.1" #こんな感じで結果が。

その他にも、
# sudo named -version とか。方法は、たくさんあるみたい。
ちなみに、ローカルホストで調べる場合は、
# named -v とだけで結果が出たりする。

■Apache(httpdコマンド)
# httpd -v
Server version: Apache/1.3.27  #こんな感じで結果が。

■sendmail(sendmailとかtelnetコマンド)
# sendmail -d0.101 か、# /usr/sbin/sendmail -d0.101 とか、

# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.zoo.
Escape character is '^]'.
220 cheetah.zoo ESMTP Sendmail 8.12.6/8.12.6
#こんな感じで結果が。

■postfix
# postconf mail_version

| | コメント (0) | トラックバック (0)

トップページ | 2008年8月 »