linux cacti使用教程,Linux下Cacti详细部署指南

Linux下Cacti详细部署指南

[日期:2012-09-14]

来源:Linux社区

作者:ahzzk2008

[字体:大 中 小]

Cacti部署文档

1、配置yum本地源并安装所需包

[root@cactic ~]# vi /etc/yum.repos.d/rhel-debuginfo.repo

[rhel-debuginfo]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///mnt/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release

~

~

"/etc/yum.repos.d/rhel-debuginfo.repo" 6L, 185C written

[root@cactic ~]# mount /dev/cdrom /mnt

mount: block device /dev/cdrom is write-protected, mounting read-only

[root@cactic ~]# yum clean all

Loading "security" plugin

Loading "rhnplugin" plugin

Cleaning up Everything

[root@cactic tmp]# yum install httpd mysql-server php php-mysql php-snmp net-snmp net-snmp-utils

Loading "security" plugin

Loading "rhnplugin" plugin

This system is not registered with RHN.

RHN support will be disabled.

rhel-debuginfo            100% |=========================| 1.3 kB    00:00

primary.xml.gz            100% |=========================| 806 kB    00:00

rhel-debug: ################################################## 2944/2944

Setting up Install Process

Parsing package install arguments

Resolving Dependencies

--> Running transaction check

---> Package php-snmp.x86_64 0:5.1.6-20.el5 set to be updated

--> Processing Dependency: php-common = 5.1.6-20.el5 for package: php-snmp

---> Package mysql-server.x86_64 0:5.0.45-7.el5 set to be updated

--> Processing Dependency: libmysqlclient_r.so.15(libmysqlclient_15)(64bit) for package: mysql-server

--> Processing Dependency: perl-DBI for package: mysql-server

--> Processing Dependency: libmysqlclient.so.15()(64bit) for package: mysql-server

--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: mysql-server

--> Processing Dependency: mysql = 5.0.45-7.el5 for package: mysql-server

--> Processing Dependency: perl(DBI) for package: mysql-server

--> Processing Dependency: perl-DBD-MySQL for package: mysql-server

--> Processing Dependency: libmysqlclient_r.so.15()(64bit) for package: mysql-server

---> Package php.x86_64 0:5.1.6-20.el5 set to be updated

--> Processing Dependency: php-cli = 5.1.6-20.el5 for package: php

---> Package net-snmp.x86_64 1:5.3.1-24.el5 set to be updated

--> Processing Dependency: libsensors.so.3()(64bit) for package: net-snmp

---> Package php-mysql.x86_64 0:5.1.6-20.el5 set to be updated

--> Processing Dependency: php-pdo for package: php-mysql

---> Package net-snmp-utils.x86_64 1:5.3.1-24.el5 set to be updated

---> Package httpd.x86_64 0:2.2.3-11.el5_1.3 set to be updated

filelists.xml.gz          100% |=========================| 2.5 MB    00:00

--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd

--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd

--> Running transaction check

---> Package lm_sensors.x86_64 0:2.10.0-3.1 set to be updated

---> Package php-common.x86_64 0:5.1.6-20.el5 set to be updated

---> Package perl-DBI.x86_64 0:1.52-1.fc6 set to be updated

---> Package apr.x86_64 0:1.2.7-11 set to be updated

---> Package mysql.x86_64 0:5.0.45-7.el5 set to be updated

---> Package php-pdo.x86_64 0:5.1.6-20.el5 set to be updated

---> Package apr-util.x86_64 0:1.2.7-7.el5 set to be updated

--> Processing Dependency: libpq.so.4()(64bit) for package: apr-util

---> Package perl-DBD-MySQL.x86_64 0:3.0007-1.fc6 set to be updated

---> Package php-cli.x86_64 0:5.1.6-20.el5 set to be updated

--> Running transaction check

---> Package postgresql-libs.x86_64 0:8.1.11-1.el5_1.1 set to be updated

--> Finished Dependency Resolution

Dependencies Resolved

======================================================================

Package                 Arch       Version          Repository        Size

======================================================================

Installing:

mysql-server            x86_64     5.0.45-7.el5     rhel-debuginfo    9.7 M

net-snmp-utils          x86_64     1:5.3.1-24.el5   rhel-debuginfo    182 k

php                     x86_64     5.1.6-20.el5     rhel-debuginfo    1.2 M

php-mysql               x86_64     5.1.6-20.el5     rhel-debuginfo     86 k

php-snmp                x86_64     5.1.6-20.el5     rhel-debuginfo     28 k

