cactiの立ち上げ
cactiの立ち上げ
最初はMRTGを使おうと思ってたんだけど、以前から評判になってるMRTGの後継(???)のcactiを使うよう、路線変更しました。
- http://cacti.loaded.jp/
- 以前MRTGを自宅で実験したとき、インストールが面倒だった(結局途中で断念した。前準備の別のインストールがあれこれ必要だということが途中でわかって面倒になったため)
- cactiではそのあたりが解消されてる(っぽい)。うたい文句にも書いてある。
cactiのインストール
MRTGよりもインストールなどが楽になっている→yumでインストール出来るように準備されてるだろう。
[root@linux38 sbin]# yum -y install cacti
インストールできました。依存関係のパッケージ(mysqlとかも)も自動でupdateしてくれました。 apache httpdもcactiの依存対象にされてるみたいなので、個別にapache httpdを入れなくても、このcactiのインストールだけでまとめてインストールしてくれそうです。
cactiユーザの作成までやってくれてます。
/etc/passwd
cacti:x:100:501::/usr/share/cacti:/sbin/nologin
インストールログ
なぜにインストールログなんてものを貼るんだ!
という意見もあるかと思いますが、同じようなことをやってる人が、困ったときとかに検索して引っかかったら、何か役立つかもしれないかなぁ、というのと、同じことをやろうとする人が現れた時に過去の実物を見られると今やってることの妥当性がわかる(こんなにたくさん関連物がインストールされちゃってるけど、これは別に問題ないんだ等)って感じで安心するのに役立つんじゃないかと思って、貼ってます。
自分でいうとエラーが起きたときとか、そのエラーメッセージをそのままgoogleの検索窓にコピペしてすぐに解決策がわかったことが多いし。
あとは、自分の記憶が薄くなったときに、あの時どうやったっけ?と過去検索するときに同様な安心感を得られるかな、と。
[root@linux38 sbin]# yum -y install cacti
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
core [1/3]
core 100% |=========================| 1.1 kB 00:00
updates [2/3]
updates 100% |=========================| 1.2 kB 00:00
extras [3/3]
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
- > Populating transaction set with selected packages. Please wait.
- > Downloading header for cacti to pack into transaction set.
cacti-0.8.6h-6.fc5.noarch 100% |=========================| 50 kB 00:25
- > Package cacti.noarch 0:0.8.6h-6.fc5 set to be updated
- > Running transaction check
- > Processing Dependency: php-snmp for package: cacti
- > Processing Dependency: net-snmp for package: cacti
- > Processing Dependency: rrdtool for package: cacti
- > Processing Dependency: php-mysql for package: cacti
- > Restarting Dependency Resolution with new changes.
- > Populating transaction set with selected packages. Please wait.
php-mysql-5.1.6-1.1.i386. 100% |=========================| 16 kB 00:00
php-snmp-5.1.6-1.1.i386.r 100% |=========================| 15 kB 00:01
rrdtool-1.2.15-3.fc5.i386 100% |=========================| 11 kB 00:04
net-snmp-5.3-4.2.i386.rpm 100% |=========================| 51 kB 00:01
- > Running transaction check
- > Processing Dependency: libnetsnmpagent.so.10 for package: net-snmp
- > Processing Dependency: libnetsnmp.so.10 for package: net-snmp
- > Processing Dependency: php = 5.1.6-1.1 for package: php-mysql
- > Processing Dependency: libnetsnmptrapd.so.10 for package: net-snmp
- > Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: php-mysql
- > Processing Dependency: libnetsnmphelpers.so.10 for package: net-snmp
- > Processing Dependency: libsensors.so.3 for package: net-snmp
- > Processing Dependency: php-pdo-abi = %{pdoabi} for package: php-mysql
- > Processing Dependency: php-pdo for package: php-mysql
- > Processing Dependency: php = 5.1.6-1.1 for package: php-snmp
- > Processing Dependency: libnetsnmp.so.10 for package: php-snmp
- > Processing Dependency: libnetsnmpmibs.so.10 for package: net-snmp
- > Restarting Dependency Resolution with new changes.
- > Populating transaction set with selected packages. Please wait.
- > Downloading header for php-pdo to pack into transaction set.
php-pdo-5.1.6-1.1.i386.rp 100% |=========================| 15 kB 00:00
lm_sensors-2.9.2-1.i386.r 100% |=========================| 29 kB 00:00
php-5.1.6-1.1.i386.rpm 100% |=========================| 21 kB 00:01
net-snmp-libs-5.3-4.2.i38 100% |=========================| 24 kB 00:00
mysql-5.0.22-1.FC5.1.i386 100% |=========================| 37 kB 00:01
- > Running transaction check
- > Processing Dependency: php = 5.1.2-5 for package: php-ldap
- > Processing Dependency: mysql = 5.0.18-2.1 for package: mysql-server
- > Restarting Dependency Resolution with new changes.
- > Populating transaction set with selected packages. Please wait.
php-ldap-5.1.6-1.1.i386.r 100% |=========================| 15 kB 00:01
mysql-server-5.0.22-1.FC5 100% |=========================| 34 kB 00:01
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
cacti noarch 0.8.6h-6.fc5 extras 1.1 M
Installing for dependencies:
lm_sensors i386 2.9.2-1 core 481 k
net-snmp i386 5.3-4.2 core 688 k
net-snmp-libs i386 5.3-4.2 core 2.5 M
php-mysql i386 5.1.6-1.1 updates 81 k
php-pdo i386 5.1.6-1.1 updates 60 k
php-snmp i386 5.1.6-1.1 updates 25 k
rrdtool i386 1.2.15-3.fc5 extras 436 k
Updating for dependencies:
mysql i386 5.0.22-1.FC5.1 updates 3.0 M
mysql-server i386 5.0.22-1.FC5.1 updates 9.9 M
php i386 5.1.6-1.1 updates 3.6 M
php-ldap i386 5.1.6-1.1 updates 31 k
Transaction Summary
=============================================================================
Install 8 Package(s)
Update 4 Package(s)
Remove 0 Package(s)
Total download size: 22 M
Downloading Packages:
(1/12): php-snmp-5.1.6-1. 100% |=========================| 25 kB 00:00
(2/12): rrdtool-1.2.15-3. 100% |=========================| 436 kB 00:51
(3/12): php-ldap-5.1.6-1. 100% |=========================| 31 kB 00:01
(4/12): php-pdo-5.1.6-1.1 100% |=========================| 60 kB 00:02
(5/12): lm_sensors-2.9.2- 100% |=========================| 481 kB 00:06
(6/12): net-snmp-5.3-4.2. 100% |=========================| 688 kB 00:08
http://mirror.clarkson.edu/pub/distributions/fedora/linux/extras/5/i386/cacti-0.8.6h-6.fc5.noarch.rpm: [Errno 12] Timeout:
Trying other mirror.
(7/12): cacti-0.8.6h-6.fc 100% |=========================| 1.1 MB 00:16
(8/12): php-5.1.6-1.1.i38 100% |=========================| 3.6 MB 00:58
(9/12): php-mysql-5.1.6-1 100% |=========================| 81 kB 00:01
(10/12): net-snmp-libs-5. 100% |=========================| 2.5 MB 00:29
(11/12): mysql-5.0.22-1.F 100% |=========================| 3.0 MB 00:39
(12/12): mysql-server-5.0 100% |=========================| 9.9 MB 02:19
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 1ac70ce6
Public key for rrdtool-1.2.15-3.fc5.i386.rpm is not installed
Retrieving GPG key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
Importing GPG key 0x1AC70CE6 "Fedora Project"
Key imported successfully
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : mysql ####################### [ 1/16]
Updating : php ####################### [ 2/16]
Installing: net-snmp-libs ####################### [ 3/16]
Installing: php-pdo ####################### [ 4/16]
Installing: php-mysql ####################### [ 5/16]
Installing: lm_sensors ####################### [ 6/16]
Installing: net-snmp ####################### [ 7/16]
Installing: php-snmp ####################### [ 8/16]
Installing: rrdtool ####################### [ 9/16]
Updating : php-ldap ####################### [10/16]
Installing: cacti ####################### [11/16]
Updating : mysql-server ####################### [12/16]
Cleanup : php-ldap ####################### [13/16]
Cleanup : php ####################### [14/16]
Cleanup : mysql ####################### [15/16]
Cleanup : mysql-server ####################### [16/16]
Installed: cacti.noarch 0:0.8.6h-6.fc5
Dependency Installed: lm_sensors.i386 0:2.9.2-1 net-snmp.i386 0:5.3-4.2 net-snmp-libs.i386 0:5.3-4.2 php-mysql.i386 0:5.1.6-1.1 php-pdo.i386 0:5.1.6-1.1 php-snmp.i386 0:5.1.6-1.1 rrdtool.i386 0:1.2.15-3.fc5
Dependency Updated: mysql.i386 0:5.0.22-1.FC5.1 mysql-server.i386 0:5.0.22-1.FC5.1 php.i386 0:5.1.6-1.1 php-ldap.i386 0:5.1.6-1.1
Complete!
[root@linux38 sbin]#
[root@linux38 sbin]# yum -y install cacti
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
core [1/3]
core 100% |=========================| 1.1 kB 00:00
updates [2/3]
updates 100% |=========================| 1.2 kB 00:00
extras [3/3]
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
- > Populating transaction set with selected packages. Please wait.
- > Downloading header for cacti to pack into transaction set.
cacti-0.8.6h-6.fc5.noarch 100% |=========================| 50 kB 00:25
- > Package cacti.noarch 0:0.8.6h-6.fc5 set to be updated
- > Running transaction check
- > Processing Dependency: php-snmp for package: cacti
- > Processing Dependency: net-snmp for package: cacti
- > Processing Dependency: rrdtool for package: cacti
- > Processing Dependency: php-mysql for package: cacti
- > Restarting Dependency Resolution with new changes.
- > Populating transaction set with selected packages. Please wait.
php-mysql-5.1.6-1.1.i386. 100% |=========================| 16 kB 00:00
php-snmp-5.1.6-1.1.i386.r 100% |=========================| 15 kB 00:01
rrdtool-1.2.15-3.fc5.i386 100% |=========================| 11 kB 00:04
net-snmp-5.3-4.2.i386.rpm 100% |=========================| 51 kB 00:01
- > Running transaction check
- > Processing Dependency: libnetsnmpagent.so.10 for package: net-snmp
- > Processing Dependency: libnetsnmp.so.10 for package: net-snmp
- > Processing Dependency: php = 5.1.6-1.1 for package: php-mysql
- > Processing Dependency: libnetsnmptrapd.so.10 for package: net-snmp
- > Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: php-mysql
- > Processing Dependency: libnetsnmphelpers.so.10 for package: net-snmp
- > Processing Dependency: libsensors.so.3 for package: net-snmp
- > Processing Dependency: php-pdo-abi = %{pdoabi} for package: php-mysql
- > Processing Dependency: php-pdo for package: php-mysql
- > Processing Dependency: php = 5.1.6-1.1 for package: php-snmp
- > Processing Dependency: libnetsnmp.so.10 for package: php-snmp
- > Processing Dependency: libnetsnmpmibs.so.10 for package: net-snmp
- > Restarting Dependency Resolution with new changes.
- > Populating transaction set with selected packages. Please wait.
- > Downloading header for php-pdo to pack into transaction set.
php-pdo-5.1.6-1.1.i386.rp 100% |=========================| 15 kB 00:00
lm_sensors-2.9.2-1.i386.r 100% |=========================| 29 kB 00:00
php-5.1.6-1.1.i386.rpm 100% |=========================| 21 kB 00:01
net-snmp-libs-5.3-4.2.i38 100% |=========================| 24 kB 00:00
mysql-5.0.22-1.FC5.1.i386 100% |=========================| 37 kB 00:01
- > Running transaction check
- > Processing Dependency: php = 5.1.2-5 for package: php-ldap
- > Processing Dependency: mysql = 5.0.18-2.1 for package: mysql-server
- > Restarting Dependency Resolution with new changes.
- > Populating transaction set with selected packages. Please wait.
php-ldap-5.1.6-1.1.i386.r 100% |=========================| 15 kB 00:01
mysql-server-5.0.22-1.FC5 100% |=========================| 34 kB 00:01
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
cacti noarch 0.8.6h-6.fc5 extras 1.1 M
Installing for dependencies:
lm_sensors i386 2.9.2-1 core 481 k
net-snmp i386 5.3-4.2 core 688 k
net-snmp-libs i386 5.3-4.2 core 2.5 M
php-mysql i386 5.1.6-1.1 updates 81 k
php-pdo i386 5.1.6-1.1 updates 60 k
php-snmp i386 5.1.6-1.1 updates 25 k
rrdtool i386 1.2.15-3.fc5 extras 436 k
Updating for dependencies:
mysql i386 5.0.22-1.FC5.1 updates 3.0 M
mysql-server i386 5.0.22-1.FC5.1 updates 9.9 M
php i386 5.1.6-1.1 updates 3.6 M
php-ldap i386 5.1.6-1.1 updates 31 k
Transaction Summary
=============================================================================
Install 8 Package(s)
Update 4 Package(s)
Remove 0 Package(s)
Total download size: 22 M
Downloading Packages:
(1/12): php-snmp-5.1.6-1. 100% |=========================| 25 kB 00:00
(2/12): rrdtool-1.2.15-3. 100% |=========================| 436 kB 00:51
(3/12): php-ldap-5.1.6-1. 100% |=========================| 31 kB 00:01
(4/12): php-pdo-5.1.6-1.1 100% |=========================| 60 kB 00:02
(5/12): lm_sensors-2.9.2- 100% |=========================| 481 kB 00:06
(6/12): net-snmp-5.3-4.2. 100% |=========================| 688 kB 00:08
http://mirror.clarkson.edu/pub/distributions/fedora/linux/extras/5/i386/cacti-0.8.6h-6.fc5.noarch.rpm: [Errno 12] Timeout:
Trying other mirror.
(7/12): cacti-0.8.6h-6.fc 100% |=========================| 1.1 MB 00:16
(8/12): php-5.1.6-1.1.i38 100% |=========================| 3.6 MB 00:58
(9/12): php-mysql-5.1.6-1 100% |=========================| 81 kB 00:01
(10/12): net-snmp-libs-5. 100% |=========================| 2.5 MB 00:29
(11/12): mysql-5.0.22-1.F 100% |=========================| 3.0 MB 00:39
(12/12): mysql-server-5.0 100% |=========================| 9.9 MB 02:19
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 1ac70ce6
Public key for rrdtool-1.2.15-3.fc5.i386.rpm is not installed
Retrieving GPG key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
Importing GPG key 0x1AC70CE6 "Fedora Project"
Key imported successfully
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : mysql ####################### [ 1/16]
Updating : php ####################### [ 2/16]
Installing: net-snmp-libs ####################### [ 3/16]
Installing: php-pdo ####################### [ 4/16]
Installing: php-mysql ####################### [ 5/16]
Installing: lm_sensors ####################### [ 6/16]
Installing: net-snmp ####################### [ 7/16]
Installing: php-snmp ####################### [ 8/16]
Installing: rrdtool ####################### [ 9/16]
Updating : php-ldap ####################### [10/16]
Installing: cacti ####################### [11/16]
Updating : mysql-server ####################### [12/16]
Cleanup : php-ldap ####################### [13/16]
Cleanup : php ####################### [14/16]
Cleanup : mysql ####################### [15/16]
Cleanup : mysql-server ####################### [16/16]
Installed: cacti.noarch 0:0.8.6h-6.fc5
Dependency Installed: lm_sensors.i386 0:2.9.2-1 net-snmp.i386 0:5.3-4.2 net-snmp-libs.i386 0:5.3-4.2 php-mysql.i386 0:5.1.6-1.1 php-pdo.i386 0:5.1.6-1.1 php-snmp.i386 0:5.1.6-1.1 rrdtool.i386 0:1.2.15-3.fc5
Dependency Updated: mysql.i386 0:5.0.22-1.FC5.1 mysql-server.i386 0:5.0.22-1.FC5.1 php.i386 0:5.1.6-1.1 php-ldap.i386 0:5.1.6-1.1
Complete!
[root@linux38 sbin]#
インストール直後のcactiの状態把握
yumを使ったcactiのインストールで、どこまで自動でやってくれているのか把握できないので、下記の手順でやっていることが出来てるのか確認していく。
cactiを動かすために必要なプロダクト
- 必要なものリスト
Updating : mysql ####################### [ 1/16] Updating : php ####################### [ 2/16] Installing: net-snmp-libs ####################### [ 3/16] Installing: php-pdo ####################### [ 4/16] Installing: php-mysql ####################### [ 5/16] Installing: lm_sensors ####################### [ 6/16] Installing: net-snmp ####################### [ 7/16] Installing: php-snmp ####################### [ 8/16] Installing: rrdtool ####################### [ 9/16] Updating : php-ldap ####################### [10/16] Installing: cacti ####################### [11/16] Updating : mysql-server ####################### [12/16] Cleanup : php-ldap ####################### [13/16] Cleanup : php ####################### [14/16] Cleanup : mysql ####################### [15/16] Cleanup : mysql-server ####################### [16/16]
cacti用UNIXアカウント作成
- 必要なもの
- ユーザ名 cactiuser
- ホームディレクトリ /home/cactiuser
- シェル なし
ということでひとまずOK。
/etc/passwd
cacti:x:100:501::/usr/share/cacti:/sbin/nologin
MySQLデータベースの設定
データベースを作成
やってみた。
[root@linux38 cacti]# mysqladmin --user=root create cacti mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
mysqldが起動してないんじゃないのか?って怒られたので、mysqld(mysqlデーモン)の起動の仕方を調べる。
mysqldの起動
- mam mysqldを読む。
- 使い方
[root@linux38 init.d]# ./mysqld 使い方: ./mysqld {start|stop|status|condrestart|restart}
よし、起動。
[root@linux38 init.d]# ./mysqld start MySQL データベースを初期化中: Installing all prepared tables Fill help tables To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h linux38 password 'new-password' See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory: cd sql-bench ; perl run-all-tests Please report any problems with the /usr/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com [ OK ] MySQL を起動中: [ OK ] [root@linux38 init.d]#
いろいろ起動しました。
[root@linux38 init.d]# ps -ef|grep mysqld
root 2386 1 0 17:08 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid --log-error=/var/log/mysqld.log
mysql 2422 2386 0 17:08 ? 00:00:00 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock
root 2494 1714 0 17:13 pts/0 00:00:00 grep mysqld
データベースを作成(再挑戦)
[root@linux38 init.d]# mysqladmin --user=root create cacti [root@linux38 init.d]#
テーブル等をインポート
shell# mysql cacti < cacti.sql
[root@linux38 cacti]# find / -name cacti.sql
find: WARNING: Hard link count is wrong for /selinux: this may be a bug in your filesystem
driver. Automatically turning on find's -noleaf option. Earlier results may have failed to
include directories that should have been searched.
/usr/share/doc/cacti-0.8.6h/cacti.sql
[root@linux38 cacti]# mysql cacti < /usr/share/doc/cacti-0.8.6h/cacti.sql [root@linux38 cacti]#
アカウントを作成
[root@linux38 cacti]# 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 -AWelcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.22Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> grant all on cacti.* to cacti@linux38 identified by (秘密のパスワード);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(秘密のパスワード)' at line 1
mysql> grant all on cacti.* to cacti@linux38 identified by '(秘密のパスワード)';
Query OK, 0 rows affected (0.00 sec)mysql> flush priviledges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'priviledges' at line 1
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
cacti動作環境の設定(この節には、間違い作業も含まれてるので要注意です。最後には気づいて治っていく様子も顛末記という意味合いで載せてます)
MySQLのアカウント設定
include/config.phpの場所を探す
[root@linux38 cacti]# find / -name config.php
find: WARNING: Hard link count is wrong for /selinux: this may be a bug in your filesystem driver. Automatically turning on find's -noleaf option. Earlier results may have failed to include directories that should have been searched.
/usr/share/cacti/include/config.php
include/config.phpを開くとわかるんだけど、
$database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "パスワード";
に該当する場所はない。ただ、こららの4つの変数は使われている。こういうのは外部ファイルで定義するように変更されがちなので、(phpの文法は知らないけど)よく読んでみると最初の方に、
*/ require_once("db.php"); /* ----- you probably do not need to change anything below this line ----- */
なんてのが書いてある。DBの定義を外でやってるのね、と。
root@linux38 cacti]# ls -la 合計 16 drwxr-xr-x 2 root root 19 10月 22 15:50 . drwxr-xr-x 83 root root 8192 10月 22 16:28 .. -rw-rw---- 1 cacti apache 264 6月 4 06:30 db.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 = "cactiuser"; $database_port = "3306"; ?>
編集後
[root@linux38 cacti]# more db.php <? /* make sure these values refect your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "linux38"; $database_username = "cacti"; $database_password = "(秘密のパスワード)"; $database_port = "3306"; ?>
パーミッションの変更
[root@linux38 cacti]# ls -la rra log lrwxrwxrwx 1 root root 15 10月 22 15:50 log -> /var/log/cacti/ lrwxrwxrwx 1 root root 18 10月 22 15:50 rra -> /var/lib/cacti/rra [root@linux38 cacti]# chown -R cacti rra/ log/ [root@linux38 cacti]# ls -la rra log lrwxrwxrwx 1 root root 15 10月 22 15:50 log -> /var/log/cacti/ lrwxrwxrwx 1 root root 18 10月 22 15:50 rra -> /var/lib/cacti/rra
変更できてない?
[root@linux38 cacti]# ls -la /var/log/cacti/ 合計 4 drwxrwxr-x 2 cacti apache 22 10月 22 15:50 . drwxr-xr-x 10 root root 4096 10月 22 16:03 .. -rw-rw-r-- 1 cacti apache 0 6月 4 06:30 cacti.log [root@linux38 cacti]# ls -la /var/lib/cacti/rra 合計 0 drwxr-xr-x 2 cacti root 6 6月 4 06:30 . drwxr-xr-x 4 root root 30 10月 22 15:50 .. [root@linux38 cacti]#
出来てるっぽい。リンクの場合、こういう表示でOKということ?ここのパーミッショはひとまずcareしておいて、次に進む([TODO])←課題検索用タグ
- データ収集スクリプトの動作確認
mysqlに接続拒否されてる。
[root@linux38 cacti]# php poller.php PHP Warning: mysql_pconnect(): Access denied for user 'cacti'@'linux38' (using password: NO) in /usr/share/cacti/lib/adodb/drivers/adodb-mysql.inc.php on line 355
-
- 怪しむ箇所
- [候補]mysqlが起動していない。 →してた。
- 怪しむ箇所
[root@linux38 cacti]# ps -ef |grep mysql
mysql 3120 1 0 18:02 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid --log-error=/var/log/mysqld.log
mysql 3151 3120 0 18:02 ? 00:00:00 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock
-
-
- [候補]mysqldがlistenしていない。→してた。(これでOK?)
-
[root@linux38 cacti]# netstat -a|more Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:58817 *:* LISTEN tcp 0 0 *:rsync *:* LISTEN ''tcp 0 0 *:mysql *:* LISTEN''
-
-
- [候補]mysqlユーザID,パスワードが間違っている。
-
ここっぽい。mysqlのcactiユーザのパスワードを確認or新しいパスワードで上書きする。
-
-
- [候補]IPレベルで接続拒否されている
-
hosts.allow, hosts.denyレベルで。
ここまでやってた時に、先日の懸案だったiptablesの件が解決した。
$database_hostname = "linux38";
が
$database_hostname = "localhost";
になってて
[root@linux38 cacti]# php poller.php PHP Warning: mysql_pconnect(): Access denied for user 'cacti'@'localhost' (using password: YES) in /usr/share/cacti/lib/adodb/drivers/adodb-mysql.inc.php on line 355
と出てたので、
$database_hostname = "linux38";
に修正したら、このエラーが出なくなった。
※ここに間違いの原因が表示されているんだけど、この時は気づいてなかったし、顛末記の意味合いもあるので、このままログを貼ってます。
ホスト名は 「'cacti'@'localhost'」 じゃなくて、 「cacti@localhost」だろってあたりに。
[root@linux38 cacti]# more db.php <? /* make sure these values refect your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "linux38"; $database_username = "cacti"; $database_password = "(注:秘密です)"; $database_port = "3306"; ?>
[root@linux38 cacti]# php poller.php sh: -: command not found
と出て、データ収集スクリプトの動作確認が終わらない・・・
なぜこの箇所の見直しをしたかというと
MySQL サーバを実行しているホスト以外のホストから接続しようとして以下のエラーが発生する場合、そのホストと一致するレコードが user テーブルにないということである。
Host ... is not allowed to connect to this MySQL server
http://dev.mysql.com/doc/refman/4.1/ja/access-denied.html
MySQLサーバに外部から接続する場合、ここら辺が原因となって接続できない場合がある、というのがわかったため。
windowsのMySQLAdministratorの接続を試みているが、今このエラーが出ている。
windowsからMySQLadministratorを使って接続できた。
cactiデータベースに接続
[root@linux38 cacti]# mysql -u root -p cacti Enter password: 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 20 to server version: 5.0.22 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> grant all on cacti.* to 'cacti'@'192.168.10.23' identified by '(秘密のパスワード)'; Query OK, 0 rows affected (0.00 sec)
※大いなる間違いコマンドが!!'cacti'@'192.168.10.23'じゃないって。cacti@192.168.10.23だって。
権限を反映する。
[root@linux38 cacti]# mysqladmin -u root -p flush-privileges; Enter password: [root@linux38 cacti]#
ここで仕切りなおし
cronへの登録
# crontab -u cactiuser -e */5 * * * * /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
cactiをwwwから見れるようにする。
#mkdir /var/www/html/cacti #ln -s /usr/share/cacti /var/www/html/cacti
リンクの貼り方を間違えてる。cacti階層が2重になってる。
[root@linux38 cacti]# pwd /var/www/html/cacti/cacti [root@linux38 cacti]# ls -la index.php -rw-r--r-- 1 cacti cacti 2271 6月 4 06:30 index.php
直し
#rm -fr /var/www/html/cacti #ln -s /usr/share/cacti /var/www/html/cacti
疎通
この時点でアクセスすると403が出る。
webサーバのホスト認証をいじらないとダメっぽい。というのも
- /var/www/html/の設定はやったが
- /var/www/html/cactiの設定はまだ書いてないから
- cactiの下に固定のhtmlファイルをおいて、それにアクセスを試みるも403だった。つまりwebサーバのcgi-binとかphpの部分の設定ではなくて、ディレクトリのアクセス権限のところがおかしいはず。
やはりdenyされてた!
[root@linux38 logs]# pwd /etc/httpd/logs [root@linux38 logs]# tail -f error_log [Mon Oct 23 22:07:53 2006] [error] [client 192.168.10.23] client denied by server configuration: /usr/share/cacti/cacti [Mon Oct 23 22:11:42 2006] [error] [client 192.168.10.23] client denied by server configuration: /usr/share/cacti/index [Mon Oct 23 22:13:24 2006] [error] [client 192.168.10.23] client denied by server configuration: /usr/share/cacti/unko.html
こんな設定ファイルたちが見つかった。こいつらだ。 httpd.conをいじるんじゃなくて、個別の設定はこうやってファイルを分けてここにおいておく方式のようだ。
[root@linux38 conf.d]# ls -la 合計 56 drwxr-xr-x 2 root root 4096 10月 22 15:50 . drwxr-xr-x 4 root root 65 10月 22 15:26 .. -rw-r--r-- 1 root root 392 7月 27 00:13 README -rw-r--r-- 1 root root 173 6月 4 06:30 cacti.conf -rw-r--r-- 1 root root 295 7月 27 00:13 manual.conf -rw-r--r-- 1 root root 1796 4月 22 2005 perl.conf -rw-r--r-- 1 root root 560 10月 16 23:03 php.conf -rw-r--r-- 1 root root 566 7月 27 00:13 proxy_ajp.conf -rw-r--r-- 1 root root 1671 2月 28 2006 python.conf -rw-r--r-- 1 root root 332 2月 12 2006 squid.conf -rw-r--r-- 1 root root 9677 7月 27 00:13 ssl.conf -rw-r--r-- 1 root root 352 2月 13 2006 webalizer.conf -rw-r--r-- 1 root root 299 7月 27 00:13 welcome.conf [root@linux38 conf.d]# pwd /etc/httpd/conf.d [root@linux38 conf.d]# more cacti.conf # # Cacti: An rrd based graphing tool # Alias /cacti /usr/share/cacti <Directory /usr/share/cacti/> Order Deny,Allow Deny from all Allow from 127.0.0.1 </Directory> [root@linux38 conf.d]#
しっかりと
Allow from 127.0.0.1
と書いてある。ここに、windowsのIPを加える。
[root@linux38 conf.d]# vi cacti.conf # # Cacti: An rrd based graphing tool # Alias /cacti /usr/share/cacti <Directory /usr/share/cacti/> Order Deny,Allow Deny from all Allow from 127.0.0.1 192.168.10.23 </Directory>
編集後、httpdを再起動する。
[root@linux38 conf.d]# /etc/init.d/httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ] [root@linux38 conf.d]#
固定ファイルは403が出なくなり、見られるようになった。
http://192.168.10.38/cacti/unko.html
こっちはダメ。
http://192.168.10.38/cacti/index.php
cactiさんが正常に動いてない。
[root@linux38 logs]# pwd
/etc/httpd/logs
[root@linux38 logs]# tail -f error_log
[Mon Oct 23 22:22:43 2006] [error] [client 192.168.10.23] PHP Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to MySQL server on 'linux38' (13) in /usr/share/cacti/lib/adodb/drivers/adodb-mysql.inc.php on line 355
[Mon Oct 23 22:22:45 2006] [notice] child pid 3823 exit signal Segmentation fault (11)
linux38上のMySQLサーバに繋がらねぇ、と。
※ここでやっと気づいたのです。
'linux38'というサーバじゃなくて、linux38というサーバ名なので、grantの分を書き直した。
mysql>grant all on cacti.* to cacti@192.168.10.23 identified by '(秘密のパスワード)'; mysql>grant all on cacti.* to cacti@192.168.10.38 identified by '(秘密のパスワード)'; mysql>grant all on cacti.* to cacti@localhost identified by '(秘密のパスワード)'; mysql>flush privileges; http://192.168.10.38/cacti/index.php
接続できた
MySQLAdministratorのUserAdministrationのページでエラーが出るのは未解決。
疎通できた。
memo
ln -sじゃなくて、aliasが正解では?
apacheの設定ファイルに追加 Alias /cacti/ /usr/local/cacti/
設定画面@ブラウザ
http://blog.so-net.ne.jp/oyazi/archive/20051120-0-10
net-snmp yum-yで! devtoolも入れる。snmpwalkとsnmpget。 調べるときは、 snmpwalk -v 1 -c public xxx.xxx.xxx.xxx --------------------- いざ、インストール 環境:fedora core 3 --------------------- 1.net-snmp yum -y install net-snmp* snmpwalk -v 1 -c public 1.2.3.4
これ! cactiのyumのときはdevtoolが入っていない。
[root@linux38 logs]# yum -y install net-snmp* Loading "installonlyn" plugin Setting up Install Process Setting up repositories core [1/3] updates [2/3] extras [3/3] Reading repository metadata in from local files Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for net-snmp-devel to pack into transaction set. net-snmp-devel-5.3-4.2.i3 100% |=========================| 57 kB 00:01 ---> Package net-snmp-devel.i386 0:5.3-4.2 set to be updated ---> Downloading header for net-snmp-utils to pack into transaction set. net-snmp-utils-5.3-4.2.i3 100% |=========================| 27 kB 00:01 ---> Package net-snmp-utils.i386 0:5.3-4.2 set to be updated ---> Downloading header for net-snmp-perl to pack into transaction set. net-snmp-perl-5.3-4.2.i38 100% |=========================| 29 kB 00:01 ---> Package net-snmp-perl.i386 0:5.3-4.2 set to be updated --> Running transaction check --> Processing Dependency: beecrypt-devel for package: net-snmp-devel --> Processing Dependency: elfutils-devel for package: net-snmp-devel --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. ---> Downloading header for beecrypt-devel to pack into transaction set. beecrypt-devel-4.1.2-9.2. 100% |=========================| 13 kB 00:00 ---> Package beecrypt-devel.i386 0:4.1.2-9.2.1 set to be updated ---> Downloading header for elfutils-devel to pack into transaction set. elfutils-devel-0.119-1.2. 100% |=========================| 11 kB 00:00 ---> Package elfutils-devel.i386 0:0.119-1.2.1 set to be updated --> Running transaction check Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: net-snmp-devel i386 5.3-4.2 core 263 k net-snmp-perl i386 5.3-4.2 core 191 k net-snmp-utils i386 5.3-4.2 core 178 k Installing for dependencies: beecrypt-devel i386 4.1.2-9.2.1 core 138 k elfutils-devel i386 0.119-1.2.1 core 110 k Transaction Summary ============================================================================= Install 5 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 879 k Downloading Packages: (1/5): net-snmp-devel-5.3 100% |=========================| 263 kB 00:04 (2/5): beecrypt-devel-4.1 100% |=========================| 138 kB 00:02 (3/5): net-snmp-utils-5.3 100% |=========================| 178 kB 00:03 (4/5): net-snmp-perl-5.3- 100% |=========================| 191 kB 00:03 (5/5): elfutils-devel-0.1 100% |=========================| 110 kB 00:02 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: elfutils-devel ######################### [1/5] Installing: beecrypt-devel ######################### [2/5] Installing: net-snmp-devel ######################### [3/5] Installing: net-snmp-utils ######################### [4/5] Installing: net-snmp-perl ######################### [5/5] Installed: net-snmp-devel.i386 0:5.3-4.2 net-snmp-perl.i386 0:5.3-4.2 net-snmp-utils.i386 0:5.3-4.2 Dependency Installed: beecrypt-devel.i386 0:4.1.2-9.2.1 elfutils-devel.i386 0:0.119-1.2.1 Complete! [root@linux38 logs]#
狙い通りに、snmp関連のバイナリがインストールされた。
[root@linux38 logs]# which snmpget /usr/bin/snmpget [root@linux38 logs]# which snmpbulkwalk /usr/bin/snmpbulkwalk [root@linux38 logs]# which snmpwalk /usr/bin/snmpwalk [root@linux38 logs]# which snmpgetnext /usr/bin/snmpgetnext [root@linux38 logs]#
初期設定
http://www.stackasterisk.jp/tech/systemManagement/snmp05_01.jsp
snmpdの起動をやると、進展あった
[root@linux38 logs]# ps -ef|grep snmp root 4417 3407 0 23:24 pts/0 00:00:00 grep snmp [root@linux38 logs]# which snmpd /usr/sbin/snmpd [root@linux38 logs]# snmpd [root@linux38 logs]# ps -ef|grep snmp root 4423 1 3 23:24 ? 00:00:00 snmpd root 4425 3407 0 23:24 pts/0 00:00:00 grep snmp [root@linux38 logs]# [root@linux38 logs]#
正確にはこっちで起動か
[root@linux38 logs]# /etc/init.d/snmpd 使い方: /etc/init.d/snmpd {start|stop|status|restart|condrestart|reload} [root@linux38 logs]# /etc/init.d/snmpd start snmpd を起動中: [ OK ] [root@linux38 logs]#
とりあえず表示されるようになりました。
表示項目の選択がてきとうなので、そのうち洗練させていきます。あと、応用編も一応読んで実際にやっておく。
http://www.stackasterisk.jp/tech/systemManagement/snmp06_01.jsp
cactiのログインパスワード忘れた!!
adminのパスワードがわからなくなったので、
- 初期データ作成用SQL/usr/share/doc/cacti-0.8.6h/cacti.sql)
- アカウント作成部分のSQL
- INSERT INTO user_auth VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,'Administrator','on','on','on','on','on',1, 1,1,1,1);
- INSERT INTO user_auth VALUES (3,'guest','43e9a4ab75570f5b',0,'Guest Account','on','on','on','on','on',3,1,1,1,1);
- アカウント作成部分のSQL
ここの「21232f297a57a5a743894a0e4a801fc3」が「admin」という文字列の暗号化後だと知ってるので、この値でDBのuser_authテーブルのid=1の列のpassword列の値をupdate文を書いて上書きした。
adminというパスワードに更新されて無事ログインできた。