Create: 2013/01/18
LastUpdate: 2013/01/23
ここでは、「 監視サーバの準備」で用意した環境に Cacti をインストールします。ユーザーを明示していない箇所は、 root ユーザーで作業しています。
今回使用する cacti のバージョンは 0.8.8a です。インストールの詳細は、「Cacti Manual 0.8.8 - Install and Configure Cacti」 を参照してください。
1.yum のレポジトリに rpmforge を追加
ここでは、rpmforge から yum で Cacti パッケージをインストールするので、yumに rpmforge のレポジトリを追加します。
レポジトリの追加手順については、ここ を参照してください。
2.Cactiパッケージのインストール
yum で Cacti パッケージと同時に、依存関係のある RRDTool や SNMP などをインストールします。
# yum --enablerepo=rpmforge install cactiインストールされる Cacti 関連の主なディレクトリ、ファイルは以下のとおり。
- /var/www/cacti ・・・ Cacti 本体を格納したディレクトリ。プログラム、設定ファイルなどを格納
- /etc/httpd/conf.d/cacti.conf ・・・ Apache用の設定ファイル
- /etc/cron.d/cacti ・・・ crontab の定義ファイル
3.DBの作成
Cacti用のデータベースを作成します。
# mysqladmin --user=root create cactiCacti用のテーブルなどのデータをインポートします。
# cd /var/www/cacti # mysql cacti < cacti.sqlCacti用のデータベースユーザーを作成します。
# mysql --user=root mysql 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 110 Server version: 5.1.66 Source distribution Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cacti'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)Cactiの設定ファイルにDBの情報を設定します。
/var/www/cacti/include/config.php を以下のように修正します。
/* make sure these values refect your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cacti"; $database_port = "3306"; $database_ssl = false;
4.Apache の設定変更
Cacti 本体の格納されたディレクトリのオーナーをWEBサーバと同じ apache に変更します。
# chown -R apache.apache /var/www/cactiCacti 用の Apache の初期設定では、ローカルホスト(127.0.0.1)からのアクセスだけ許可しています。
これだと、他のマシンからブラウザでアクセスできないので不便です。なので、ローカルのネットワーク(10.34.195.0/24) からのアクセスを許可します。
/etc/httpd/conf.d/cacti.conf を以下のように修正します。(赤字部分を追加)
Alias /cacti/ /var/www/cacti/
<Directory /var/www/cacti/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
deny from all
allow from 127.0.0.1
allow from 10.34.195.0/24
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
Apache を再起動します。# service httpd restart
5.Crontab用 の設定
Cacti では、crontab を利用して cacti ユーザで、5分間隔でプログラム(/var/www/cacti/poller.php)を実行します。このプログラムが、本体の格納されたディレクトリにある、rra/ と log/ に書き込みできるように、オーナーを cacti に変更します。
# chown -R cacti /var/www/cacti/rra # chown -R cacti /var/www/cacti/log
6.Cacti の初期設定
ブラウザで、http://<IPアドレス>/cacti/ にアクセスします。
初回のみインストールウィザードが表示されます。
下図のページが表示されたら、[Next]ボタンをクリックします。
下図のページが表示されたら、"New Install" を選択して、[Next]ボタンをクリックします。
下図のページが表示されたら、すべてのPATHの確認が "OK" と表示されていることを確認して [Finish]ボタンをクリックします。
下図のログイン画面が表示されたら、[User Name]に "admin" 、[Password]に "admin" を入力して、[Login]ボタンをクリックします。
パスワードを変更するように要求されるので、新しいパスワードを入力して、[Save]ボタンをクリックします。
ログインに成功して、下図のページが表示されたらOKです。