Cacti安装

Cacti

一、首先,安装LAMP环境
注:PHP需增加Socket模块:
cd /root/php-5.3.3/ext/sockets
/usr/local/php/bin/phpize
./configure --enable-sockets --with-php-config=/usr/local/php/bin/php-config
make
make install

vim /usr/local/lib/php.ini
追加
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"
extension=sockets.so
注:no-debug-non-zts-20090626为make install后创建的,各个版本都不一样需手动去修改。

二、安装Cacti
1.安装rrdtool
yum install pango pango-devel
tar zxvf rrdtool-1.4.3.tar.gz
./configure --prefix=/usr/local/rrdtool
make;make install
2.安装net-snmp
http://sourceforge.net/projects/net-snmp/files/net-snmp/5.6.1.1/net-snmp-5.6.1.1.tar.gz/download
tar zxvf net-snmp-5.6.1.1.tar.gz
./configure --prefix=/usr/local/net-snmp --with-mysql=/usr/local//mysql/bin/mysql_config --with-openssl=/usr
make;make install
cp EXAMPLE.conf /usr/local/net-snmp/share/snmpd.conf

configure中说明:
default version of-snmp-version(3):2(在这里版本通常有三种形式:1,2c,3)
Systemcontact information(配置该设备的联系信息): (也可以是邮箱地址)
System location (该系统设备的地理位置):Fujian P.R.C
Location to write logfile (日志文件位置):/var/log/snmpd.log
Location to Write persistent(数据存储目录):/var/net-snmp

/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmpd.conf
vim /etc/rc.d/rc.local
追加 /usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmpd.conf


以下为认证:(可不做设置,为了安全建议设置)
vim /usr/local/net-snmp/share/snmpd.conf
追加rouser snmpd auth
vim /var/net-snmp/snmpd.conf
追加:createUser snmpd MD5 12345678

 

lsof -i:161
ps aux |grep snmp

 

/usr/local/net-snmp/bin/snmpget -c public -v 2c 127.0.0.1 .1.3.6.1.2.1.6.9.0
/usr/local/net-snmp/bin/snmpwalk -c public -v 2c 127.0.0.1 .1.3.6.1.4.1.2021.18
/usr/local/net-snmp/bin/snmpwalk -v 2c -c public 127.0.0.1


注:snmp version设置为2.
3.安装cacti
tar zxvf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g /usr/local/cacti
useradd -s /sbin/nologin cacti
passwd cacti
chown -R cacti:cacti /usr/local/cacti

4.安装cacti-spine
tar zxvf cacti-spine-0.8.7g.tar.gz
cd cacti-spine-0.8.7g
./configure --prefix=/usr/local/cacti-spine --with-mysql=/usr/local/mysql --with-snmp=/usr/local/net-snmp
make;make install

5.配置cacti、cacti-spine
1)创建cacti数据库,并初始化该数据库

/usr/local/mysql/bin/mysql -uroot -p
create database cacti;
grant all on cacti.* to identified by '123456';
flush privileges;
/usr/local/mysql/bin/mysql -ucacti -p123456 cacti< /usr/local/cacti/cacti.sql

如无法初始化,并出现如下错误:
/usr/local/mysql/bin/mysql -ucacti -p cacti< /usr/local/cacti/cacti.sql
Enter password:
ERROR 1064 (42000) at line 5: 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 'TYPE=MyISAM' at line 8
处理方法:vim cacti.sql并且将其中TYPE=MyISAM全部删除。

2)编译配置文件/usr/local/cacti-spine/etc/spine.conf
cp /usr/local/cacti-spine/etc/spine.conf.dist /usr/local/cacti-spine/etc/spine.conf
vim /usr/local/cacti-spine/etc/spine.conf

DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass 123456
DB_Port 3306
3)配置cacti的虚拟目录
vim /usr/local/apache2/conf/extra/httpd-cacti.conf
Alias /cacti /usr/local/cacti
<Directory /usr/local/cacti>
DirectoryIndex index.php
AllowOverride none
order deny,allow
deny from all
Allow from 127.0.0.1 192.168.1.0/24
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>

vim /usr/local/apache2/conf/httpd.conf
追加Include conf/extra/httpd-cacti.conf


/usr/local/apache2/bin/apachectl restart

4)配置cacti的config.php配置文件
vim /usr/local/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "123456";
$database_port = "3306";
$config['url_path'] = "/cacti/";

5)配置任务文件
vim /etc/crontab
*/1 * * * * cacti /usr/local/php/bin/php /usr/local/cacti/poller.php > /dev/null 2>&1

chkconfig --level 3 crond on
service crond restart

6)测试
killall -HUP httpd #重新加载一下httpd.conf配置文件
开始安装配置:默认登录用户名、密码均为admin
settings---设置paths和poller

ls /usr/local/cacti/rra
/usr/local/php/bin/php -q /usr/local/cacti/poller.php --force --debug
:无法显示本机信息:

首先,执行/usr/local/php/bin/php -q /usr/local/cacti/poller.php --force --debug 查看错误:
vim /usr/local/lib/php.ini
修改date.timezone =PRC
还是无法显示则:
ln -s /usr/local/mysql/lib/libmysqlclient_r.so.18 /usr/lib
yum install gdk

你可能感兴趣的:(监控,cacti)