2009/10/27

Hobbit

サーバー監視ツール「Hobbit」のインストールについて記述します。

Hobbitを動作させるには大きく分けて下記の3つのステップがあります。

1.サーバーのインストール
2.クライアントのインストール
3.監視項目 / しきい値 / アラート・メールの設定

まず、1.の「サーバーのインストール」を説明します。
※HobbitはUnix系OSならどれでも利用できるのですが、今回のOSは「CentOS5.3」を使用します。

はじめに必要なパッケージをインストールします。
yum install openldap-devel openssl-devel pcre-devel 


その他のパッケージをインストールする為、レポジトリの追加を行います。
GPG-KEYのインポートを行います。
rpm --import http://ftp.riken.go.jp/pub/Linux/dag/RPM-GPG-KEY.dag.txt


次にレポジトリ・ファイルを作成します。
# vi /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://ftp.riken.go.jp/pub/Linux/dag/RPM-GPG-KEY.dag.txt
enabled=0


設定したレポジトリを有効にするようにしてインストールします。
# yum --enablerepo=dag install fping rrdtool-devel


インストールが終わったら、Hobbitを実行するユーザーを作成作成します。
# useradd -c 'Hobbit Admini' hobbit
# passwd hobbit


fpingのグループとパーミッションを変更します。
# chgrp hobbit /usr/sbin/fping
# chmod g+x /usr/sbin/fping


次にhobbitをダウンロードします。
# cd /usr/local/src
# wget http://downloads.sourceforge.net/hobbitmon/hobbit-4.2.0.tar.gz?modtime=1155195064&big_mirror=0


ダウンロードしたTAR.GZファイルを解凍し、解凍先のディレクトリに移動します。
# tar zxf hobbit-4.2.0.tar.gz
# cd hobbit-4.2.0


インストールしてみます。ホスト名とIPアドレスは環境に合わせてください。(*1)

# ./configure
Configuration script for Hobbit

This script asks a few questions and builds a Makefile to compile Hobbit

Checking your make-utility
Checking pre-requisites for building Hobbit

Checking for fping ...
Hobbit has a built-in ping utility (hobbitping)
However, it is not yet fully stable and therefore it
may be best to use the external fping utility instead.
I found fping in /usr/sbin/fping
Do you want to use it [Y/n] ?
y
Checking to see if '/usr/sbin/fping 127.0.0.1' works ...
127.0.0.1 is alive
OK, will use '/usr/sbin/fping' for ping tests
NOTE: If you are using an suid-root wrapper, make sure the 'hobbit'
user is also allowed to run fping without having to enter passwords.
For 'sudo', add something like this to your 'sudoers' file:
hobbit: ALL=(ALL) NOPASSWD: /usr/local/sbin/fping

Checking for RRDtool ...
test-rrd.c: In function ‘main’:
test-rrd.c:30: error: too few arguments to function ‘rrd_graph’
make: *** [test-compile] エラー 1
Not RRDtool 1.0.x, checking for 1.2.x
Found RRDtool include files in /usr/include
Found RRDtool libraries in /usr/lib
Linking RRD with PNG library: -L/usr/lib -lpng

Checking for PCRE ...
Found PCRE include files in /usr/include
Found PCRE libraries in /usr/lib

Checking for OpenSSL ...
Found OpenSSL include files in /usr/include
Found OpenSSL libraries in /usr/lib

Hobbit can use the OpenSSL library to test SSL-enabled services
like POP3S, IMAPS, NNTPS and TELNETS. If you have the OpenSSL
library installed, I recommend that you enable this.

Do you want to be able to test SSL-enabled services (y) ?
y

Checking for LDAP ...
test-ldap.c: In function ‘main’:
test-ldap.c:16: 警告: implicit declaration of function ‘ldap_init’
test-ldap.c:16: 警告: assignment makes pointer from integer without a cast
Found LDAP include files in /usr/include
Found LDAP libraries in /usr/lib

Hobbit can use your OpenLDAP LDAP client library to test LDAP servers.

