CentOS7 cacti
链接:https://pan.baidu.com/s/1Hu-RykIAs6xzahM2Ldby8g
提取码:6un5
此实验需要联网,所以要两块网卡,一块仅主机,一块桥接
systemctl stop firewalldsetenforce 0cd /etc/yum.repos.d/cp back/* ./添加所需的yum源vi all.repo---新增中科大mariadb源----[mariadb]name = MariaDBbaseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDBgpgcheck=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.confServerName www.aa.com DirectoryIndex index.html //把html改成php
vi /etc/httpd/conf.d/php.conf ------末尾新增LoadModule php5_module modules/libphp5.so
vi /etc/php.inisafe_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 = utf8mb4collation_server = utf8mb4_unicode_cicharacter_set_client = utf8mb4max_connections = 100max_heap_table_size = 256Mmax_allowed_packet = 16777216join_buffer_size = 64Mtmp_table_size = 64Minnodb_file_per_table = ONinnodb_buffer_pool_size = 1024Minnodb_doublewrite = OFFinnodb_lock_wait_timeout = 50innodb_flush_log_at_timeout = 3innodb_read_io_threads = 32innodb_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.phpSuccess!!";else echo "Fail!!";?>
测试检测mysql php是否协同工作,在浏览器中输入192.168.80.100
---------------------到此,LAMP架构结束---------------------------
yum install -y lrz*s安装cactitar xf cacti-1.1.26.tar.gzmv cacti-1.1.26 /var/www/html/cactimysql -ucacti -p cacti < /var/www/html/cacti/cacti.sqlmysql_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 snmpdsystemctl enable snmpd
useradd -r -M cactichown -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/cachechown -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.gzcd 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 localhostDB_Database cactiDB_User cactiDB_Pass admin123DB_Port 3306 RDB_Host localhostRDB_Database cactiRDB_User cactiRDB_Pass admin123RDB_Port 3306
/usr/local/spine/bin/spine -c /usr/local/spine/etc/spine.conf
systemctl restart httpdsystemctl 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
测试能不能抓取到数据