Cactiインストール
Cactiのインストールが終わった。
それ用にサーバを買ったのが今年の1月で、インストールに一度失敗した後、そのほかの業務が忙しくて半年がたってしまった。
CactiはMRTGなどと並んでサーバやネットワーク負荷などを監視するフリーソフト。監視対象の設定はWEBで出来る。
本家のHPはhttp://cacti.net/。
参考にしたHPはcacti - グラフツールcactiとは?、にわか鯖管のメモ - Cacti (RRDToolフロントエンド) 〜 Linux編 〜。
使用した機器はDELL PowerEdge 860、OSはCentOS4.5です。Serverインストールしましたが、gccやらperl等はそのままインストールしましたがApache、PHP、mysqlはパッケージをインストールせずにソースからDownloadしてインストールしました。
下準備
# vi /etc/ld.so.conf
して
/usr/lib /usr/local/lib
を追加して
# ldconfig
しておきました。
Apache2のインストール
# cd /usr/local/src # wget http://www.ring.gr.jp/archives/net/apache/httpd/httpd-2.0.59.tar.gz : # tar -zxvf httpd-2.0.59.tar.gz : # cd httpd-2.0.59 # ./configure --enable-module=so : # make : # make install :
で、エラー無くインストールできたら
# cd /usr/local/apache2/conf # vi httpd.conf
して
ServerAdminとServerNameをセットします。
とりあえず、Apacheが動くかどうかの確認をします。
# /usr/local/apache2/bin/apachectl start
MySQL
まず、MySQL用のグループとユーザを作ります。
# groupadd mysql # useradd -g mysql mysql
wgetでMySQLをGETします。Configureはいろいろオプションを設定しますが、ここでは/dataと言うディレクトリをMySQLのデータベースを格納するディレクトリとして設定しています。
# cd /usr/local/src # wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.45.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/ : # tar -zxvf mysql-5.0.45.tar.gz : # cd mysql-5.0.45 # ./configure --prefix=/usr/local/mysql --localstatedir=/data --with-extra-charsets=all --with-charset=ujis --with-mysqld-user=mysql : # make : # make install : # cp support-files/my-medium.cnf /etc/my.cnf # cd /usr/local/mysql # /usr/local/mysql/bin/mysql_install_db --user=mysql # chown -R mysql /data # chgrp -R mysql /data
下記コマンドでMySQLを起動します。
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
PHPインストールの準備
PHPをインストールする前にlibjpegとlibpngのインストールをします。
libjpegのインストール
# cd /usr/local/src # wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz : # tar -zxvf jpegsrc.v6b.tar.gz : # cd jpeg-6b/ # ./configure --enable-shared : # make : # mkdir /usr/local/include # make install :
libpngのインストール
# cd /usr/local/src # wget http://downloads.sourceforge.net/libpng/libpng-1.2.18.tar.gz?modtime=1179259677&big_mirror=0 : # tar -zxvf libpng-1.2.18.tar.gz : # cd libpng-1.2.18 # ./configure --enable-shared : # make : # make install :
PHPのインストール
# cd /usr/local/src # wget http://jp.php.net/get/php-5.2.3.tar.gz/from/this/mirror : # tar -zxvf php-5.2.3.tar.gz : # cd php-5.2.3 # ./configure --with-apxs2=/usr/local/apache2/bin/apxs --enable-mbstring --enable-zend-multibyte --with-zlib --enable-sqlite-utf8 --enable-memory-limit --with-mysql=/usr/local/mysql --with-gd --with-jpeg-dir --with-png-dir --with-zlib : # make : # make install :
vi /usr/local/apaches/conf/httpd.conf
で
AddType application/x-httpd-php .php
を追加する。また、DirectoryIndexにindex.phpを追加する。
RRDTOOLインストールの準備
RRDTOOLの1.2.23のインストールをしようとしたらいろいろひっかかった。無難に済ませようと思ったらRRDTOOLの1.0系のほうが簡単かもしれない。また、LIBの依存関係でインストール終了後に動かしたときに問題が出たものがあった。結果的には動作した。
libart_lgplのインストール
libart_lgplは最新版の2.3.19を使用した場合に実際にRRDTOOLを動かすと
/usr/local/rrdtool-1.2.23/bin/rrdtool: symbol lookup error: /usr/local/rrdtool-1.2.23/lib/librrd.so.2: undefined symbol: art_alloc
と言うエラーが出た。調べてみるとlibart_lgplの2.3.19使用時に出る障害で、2.3.17ならば出ないと言うことのようだった。
だからlibart_lgplの2.3.17をインストールします。
# cd /usr/local/src # wget http://ftp.gnome.org/pub/gnome/sources/libart_lgpl/2.3/libart_lgpl-2.3.17.tar.gz : # tar -zxvf libart_lgpl-2.3.17.tar.gz : # cd libart_lgpl-2.3.19 # ./configure : # make : # make install : # ln -s /usr/local/include/libart-2.0 /usr/include/libart-2.0
freetypeのインストール
正直、何に使うかわからない。だけど、インストールしなければRRDTOOL1.2.23がごねるので入れました。
# cd /usr/local/src # wget http://download.savannah.gnu.org/releases/freetype/freetype-2.1.10.tar.gz : # tar -zxvf freetype-2.1.10.tar.gz : # cd freetype-2.1.10 # ./configure : # make : # make install : # ln -s /usr/local/include/freetype2 /usr/include/freetype2
TCLのインストール
# cd /usr/local/src # wget http://prdownloads.sourceforge.net/tcl/tcl8.4.15-src.tar.gz : # tar zxvf tcl8.4.15-src.tar.gz : # cd tcl8.4.15/unix # ./configure : # make : # make install
RRDTOOLのインストール
# cd /usr/local/src # wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.23.tar.gz : # tar zxvf rrdtool-1.2.23.tar.gz : # ./configure : # make : # make install :
rrdtoolを動かしたときに
/usr/local/rrdtool-1.2.23/bin/rrdtool: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
と言うエラーが出た。
ln -s /usr/local/lib/libpng12.so.0.18.0 /usr/lib/libpng12.so.0
でしのいだ。
NET-SNMPのインストール準備
5.1の頃は問題が無かったが、5.3になると事前準備が無ければいろいろごねる事が多い。すべてyumでインストールした。
# yum install -y beecrypt-devel # yum install elfutils # yum install elfutils-devel # ln -s /usr/lib/libelf-0.97.1.so /usr/lib/libelf.so
NET-SNMPのインストール
snmpwalk他のコマンドを使う目的でインストールする。
# cd /usr/local/src # wget http://downloads.sourceforge.net/net-snmp/net-snmp-5.3.1.tar.gz : # tar zxvf net-snmp-5.3.1.tar.gz : # cd net-snmp-5.3.1 # ./configure : # make : # make install :
Cacti本体のインストール
Cacti本体のインストールを行います。(Password)は適当に決めてください。
# useradd cactiuser # cd ~cactiuser # chmod 755 /home/cactiuser # wget http://www.cacti.net/downloads/cacti-0.8.6j.tar.gz : # tar zxvf cacti-0.8.6j.tar.gz : # chown -R cactiuser:cactiuser cacti-0.8.6j # cd cacti-0.8.6j # /usr/local/mysql/bin/mysqladmin --user=root create cacti # /usr/local/mysql/bin/mysql cacti < cacti.sql # /usr/local/mysql/bin/mysql --user=root mysql mysql> grant all on cacti.* to cactiuser@localhost identified by '(Password)'; mysql> flush privileges; mysql> exit #
CactiからMySQLにアクセスする際のパスワードを書き込みます。
# cd /home/cactiuser/cacti-0.8.6j/include # vi config.php
で、
$database_password = "(Password)";
のように編集します。
rra/logの作成とアクセス権の設定
# mkdir rra/log # chown -R cactiuser rra/log
poller.phpが動作するかどうか、確認します。
# php /home/cactiuser/cacti-0.8.6j/poller.php sh: -: command not found
でOKの様子??
CactiのPollerをcrontabで起動設定します。
# crontab -u cactiuser -e
で
*/5 * * * * /usr/local/bin/php /home/cactiuser/cacti-0.8.6j/poller.php > /dev/null 2>&1
とします。
最後に
# ln -s /home/cactiuser/cacti-0.8.6j /usr/local/apache2/htdocs/cacti
でブラウザよりCactiが見えるようになります。
cactid
cactidはpoller.phpで行っている問い合わせを高速で行う処理です。
# cd /usr/local/src # wget http://www.cacti.net/downloads/cactid/cacti-cactid-0.8.6i.tar.gz # tar -zxvf cacti-cactid-0.8.6i.tar.gz : # cd cacti-cactid-0.8.6i # ./configure : # make : # make install :
設定ファイルはソースディレクトリよりbinaryのディレクトリにコピーします。
# cp cactid.conf /usr/local/cactid/bin
設定ファイルの中のパスワードを変更します。
# vi /usr/local/cactid/bin/cactid.conf
で中のパスワードの部分の変更します。
DB_Pass (Password)
とりあえず、インストール関係は上記の通り。