Centos7安装cacit

本文详细记录了根据Linux公社的教程,使用lamp架构在服务器上搭建Cacti监控系统的全过程,包括配置Apache、Mariadb、PHP,安装RRDTool、SNMP服务,以及创建数据库和用户等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这篇微博是记录我根据Linux公社的lidaxia搭建的,用来记录我搭建成功的过程,原文是这个链接https://www.linuxidc.com/Linux/2017-03/141995.htm

搭建过程主要如下:

cacti是基于lamp或者lnmp,这里使用的是lamp架构,首先配置Apache

[root@cacti-server ~]# yum -y install httpd

[root@cacti-server ~]# systemctl start httpd

[root@cacti-server ~]# systemctl enable httpd

[root@cacti-server ~]# firewall-cmd --permanent --add-service=http

success

[root@cacti-server ~]# firewall-cmd --reload

配置mariadb,mariadb是mysql的一个分支,登录时还是要用mysql -u user -p命令

[root@cacti-server ~]# yum -y install mariadb-server mysql-devel

[root@cacti-server ~]# systemctl start mariadb

[root@cacti-server ~]# mysql_secure_installation

Set root password? [Y/n]

Remove anonymous users? [Y/n] y

Disallow root login remotely? [Y/n] y

Remove test database and access to it? [Y/n] y

Reload privilege tables now? [Y/n] y

[root@cacti-server ~]# mysql -u root -p

MariaDB [(none)]> grant all privileges on *.* to test@localhost identified by 'RedHat'; 创建用于测试php和mariadb连通性的用户

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

[root@cacti-server ~]# systemctl restart mariadb

[root@cacti-server ~]# systemctl enable mariadb

[root@cacti-server ~]# firewall-cmd --permanent --add-port=3306/tcp

success

[root@cacti-server ~]# firewall-cmd --reload

success

配置php

[root@cacti-server ~]# yum -y install php php-mysql php-gd php-pear

[root@cacti-server ~]# vim /etc/php.ini 

date.timezone =PRC      修改时区(这里要添加这条消息,不设置时区安装会报错)

[root@cacti-server ~]# vim /var/www/html/index.php    编辑测试页面

<?php

    $conn=mysql_connect('localhost','test','redhat');

    if ($conn)

      echo "database connect ok";

    else

      echo "database connect failure";

?>

<?php

    phpinfo()

?>

[root@cacti-server ~]# systemctl restart httpd

2.安装配置cacti

下载软件

[root@cacti-server ~]# cd /usr/local/src/

[root@cacti-server src]# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz

[root@cacti-server src]# tar zxvf cacti-0.8.8f.tar.gz

[root@cacti-server src]# mv cacti-0.8.8f /var/www/html/cacti

也可以直接在官网上下载,shell上传就行,官网的版本已经是1.1.38了

创建cacti数据库和cacti用户,赋予权限

[root@cacti-server ~]# mysql -u root -p

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

MariaDB [(none)]> grant all privileges on cacti.* to cacti@localhost identified by 'redhat';

MariaDB [(none)]> flush privileges;

把cacti.sql导入数据库

[root@cacti-server cacti]# mysql -ucacti -predhat cacti < /var/www/html/cacti/cacti.sql

编辑config.php和global.php

[root@cacti-server cacti]# vim /var/www/html/cacti/include/config.php|global.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cacti";

$database_password = "redhat";

$database_port = "3306";

$database_ssl = false;

安装rrdtool以生成图像

[root@cacti-server src]# yum -y install rrdtool rrdtool-devel rrdtool-php rrdtool-perl

[root@cacti-server src]# yum -y install gd gd-devel php-gd    ---rrdtool绘制图像需要的图形库

安装snmp服务

[root@cacti-server cacti]# yum -y install net-snmp net-snmp-utils php-snmp net-snmp-libs

编辑配置文件

[root@cacti-server ~]# vim /etc/snmp/snmpd.conf

41  com2sec notConfigUser  127.0.0.1      public

62  access  notConfigGroup ""  any    noauth    exact  all none none

85  view all    included  .1          80

[root@cacti-server ~]# systemctl restart snmpd.service

[root@cacti-server ~]# systemctl enable snmpd.service

授权目录权限

[root@cacti-server ~]# useradd -r -M cacti

[root@cacti-server ~]# chown -R cacti /var/www/html/cacti/rra/

[root@cacti-server ~]# chown -R cacti /var/www/html/cacti/log/

这里必须给目录权限,不然安装时会报错。

做完以上步骤就可以登录http://IP_address/cacti来进行安装了,安装过程中必须的php模块一定要安装完,我用的是阿里云的yum源,却什么扩展就php-扩展名,就能安装下来了,还有一点就是mysql会报一个时区的错误,这个错误的解决办法如下:

登录到数据库,输入如下命令

grant select on mysql.time_zone_name to cacti@localhost identified by 'redhat';

flush privileges;

exit

/usr/bin/mysql_tzinfo_to_sql  /usr/share/zoneinfo | mysql -u root -p

解决完这些后错误和安装PHP扩展模块就可以next了,一直next就行,基本的cacti就安装完成了,最后登录的初始化账户密码都是admin

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值