Do you want to be able to test LDAP servers (y) ?
y
Enable experimental support for LDAP/SSL (OpenLDAP 2.x only) (y) ?
y

Checking for Large File Support ...
Large File Support OK

Setting up for a Hobbit server

What userid will be running Hobbit [hobbit] ?

Found passwd entry for user hobbit:x:501:501:Hobbit
Admin:/home/hobbit:/bin/bash

Where do you want the Hobbit installation [/home/hobbit] ?

OK, will configure to use /home/hobbit as the Hobbit toplevel directory

What URL will you use for the Hobbit webpages [/hobbit] ?

Where to put the Hobbit CGI scripts [/home/hobbit/cgi-bin] ?
(Note: This is the filesystem directory - we will get to the URL shortly)

What is the URL for the Hobbit CGI directory [/hobbit-cgi] ?
(Note: This is the URL - NOT the filesystem directory)

********************** SECURITY NOTICE ****************************
If your Hobbit server is accessible by outsiders, then you should
restrict access to the CGI scripts that handle enable/disable of
hosts, and acknowledging of alerts. The easiest way to do this is
to put these in a separate CGI directory and require a password to
access them.
Even if your Hobbit server is on a secured, internal network, you
may want to have some operations (like disabling a host) be password-
protected - that lets you see who disabled or acknowledged an alert.

Where to put the Hobbit Administration CGI scripts [/home/hobbit/cgi-secure] ?
(Note: This is the filesystem directory - we will get to the URL shortly)

What is the URL for the Hobbit Administration CGI directory [/hobbit-seccgi] ?
(Note: This is the URL - NOT the filesystem directory)

** Note that you may need to modify your webserver configuration.
** After installing, see /home/hobbit/server/etc/hobbit-apache.conf for
an example configuration.

To generate Hobbit availability reports, your webserver
must have write-access to a directory below the Hobbit
top-level directory. I can set this up if you tell me
what group-ID your webserver runs with. This is typically
'nobody' or 'apache' or 'www-data'
If you dont know, just hit ENTER and we will handle it later.

What group-ID does your webserver use ?
apache (*1)

Where to put the Hobbit logfiles [/var/log/hobbit] ?

What is the name of this host [cent52sv.fujitoko.com] ?
cent52sv (*1)

What is the IP-address of this host [127.0.0.1] ?
192.168.0.15(*1)

** NOTE: Using 127.0.0.1 (loopback), but it is probably not what you want **

Where should I install the Hobbit man-pages (/usr/local/man) ?

Using Linux Makefile settings

Created Makefile with the necessary information to build Hobbit
Some defaults are used, so do look at the Makefile before continuing.

Configuration complete - now run make (GNU make) to build the tools

# make && make install

2009/10/25

Linux 設定周り

とりあえず、インストールしたら追加するパッケージをメモ
(※sshは導入済みが前提)

1.apache
yum install httpd

2.subversion
yum install subversion
yum install mod_dav_svn (WebDavとの連携モジュール、必要に応じ)

3.VNC SERVER
yum install vnc-server

4.gFTP
yum install gftp

5.PostgreSql
yum install postgresql

6.MySQL
yum install mysql

7.WebDav設定
 WebDavの機能を利用するには、特に新しく何かをインストールする必要はありません。
 設定を変更するだけで使用できます。

 ------------------------------ httpd.conf編集
 # 175行目と179行目のdav_moduleとdav_fs_moduleのコメントをはずし、有効にします
 LoadModule dav_module modules/mod_dav.so
 LoadModule dav_fs_module modules/mod_dav_fs.so
 # 551行目と554行目ののコメントをはずします
 
  DAVLockDB /var/lib/dav/lockdb
 


 # WebDavを有効にするディレクトリの設定を行う。ファイルの末尾に追加する。
 
# WebDavを有効にする
DAV On
 

 ------------------------------ httpd.conf終了
 # /etc/init.d/httpd restart # apacheを再起動する
 httpd を停止中: [ OK ]
 httpd を起動中: [ OK ]