Installing for dependencies:

apr                     x86_64     1.2.7-11         rhel-debuginfo    118 k

apr-util                x86_64     1.2.7-7.el5      rhel-debuginfo     74 k

httpd                   x86_64     2.2.3-11.el5_1.3 rhel-debuginfo    1.1 M

lm_sensors              x86_64     2.10.0-3.1       rhel-debuginfo    503 k

mysql                   x86_64     5.0.45-7.el5     rhel-debuginfo    4.2 M

net-snmp                x86_64     1:5.3.1-24.el5   rhel-debuginfo    703 k

perl-DBD-MySQL          x86_64     3.0007-1.fc6     rhel-debuginfo    147 k

perl-DBI                x86_64     1.52-1.fc6       rhel-debuginfo    605 k

php-cli                 x86_64     5.1.6-20.el5     rhel-debuginfo    2.2 M

php-common              x86_64     5.1.6-20.el5     rhel-debuginfo    154 k

php-pdo                 x86_64     5.1.6-20.el5     rhel-debuginfo     63 k

postgresql-libs         x86_64     8.1.11-1.el5_1.1 rhel-debuginfo    195 k

Transaction Summary

=============================================================================

Install     17 Package(s)

Update       0 Package(s)

Remove       0 Package(s)

Total download size: 21 M

Is this ok [y/N]: y

Downloading Packages:

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 37017186

Importing GPG key 0x37017186 "Red Hat, Inc. (release key) " from /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Is this ok [y/N]: y

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing: php-common                   ####################### [ 1/17]

Installing: perl-DBI                     ####################### [ 2/17]

Installing: mysql                        ####################### [ 3/17]

Installing: apr                          ####################### [ 4/17]

Installing: perl-DBD-MySQL               ####################### [ 5/17]

Installing: php-pdo                      ####################### [ 6/17]

Installing: php-cli                      ####################### [ 7/17]

Installing: lm_sensors                   ####################### [ 8/17]

Installing: net-snmp                     ####################### [ 9/17]

Installing: postgresql-libs              ####################### [10/17]

Installing: apr-util                     ####################### [11/17]

Installing: httpd                        ####################### [12/17]

Installing: php-snmp                     ####################### [13/17]

Installing: mysql-server                 ####################### [14/17]

Installing: php                          ####################### [15/17]

Installing: php-mysql                    ####################### [16/17]

Installing: net-snmp-utils               ####################### [17/17]

Installed: mysql-server.x86_64 0:5.0.45-7.el5 net-snmp-utils.x86_64 1:5.3.1-24.el5 php.x86_64 0:5.1.6-20.el5 php-mysql.x86_64 0:5.1.6-20.el5 php-snmp.x86_64 0:5.1.6-20.el5

Dependency Installed: apr.x86_64 0:1.2.7-11 apr-util.x86_64 0:1.2.7-7.el5 httpd.x86_64 0:2.2.3-11.el5_1.3 lm_sensors.x86_64 0:2.10.0-3.1 mysql.x86_64 0:5.0.45-7.el5 net-snmp.x86_64 1:5.3.1-24.el5 perl-DBD-MySQL.x86_64 0:3.0007-1.fc6 perl-DBI.x86_64 0:1.52-1.fc6 php-cli.x86_64 0:5.1.6-20.el5 php-common.x86_64 0:5.1.6-20.el5 php-pdo.x86_64 0:5.1.6-20.el5 postgresql-libs.x86_64 0:8.1.11-1.el5_1.1

Complete!

[root@cactic tmp]# yum install freetype libart_lgpl libpng

Loading "security" plugin

Loading "rhnplugin" plugin

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Parsing package install arguments

Package freetype - 2.2.1-19.el5.x86_64 is already installed.

Package freetype - 2.2.1-19.el5.i386 is already installed.

Package libart_lgpl - 2.3.17-4.i386 is already installed.

Package libart_lgpl - 2.3.17-4.x86_64 is already installed.

Package libpng - 2:1.2.10-7.1.el5_0.1.i386 is already installed.

Package libpng - 2:1.2.10-7.1.el5_0.1.x86_64 is already installed.

Nothing to do

[root@cactic tmp]# rpm -ivh cacti-0.8.8a-2.el5.noarch.rpm rrdtool-1.2.27-3.el5.x86_64.rpm rrdtool-php-1.2.27-3.el5.x86_64.rpm

warning: cacti-0.8.8a-2.el5.noarch.rpm: Header V4 DSA signature: NOKEY, key ID 217521f6

