置顶 2018年01月27日 12:57:23 友人a笔记 阅读数:380 标签: zabbix 更多php
我的分类: 监控前端
版权声明:本文为博主原创文章,未经博主容许不得转载。 https://blog.csdn.net/tladagio/article/details/79056421node
[root@ecs-5c78-0001 ~]# cat /etc/redhat-release
mysql
CentOS Linux release 7.3.1611 (Core)
linux
为了方便测试,中止而且开机不启动防火墙,生产环境根据须要进行调整web
[root@ecs-5c78-0001 ~]# systemctl stop firewalld.service
sql
[root@ecs-5c78-0001 ~]# systemctl disable firewalld.service
数据库
关闭selinuxvim
[root@ecs-5c78-0001 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
centos
[root@ecs-5c78-0001 ~]# grep SELINUX=disabled /etc/selinux/config
SELINUX=disabled
[root@ecs-5c78-0001 ~]# setenforce 0
setenforce: SELinux is disabled
一、安装以前检查系统中是否存在使用rpm安装的MySQL或者MariaDB
[root@ecs-5c78-0001 ~]# rpm -qa | grep mysql [root@ecs-5c78-0001 ~]# rpm -qa | grep mariadb mariadb-libs-5.5.52-1.el7.x86_64
二、若是须要卸载,执行命令:rpm -e 软件名,执行失败的时候可使用:rpm -e --nodeps 软件名强制卸载,卸载以后再使用
rpm -qa | grep mysql 或者rpm -qa | grep mariadb查看结果。
[root@ecs-5c78-0001 ~]# rpm -e mariadb-libs-5.5.52-1.el7.x86_64 error: Failed dependencies: libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64 libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64 [root@ecs-5c78-0001 ~]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
安装mariadb
[root@ecs-5c78-0001 ~]# yum install mariadb-server mariadb –y
启动数据库并设置为开机启动
[root@ecs-5c78-0001 ~]# systemctl start mariadb
[root@ecs-5c78-0001 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
#数据库其余操做命令
[root@ecs-5c78-0001 ~]# systemctl restart mariadb #重启
[root@ecs-5c78-0001 ~]# systemctl stop mariadb #中止
一、安装zabbix(这里的http://连接注意会更新,能够直接打开网站查询最新的RPM包连接,而后使用rpm -ivh安装便可)
[root@ecs-5c78-0001 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
Retrieving http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
Preparing... ################################# [100%]
Updating / installing... 1:zabbix-release-3.4-1.el7.centos ################################# [100%]
[root@ecs-5c78-0001 ~]# yum install zabbix-server-mysql zabbix-web-mysql -y
二、建立数据库
[root@ecs-5c78-0001 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
三、导入数据库(这里的zabbix-mysql-3.4.5注意版本号会更新)
[root@ecs-5c78-0001 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.5/create.sql.gz |mysql -uzabbix -pzabbix zabbix
四、配置数据库用户及密码
[root@ecs-5c78-0001 ~]# vim /etc/zabbix/zabbix_server.conf
五、修改以下配置
DBName=zabbix
DBUser=zabbix
#DBPassword= 改成》》DBPassword=zabbix
保存退出:wq
六、启动zabbix server 并设置开机启动
[root@ecs-5c78-0001 ~]# systemctl start zabbix-server.service [root@ecs-5c78-0001 ~]# systemctl enable zabbix-server.service Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
七、编辑zabbix前端PHP配置,更改时区
[root@ecs-5c78-0001 ~]# vim /etc/httpd/conf.d/zabbix.conf
# php_value date.timezone Europe/Riga 改成》》 php_value date.timezone Asia/Shanghai
保存退出:wq
更改成以下
八、Selinux配置
[root@ecs-5c78-0001 ~]# setsebool -P httpd_can_connect_zabbix on
setsebool: SELinux is disabled.
[root@ecs-5c78-0001 ~]# setsebool -P httpd_can_cetwork_connect_db on
setsebool: SELinux is disabled.
九、启动httpd而且设置开机启动
[root@ecs-5c78-0001 ~]# systemctl start httpd [root@ecs-5c78-0001 ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
1.浏览器登陆本机IP:http://192.168.2.216/zabbix/
2.点击:Next step
3.点击:Next step
4.点击:Next step
5.确认输入信息,点击Next step
6.点击Finish,生成配置文件在:/etc/zabbix/web/zabbix.conf.php
查看配置文件:
cat /etc/zabbix/web/zabbix.conf.php
登陆Zabbix3.4,默认用户名:Admin 默认密码:zabbix
登陆页面
更换为中文
Zabbix服务器端安装完成!
安装zabbix-agent
[root@ecs-5c78-0002 ~]# rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarh.rpm Retrieving https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm Preparing... ################################# [100%] Updating / installing... 1:zabbix-release-3.4-1.el7.centos ################################# [100%] [root@ecs-5c78-0002 ~]# yum install zabbix-agent –y
或者使用官网提供的连接,而后rpm -ivh进行安装:rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.0-1.el7.x86_64.rpm
配置zabbix-agent
[root@ecs-5c78-0002 ~]# vim /etc/zabbix/zabbix_agentd.conf
修改server IP地址
修改成zabbix-server服务端的IP地址
修改ServerActive IP地址
修改成zabbix-server服务器端的IP地址
启动zabbix-agent并设置开机启动
[root@ecs-5c78-0002 ~]# systemctl start zabbix-agent.service [root@ecs-5c78-0002 ~]# systemctl enable zabbix-agent.service Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
手动添加监控主机
指定zabbix-agent机器IP
增长监控模板,只有添加了模板才会真正监控到主机
添加图形,以便观察数据
监控成功(客户端要关闭防火墙或者放通端口,要不ZBX图标会红色报错)
自动发现主机
添加发现规则
查看自动发现的主机
到此,zabbix简单监控就部署好了。
首先本人是一片空白的进行zabbix搭建工做,其实搭建这个以前我搭建过zabbix 2.4,我感受以前的那个太老了,而后就又推到了从新干了一遍,感受收获满满。其实最重要的仍是要多折腾,折腾多...