到目前为止,我们只是搭建了一个LAMP的工作环境,下面我们开始cacti的安装,首先我们要给cacti创建一个数据库。
Mysql-u root �Cp
create database cactidb
grant all on cactidb.* to root
grant all on cactidb.* to
grant all on cactidb.* to cactiuser
grant all on cactidb.* to cactiuser@localhost
set password for cactiuser@localhost=password(‘cactipass’)
exit
phpmyadmin下看到的结果,更加直接一点
Emerge libart_lgpl libpng zlib freetype
Emerge rrdtool
测试
rrdtool-v
哎!连SNMP服务都没有,自己装个吧。
Emerge net-snmp
安装完成修改SNMP配置文件
cp/etc/snmp/snmp.conf.example /etc/snmp/snmp.conf
vi /etc/snmp/snmp.conf
#sec.namesourcecommunity com2sec locallocalhostpublic com2sec mynetwork 192.168.254.0/24public -------------------------------------------------------------------------- #context sec.model sec.level matchreadwritenotif access MyROGroup ""anynoauthexactallallnone access MyRWGroup ""anynoauthexactallallnone
|
启动SNMP服务并添加到启动项
/etc/init.d/snmpd start
Rc-update add snmpd default
USE=”sockets” emerge �Cav cacti
vi /var/www/localhost/htdocs/cacti/include/config.php
$database_type = "mysql"; $database_default = "cactidb"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cactipass"; $database_port = "3306"; $database_ssl = false;
|
vi /etc/crontab
*/5 * * * *cactiuser /usr/bin/php \ /var/www/localhost/htdocs/cacti/poller.php > /dev/null
|
打开IE输入http://192.168.254.123/cacti进入cacti安装界面,下图是一些常用的路径设置,配置完毕输入用户名密码登录(默认是admin/admin)
这个是不需要修复的。是您安装的时候没按照官方提示安装这个功能。
如果您希望PHP支持pdo和mysqli,请用两个-y参数,即:./zijidelu_install.sh -y -y,
但由于兼容性方面的因素,在某些机器上可能装不成功,也可以通过修改php.ini配置文
件来修复!
Mysqli的单独安装
USE=”mysqli” Emerge PEAR-MDB2_Driver_mysqli
PDO安装
USE=”pdo” Emerge php
vi /var/www/localhost/htdocs/cacti/include/global_constants.php
第一步,找到 weekdays according to date("w") builtin function
在下面添加date_default_timezone_set('Asia/Chongqing');
第二步,cp /usr/share/zoneinfo/Asia/Chongqing/etc/localtime
第三步,vi /etc/php/apach2-php5.3/php.ini找到;date.timezone=修改为Date.timezone=PRC
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'cactiuser'@'localhost' (using password: YES) in /usr/share/php/adodb/drivers/adodb-mysql.inc.php on line 383
FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'
故障原因是不能连接到mysql数据库
检查登陆到数据库用户名密码
vi /var/www/localhost/htdocs/cacti/include/config.php
vi /etc/php/apache2-php/php.ini
修改memory_limit = 128M(或者memory_limit = -1不限制内存大小)
修改完成后需要重启Apache服务
emerge libart_lgpl libpng zlib freetype
还有一些简单的问题,根据系统反馈的提示去操作就可以。
Cacti监控图片