nJcx's Blog

生而不忧,死而不怖。得其时横刀天下,不得其时蓬头而行。

zabbix实践笔记


介绍

安装

版本:centos7.3,zabbix-4.0

sudo tee -a /etc/yum.repos.d/zabbix.repo >> EOF
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX
EOF

这里没有用zabbix官网的源,不知道是不是挂了,一直time out,所以我把baseurl 改为阿里源的。

yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y

这里会报错

Requires: libiksemel.so.3()(64bit)

# wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/aevseev/CentOS_CentOS-6/x86_64/iksemel-1.4-20.1.x86_64.rpm
# yum install iksemel-1.4-20.1.x86_64.rpm
yum install mariadb-server -y

配置

首先启动MariaDB

systemctl start mariadb

设置开机启动

systemctl enable mariadb

接下来进行MariaDB的相关简单配置

mysql_secure_installation

首先是设置密码,会提示先输入密码 配置MariaDB的字符集

vim /etc/my.cnf

[mysqld]
init_connect='SET collation_connection = utf8_general_ci' 
init_connect='SET NAMES utf8' 
character-set-server=utf8 
collation-server=utf8_general_ci 
skip-character-set-client-handshake

vim /etc/my.cnf.d/client.cnf 在[client]中添加

default-character-set=utf8

vim /etc/my.cnf.d/mysql-clients.cnf 在[mysql]中添加

default-character-set=utf8

全部配置完成,重启mariadb

systemctl restart mariadb

之后进入MariaDB查看字符集

mysql> show variables like "%character%";show variables like "%collation%";
mysql> create database zabbix;
mysql> grant all privileges on zabbix.* to njcx@localhost identified by 'qwaszxerdfcv';
mysql> quit;
 zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -unjcx -p zabbix

启动 zabbix_server 报错

29225:20180714:084923.611 cannot start preprocessing service: Cannot bind socket to "/var/run/zabbix/zabbix_server_preprocessing.sock": [13] Permission denied.

关闭selinux 即可, 先临时关闭,setenforce 0

vim /etc/selinux/config

SELINUX=disabled

永久关闭

# vim /etc/php.ini
date.timezone = Asia/Shanghai
systemctl restart zabbix-server zabbix-agent mariadb  httpd
systemctl enable zabbix-server zabbix-agent mariadb  httpd

访问 http://192.168.1.110/zabbix/ 就OK,配置一下,默认用户密码 Admin/zabbix