ここまでやったら、chkconfig にサービス起動設定をしましょう。

2009/10/24

VMWare Playerに CentOS5をインストール(vmdk, vmx の生成)

1.VMware Playerのダウンロード
下記からダウンロードしてインストールします。
http://www.vmware.com/download/player/

2.仮想ディスクファイルの作成
VMWare Playerは .vmdkという特殊なファイルを仮想ハードディスクとしてマウントします。
この作成機能が商用版VMWareにしか存在しないのですが、実はQemuというフリーソフトで作成できます。

QEMU on Windows

コマンドプロンプトで以下のコマンドを実行してください。

> qemu-img.exe create -f vmdk ファイル名 サイズ
例> qemu-img.exe create -f vmdk C:\WORK\CentOS5.4.vmdk 20G

3.VMWareのコンフィグレーションファイルの作成
下記を記入し、「CentOS5.4.vmx」というファイル名で保存します。


.encoding = "Shift_JIS"
config.version = "8"
virtualHW.version = "3"
memsize = "512"
MemAllowAutoScaleDown = "FALSE"
ide0:0.present = "TRUE"
ide0:0.fileName = "CentOS5.3.vmdk"
ide1:0.present = "TRUE"
#ide1:0.fileName = "auto detect"
#ide1:0.deviceType = "cdrom-raw"
ide1:0.fileName = "C:\Work\@Soft\@OS\CentOS-5.3-i386-bin-DVD.iso"
ide1:0.deviceType = "cdrom-image"
floppy0.present = "FALSE"
#floppy0.present = "TRUE"
#floppy0.fileName = "A:"
ethernet0.present = "TRUE"
sound.present = "TRUE"
displayName = "CentOS5.3"
#guestOS = "winnetstandard" # Windows Server 2003 Standard Edition
#guestOS = "winxppro" # Windows XP Professional
#guestOS = "win2000Pro" # Windows 2000 Professional
#guestOS = "redhat" # Red Hat Linux (generic)
#guestOS = "suse" # SuSE Linux (generic)
#guestOS = "netware5" # Netware 5
#guestOS = "netware6" # Netware 6
#guestOS = "solaris9" # Solaris 9
#guestOS = "solaris10" # Solaris 10 (experimental)
#guestOS = "freebsd" # FreeBSD (generic)
#guestOS = "otherlinux" # Other Linux
guestOS = "other24xlinux" # Other Linux 2.4x kernel
#guestOS = "other26xlinux" # Other Linux 2.6x kernel


   コンフィグファイルを自動生成してくれるサイトがあるので、そちら(下記)を使用するのも有りです。
.vmxファイル生成サイト: VM Builder


  これで後は、VMWarePlayerを実行して、「ファイルを開く」から3.で作成した.vmxファイルを指定すれば、起動されます。

2009/10/16

rsync

ファイル同期アプリ

http://www.infoscience.co.jp/technical/rsync/index.html

これは便利だ!

SSH、.ppkでの認証(RSA認証)の設定

接続する側PCをクライアント、接続される側PCをサーバと呼称し、
クライアントのOSはWindowsVista、サーバのOSは、CentOS5.3を前提で記述します。
(よって、下記の「SSHの設定」とある箇所は、CentOS5.3上でのお話になります。)
その他、前提として、「PuTTYごった煮版」がクライアントにインストールされているものとします。


まず、クライアント側での作業を行います。

①秘密鍵と公開鍵を作成します。
 a.
「PuTTYごった煮版」からputtygen.exeを起動し、[PuTTY Key Generator]というウィンドウを表示します。
  画面上メニューの[メニュー]->[鍵(K)]->[SSH-2 RSA 鍵]をオンにして、
  [メニュー]->[鍵(K)]->[鍵ペアの生成]をクリックします。

 via http://www.atmarkit.co.jp/flinux/rensai/linuxtips/429usekeyssh.html

b.
画面上で適当にマウスをグリグリ動かし、乱数を発生させ、キーを生成します。



