cacti完全配置

 cacti完全配置


安装mysql
groupadd mysql
useradd mysql -c "start mysqld's account" -d /dev/null -g mysql -    s /sbin/nologin
./configure \

        --prefix=/usr/local/mysql \

        --with-mysqld-user=mysql \

        --without-debug \

        --with-client-ldflags=-all-static \

        --with-mysqld-ldflags=-all-static \

        --disable-shared \

        --localstatedir=/var/lib/mysql \

        --without-isam \

        --without-innodb \

        --enable-assembler

make
make install
cd support-files/
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R root:mysql /usr/local/mysql/
chown -R mysql:mysql /var/lib/mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql &
/usr/local/mysql/bin/mysqladmin -u root -p password cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
cd /etc/init.d
chmod 755 mysql
chkconfig --add mysql
chkconfig --level 3 mysql on

安装apache
tar -zxvf httpd-2.0.50.tar.gz

cd httpd-2.0.50

./configure --prefix=/usr/local/apache2 --enable-module=so --enable-rewrite

Make

Make instll

设置自启动

cp support/apachectl /etc/init.d/httpd

 

修改/etc/init.d/httpd

vi /etc/init.d/httpd(在第两行之后添加如下内容)

#!/bin/sh

#

# Startup script for the Apache Web Server

# chkconfig: - 85 15

# description: Apache is a World Wide Web server. It is used to serve \

# HTML files and CGI.

# processname: httpd

# pidfile: /usr/local/apache/log/httpd.pid

# config: /usr/local/apache/conf/httpd.conf

chkconfig --add httpd

chmod 755 /etc/init.d/httpd

chkconfig httpd on

 

安装php
Tar –zxvf php-5.1.2.tar.gz

./configure--with-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql/--with-gd--with-jpeg-dir=/usr/lib--enable-gd-native-ttf--with-zlib-dir=/usr/lib --with-png --with-png-dir=/usr/lib --with-freetype=/usr/lib --with-ttf  --enable-sockets

Make

Make instll

cp php.ini-dist /usr/local/lib/php.ini

vi /usr/local/apache/conf/httpd.conf

加入以下代码:

AddType application/x-httpd-php .php .phtml

 AddType application/x-httpd-php-source .phps

 AddType application/x-tar .tgz 
AddType image/x-icon .ico

 建立测试页面:info.php,添加以下内容:

 <?

 phpinfo();

?>

设置mysql
/usr/local/mysql/bin/mysql –uroot –p

create database cactidb;

grant all on cactidb.* to root;

grant all on cactidb.* to root@localhost;

grant all on cactidb.* to cactiuser;

grant all on cactidb.* to cactiuser@localhost;

set password for cactiuser@localhost=password('######');

exit

安装rrdtool
Tar –zxvf rrdtool-1.0.50.tar.gz

./configure –prefix=/usr/local/rrdtool

Make

Make install

与mrtg相比,rrdtool自带了gd库,所以不用先安装gd库.(不过由于rrdtool自带的gd库不支持中文,所以rrdtool画出来的图也不能有中文,否则会出现乱码).

 

安装net-snmp
Cacti需要用到net-snmp中的两个命令�D�Dsnmpwalk和snmpget进行数据的采集。需要安装以下软件包:

net-snmp-5.1.2-11.i386.rpm

net-snmp-devel-5.1.2-11.i386.rpm

net-snmp-libs-5.1.2-11.i386.rpm

net-snmp-perl-5.1.2-11.i386.rpm

net-snmp-utils-5.1.2-11.i386.rpm

我们可以直接在系统中运行snmpwalk和snmpget看是否有该命令

安装cacti
Tar –zxvf cacti-0.8.6i.tar.gz

Cp –rf cacti-0.8.6i /usr/local/apache/htdocs/cacti

Cd cacti

cat cacti.sql |/usr/local/mysql/bin/mysql cactidb -uroot  -p

