分类: LINUX
2008-12-15 21:24:04
cacti安装说明
说明:cacti是一套开源的网络、服务器监控软件。
一、安装依赖的软件
1、安装apache
[root@monitor ~]# yum install httpd |
检验是否安装成功:
[root@monitor cacti]# rpm -qa|grep httpd system-config-httpd-1.3.3.3-1.el5 httpd-2.2.3-11.el5_1.centos.3 httpd-manual-2.2.3-11.el5_1.centos.3 |
2、安装mysql
[root@monitor ~]# yum install mysql mysql server |
检验是否安装成功:
[root@monitor cacti]# rpm -qa|grep mysql mysql-5.0.45-7.el5 mysql-server-5.0.45-7.el5 |
3、安装php相关
[root@monitor ~]# yum install php php-mysql php-snmp |
检验是否安装成功:
[root@monitor cacti]# rpm -qa|grep php php-5.1.6-20.el5_2.1 php-common-5.1.6-20.el5_2.1 php-pdo-5.1.6-20.el5_2.1 php-cli-5.1.6-20.el5_2.1 php-mysql-5.1.6-20.el5_2.1 php-ldap-5.1.6-20.el5_2.1 php-snmp-5.1.6-20.el5_2.1 |
4、安装net-snmp相关
[root@monitor ~]# yum install net-snmp net-snmp-utils |
检验是否安装成功:
[root@monitor cacti]# rpm -qa|grep net-snmp net-snmp-5.3.1-24.el5_2.2 net-snmp-utils-5.3.1-24.el5_2.2 net-snmp-libs-5.3.1-24.el5_2.2 [root@monitor cacti]# |
5、安装RRDtool
当前版本为1.2.23-1,根据系统的版本下载相关版本,本例为CentOS5.2,所以下载el5的版本;
下载地址:
需要下载 perl-rrdtool 和 rrdtool 这2个包。
[root@monitor ~]# rpm -ivh perl-rrdtool-1.2.23-1.el5.rf.i386.rpm rrdtool-1.2.23-1.el5.rf.i386.rpm warning: perl-rrdtool-1.2.23-1.el5.rf.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6 Preparing... ########################################### [100%] 1:rrdtool ########################################### [ 50%] 2:perl-rrdtool ########################################### [100%] |
6、将apache和mysql设置成自启动
[root@monitor ~]# chkconfig --add httpd [root@monitor ~]# chkconfig httpd on [root@monitor ~]# chkconfig --list|grep httpd httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
[root@monitor ~]# chkconfig --add mysqld [root@monitor ~]# chkconfig mysqld on [root@monitor ~]# chkconfig --list|grep mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
7、手动启动mysql和httpd
[root@monitor ~]# /etc/init.d/mysqld start [root@monitor ~]# /etc/init.d/httpd start |
8、修改mysql的root用户密码
这里值得提出的是,有很多人不修改mysql的缺省口令,这样会有很大的安全隐患。
修改root用户密码有很多种方法,这里只介绍一种。
[root@monitor ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 30 Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed mysql> select host,user,password from user; +------------+-------+------------------+ | host | user | password | +------------+-------+------------------+ | localhost | root | | | domain.com | root | | | 127.0.0.1 | root | | +------------+-------+------------------+ 4 rows in set (0.00 sec)
mysql> UPDATE user SET Password=PASSWORD('YourPassWord') WHERE User='root'; Query OK, 3 rows affected (0.01 sec) Rows matched: 3 Changed: 3 Warnings: 0
mysql> select host,user,password from user; +------------+-------+------------------+ | host | user | password | +------------+-------+------------------+ | localhost | root | 3661cf4xxd958bxx | | domain.com | root | 3661cf4xxd958bxx | | 127.0.0.1 | root | 3661cf4xxd958bxx | +------------+-------+------------------+ 4 rows in set (0.00 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
mysql> quit Bye [root@monitor ~]# mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@monitor ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 32 Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> |
OK了,准备工作做完了,可以继续了!
二、安装cacti
1、获取cacti安装包
cacti是用php些的程序,所以下载下来,解压到apache的DocumentRoot目录下就可以了。
可以到官方网站去下载稳定版的版本。
官方网站:
[root@monitor ~]# wget /downloads/cacti-0.8.7b.tar.gz
将cacti解压缩到apache的DocumentRoot目录下,由于此次是rpm默认安装的,位置在/var/www/html目录下。
[root@monitor ~]# tar zxvf cacti-0.8.7b.tar.gz -C /var/www/html/cacti [root@monitor ~]# cd /var/www/html/ [root@monitor html]# chown -R apache.apache cacti |
2、创建cacti数据库
[root@monitor ~]# mysql -uroot -p Enter password: mysql> create database cacti; mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'YourPassWord'; mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
|
初始化cacti数据库
cd /var/www/html/cacti mysql -ucacti -p cacti |
3、配置数据库连接参数
修改 include/config.php 文件,指定数据库类型,数据库名称,用户名,密码,端口等设置。
$database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cacti"; $database_password = "YourPassWord"; |
4、增加cacti用户,通过这个用户的crontab定时采集数据
[root@monitor cacti]# useradd cacti [root@monitor cacti]# passwd cacti Changing password for user cacti. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully. [root@monitor cacti]# pwd /var/www/html/cacti [root@monitor cacti]# chown -R cacti rra/ log/ [root@monitor html]# su - cacti [cacti@monitor ~]$ [cacti@monitor ~]$ crontab -e #在crontab里面增加一行,没5分钟采集一次。 */5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1 |
5、通过浏览访问cacti
三、配置cacti
1、第一次通过web登录会出现一个安装向导,仔细夜读说明后按【Next>>】进入下一步;
2、选择New Install 按【Next>>】进入下一步;
3、这个页面会显示依赖的软件的位置,如果出现红色请仔细查看,并查找原因,没有问题按【Finsh】完成设置;
4、重新登录到cacti页面,会让你输入密码,用户密码均为admin;
5、修改admin用户的密码,进入到cacti的页面。