③画面が変わったら、「公開鍵の保存」ボタン、「秘密鍵の保存」ボタンをそれぞれを押下します。
 この時、公開鍵の名前を、「xxxx_local.pub」とかの名前にしておくと後で解りやすいです。
 更に秘密鍵の名前を「xxxx.ppk」とします。

 ※保存の際、パスワードなしでよいか?と聞かれても、そのままOKを選択します。

④「xxxx_local.pub」のファイルをサーバへアップロードします。
 /home/ユーザー名/.ssh/xxxx_local.pubへアップ
 ex.) /home/hogehoge/.ssh/xxxx_local.pubへアップ

※ 「.ssh」ディレクトリが無い場合は作成してください。
   (最後に、再度、説明書きします。)

------------------ここまでローカルの作業--------------------

⑤ サーバへログインします。
 ログインしたら、通常ログインするユーザー(root以外)にスイッチします。
 ex). su - hogehoge

先ほど「xxxx_local.pub」をUPしたディレクトリへ移動します。
 ex). cd /home/hogehoge/.ssh/


⑥puttygen.exeで作成した公開鍵はOpenSSHでは使用できないので、
 使用可能な形式に変換します。
 
 ssh-keygen -i -f xxxx_local.pub > xxxx.pub ←変換

 作成された「 xxxx.pub 」の権限を0640に設定
chmod 0640 xxx.pub

⑦公開鍵を変換したら、それを$HOME/.ssh/authorized_keysというファイルに追加します。

 cat xxxx.pub >> $HOME/.ssh/authorized_keys

 ※ authorized_keysファイルが無い場合、作成して下さい。


⑧最後に、authorized_keysファイルを自分だけがアクセスできるようにします。

 chmod 600 $HOME/.ssh/authorized_keys

------------------------------------------------

ここまでで作業終了なのですが、デフォルトだと、「.ssh」ディレクトリが無かったり、
「authorized_keys 」ファイルが無かったりしますので、その処理をちょっとメモ。

a.「.ssh」が無い場合、ディレクトリを作成しましょう。
 
 mkdir /home/ユーザ名/.ssh

 作成した「.ssh」ディレクトリの権限を「0700」に設定

b.「authorized_keys」ファイルが無い場合、viなどで作成しましょう。

 cd $HOME/.ssh
 vi authorized_keys



c.また、authorized_keysファイルが無い場合は、
 sshd_configファイルで鍵認証が許可されていない可能性が大ですので、
 sshd_configファイルを編集します。

 vi /etc/ssh/sshd_config

 PubkeyAuthentication yes
 AuthorizedKeysFile .ssh/authorized_keys

 →先頭に#が入ってコメントアウトされているので、#だけ外して保存して下さい。


d.SSHを再起動します。

 /etc/init.d/sshd restart


これで、正常に起動できれば設定は完了です。
後は、「hogehoge.ppk」を使用してアクセスできるか試してみて下さい。






 

rootでのログイン禁止

SSHのインストール(CentOSとかはデフォルトで入ってると思います。)

 yum install sshd


インストールしたSSHの設定ファイル(sshd_config)を編集し、rootでのログインを禁止します。

vi /etc/ssh/sshd_config

 ※デフォルトだと、/etc/sshに入りますが、ソースから入れた場合は、入れた場所を参照して下さい。


ファイルの「PermitRootLogin yes 」の記述を「PermitRootLogin no」に変更します。


んで、sshを再起動します。

# /etc/init.d/sshd restart


うんちく
PermitRootLogin (root ログイン許可) ssh (1) を使って、root がログインできるかどうか指定します。

この引数の値は
 "yes"
 "without-password"(パスワード認証なし)、
 "forced-commands-only"(強制コマンドのみ)、
 "no"
のいずれかになります。※デフォルトは「yes」です。

この設定項目を"without-password"にすると、root はパスワード認証ではログインできなくなります。
この設定項目を"forced-commands-only"にすると、root は公開鍵認証を使ってログインできます。
 ※鍵にcommand が指定されている場合にかぎります
この設定項目を"no"にすると、root はsu - のみでしかログインできなくなります。