CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

luwenze 2018-03-31

记录在CentOS 7.4下源码安装Cacti 1.1.26图文详解,希望对大家有所帮助。

此实验需要联网,所以要两块网卡,一块仅主机,一块桥接
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
所需软件压缩包
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

vi all.repo
---本地yum仓库
[base]
name=Centos-repo.repo
baseurl=file:///mnt
enabled=1
gpgcheck=0

---新增中科大mariadb源-------光盘自带的版本过低----
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos74-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

----------搭建阿里云yum仓库-------------
[Ali]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
yum install -y \ //安装httpd ,及mariadb,及php和其他依赖包插件
httpd \
MariaDB-client MariaDB-server \
MariaDB-devel \
php \
php-snmp \
php-ldap \
php-pdo \
php-mysql \
php-devel \
php-pear \
php-common \
php-gd \
php-mbstring \
php-xml \
php-process \
net-snmp \
net-snmp-utils \
net-snmp-libs \
net-snmp-agent-libs \
net-snmp-devel \
rrdtool \
rrdtool-php \
rrdtool-perl \
rrdtool-devel \
gcc openssl-devel \
dos2unix \
autoconf \
automake \
binutils libtool \
cpp postfix \
glibc-headers \
kernel-headers \
glibc-devel \
gd gd-devel \
help2man \
ntpdate \
wget patch

vi /etc/httpd/conf/httpd.conf
ServerName www.aa.com

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
vi /etc/httpd/conf.d/php.conf ——————末尾新增
LoadModule php5_module modules/libphp5.so
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

vi /etc/php.ini
safe_mode=off //在[PHP]下插入
date.timezone = PRC //去掉注释
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
systemctl stop firewalld.service //关闭防火墙
setenforce 0 //临时关闭SElinux

systemctl start httpd.service //启动httpd服务
systemctl start mariadb.service //启动mariadb数据库服务

netstat -anpt | grep 80
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
netstat -anpt | grep 3306
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

mysql_secure_installation 安全配置向导
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
初次运行直接回车
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
是否设置root用户密码,输入y并回车或直接回车
设置root用户的密码
再输入一次你设置的密码
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
是否删除匿名用户,生产环境建议删除,所以直接回车
是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
是否删除test数据库,直接回车
是否重新加载权限表,直接回车(这一步上图没有截全)

vi /var/www/html/index.php //编辑网页测试文件
<?php
phpinfo();
?>
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
测试,在浏览器中输入192.168.80.100
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
如上图,表示httpd和php已正常启动,并连接成功

vi /etc/my.cnf.d/server.cnf //配置cacti网页安装的参数
//[mysqld]下配置以下内容
character_set_server = utf8mb4
collation_server = utf8mb4_unicode_ci
character_set_client = utf8mb4
max_connections = 100
max_heap_table_size = 256M
max_allowed_packet = 16777216
join_buffer_size = 64M
tmp_table_size = 64M
innodb_file_per_table = ON
innodb_buffer_pool_size = 1024M
innodb_doublewrite = OFF
innodb_lock_wait_timeout = 50
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
mysql -u root -p //登入数据库
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
CREATE DATABASE cacti character set utf8 collate utf8_bin;
GRANT all ON cacti. TO 'cacti'@'%' IDENTIFIED BY 'admin123';
GRANT all ON cacti.
TO 'cacti'@'localhost' IDENTIFIED BY 'admin123';
flush privileges;
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

vi /var/www/html/index.php
<?php
$link=mysqli_connect('192.168.80.100','cacti','admin123');
if($link) echo "<h1>Success!!</h1>";
else echo "Fail!!";
?>
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

测试检测mysql 与php是否协同工作,在浏览器中输入192.168.80.100
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
如上图所示,表示mysql 与php正协同工作

安装cacti
tar xf cacti-1.1.26.tar.gz
mv cacti-1.1.26 /var/www/html/cacti
mysql -ucacti -p cacti < /var/www/html/cacti/cacti.sql
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot mysql -p

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
mysql -u root -p

grant select on mysql.time_zone_name to 'cacti'@'%' IDENTIFIED BY 'admin123';
//在数据库中为时区文件授权
flush privileges;
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

vi /var/www/html/cacti/include/config.php
$database_username = 'cacti';
$database_password = 'admin123';
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

配置SNMP
vi /etc/snmp/snmpd.conf

com2sec notConfigUser 127.0.0.1 public //改成环回口地址 41
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
access notConfigGroup "" any noauth exact all none none //把systemview改成all 62
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
view all included .1 80 // 去掉#号 85

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

systemctl restart snmpd.service
systemctl enable snmpd.service

useradd -r -M cacti
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.apache /var/www/html/cacti/cache
chown -R apache.apache /var/www/html/cacti/scripts

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

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
安装cacti-spine优化数据轮询速度
ln -s /usr/lib64/libmysqlclient.so.18.0.0 /usr/lib64/libmysqlclient.so

tar xf cacti-spine-1.1.26.tar.gz
cd cacti-spine-1.1.26
./configure && make && make install

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

vi /usr/local/spine/etc/spine.conf //修改相关参数

DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass admin123
DB_Port 3306

RDB_Host localhost
RDB_Database cacti
RDB_User cacti
RDB_Pass admin123
RDB_Port 3306
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

systemctl restart httpd
systemctl restart mariadb

-----------登录到页面-----------
192.168.80.181/cacti/
……
安装步骤:

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
输入账号admin和密码admin
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

重设密码,密码为大写小写特殊字符组合,如Abc123a,

Console -> 设置(Cacti Settings) -> Poller -> 在 Poller Type 下拉框中选择 spine ,点击保存 (Save)。注意:假如使用spine的话,下面两项轮训时间和计划任务间隔时间都要设置为every Minute
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

在添加完设备和图形后,需要重建采集器缓存。

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解
去cacti上查看
管理设备(device)
查看linux状态为UP即可,注意不要着急spine方式刚刚启动需要2-5分钟左右时间,有快有慢
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

设置主机的IP地址:设备——>点击local linux machine
CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

然后直接选图形,可以查看cacti处理后的图片

CentOS 7.4源码安装Cacti 1.1.26监控Linux主机图文详解

如上图所示,cacti正在监控Linux主机。

相关推荐

TiDBPingCAP / 0评论 2020-07-29