[Cacti] Server 安装

来源:转载

一、Cacti 相关资料

Cacti在英文中的意思是仙人掌的意思,Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。它通过snmpget来获取数据,使用RRDtool绘画图形,而且你完全可以不需要了解RRDtool复杂的参数。它提供了非常强大的数据和用户管理功能,可以指定每一个用户能查看树状结构、host以及任何一张图,还可以与LDAP结合进行用户验证,同时也能自己增加模板,功能非常强大完善。Cacti的发展是基于让 RRDTool 使用者更方便使用该软件,除了基本的 Snmp 流量跟系统资讯监控外,Cacti 也可外挂 Scripts 及加上Templates 来作出各式各样的监控图。


Cacti优化:

由于效率的原因,在需要大量采集数据时,如果使用自带的cmd.php轮询器会比较慢,1分钟1次的采集频率可能无法完成轮询所有的被监控的机器,从而可能导致部分监控项目不出图或图形断断续续。为了解决效率问题,Cacti官方也推出spine,采用多线程的方式高效的轮询。


Cacti 下载地址: 点击打开链接


二、初始化系统

角色

IP

服务

端口

Cacti-server

192.168.1.201

MariaDB10.1.22/Apache2.4.6/php 5.4.16/cacti1.1.1/snmp

3306/80/161

Cacti-client

192.168.1.202

snmp

161

 

默认关闭 firewalld、selinux。默认开启chronyd时间同步.

 

# timedatectl set-timezone Asia/Shanghai #该命令把时区设置为上海

 

 

1、配置系统yum 163源

#  cd /etc/yum.repos.d

# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo        # $releasever替换成相应版本 7

# yum clean all && yum makecache             (yum repolist)

 

2、配置MariaDB 10.1源

# vi /etc/yum.repos.d/MariaDB.repo

[mariadb] 

name = MariaDB 

baseurl = http://yum.mariadb.org/10.1/centos7-amd64 

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 

gpgcheck=1 

 

# yum repolist




三、搭建 LAMP 环境

1、安装apace

# yum -y install httpd

# systemctl enable httpd

# systemctl start httpd

 

2、安装mariadb并配置

# vi /etc/yum.repos.d/MariaDB.repo

[mariadb] 

name = MariaDB 

baseurl = http://yum.mariadb.org/10.1/centos7-amd64 

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 

gpgcheck=1 

 

# yum -y mariadb*

# yum -y install lsoflibboost*

# systemctl start mariadb

# systemctlenable mariadb

# mysql_secure_installation

# mysql -uroot -p

 

# vi /etc/my.cnf.d/server.cnf

[mysqld]

init_connect='SET collation_connection = utf8mb4_unicode_ci'

init_connect='SET NAMES utf8'

character-set-server=utf8mb4

collation-server=utf8mb4_unicode_ci

skip-character-set-client-handshake

 

character_set_client=utf8mb4

max_heap_table_size=90M

max_allowed_packet=16777216

tmp_table_size=64M

join_buffer_size=64M

innodb_buffer_pool_size=500M

innodb_doublewrite=OFF

innodb_additional_mem_pool_size=80M

innodb_flush_log_at_timeout=3

innodb_read_io_threads=32

innodb_write_io_threads=16

 

# systemctl restart mariadb

 

3、配置PHP

# yum -y installphp php-mysql php-gd php-pear

# vi /etc/php.ini       

date.timezone = PRC        #修改时区

 

# vi /var/www/html/index.php       #新建测试php页面

<?php

    $conn=mysql_connect('localhost','root','password');

    if ($conn)

      echo "database connect ok";

    else

      echo "database connect failure";

?>

<?php

    phpinfo()

?>

 

# systemctl restart httpd

URL:   http://192.168.1.201/index.php



四、安装 Cacti

1、下载

# cd/usr/local/src

# wgethttp://www.cacti.net/downloads/cacti-1.1.1.zip

 

2、安装

# unzip cacti-1.1.1.zip

# mv cacti-1.1.1/var/www/html/cacti

 

3、配置数据库

# mysql -uroot -p

