#首先开启数据库并数据库设置密码
systemctl start mariadb.service
mysqladmin -uroot password abc123
#进入数据库船舰cacti数据库并授予权限
mysql -u root -p
#创建名为cacti的数据库并设定字符集utf-8
create database cacti default character set utf8;
#授予cacti用户权限登陆密码为asd123
grant all on cacti.* to cacti@localhost identified by 'asd123';
quit
#把cacti目录底下的cacti.sql导入到cacti数据库里面(这边使用的用户时cacti用户授予的密码时asd123)
mysql -u cacti -p cacti < cacti.sql
(3)修改snmp协议的配置文件
在本机模拟linux cacti被控端
vim /etc/snmp/snmpd.conf
41行:com2sec notConfigUser 192.168.179.151 public
62行:access notConfigGroup "" any noauth exact all none none
85行:view all included .1 80 #去掉前面的#号
#开启snmp协议
systemctl start snmpd.service
(4)进入安装页面http://192.168.1789.151/cacti
进入下面页面后,要解决PHP一些拓展应用
1、解决PHP拓展模块
#进入数据库授权
GRANT SELECT ON mysql.time_zone_name TO cacti@localhost IDENTIFIED BY 'cactiwhsir';
#再把以下命令重新授权一下
grant all on cacti.* to cacti@localhost identified by 'asd123';
#刷新
flush privileges;
#又会出现下面报错
ERROR: Your MySQL TimeZone database is not populated. Please populate this database before proceeding.
#解决办法
mysql_tzinfo_to_sql /usr/share/zoneinfo/Asia/Shanghai Shanghai | mysql -u root -p mysql
#重启数据库
systemctl restart mariadb.service
3、我们再看问题都解决了还是不能安装因为还有一个cacti报错看下图:
报错的意思是:错误:您的Web服务器没有设置PHP时区设置。请编辑PHP。然后取消对日期的评论。在安装Cacti之前,根据PHP安装说明将其设置为Web服务器时区。
解决方法:
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
Alias /nagios "/usr/local/nagios/share"
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
9:设置网页访问密码
[root@bogon nagios-plugins-1.5]# htpasswd -c /usr/local/nagios/etc/htpasswd jack
New password: 321321
Re-type new password: 321321
Adding password for user jack
[root@bogon nagios-plugins-1.5]# cat /usr/local/nagios/etc/htpasswd
jack:$apr1$G40eVtso$JGHxlhg0dolYoeGWZ4pkA0
10:配置nagios一般在目录/usr/local/nagios/etc/下
[root@bogon ~] cd /usr/local/nagios/etc/
[root@bogon etc] ls
cgi.cfg htpasswd nagios.cfg objects resource.cfg
[root@bogon etc] cd objects/
[root@bogon objects] ls
commands.cfg localhost.cfg switch.cfg timeperiods.cfg
contacts.cfg printer.cfg templates.cfg windows.cfg
1.templates.cfi nagios
主要用于监控主机资源以及服务,在nagios配置中称为对象,
为了不必重复定义一些监控对象,Nagios引入了一个模板配置文件,
将一些共性的属性定义成模板,以便于多次引用。
contact_groups 联系组属性改成 ts 将在后面的contacts.cfg文件中定义
Nagios Core 4.0.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-15-2013
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 9 services.
Checked 2 hosts.
Checked 2 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 2 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
启动nagios
[root@localhost ~]# cd /usr/local/nagios/
[root@localhost nagios]# ls
bin etc libexec sbin share var
[root@localhost nagios]# cd bin/
[root@localhost bin]# ls
nagios nagiostats
[root@localhost bin]# ./nagios -d ../etc/nagios.cfg
systemctl start httpd.service
systemctl start mariadb.service
mysql_secure_installation
vi /var/www/html/index.php
2-进入数据库创建zabbix数据库,授予zabbix用户操作权限
mysql -u root -p
CREATE DATABASE zabbix character set utf8 collate utf8_bin;
GRANT all privileges ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'admin123';
flush privileges;
编辑index.php测试能否连接数据库,连接成功页面显示Success!!连接失败显示Fail!!