Linux搭建zabbix-server

一、准备工作
我用的是CentOS 7.x 的系统
zabbix 3.4
database:MariaDB
首先关闭防火墙 不然会报错

systemctl stop firewalld

开机不自启

systemctl disable firewalld

关闭selinux:

临时:setenforce 0
永久:sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

这一步很重要

https://blog.51cto.com/bguncle/957315  查看你selinux状态

rpm安装zabiix的yum源
 

rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

安装zabbix

yum -y install zabbix-server-mysql zabbix-web-mysql
#zabbix-server-mysql @ server端连接MySQL的组件
#zabbix-web-mysql @ zabbix web与MySQL交互组件

安装MariaDB

yum -y install mariadb-server
设置开机自启 启用数据库
systemctl enable mariadb.service
systemctl start mariadb.service

初始化数据库

mysql_secure_installation

登陆mysql

mysql -uroot -p **
创建数据库 zabbix 编码格式是utf8
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
对数据库进行授权 设置用户及密码
MariaDB [(none)]> grant all on zabbix.* to zabbix@'localhost' identified by '123456';
MariaDB [(none)]> flush privileges;

导入表

zcat /usr/share/doc/zabbix-server-mysql-3.4.15/create.sql.gz | mysql -uzabbix -p123456 zabbix
备份配置文件
cp /etc/httpd/conf/httpd.conf //etc/httpd/conf/httpd.conf.bak

修改时区

vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai

解决中文乱码问题

方法一
yum -y install wqy-microhei-fonts
cp -f /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
如果事前忘了设置 还有一个办法解决
方法二
windows c盘里面有一个windows的目录进去/找到Fonts/进去找到任意一种中文字体复制出来上传到/usr/share/zabbix/fonts目录下
修改文件名 
\mv xxxx.ttf xxxx.ttf

启动apache

systemctl enable httpd
systemctl start httpd
使用浏览器访问 //server IP /zabbix

登陆完成后进入首页界面

默认server 还没有运行

 配置 zabbix-server

 vim /etc/zabbix/zabbix_server.conf 

 修改 DBPassword=123456

 systemctl enable zabbix-server

 systemctl start zabbix-server

启动就可以看到了

服务端安装zabbix-get检测工具

yum install zabbix-get

注意:只能在服务端进行测试

#下面是配置过的节点

zabbix_get -s 192.168.226.148 -p 10050 -k "system.cpu.load[all,avg1]"
zabbix_get -s 192.168.226.141 -p 10050 -k "system.cpu.load[all,avg1]"

返回了

[root@bogon ~]# zabbix_get -s 192.168.226.148 -p 10050 -k "system.cpu.load[all,avg1]"
0.030000
发布了143 篇原创文章 · 获赞 255 · 访问量 18万+

猜你喜欢

转载自blog.csdn.net/jiulanhao/article/details/103714009