Preparing...                ########################################### [100%]

1:rrdtool                ########################################### [ 33%]

2:cacti                  ########################################### [ 67%]

3:rrdtool-php            ########################################### [100%] 2、启动 MySQL 并设置 root 密码:

[root@cactic tmp]# /etc/init.d/mysqld restart

Stopping MySQL:                                            [FAILED]

Initializing MySQL database: Installing MySQL system tables...

OK

Filling help tables...

OK

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h cactic password 'new-password'

See the manual for more instructions.

You can start the MySQL daemon with:

cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

[ OK ]

Starting MySQL:                                            [ OK ]

[root@cactic tmp]# /usr/bin/mysqladmin -u root password 'redhat'

创建数据库:

[root@cactic tmp]# mysqladmin -uroot -p create cacti

Enter password:******

导入 cacti.sql 数据库:

[root@cactic tmp]# mysql -uroot -p cacti < /usr/share/doc/cacti-0.8.8a/cacti.sql

Enter password:******

设置数据库权限:

[root@cactic tmp]# mysql -uroot -p mysql

Enter password:

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL ON cacti.* TO cactic@localhost IDENTIFIED BY 'redhat';

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

编辑 cacti 的配置文件 /usr/share/cacti/include/config.php,设置 MYSQL 信息:

[root@cactic tmp]# vi /usr/share/cacti/include/config.php

/*

+-------------------------------------------------------------------------+

| Copyright (C) 2004-2012 The Cacti Group                                 |

|                                                                    |

| This program is free software; you can redistribute it and/or                    |

| modify it under the terms of the GNU General Public License                   |

| as published by the Free Software Foundation; either version 2                  |

| of the License, or (at your option) any later version.                           |

|                                                                     |

| This program is distributed in the hope that it will be useful,                     |

| but WITHOUT ANY WARRANTY; without even the implied warranty of         |

| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the    |

| GNU General Public License for more details.                               |

+-------------------------------------------------------------------------+

| Cacti: The Complete RRDTool-based Graphing Solution                       |

+-------------------------------------------------------------------------+

| This code is designed, written, and maintained by the Cacti Group. See           |

| about.php and/or the AUTHORS file for specific developer information.          |

+-------------------------------------------------------------------------+

| http://www.cacti.net/                                                   |

+-------------------------------------------------------------------------+

*/

/* make sure these values refect your actual database/host/user/password */

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "root";

$database_password = "redhat";

"/usr/share/cacti/include/config.php" 44L, 2121C written

设置目录权限:

[root@cactic tmp]# chown -R cacti /var/lib/cacti/rra

[root@cactic tmp]# chown -R cacti /var/log/cacti/

设置 crontab:

[root@cactic tmp]# crontab -e -u cacti

*/5 * * * * php /usr/share/cacti/poller.php > /dev/null 2>&1

设置 cacti 目录的访问权限: /etc/httpd/conf.d/cacti.conf

[root@cactic tmp]# vi /etc/httpd/conf.d/cacti.conf

#

# Cacti: An rrd based graphing tool

#

# Change the following ACLs to open up Cacti to other network devices.

# For example:

# On httpd 2.4, change "Require host localhost" to "Require all granted".

# On httpd 2.2, change "Allow from localhost" to "Allow from all".

Alias /cacti    /usr/share/cacti

# httpd 2.4

Require host localhost

# httpd 2.2

Order deny,allow

#               Deny from all

#               Allow from localhost

Allow from all

"/etc/httpd/conf.d/cacti.conf" 56L, 1396C written

3、启动

启动 snmpd:

[root@cactic tmp]# /etc/init.d/snmpd restart

Stopping snmpd:                                            [FAILED]

Starting snmpd:                                            [ OK ]

[root@cactic tmp]# /etc/init.d/snmptrapd restart

Stopping snmptrapd:                                        [FAILED]

Starting snmptrapd:                                        [ OK ]

启用必须的服务:

[root@cactic tmp]# for i in httpd mysqld snmpd snmptrapd; do chkconfig --level 35 $i on; done

浏览器安装(首次登陆账号admin 密码admin 登陆后需要修改)

1、打开浏览器并输入地址192.168.85.40/cacti,根据提示安装即可

2、选择new install

3、点击 finish(首次登陆需要重设密码)

安装插件 monitor thold settings

[root@cactic tmp]# tar -zxvf monitor-0.8.2.tar.gz

monitor/wz_tooltip.js

monitor/index.php

monitor/LICENSE