MariaDB [(none)]> create database cacti default character set utf8;

MariaDB [(none)]> use cacti;

MariaDB [(none)]> source/var/www/html/cacti/cacti.sql;

MariaDB [(none)]> grant all privileges on cacti.* to [email protected] identified by 'cacti';

MariaDB [(none)]> flush privileges;

 

4、配置cacti配置文件

# vi /var/www/html/cacti/include/config.php

$database_type     = 'mysql';

$database_default  = 'cacti';

$database_hostname = 'localhost';

$database_username = 'cacti';

$database_password = 'cacti';

$database_port     = '3306';

$database_ssl      = false;

 

# vi /var/www/html/cacti/include/global.php

$database_type = 'mysql';

$database_default = 'cacti';

$database_hostname = 'localhost';

$database_username = 'cacti';

$database_password = 'cacti';

$database_port = '3306';

$database_ssl = false;

 

5、安装rrdtool以生成图像

# yum -y install rrdtool rrdtool-devel rrdtool-php rrdtool-perl

# yum -y install gdgd-devel php-gd           #rrdtool绘制图像所需要的图形库

 

6、安装snmp服务

# yum -y installhelp2mannet-snmp* net-snmp-develnet-snmp-utils php-snmp net-snmp-libs

# vi /etc/snmp/snmpd.conf

com2sec notConfigUser 127.0.0.1       public

group   notConfigGroup v1           notConfigUser

group   notConfigGroup v2c           notConfigUser

view    systemview    included   .1.3.6.1.2.1.1

view    systemview    included   .1.3.6.1.2.1.25.1.1

access  notConfigGroup ""      any       noauth    exact all none none

view all    included  .1                               80

syslocation Unknown (edit /etc/snmp/snmpd.conf)

syscontact Root <[email protected]> (configure /etc/snmp/snmp.local.conf)

dontLogTCPWrappersConnects yes

 

# systemctl restart snmpd

# systemctl enable snmpd

 

7、授予目录权限

# useradd -r -Mcacti

# chown -R cacti/var/www/html/cacti/rra/

# chown -R cacti/var/www/html/cacti/log/

# chown -R apache.apache /var/www/html/cacti/resource

# chown -R apache /var/www/html/cacti/script

# chown -R apache /var/www/html/cacti/scripts/

# chown -R apache /var/www/html/cacti/log

# chown -R apache /var/www/html/cacti/cache/boost

 # chown -R apache /var/www/html/cacti/cache/mibcache

 # chown -R apache /var/www/html/cacti/cache/realtime

 # chown -R apache /var/www/html/cacti/cache/spikekill

 

8、添加定时抓图计划任务

# crontab -u cacti -e

*/5 * * * * /usr/bin/php  /var/www/html/cacti/poller.php >> /tmp/cacti_rrdtool.log

 

# /usr/bin/php  /var/www/html/cacti/poller.php  #手动测试

 


五、安装 Cacti-Spine

1、下载安装

# cd /usr/local/src

# wgethttp://www.cacti.net/downloads/spine/cacti-spine-1.1.1.tar.gz

# tar -zxvf cacti-spine-1.1.1.tar.gz

# cd cacti-spine-1.1.1

# ./configure

# make && make install

 

2、配置

# cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf

# vi /etc/spine.conf

DB_Host                 localhost

DB_Database             cacti

DB_User                 cacti

DB_Pass                 cacti

DB_Port                 3306

 

# /usr/local/spine/bin/spine   #测试

SPINE: Using spine config file [/etc/spine.conf]

SPINE: Version 1.1.1 starting

SPINE: Time: 0.2576 s, Threads: 5, Devices: 1



六、WEB 端配置

1、勾选Accept




2、查看是否有红色(不合规项),按照推荐值更改后重启httpd继续


3、核实数据库信息


4、核实各命令路径



5、核实各路径权限


6、选择需要的模板

7、登录界面

登录地址: http://192.168.1.201/cacti/

初始账号密码:  Admin/admin



分享给朋友:
您可能感兴趣的文章:
随机阅读: