一、安装apache、rrdtool、mariadb、snmp、php软件
root@debian:~# apt-get install -y apache2 rrdtool mariadb-server snmp php php-mysql
root@debian:~# echo $?
0
root@debian:/etc/apache2/sites-enabled# dpkg -l | grep -i php
ii libapache2-mod-php7.4 7.4.28-1+deb11u1 amd64 server-side, HTML-embedded scripting language (Apache 2 module)
ii php 2:7.4+76 all server-side, HTML-embedded scripting language (default)
ii php-common 2:76 all Common files for PHP packages
ii php-fpm 2:7.4+76 all server-side, HTML-embedded scripting language (FPM-CGI binary) (default)
ii php-mysql 2:7.4+76 all MySQL module for PHP [default]
ii php7.4 7.4.28-1+deb11u1 all server-side, HTML-embedded scripting language (metapackage)
ii php7.4-cli 7.4.28-1+deb11u1 amd64 command-line interpreter for the PHP scripting language
ii php7.4-common 7.4.28-1+deb11u1 amd64 documentation, examples and common module for PHP
ii php7.4-fpm 7.4.28-1+deb11u1 amd64 server-side, HTML-embedded scripting language (FPM-CGI binary)
ii php7.4-gd 7.4.28-1+deb11u1 amd64 GD module for PHP
ii php7.4-gmp 7.4.28-1+deb11u1 amd64 GMP module for PHP
ii php7.4-json 7.4.28-1+deb11u1 amd64 JSON module for PHP
ii php7.4-ldap 7.4.28-1+deb11u1 amd64 LDAP module for PHP
ii php7.4-mbstring 7.4.28-1+deb11u1 amd64 MBSTRING module for PHP
ii php7.4-mysql 7.4.28-1+deb11u1 amd64 MySQL module for PHP
ii php7.4-opcache 7.4.28-1+deb11u1 amd64 Zend OpCache module for PHP
ii php7.4-readline 7.4.28-1+deb11u1 amd64 readline module for PHP
ii php7.4-snmp 7.4.28-1+deb11u1 amd64 SNMP module for PHP
ii php7.4-xml 7.4.28-1+deb11u1 amd64 DOM, SimpleXML, XML, and XSL module for PHP
ii php7.4-zip 7.4.28-1+deb11u1 amd64 Zip module for PHP
查看安装结果,访问网址显示apache works!
查看php安装结果
root@debian:~# php -v
PHP 7.4.28 (cli) (built: Feb 17 2022 16:17:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies
查看数据库状态为active状态
root@debian:~# service mysqld status
● mariadb.service - MariaDB 10.5.15 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-06-18 13:07:26 CST; 18min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 11624 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 8 (limit: 19164)
Memory: 79.5M
CPU: 1.248s
CGroup: /system.slice/mariadb.service
└─11624 /usr/sbin/mariadbd
6月 18 13:07:26 debian mariadbd[11624]: 2022-06-18 13:07:26 0 [Note] InnoDB: 10.5.15 started; log sequence number 45106; transaction id 20
6月 18 13:07:26 debian mariadbd[11624]: 2022-06-18 13:07:26 0 [Note] Plugin 'FEEDBACK' is disabled.
6月 18 13:07:26 debian mariadbd[11624]: 2022-06-18 13:07:26 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
6月 18 13:07:26 debian mariadbd[11624]: 2022-06-18 13:07:26 0 [Note] InnoDB: Buffer pool(s) load completed at 220618 13:07:26
6月 18 13:07:26 debian mariadbd[11624]: 2022-06-18 13:07:26 0 [Note] Server socket created on IP: '127.0.0.1'.
6月 18 13:07:26 debian mariadbd[11624]: 2022-06-18 13:07:26 0 [Note] Reading of all Master_info entries succeeded
6月 18 13:07:26 debian mariadbd[11624]: 2022-06-18 13:07:26 0 [Note] Added new Master_info '' to hash table
6月 18 13:07:26 debian mariadbd[11624]: 2022-06-18 13:07:26 0 [Note] /usr/sbin/mariadbd: ready for connections.
6月 18 13:07:26 debian mariadbd[11624]: Version: '10.5.15-MariaDB-0+deb11u1' socket: '/run/mysqld/mysqld.sock' port: 3306 Debian 11
6月 18 13:07:26 debian systemd[1]: Started MariaDB 10.5.15 database server.
二、下载Cacti1.2.16及其他组件包
由于我之前已经下载过这些软件包,这里我把它们放在百度网盘中共享出来,大家可以打包下载,不用一一去官网找版本下载,当然如果你想安装更高的版本的话除外。
https://pan.baidu.com/s/17pwpD8QZcEzbfzynKrWBDQ?pwd=sd9f
提取码:sd9f(永久有效)
root@debian:~# dpkg -l | grep -i lrzsz //检查系统是否安装lrzsz,没有的话按下面方法安装
安装Lrzsz软件包,rz从本地上传至服务器,debian下安装lrzsz方法参见:http://t.csdn.cn/5bw4u
root@debian:~/softlist# rz
rz waiting to receive.
Starting zmodem transfer. Press Ctrl+C to cancel.
Transferring cacti-1.2.16.tar.gz...
100% 28512 KB 445 KB/sec 00:01:04 0 Errors
Transferring cacti-spine-1.2.16.tar.gz...
100% 105 KB 105 KB/sec 00:00:01 0 Errors
Transferring fzhtk.ttf...
100% 9727 KB 540 KB/sec 00:00:18 0 Errors
Transferring plugin_monitor-2.3.6.tar.gz...
100% 3762 KB 940 KB/sec 00:00:04 0 Errors
Transferring plugin_thold-1.3.2.tar.gz...
100% 816 KB 816 KB/sec 00:00:01 0 Errors
Transferring rrdtool-1.7.2.tar.gz...
100% 2816 KB 1408 KB/sec 00:00:02 0 Errors
三、开始部署CACTI
1.解压cacti并移动到网站根目录
root@debian:~/softlist# tar zxvf cacti-1.2.16.tar.gz
root@debian:~/softlist# mv cacti-1.2.16 /var/www/html/cacti
root@debian:~/softlist# cd /var/www/html/cacti/
2.配置mariadb数据库,为cacti创建一个数据库
root@debian:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 48
Server version: 10.5.15-MariaDB-0+deb11u1 Debian 11
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE cacti DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.023 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'your cactiuser password';
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit;
Bye
3.到如cacti数据库文件
root@debian:~# mysql -u root -p cacti < /var/www/html/cacti/cacti.sql
Enter password:
4.修改cacti配置文件
root@debian:~# cd /var/www/html/cacti/include
root@debian:~# vi config.php
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'your cactiuser password';
$database_port = '3306';
$database_retries = 5;
$database_ssl = false;
$database_ssl_key = '';
5.修改apache2配置文件设置网站DocumentRoot路径,这里默认无需修改
root@debian:~# vi /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
6.重启apache2、mysqld
root@debian:~# service apache2 restart
root@debian:~# service mysqld restart
7.访问网址显示错误,由于cacti.log文件没有写入权限导致
System log file is not available for writing, please enable write access Log: /var/www/html/cacti/log/cacti.log
root@debian:~# touch /var/www/html/cacti/log/cacti.log
root@debian:~# chmod -R 777 /var/www/html/cacti/log
root@debian:~# chmod -R 777 /var/www/html/cacti/log/cacti.log
8.再次访问
根据提示调整PHP,MYSQL的相关参数以最优化。
[PHP - Recommendations (web)]
date.timezone: 错误 A valid timezone that matches MySQL and the system
-->
root@debian:~# cp /etc/php/7.4/apache2/php.ini /etc/php/7.4/apache2/php.ini.bak
root@debian:~# vi /etc/php/7.4/apache2/php.ini
date.timezone = Asia/Shanghai //解除该注释并设置参数为Asia/Shanghai
memory_limit = 500M //A minimum of 400M memory limit
max_execution_time = 60 //至少 60 m 执行时间
root@debian:~# systemctl restart php7.4-fpm.service
root@debian:~# systemctl restart apache2.service
[PHP - Recommendations (cli)]
date.timezone: 错误 A valid timezone that matches MySQL and the system
-->
root@debian:~# cp /etc/php/7.4/cli/php.ini /etc/php/7.4/cli/php.ini.bak
root@debian:~# vi /etc/php/7.4/cli/php.ini
date.timezone = Asia/Shanghai //解除该注释并设置参数为Asia/Shanghai
root@debian:~# systemctl restart php7.4-fpm.service
root@debian:~# systemctl restart apache2.service
[MySQL - 时区支持]
ERROR: 您的Cacti 数据库登录帐户无权访问MySQL TimeZone 数据库. 请提供Cacti 数据库帐户对 "mysql" 数据库中 "time_zone_name" 表的 "select" 访问权,并在继续之前填充MySQL 的TimeZone 信息.
-->
root@debian:~# mysql -u root -p
MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'your cactiuser password';
Query OK, 0 rows affected (0.006 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
root@debian:~# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p
root@debian:~# systemctl restart php7.4-fpm.service
root@debian:~# systemctl restart apache2.service
[MySQL - 设置]
root@debian:~# vi /etc/mysql/mariadb.conf.d/50-server.cnf //MariaDB service配置文件,和my.cnf作用一样
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
max_allowed_packet = 18M
max_heap_table_size = 300M
tmp_table_size = 256M
join_buffer_size = 600M
innodb_buffer_pool_size = 4096M
innodb_doublewrite = ON
innodb_buffer_pool_instances = 18
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_file_format = Barracuda
innodb_large_prefix = 1
log-error = /var/log/mysql/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
//复制粘贴到50-server.cnf配置文件中,注意参数不要有重复的,一般character-set-server和collation-server两个参数原本就有且生效中。
root@debian:~# systemctl restart mysql.service
我需要1分钟的监控频率,因此我选1分钟,如果需要5分钟的选5分钟即可。
9. 验证cacti snmp是否正常,如果正常,会返回以下内容
root@debian:~# snmpwalk -v 2c -c public localhost
iso.3.6.1.2.1.1.1.0 = STRING: "Linux debian 5.10.0-15-amd64 #1 SMP Debian 5.10.120-1 (2022-06-09) x86_64"
iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.8072.3.2.10
iso.3.6.1.2.1.1.3.0 = Timeticks: (4858198) 13:29:41.98
iso.3.6.1.2.1.1.4.0 = STRING: "Me <me@example.org>"
iso.3.6.1.2.1.1.5.0 = STRING: "debian"
iso.3.6.1.2.1.1.6.0 = STRING: "Sitting on the Dock of the Bay"
iso.3.6.1.2.1.1.7.0 = INTEGER: 72
iso.3.6.1.2.1.1.8.0 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.2.1 = OID: iso.3.6.1.6.3.10.3.1.1
iso.3.6.1.2.1.1.9.1.2.2 = OID: iso.3.6.1.6.3.11.3.1.1
iso.3.6.1.2.1.1.9.1.2.3 = OID: iso.3.6.1.6.3.15.2.1.1
iso.3.6.1.2.1.1.9.1.2.4 = OID: iso.3.6.1.6.3.1
iso.3.6.1.2.1.1.9.1.2.5 = OID: iso.3.6.1.6.3.16.2.2.1
iso.3.6.1.2.1.1.9.1.2.6 = OID: iso.3.6.1.2.1.49
iso.3.6.1.2.1.1.9.1.2.7 = OID: iso.3.6.1.2.1.50
iso.3.6.1.2.1.1.9.1.2.8 = OID: iso.3.6.1.2.1.4
iso.3.6.1.2.1.1.9.1.2.9 = OID: iso.3.6.1.6.3.13.3.1.3
iso.3.6.1.2.1.1.9.1.2.10 = OID: iso.3.6.1.2.1.92
iso.3.6.1.2.1.1.9.1.3.1 = STRING: "The SNMP Management Architecture MIB."
iso.3.6.1.2.1.1.9.1.3.2 = STRING: "The MIB for Message Processing and Dispatching."
iso.3.6.1.2.1.1.9.1.3.3 = STRING: "The management information definitions for the SNMP User-based Security Model."
iso.3.6.1.2.1.1.9.1.3.4 = STRING: "The MIB module for SNMPv2 entities"
iso.3.6.1.2.1.1.9.1.3.5 = STRING: "View-based Access Control Model for SNMP."
iso.3.6.1.2.1.1.9.1.3.6 = STRING: "The MIB module for managing TCP implementations"
iso.3.6.1.2.1.1.9.1.3.7 = STRING: "The MIB module for managing UDP implementations"
iso.3.6.1.2.1.1.9.1.3.8 = STRING: "The MIB module for managing IP and ICMP implementations"
iso.3.6.1.2.1.1.9.1.3.9 = STRING: "The MIB modules for managing SNMP Notification, plus filtering."
iso.3.6.1.2.1.1.9.1.3.10 = STRING: "The MIB module for logging SNMP Notifications."
iso.3.6.1.2.1.1.9.1.4.1 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.2 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.3 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.4 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.5 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.6 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.7 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.8 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.9 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.4.10 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.25.1.1.0 = Timeticks: (4859538) 13:29:55.38
iso.3.6.1.2.1.25.1.2.0 = Hex-STRING: 07 E6 06 13 0C 33 31 00 2B 08 00
iso.3.6.1.2.1.25.1.3.0 = INTEGER: 393216
iso.3.6.1.2.1.25.1.4.0 = STRING: "BOOT_IMAGE=/boot/vmlinuz-5.10.0-15-amd64 root=UUID=a091c396-257e-40d7-8d0e-eb0aeab8b4a5 ro quiet
"
iso.3.6.1.2.1.25.1.5.0 = Gauge32: 1
iso.3.6.1.2.1.25.1.6.0 = Gauge32: 107
iso.3.6.1.2.1.25.1.7.0 = INTEGER: 0
iso.3.6.1.2.1.25.1.7.0 = No more variables left in this MIB View (It is past the end of the MIB tree)
10.验证默认的cmd poller工作是否正常,返回如下的话表示正常
root@debian:~# /usr/bin/php /var/www/html/cacti/poller.php
OK u:0.01 s:0.01 r:1.03
OK u:0.01 s:0.01 r:1.03
OK u:0.01 s:0.02 r:1.06
OK u:0.01 s:0.02 r:1.07
OK u:0.01 s:0.02 r:1.09
OK u:0.01 s:0.02 r:1.09
OK u:0.01 s:0.03 r:1.12
OK u:0.01 s:0.03 r:1.12
2022-06-19 12:56:32 - SYSTEM STATS: Time:1.3908 Method:cmd.php Processes:1 Threads:1 Hosts:1 HostsPerProcess:1 DataSources:5 RRDsProcessed:5
OK u:0.01 s:0.03 r:1.15
OK u:0.01 s:0.03 r:1.15
四、Cacti安装后的配置
1.安装cacti spine轮询器
由于cmd poller效率比较低,因此我们需要采用spine poller替代它,
注意:选择安装的spine poller版本一定要和cacti版本一致,我这里安装1.2.16版本
root@debian:~/softlist# tar zxf cacti-spine-1.2.16.tar.gz
root@debian:~/softlist# cd cacti-spine-1.2.16
root@debian:~/softlist/cacti-spine-1.2.16# ./bootstrap
INFO: Starting Spine build process
INFO: Removing cache directories
INFO: Running auto-tools to verify buildability
./bootstrap: 50: aclocal: not found
./bootstrap: 51: libtoolize: not found
./bootstrap: 52: autoheader: not found
./bootstrap: 53: automake: not found
./bootstrap: 54: autoreconf: not found
ERROR: 'autoreconf' exited with errors
./bootstrap: 55: exit: Illegal number: -1
//根据错误提示我们知道没有安装automake工具集,automake同时需要autoconf和libtool等辅助库支持
root@debian:~/softlist/cacti-spine-1.2.16# apt-get install -y dos2unix autoconf automake binutils libtool cpp help2man
root@debian:~/softlist/cacti-spine-1.2.16# echo $?
0
//再次执行./bootstrap
root@debian:~/softlist/cacti-spine-1.2.16# ./bootstrap
These instructions assume the default install location for spine
of /usr/local/spine. If you choose to use another prefix, make
sure you update the commands as required for that new path.
To compile and install Spine using MySQL versions 5.5 or higher
please do the following:
./configure
make
make install
chown root:root /usr/local/spine/bin/spine
chmod +s /usr/local/spine/bin/spine
To compile and install Spine using MySQL versions previous to 5.5
please do the following:
./configure --with-reentrant
make
make install
chown root:root /usr/local/spine/bin/spine
chmod +s /usr/local/spine/bin/spine
root@debian:~/softlist/cacti-spine-1.2.16# echo $?
0
//执行编译过程 ./configure
root@debian:~/softlist/cacti-spine-1.2.16# ./configure
checking whether time.h and sys/time.h may both be included... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking return type of signal handlers... void
checking for malloc... no
checking for calloc... no
checking for gettimeofday... no
checking for strerror... no
checking for strtoll... no
checking priv.h usability... no
checking priv.h presence... no
checking for priv.h... no
checking whether we are using Solaris privileges... no
checking sys/capability.h usability... no
checking sys/capability.h presence... no
checking for sys/capability.h... no
checking whether we are using Linux Capabilities... no
configure: error: Cannot find MySQL headers. Use --with-mysql= to specify non-default path.
root@debian:~/softlist/cacti-spine-1.2.16# echo $?
1
//解决错误(configure: error: Cannot find MySQL headers. Use --with-mysql= to specify non-default path.)可以看到是关于MySQL路径的,我们采用错误建议方法看看行不行不行的话,就需要安装glibc了,debian镜像源中是没有该组件库的,需要添加镜像源安装
root@debian:~/softlist/cacti-spine-1.2.16# apt-get upgrade glibc //验证执行检查镜像源是否有该组件包,结果没有该库文件
root@debian:~/softlist/cacti-spine-1.2.16# vi /etc/apt/sources.list
deb http://ftp.cn.debian.org/debian sid main //最底部添加该源,后面安装好glibc后再删掉
root@debian:~/softlist/cacti-spine-1.2.16# apt-get update
获取:11 http://ftp.cn.debian.org/debian sid/main Translation-zh [1,215 B]
已下载 16.5 MB,耗时 0分 12秒 (2300.7 kB/s)
正在读取软件包列表... 完成
root@debian:~/softlist/cacti-spine-1.2.16# apt-get -t sid install libc6 libc6-dev libc6-dbg libmysql++-dev
checking priv.h usability... no
checking priv.h presence... no
checking for priv.h... no
checking whether we are using Solaris privileges... no
checking sys/capability.h usability... no
checking sys/capability.h presence... no
checking for sys/capability.h... no
checking whether we are using Linux Capabilities... no
checking for mysql_init in -lmysqlclient... yes
configure: error: Cannot find SNMP headers. Use --with-snmp= to specify non-default path.
//又报SNMP的错误,看来给装系统的人装的太缺组件了,继续解决configure: error: Cannot find SNMP headers. Use --with-snmp= to specify non-default path.
从错误结果看spine安装缺少和snmp之间的组件libsnmp-dev 安装即可
root@debian:~/softlist/cacti-spine-1.2.16# apt-get install libsnmp-dev -y
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
root@debian:~/softlist/cacti-spine-1.2.16# echo $?
0
root@debian:~/softlist/cacti-spine-1.2.16# ./configure
root@debian:~/softlist/cacti-spine-1.2.16# echo $?
0
root@debian:~/softlist/cacti-spine-1.2.16# make && make install
/usr/bin/mkdir -p '/usr/local/spine/bin'
/bin/bash ./libtool --mode=install /usr/bin/install -c spine '/usr/local/spine/bin'
libtool: install: /usr/bin/install -c spine /usr/local/spine/bin/spine
/usr/bin/mkdir -p '/usr/local/spine/etc'
/usr/bin/install -c -m 644 spine.conf.dist '/usr/local/spine/etc'
/usr/bin/mkdir -p '/usr/local/spine/share/man/man1'
/usr/bin/install -c -m 644 spine.1 '/usr/local/spine/share/man/man1'
make[1]: 离开目录“/root/softlist/cacti-spine-1.2.16”
root@debian:~/softlist/cacti-spine-1.2.16# echo $?
0
root@debian:~/softlist/cacti-spine-1.2.16# chown root:root /usr/local/spine/bin/spine
root@debian:~/softlist/cacti-spine-1.2.16# chmod +s /usr/local/spine/bin/spine
2.修改spine配置
root@debian:~# cd /usr/local/spine/etc
root@debian:/usr/local/spine/etc# ls
spine.conf.dist
root@debian:/usr/local/spine/etc# cp spine.conf.dist spine.conf
root@debian:/usr/local/spine/etc# vi spine.conf
DB_Host localhost //cacti地址,这里在本机
DB_Database cacti //cacti数据库名称
DB_User cactiuser //cacti数据库所使用的用户
DB_Pass your cactiuser password //你的cacti数据库用户cactiuser密码
DB_Port 3306
3.验证spine工作是否正常,结果显示没有问题
root@debian:/usr/local/spine/etc# /usr/local/spine/bin/spine
SPINE: Using spine config file [spine.conf]
SPINE: Version 1.2.16 starting
SPINE: Time: 0.3857 s, Threads: 1, Devices: 2
4.修改web管理界面poller类型为spine
5.设置确认spine路径
至此关于spine的安装配置就结束了,我们来看下前台图形是否显示,正常应该没有数据才对,单个图形的实时数据应该是OK的,因为我们还没有配置cron计划任务来定期执行poller。
猜想既是如此
五、配置Cron计划任务执行poller
root@debian:~# crontab -e
#For cacti poller executing
*/1 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
root@debian:~# systemctl restart cron.service
六、开启相关服务的自启动
root@debian:~# systemctl enable crond.service
root@debian:~# systemctl enable apache2.service
root@debian:~# systemctl enable mysql.service
root@debian:~# systemctl enable php7.4-fpm.service
至此我们就完成了在Debian 11.3系统中安装部署Cacti监控系统,加上整理文档历时近4个小时,从这个过程中,我们要克服烦躁,毕竟Linux中安装软件需要各种环境支持及异常报错,不怕有错就怕沉不下心去解决,如果是新手这个估计没几天完成不了,各种报错,所以在运维过程中,前提基础要搞好,从装系统开始就准备避免后面软件安装异常报错程度。总之,熟能生巧,熟能判断报错问题原因,动手,频繁动手,第一次安装没有报错不代表第二次第三次安装就有报错。
后面会继续完善这个监控系统,目前是1台,目标是实现2台cacti能够主备负载均衡以满足监控节点数量多的性能需求,最后再公布采用脚本方式在debian中自动安装cacti,实现系统版本检测环境检测适应不同版本,还是要加强下基础的功力才行。
就这些,关注我THHT,为大家继续发布实际生产环境中遇到的问题及工作内容,为大家提出个人的思路建议,同时可以给予痛苦中的你一个指路明灯。