monitor/sounds/index.php

monitor/sounds/attn-noc.wav

monitor/monitor.php

monitor/images/index.php

monitor/images/button_nosound.gif

monitor/images/blue.gif

monitor/images/muted.gif

monitor/images/tab_monitor.gif

monitor/images/red.gif

monitor/images/orange.gif

monitor/images/green.gif

monitor/setup.php

monitor/README

monitor/monitor.sql

[root@cactic tmp]# tar -zxvf settings-0.5.tar.gz

settings/index.php

settings/LICENSE

settings/setup.php

settings/README

settings/email-test.php

settings/include/index.php

settings/include/mailer.php

settings/include/functions.php

[root@cactic tmp]# tar -zxvf thold-0.4.3.tar.gz

thold/

thold/images/

thold/images/tab_thold.gif

thold/images/tab_thold_down.gif

thold/images/index.php

thold/images/reddot.png

thold/images/enable_thold.png

thold/images/view_graphs.gif

thold/images/disable_thold.png

thold/images/edit_object.png

thold/LICENSE

thold/README

thold/thold.sql

thold/thold_functions.php

thold/index.php

thold/setup.php

thold/listthold.php

thold/extras/

thold/extras/upgrade.php

thold/extras/apply_realms.php

thold/includes/

thold/includes/index.php

thold/includes/polling.php

thold/includes/tab.php

thold/includes/database.php

thold/includes/settings.php

thold/thold_graph.php

thold/thold_add.php

thold/thold_templates.php

thold/cli_thresholds.php

thold/thold.php

[root@cactic tmp]# cp -r monitor settings thold /usr/share/cacti/plugins

修改global.conf

在$config = array();下面插入以下几行

$plugins[] = 'thold';

$plugins[] = 'settings';

$plugins[] = 'monitor';

打开浏览器登陆cacti

在user management下将view monitoring勾选

在plugin management下启用插件

在graph management下勾选要描绘的项目

详细使用就根据个人喜好设定吧!0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Cacti是一种开源的网络图形化监控工具,它可以监控网络设备、服务器等各种设备,提供可视化的监控数据,方便管理员进行监控和管理。 下面是在Linux系统上部署Cacti的步骤: 1.安装LAMP环境 Cacti是基于PHP开发的,因此需要安装LAMP环境。在Linux系统中,可以通过以下命令安装: ``` sudo apt-get install lamp-server^ ``` 安装过程中需要设置MySQL的root密码。 2.安装SNMP Cacti需要使用SNMP协议来监控网络设备,因此需要安装SNMP。 ``` sudo apt-get install snmp ``` 3.安装RRDtool RRDtool是Cacti的一个依赖库,用于存储和处理监控数据。 ``` sudo apt-get install rrdtool ``` 4.下载Cacti 可以从Cacti官网下载最新版本的Cacti,并解压到web服务器的根目录下。 ``` cd /var/www/html sudo wget https://www.cacti.net/downloads/cacti-latest.tar.gz sudo tar zxvf cacti-latest.tar.gz sudo mv cacti-* cacti ``` 5.创建Cacti数据库 使用MySQL创建一个Cacti数据库和用户,并授权: ``` mysql -u root -p create database cacti; grant all privileges on cacti.* to cactiuser@localhost identified by 'cactiuser_password'; flush privileges; exit; ``` 6.导入Cacti数据库 在Cacti源码包中,可以找到cacti.sql文件,将其导入到cacti数据库中: ``` cd /var/www/html/cacti sudo mysql -u cactiuser -p cacti < cacti.sql ``` 7.配置Cacti 进入Cacti目录,复制config.php文件: ``` cd /var/www/html/cacti/include sudo cp config.php{.dist,} ``` 编辑config.php文件,将以下几行代码修改为正确的值: ``` $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cactiuser_password"; ``` 8.配置Web服务器 修改Apache的配置文件,启用mod_rewrite模块: ``` sudo a2enmod rewrite ``` 编辑Cacti的.htaccess文件: ``` sudo nano /var/www/html/cacti/.htaccess ``` 将AllowOverride设置为All: ``` <Directory "/var/www/html/cacti"> AllowOverride All </Directory> ``` 重启Apache服务: ``` sudo service apache2 restart ``` 9.访问Cacti 在浏览器中输入服务器的IP地址,加上/cacti路径,例如: ``` http://192.168.1.100/cacti ``` 按照提示进行配置,设置管理员账户和密码。完成后,就可以登录Cacti了,并开始监控网络设备。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值