CentOS7cacti
云计算
链接:https://pan.baidu.com/s/1Hu-RykIAs6xzahM2Ldby8g
提取码:6un5
此实验需要联网,所以要两块网卡,一块仅主机,一块桥接
systemctl stop firewalld
setenforce 0
cd /etc/yum.repos.d/
cp back/* ./
添加所需的yum源
vi all.repo
---新增中科大mariadb源----
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
安装所需的安装包:
yum install -y \\
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
DirectoryIndex index.html //把html改成php
vi /etc/httpd/conf.d/php.conf ——————末尾新增
LoadModule php5_module modules/libphp5.so
vi /etc/php.ini
safe_mode=off //在[PHP]下插入
date.timezone = PRC //去掉注释
systemctl stop firewalld
setenforce 0
systemctl start httpd
systemctl start mariadb
netstat -anpt | grep 80
netstat -anpt | grep 3306
Mysql_secure_installation 安全配置向导
y-n-y-y
vi /var/www/html/index.php //编辑网页测试文件
测试,在浏览器中输入192.168.80.100
vi /etc/my.cnf.d/server.cnf //[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
mysql -u root -p //登入数据库
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;
vi /var/www/html/index.php
Success!!;
else echo Fail!!;
?>
测试检测mysql php是否协同工作,在浏览器中输入192.168.80.100
---------------------到此,LAMP架构结束---------------------------
yum install -y lrz*s
安装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
mysql -u root -p
grant select on mysql.time_zone_name to \'cacti\'@\'%\' IDENTIFIED BY \'admin123\';
//在数据库中为时区文件授权
flush privileges;
vi /var/www/html/cacti/include/config.php
$database_hostname=\'192.168.80.100\';
$database_username = \'cacti\';
$database_password = \'admin123\';
配置SNMP 简单网络管理协议
vi /etc/snmp/snmpd.conf
access notConfigGroup any noauth exact all none none //把systemview改成all 62
view all included .1 80 // 去掉#号 85
systemctl restart snmpd
systemctl enable snmpd
useradd -r -M cacti
chown -R 777 /var/www/html/cacti/rra/
chown -R 777 /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
安装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
/usr/local/spine/bin/spine -c /usr/local/spine/etc/spine.conf
systemctl restart httpd
systemctl restart mariadb
-----------登录到页面-----------
192.168.80.100/cacti/
安装过程
用户名与密码默认admin,登录后密码要求修改(至少八位,并且复杂)
重设密码,密码为大写小写特殊字符组合
重新访问:http://192.168.80.10/cacti/
(控制台)Console -> 系统配置 -> 设置(Cacti Settings) -> Paths -> 在 Spine Binary File Location 文本框内填入配置文件路径 /usr/local/spine/bin/spine ,点击保存 (Save)。
Console -> 设置(Cacti Settings) -> Poller -> 在 Poller Type 下拉框中选择 spine ,点击保存 (Save)。注意:假如使用spine的话,下面两项轮训时间和计划任务间隔时间都要设置为every Minute
在查看图形数据的时候如果报错:
/bin/rrdtool :symbol lookup error: /lib64/libpango-1.0.so.0:undefined symboll
解决方法:
yum update glib2 -y
如果报错:
error:opening \'/var/www/html/cacti/rra/local_linux_machine_load_1min_2.rrd\':No such file or directory
解决方法:
chmod -R 777 /var/www/html/cacti/rra
/usr/bin/php /var/www/html/cacti/poller.php
添加设备:
Win7设置:
控制面板—程序和功能
打开服务管理器:
Win+r,services.msc
在添加完设备和图形后,需要重建采集器缓存。
去cacti上查看
管理à设备(device)
查看linux状态为UP即可,注意不要着急spine方式刚刚启动需要2-5分钟左右时间,有快有慢
设置主机的IP地址:
然后直接选图形,可以查看cacti处理后的图片
--------------------------添加一台linux服务器:-------------------------
yum install -y \\
net-snmp \\
net-snmp-utils \\
net-snmp-libs \\
net-snmp-agent-libs \\
net-snmp-devel
配置SNMP 简单网络管理协议
vi /etc/snmp/snmpd.conf
com2sec notConfigUser 192.168.80.100 public #允许哪个服务器监控本机 ,public团体名
access notConfigGroup "" any noauth exact all none none //把systemview改成all 62
view all included .1 80 // 去掉#号 85
systemctl restart snmpd
可以再cacti服务器端执行如下命令:
snmpwalk -v2c -c public 192.168.80.101
测试能不能抓取到数据
分享文章:CentOS7cacti
当前路径:http://ybzwz.com/article/cpdhse.html