chown –R cactiuser rra/ log/

vi  /usr/local/apache/htdocs/cacti/include/config.php

配置以下代码:

$database_type = “mysql”; 
$database_default = “cactidb”; 
$database_hostname = “localhost”; 
$database_username = “cactiuser”; 
$database_password = “######”;

Useradd cactiuser –d /dev/null –s /sbin/nologin

crontab –u cactiuser –e

*/5 * * * * /usr/local/bin/php /usr/local/apache2/htdocs/cacti/poller.php > /dev/null 2>&1

页面设置
    在浏览器上输入:

http://IP/cacti

进入cacti的初始设置页面:

在这里我们要输入一些原始的信息:

注意路径的正确性

安装完成

 

 

 

Cacti系统设置
为了让cacti能取到我们需要的数据,比如CPU和系统负载的数据,我们需要对snmpd.conf这个文件进行设置,其原因应该是snmp设置默认没有允许取这些数据。

打开默认的/etc/snmp/snmpd.conf文件,更改如下配置:

#       sec.name  source          community
com2sec notConfigUser  default       public

将"comunity"字段改为你要设置的密码.比如"123456".
将“default”改为“安装了cacti机器的IP” 
# Finally, grant the group read-only access to the systemview view.
#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup ""      any       noauth    exact  all none none
将"read"字段改为all.

##           incl/excl subtree                          mask
#view all    included  .1                               80
将该行前面的"#"去掉.

重新启动snmpd

Service snmpd restart

Chkconfig –-level 3 snmpd on

查看snmp的端口号
[root@localhost snmp]# netstat -ln|grep 161
udp        0      0 0.0.0.0:161             0.0.0.0:*

如果看到161端口,说明snmpd服务器启动成功。

 

1.开始建立我们的配置模板:

   因为cacti提供很多配置模板,这里我们选择Generic SNMP-enabled Host 模板:

   console----Host Templates----Generic SNMP-enabled Host,添加以下数据取样:

   Host Templates [edit: Generic SNMP-enabled Host] 
 
Name
A useful name for this host template.   
   
Associated Graph Templates 
 
1) Host MIB - Logged in Users    
2) Host MIB - Processes    
3) ucd/net - CPU Usage    
4) ucd/net - Load Average    
5) ucd/net - Memory Usage    
6) Unix - Ping Latency    
Add Graph Template:  Cisco - CPU Usage Host MIB - Available Disk Space Host MIB - CPU Utilization Interface - Errors/Discards Interface - Non-Unicast Packets Interface - Traffic (bits/sec) Interface - Traffic (bits/sec, 95th Percentile) Interface - Traffic (bits/sec, Total Bandwidth) Interface - Traffic (bytes/sec) Interface - Traffic (bytes/sec, Total Bandwidth) Interface - Unicast Packets Karlnet - Wireless Levels Karlnet - Wireless Transmissions Linux - Memory Usage Netware - CPU Utilization Netware - Directory Information Netware - File System Activity Netware - File System Cache Netware - Logged In Users Netware - Open Files Netware - Volume Information SNMP - Generic OID Template ucd/net - Available Disk Space Unix - Available Disk Space Unix - Load Average Unix - Logged in Users Unix - Processes    
 
 

Associated Data Queries 
 
1) SNMP - Get Mounted Partitions    
2) SNMP - Interface Statistics    
Add Data Query:  Karlnet - Wireless Bridge Statistics Netware - Get Available Volumes Netware - Get Processor Information SNMP - Get Processor Information ucd/net - Get Monitored Partitions Unix - Get Mounted Partitions     
 
 


点击‘save’保存退出。

下面开始添加设备:


console----Devices----add,输入该主机描述,ip地址,点击create创建完成。

然后把主机添加默认树:

console----Graph TreesGrap----Default Tree----add----Tree Item Type(host)----tetle(主机ip),然后就完成了。

你可能感兴趣的:(安装,职场,cacti,休闲)