IT运维技术文档
当前位置: 主页 > 监控工具 >

Centos8 安装CACTI1.2

时间:2021-03-17 12:53来源:未知 作者:umibbs 点击:
在RHEL 8/CentOS 8服务器上安装和配置Cacti的步骤
广告位API接口通信错误,查看德得广告获取帮助
本文介绍在RHEL 8/CentOS 8服务器上安装和配置Cacti的详细步骤。Cacti是一个完全开源的网络监控和图形工具,被设计为行业标准数据记录工具(RRDtool)的前端应用程序,它提供直观且易于使用的Web界面,用于管理网络监控和配置。
 
第1步:安装构建工具和系统依赖项
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
timedatectl set-timezone Asia/Shanghai
centos8 时间同步是chrony
vim /etc/chrony.conf
server ntp.aliyun.com iburst
server cn.pool.ntp.org iburst
pool 2.centos.pool.ntp.org iburst
重新加载配置
systemctl restart chronyd.service
时间同步
chronyc sources -v
 
安装开发工具后,还要安装SNMP软件包:
dnf update
sudo dnf install -y net-snmp net-snmp-utils rrdtool net-snmp-devel
 
第2步:安装php和必需的扩展
 
在RHEL/CentOS 8上安装Cacti所需的PHP和扩展:
 
sudo dnf install @php
 
sudo dnf install -y php php-{mysqlnd,curl,gd,intl,pear,recode,ldap,xmlrpc,snmp,mbstring,gettext,gmp,json,xml,common}
 
验证PHP版本和加载的模块:
 
$ php -v
 
PHP 7.2.11 (cli) (built: Oct 9 2018 15:09:36) ( NTS )
 
Copyright (c) 1997-2018 The PHP Group
 
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
 
在/etc/php.ini文件中设置PHP时区:
 
$ vi /etc/php.ini
date.timezone = Asia/Shanghai
将PHP内存限制更改为1024M:
memory_limit = 1024M
max_execution_time = 180
启动php-fpm服务:
sudo systemctl enable --now php-fpm
 
确认状态,运行systemctl status php-fpm命令:
第3步:安装Apache Web服务器
使用以下命令安装Apache httpd服务器:
sudo dnf install @httpd
启动并启用服务以在启动时启动:
sudo systemctl enable --now httpd
状态应指示正在运行,运行systemctl status httpd命令查看:
允许防火墙上的http和https端口:
sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload
 
第4步:安装和配置数据库
第1步:更新RHEL 8系统
请运行以下命令来更新RHEL 8系统:
sudo yum update
sudo yum upgrade
 
步骤2:在RHEL 8上安装MariaDB数据库
1、mariadb包在AppStream存储库中可用,可以通过运行命令来安装:
sudo dnf install mariadb-server mariadb-devel
2、请使用y来确认安装,即让你选择[y/N]时选择y:
Transaction Summary
Install  13 Packages
Total download size: 32 M
Installed size: 164 M
Is this ok [y/N]: y
3、确认已安装MariaDB的版本
$ rpm -qi mariadb-server
注:根据上面的信息可以得出,安装的版本是10.3.10 x86_64。
 
步骤3:在RHEL 8上启动并配置MariaDB
现在来调整Cacti的MariaDB数据库,先在[mysqld]下添加以下设置文件/etc/my.cnf.d/mariadb-server.cnf:
[mysqld]
(修改目录)
datadir=/home/mysql
增加配置
default-time_zone = '+8:00'
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
max_heap_table_size=256M
tmp_table_size=256M
join_buffer_size=512M
innodb_file_format=Barracuda
innodb_large_prefix=1
innodb_buffer_pool_size=3072M
innodb_doublewrite=ON
innodb_flush_log_at_timeout=3
innodb_read_io_threads=32
innodb_write_io_threads=16
innodb_buffer_pool_instances=25
innodb_io_capacity=5000
innodb_io_capacity_max=10000
 
