1 Requirements( 需求)
- Red Hat Enterprise Linux Server release 5.2 (Tikanga)
- RRDTool 1.0.49 or 1.2.x or greater
- MySQL 4.1.x or 5.x or greater
- PHP 4.3.6 or greater, 5.x greater highly recommended for advanced features
- A Web Server e.g. Apache
2 Installing Under Unix(安装)
Please make sure, the following packages are installed according to your operating systems requirements. Verify,that httpd and mysqld are started at systemstartup.
2.1 Required Packages for RPM-based Operating Systems(需要安装rpm包)
php-cli-5.1.6-15.el5
php-ldap-5.1.6-15.el5
php-mbstring-5.1.6-15.el5
php-common-5.1.6-15.el5
php-gd-5.1.6-15.el5
php-5.1.6-15.el5
php-mysql-5.1.6-15.el5
php-snmp-5.1.6-15.el5
php-pdo-5.1.6-15.el5
libdbi-dbd-mysql-0.8.1a-1.2.2
mysql-devel-5.0.22-2.1.0.1
mysql-server-5.0.22-2.1.0.1
mysql-connector-odbc-3.51.12-2.2
php-mysql-5.1.6-15.el5
mysql-5.0.22-2.1.0.1
net-snmp-5.3.1-19.el5
net-snmp-libs-5.3.1-19.el5
net-snmp-utils-5.3.1-19.el5
net-snmp-devel-5.3.1-19.el5
php-snmp-5.1.6-15.el5
2.1.1 安装apache
[root@localhost Server]# rpm -icvh apr-1.2.7-11.i386.rpm warning: apr-1.2.7-11.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:apr ########################################### [100%]
[root@localhost Server]# rpm -icvh postgresql-libs-8.1.11-1.el5_1.1.i386.rpm warning: postgresql-libs-8.1.11-1.el5_1.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:postgresql-libs ########################################### [100%] [root@localhost Server]# rpm -icvh apr-util-1.2.7-7.el5.i386.rpm warning: apr-util-1.2.7-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:apr-util ########################################### [100%] [root@localhost Server]# rpm -icvh httpd-2.2.3-11.el5_1.3.i386.rpm warning: httpd-2.2.3-11.el5_1.3.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:httpd ########################################### [100%] [root@localhost Server]#
[root@localhost ~]# rpm -qa|grep httpd httpd-2.2.3-11.el5_1.3 |
2.1.2 安装net-snmp
[root@localhost ~]# rpm -qa|grep net-snmp net-snmp-libs-5.3.1-24.el5 net-snmp-5.3.1-24.el5 net-snmp-utils-5.3.1-24.el5
|
2.1.3 安装php5
php-common-5.1.6-20.el5
php-pdo-5.1.6-20.el5
php-mbstring-5.1.6-20.el5
php-cli-5.1.6-20.el5
php-mysql-5.1.6-20.el5
php-ldap-5.1.6-20.el5
php-gd-5.1.6-20.el5
php-5.1.6-20.el5
php-snmp-5.1.6-20.el5
[root@localhost Server]# rpm -icvh gmp-4.1.4-10.el5.i386.rpm warning: gmp-4.1.4-10.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:gmp ########################################### [100%] [root@localhost Server]# rpm -icvh php-common-5.1.6-20.el5.i386.rpm warning: php-common-5.1.6-20.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:php-common ########################################### [100%]
[root@localhost Server]# rpm -icvh php-cli-5.1.6-20.el5.i386.rpm warning: php-cli-5.1.6-20.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:php-cli ########################################### [100%] [root@localhost Server]#
[root@localhost Server]# rpm -icvh php-5.1.6-20.el5.i386.rpm warning: php-5.1.6-20.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:php ########################################### [100%] [root@localhost ~]# rpm -icvh /mnt/dvd/Server/php-ldap-5.1.6-20.el5.i386.rpm warning: /mnt/dvd/Server/php-ldap-5.1.6-20.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:php-ldap ########################################### [100%] [root@localhost ~]# rpm -icvh /mnt/dvd/Server/php-mbstring-5.1.6-20.el5.i386.rpm warning: /mnt/dvd/Server/php-mbstring-5.1.6-20.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:php-mbstring ########################################### [100%] [root@localhost ~]# [root@localhost ~]# rpm -icvh /mnt/dvd/Server/php-gd-5.1.6-20.el5.i386.rpm warning: /mnt/dvd/Server/php-gd-5.1.6-20.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:php-gd ########################################### [100%] |
2.1.4 安装php-mysql
[root@localhost Server]# rpm -icvh php-pdo-5.1.6-20.el5.i386.rpm warning: php-pdo-5.1.6-20.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:php-pdo ########################################### [100%] [root@localhost Server]# rpm -icvh php-mysql-5.1.6-20.el5.i386.rpm warning: php-mysql-5.1.6-20.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:php-mysql ########################################### [100%]
|
2.1.5 安装php-snmp
[root@localhost Server]# rpm -icvh lm_sensors-2.10.0-3.1.i386.rpm warning: lm_sensors-2.10.0-3.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:lm_sensors ########################################### [100%] [root@localhost Server]# rpm -icvh lm_sensors-devel-2.10.0-3.1.i386.rpm warning: lm_sensors-devel-2.10.0-3.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:lm_sensors-devel ########################################### [100%] [root@localhost Server]# rpm -icvh net-snmp-5.3.1-24.el5.i386.rpm warning: net-snmp-5.3.1-24.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:net-snmp ########################################### [100%] [root@localhost Server]# rpm -icvh php-snmp-5.1.6-20.el5.i386.rpm warning: php-snmp-5.1.6-20.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:php-snmp ########################################### [100%] |
2.1.6 安装mysql
mysql-5.0.45-7.el5
libdbi-dbd-mysql-0.8.1a-1.2.2
mysql-devel-5.0.45-7.el5
php-mysql-5.1.6-20.el5
mysql-connector-odbc-3.51.12-2.2
mysql-server-5.0.45-7.el5
rpm -icvh perl-DBI-1.52-1.fc6.i386.rpm rpm -icvh mysql-5.0.45-7.el5.i386.rpm rpm -icvh perl-DBD-MySQL-3.0007-1.fc6.i386.rpm rpm -icvh mysql-server-5.0.45-7.el5.i386.rpm
rpm -icvh /mnt/dvd/Server/libdbi-0.8.1-2.1.i386.rpm rpm -icvh /mnt/dvd/Server/libdbi-drivers-0.8.1a-1.2.2.i386.rpm rpm -icvh /mnt/dvd/Server/libdbi-dbd-mysql-0.8.1a-1.2.2.i386.rpm rpm -icvh /mnt/dvd/Server/e2fsprogs-devel-1.39-15.el5.i386.rpm rpm -icvh /mnt/dvd/Server/keyutils-libs-devel-1.2-1.el5.i386.rpm rpm -icvh /mnt/dvd/Server/libsepol-devel-1.15.2-1.el5.i386.rpm rpm -icvh /mnt/dvd/Server/libselinux-devel-1.33.4-5.el5.i386.rpm rpm -icvh /mnt/dvd/Server/krb5-devel-1.6.1-25.el5.i386.rpm rpm -icvh /mnt/dvd/Server/zlib-devel-1.2.3-3.i386.rpm rpm -icvh /mnt/dvd/Server/openssl-devel-0.9.8b-10.el5.i386.rpm rpm -icvh /mnt/dvd/Server/mysql-devel-5.0.45-7.el5.i386.rpm
rpm -icvh /mnt/dvd/Server/libtool-ltdl-1.5.22-6.1.i386.rpm rpm -icvh /mnt/dvd/Server/unixODBC-2.2.11-7.1.i386.rpm rpm -icvh /mnt/dvd/Server/mysql-connector-odbc-3.51.12-2.2.i386.rpm
rpm -icvh /mnt/dvd/Server/beecrypt-devel-4.1.2-10.1.1.i386.rpm rpm -icvh /mnt/dvd/Server/elfutils-devel-0.125-3.el5.i386.rpm rpm -icvh /mnt/dvd/Server/elfutils-libs-0.125-3.el5.i386.rpm rpm -icvh elfutils-libelf-devel-static-0.125-3.el5.i386.rpm elfutils-libelf-devel-0.125-3.el5.i386.rpm rpm -icvh elfutils-devel-static-0.125-3.el5.i386.rpm elfutils-devel-0.125-3.el5.i386.rpm |
2.2 安装rrd-tool
2.2.1 安装microsoft雅黑字体
E:/Server/dejavu-lgc-fonts-2.10-1.noarch.rpm
[root@vm195002029 ~]# rpm -icvh dejavu-lgc-fonts-2.10-1.noarch.rpm warning: dejavu-lgc-fonts-2.10-1.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%]
|
2.2.2 安装rrdtool
下载地址
http://www.rpmfind.net/linux/rpm2html/search.php?query=rrdtool
下载rrdtool-1.3.4-1.26.x86_64.rpm
http://rpm.pbone.net/index.php3/stat/4/idpl/12986118/com/rrdtool-1.3.9-1.el5.pp.i386.rpm.html
下载rrdtool-1.3.9-1.el5.pp.i386.rpm
[root@vm195002029 ~]# rpm -icvh rrdtool-1.3.9-1.el5.pp.i386.rpm warning: rrdtool-1.3.9-1.el5.pp.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6971f6ac Preparing... ########################################### [100%] 1:rrdtool ########################################### [100%] |
2.2.3 测试rrdtool
[root@vm195002029 /usr/bin]# ./rrdtool -v RRDtool 1.3.9 Copyright 1997-2009 by Tobias Oetiker <tobi@oetiker.ch> Compiled Oct 27 2009 10:37:10
Usage: rrdtool [options] command command_options
Valid commands: create, update, updatev, graph, graphv, dump, restore, last, lastupdate, first, info, fetch, tune, resize, xport
RRDtool is distributed under the Terms of the GNU General Public License Version 2. (www.gnu.org/copyleft/gpl.html)
For more information read the RRD manpages
|
3 Installing Cacti under Redhat As 5.2
3.1 配置web server(apache)
3.1.1 编译/etc/httpd/conf/httpd.conf
# # Load config files from the config directory "/etc/httpd/conf.d". # Include conf.d/*.conf[w1] |
3.1.2 编译/etc/httpd/conf.d/php.conf
# # PHP is an HTML-embedded scripting language which attempts to make it # easy for developers to write dynamically generated webpages. #
LoadModule php5_module modules/libphp5.so
# # Cause the PHP interpreter to handle files with a .php extension. # AddHandler php5-script .php AddType text/html .php
# # Add index.php to the list of files that will be served as directory # indexes. # DirectoryIndex index.php
# # Uncomment the following line to allow PHP to pretty-print .phps # files as PHP source code: # #AddType application/x-httpd-php-source .phps |
3.1.3 启动apache
[root@localhost ~] # service httpd start
|
l 自动启动apache
ntsysv
3.1.4 测试php
/var/www/html目录下创建文件test.php
<?php
/** * Simple test for PHP5 */
phpinfo();
?> |
3.2 设置mysql
3.2.1 启动mysql
[root@localhost ~]# service mysqld start |
3.2.2 Mysql自动启动
ntsysv
Tab键 àEnter 键,退出
3.2.3 创建数据库cacti
s128000022:~ # mysql Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 2 Server version: 5.0.67 SUSE MySQL RPM
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> create database cacti;[w2] Query OK, 1 row affected (0.00 sec)
mysql> show databases[w3] ; +--------------------+ | Database | +--------------------+ | information_schema | | cacti | | mysql | | test | +--------------------+ 4 rows in set (0.00 sec) |
3.3 安装cacti
下载地址:http://www.cacti.net
[root@vm195002029 ~]# tar xvfz cacti-0.8.7e.tar.gz[w4] …… cacti-0.8.7e/log/cacti.log cacti-0.8.7e/settings.php cacti-0.8.7e/graph_templates_inputs.php cacti-0.8.7e/host_templates.php [root@localhost cacti-0.8.7g]# mysql cacti <cacti.sql [root@vm195002029 ~/cacti-0.8.7e]# mysql cacti < cacti.sql[w5] [root@vm195002029 ~/cacti-0.8.7e]# mysql Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 8 Server version: 5.0.67 SUSE MySQL RPM
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';[w6] Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> select host,user,password from mysql.user;[w7] +-------------+-----------+------------------+ | host | user | password | +-------------+-----------+------------------+ | localhost | root | | | vm195002029 | root | | | 127.0.0.1 | root | | | localhost | cactiuser | 2d6bfde554cd0e36 | +-------------+-----------+------------------+ 4 rows in set (0.00 sec) |
3.4 设置cacti
l Edit include/config.php and specify the MySQL user, password and database for your Cacti configuration.
/var/www/html/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 = "somepassword "; $database_port = "3306"; <?php |
l Set the appropriate permissions on cacti’s directories for graph/log generation. You should execute these commands from inside cacti’s directory to change the permissions.(设置rra和log的权限)
chown -R root rra/ log/ |
(Enter a valid username for cactiuser, this user will also be used in the next step for data gathering.)
l Crontab
[root@localhost ~]# crontab -e */5 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1 |
l 下载cacti patch
http://www.cacti.net/downloads/patches/0.8.7g/
wget http://www.cacti.net/downloads/patches/0.8.7e/cli_add_graph.patch |
3.5 关闭selinux
[root@localhost ~]# setenforce 0 |
自动关闭selinux
/etc/selinux/config
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. #SELINUX=enforcing # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted
|
3.6 配置cacti
http://10.155.2.81/cacti/install/
NEXT-->NEXT
Cacti Installation Guide |
Make sure all of these values are correct before continuing. [FOUND] RRDTool Binary Path: The path to the rrdtool binary. [FOUND] PHP Binary Path: The path to your PHP binary file (may require a php recompile to get this file). [FOUND] snmpwalk Binary Path: The path to your snmpwalk binary. [FOUND] snmpget Binary Path: The path to your snmpget binary. [FOUND] snmpbulkwalk Binary Path: The path to your snmpbulkwalk binary. [FOUND] snmpgetnext Binary Path: The path to your snmpgetnext binary. [FOUND] Cacti Log File Path: The path to your Cacti log file. SNMP Utility Version: The type of SNMP you have installed. Required if you are using SNMP v2c or don't have embedded SNMP support in PHP. RRDTool Utility Version: The version of RRDTool that you have installed. NOTE: Once you click "Finish", all of your settings will be saved and your database will be upgraded if this is an upgrade. You can change any of the settings on this screen at a later time by going to "Cacti Settings" from within Cacti.
|
用户名/密码=admin/admin
4 在windows 上安装snmp
5 Linux上配置snmp
编辑/etc/snmp/snmpd.conf
rocommunity public |
启动snmp服务
[root@vm195002029 /etc/snmp]# service snmpd restart |
自动启动snmp服务
6 问题与解决
6.1 没有图表,是红叉?
说明还没有数据产生,添加设备后需要一些时间(5分钟)才会有图表,如果等待后,还是红叉,在rra目下也没有文件,需要手工执行/usr/bin/php /var/www/html/cacti/poller.php。
6.2 有图表,没有数据?
1怀疑snmp客户端没有设置好。如下命令检查
snmpwalk -c chrsnmp -v 2c 10.155.3.9 if
返回Timeout: No Response,snmp设置有问题
2怀疑crontab没有正常工作,可以在cacti的日志中(System Utilities->View Cacti Log File),是否没5分钟一次日志,从以下日志可以看到每5分钟执行一次,黄色部分有错误日志产生
3第一次打开http://ip/ciacit/install或者http://ip/cacit页面是空白,php测试页正常,是php的一个rpm没有安装造成的,请检查。