下载和安装配置 cacti
[root@localhost ~]# wget https://www.cacti.net/downloads/cacti-latest.tar.gz
[root@localhost ~]# tar -zxvf cacti-latest.tar.gz -C /var/www/html/
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# mv cacti-1.2.2/ cacti
[root@localhost ~]# chown -R root:root /var/www/html/cacti/
[root@localhost ~]# chmod -R 777 /var/www/html/cacti/
[root@localhost ~]# groupadd cacti
[root@localhost ~]# useradd -g cacti cacti
[root@localhost ~]# chown -R cacti:cacti /var/www/html/cacti/log/
[root@localhost ~]# chown -R cacti:cacti /var/www/html/cacti/rra/
[root@localhost ~]# cd /var/www/html/cacti/
配置 cacti 数据库
[root@localhost cacti]# vim include/config.php
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_hostname = '127.0.0.1';
$database_username = 'cacti';
$database_password = 'cacti';
$database_port = '3306';
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';
[root@localhost cacti]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5713
Server version: 5.6.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database cacti default character set utf8;
Query OK, 1 row affected (0.01 sec)
mysql> grant all on cacti.* to 'cacti'@'localhost' identified by 'cacti';
Query OK, 0 rows affected (0.03 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
MySQL 调优
[root@localhost ~]# vim /etc/my.cnf
max_heap_table_size = 64M
max_allowed_packet = 18777216
tmp_table_size = 96M
join_buffer_size = 96M
innodb_buffer_pool_size = 256M
innodb_doublewrite = OFF
innodb_additional_mem_pool_size = 128M
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
mysql> grant all privileges on *.* to cacti@localhost identified by 'cacti';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@localhost ~]# /usr/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -uroot -p mysql
安装 spine
[root@localhost ~]# wget https://www.cacti.net/downloads/spine/cacti-spine-latest.tar.gz #下载 spine
[root@localhost ~]# tar zxvf cacti-spine-latest.tar.gz -C /usr/local/ #解压文件到/usr/local/
[root@localhost ~]# cd /usr/local/ #切换到/usr/local/目录
[root@localhost local]# mv cacti-spine-1.2.2/ spine/ #重命名目录名称
[root@localhost ~]# cd spine/ #切换到 spine/目录
[root@localhost spine]# yum install -y net-snmp-devel mysql-devel openssl-devel dos2unix autoconf automake binutils libtool gcc cpp glibc-headers kernel-headers glibc-devel help2man #安装依赖库
[root@localhost spine]# sh bootstrap #运行 sh 脚本
根据以以下提示数据库版本来运行安装方式
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@localhost ~]# ./configure --with-reentrant
make
make install
chown root:root /usr/local/spine/bin/spine
chmod +s /usr/local/spine/bin/spine
配置 spine.conf:
[root@localhost ~]# cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
[root@localhost ~]# vi /etc/spine.conf
DB_Host 127.0.0.1
DB_Database cacti
DB_User cacti
DB_Pass cacti
DB_Port 3306
执行 spine 初始化
[root@localhost ~]# /usr/local/spine/bin/spine
将 spine 文件复制以正确路径(将 bin 目录下的 spine 复制并新建目录为 spine/下)
[root@localhost ~]# mv /usr/local/spine/bin/spine /usr/local/spine/bin/spine/
访问 cacti web http://127.0.0.1/cacti/install/
如果访问 web 出现以下错误:
Forbidden
You don't have permission to access /cacti/install on this server.
修改以下内容
[root@localhost ~]# vi /etc/httpd/conf.d/cacti.conf
Alias /cacti /usr/share/cacti
<Directory /usr/share/cacti/>
Order Deny,Allow
Allow from all
</Directory>
如果访问 web 出现以下错误:
FATAL: Connection to Cacti database failed. Please ensure the database is running and your credentials in config.php are valid.
重启 mysql
[root@localhost ~]# service mysqld restart
一切就绪后可即可正常安全访问 cacti 配置页面:仙人掌安装向导(Cacti Installation Wizard)
1、接受许可协议(License Agreement)
2、配置安装前检测页面(Pre-installation Checks)
3、配置安装类型页面(Installation Type)
4、配置关键二进制位置和版本(Critical Binary Locations and Versions)
5、显示目录权限检查(Directory Permission Checks)
6、配置模板设置(Template Setup)
// 选择要使用的设备模板。如果操作系统是 Windows,则需要确保选择 “Windows 设备” 模板。如果您的操作系统是 Linux / UNIX,请确保选择 “本地 Linux 计算机” 设备模板。
成功完成以上配置后,即可跳转到 cacti 登录界面,默认用户名和密码为 admin:admin,登录后,根据提示更改密码;
Current password / 当前密码
New password / 新密码
Confirm new password / 确认新密码
完成。
0 条评论