1、使用以下命令激活mariadb服务:
sudo systemctl enable --now mariadb
systemctl status mariadb
2、启动服务后,运行命令mysql_secure_installation以强化MariaDB数据库安全性:
$ mysql_secure_installation 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
 SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password: <ENTER NEW PASSWORD>
Re-enter new password: <CONFIRM PASSWORD>
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
请确保:
设置数据库root用户密码。
删除匿名用户。
禁止root用户远程登录。
删除测试数据库并访问它。
3、完成后,使用root用户测试访问权限:
$ mysql -u root -p
至此,已经成功的在RHEL 8上安装了MariaDB数据库。
安装数据库后,为Cacti Monitoring工具创建数据库和用户:
$ mysql -u root -p
CREATE DATABASE cacti;
GRANT ALL ON cacti.* TO 'cacti'@'localhost' IDENTIFIED BY 'StrongDBPassword';
FLUSH PRIVILEGES;
exit
 
 
第5步:下载并配置Cacti
将最新版本的Cacti源码下载到你的系统中:
mkdir cacti && cd cacti
curl -SL https://www.cacti.net/downloads/cacti-latest.tar.gz | tar --strip 1 -xzf -
将cacti文件夹移动到/home/www/cacti目录:
cd ..
sudo mv cacti/ /home/www/html/
导入Cacti数据库数据:
mysql -u root -p cacti < /home/www/html/cacti/cacti.sql
为cacti数据库用户设置mysql时区:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
授予cacti MySQL数据库用户访问Timezone数据库的权限:
$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 12
Server version: 10.3.10-MariaDB MariaDB Server
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)]> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> QUIT
Bye
 
第6步:配置Cacti
编辑文件/var/www/html/include/config.php 和global.php并设置数据库连接参数:
$database_type     = 'mysql';
$database_default  = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cacti';
$database_password = 'StrongDBPassword';
$database_port     = '3306';
.............
$url_path = '/';
将StrongDBPassword替换为你的cacti用户数据库密码,完成后保存文件并退出:
创建Cacti系统日志文件:
touch /var/www/html/cacti/log/cacti.log
设置目录权限:
sudo chown -R apache:apache  /var/www/html/cacti
设置Cacti cron job:
sudo crontab -e
在下面添加:
*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1
 
yum install font*
vi /home/www/cacti/lib/functions.php
在文件后尾倒数第二行添加以下内容:
setlocale(LC_CTYPE,"zh_CN.UTF-8");
如:
}
setlocale(LC_CTYPE,"zh_CN.UTF-8");
?>
 中文字体支持,上传windows字体c:windows ontssimsun.ttc到/usr/share/fonts/chinese
执行命令:fc-cache -f -v
第7步:访问Cacti安装向导
在浏览器中访问http://[ServerIP/Hostname]/cacti上的Cacti Installation Wizard界面:
默认登录用户名及密码都是admin,建议在下一页更改密码,如下图:
建议把密码改得复杂一些,包含至少1个数字字符及包含至少1个特殊字符。然后接受GPL许可协议并点击Begin:
所有安装前检查都应显示绿色,表示已通过,如下图所示:
在下一个窗口中选择安装类型,如下图:
确保目录权限检查正常:
确认所有二进制文件都已找到并单击Next:
选择默认数据源:
选择安装后要使用的设备模板:
确认数据库设置没问题:
确认安装,如下图:
应该开始安装,等待它完成然后访问cacti管理面板:
 
第8步:使用Cacti监控Linux服务器
启动并启用snmpd守护程序以在启动时启动:
sudo systemctl enable --now snmpd
确认它正在运行,运行systemctl status snmpd命令查看:
添加Linux服务器以进行监视,以管理员用户身份登录Cacti,然后转到Console > Create > New Device(控制台>创建>新设备),提供服务器详细信息并保存配置。
至此,安装和配置Cacti全部完成。
 
 
(责任编辑:umibbs)
织梦二维码生成器
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
  • 上一篇:没有了
  • 下一篇:没有了
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
广告位API接口通信错误,查看德得广告获取帮助
推荐内容
热点内容
广告位API接口通信错误,查看德得广告获取帮助
广告位API接口通信错误,查看德得广告获取帮助