安装zabbix的方法 https://blog.51cto.com/lishiyan/2631080

第一页

第二页

第三页

第四页

mysql> 
mysql> 
mysql> alter user 'zabbix'@'%' identified with mysql_native_password by 'Root@123456';
Query OK, 0 rows affected (0.00 sec)

mysql> alter user 'zabbix'@'127.0.0.1' identified with mysql_native_password by 'Root@123456';
Query OK, 0 rows affected (0.00 sec)

mysql> alter user 'zabbix'@'localhost' identified with mysql_native_password by 'Root@123456';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select user,host,plugin,authentication_string from user;
+------------------+-----------+-----------------------+------------------------------------------------------------------------+
| user             | host      | plugin                | authentication_string                                                  |
+------------------+-----------+-----------------------+------------------------------------------------------------------------+
| repl             | %         | mysql_native_password | *286872C85B04AF686EFB0743834334D81AC2EE1E                              |
| zabbix           | %         | mysql_native_password | *286872C85B04AF686EFB0743834334D81AC2EE1E                              |
| zabbix           | 127.0.0.1 | mysql_native_password | *286872C85B04AF686EFB0743834334D81AC2EE1E                              |
| mysql.infoschema | localhost | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.session    | localhost | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.sys        | localhost | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| root             | localhost | caching_sha2_password | $A$005$u#!vi\u;dcciY`pw46.Z387Zv/c4XEcVmmoTAcmHv7GjffosP0j9r/lFE. |
| zabbix           | localhost | mysql_native_password | *286872C85B04AF686EFB0743834334D81AC2EE1E                              |
+------------------+-----------+-----------------------+------------------------------------------------------------------------+
8 rows in set (0.00 sec)


mysql> 

第五页

部署zabbix之后,在系统信息里提示以下错误
Incorrect default charset for Zabbix database: "utf8mb4" instead "UTF8".
故障原因:zabbix使用MySQL数据库时只支持utf8编码,使用utf8mb4编码虽然也没发现什么问题,但是说不定什么时候就发生了什么故障了,所以还是更改为utf8数据编码。
解决方法:
#备份数据库
mysqldump -uroot -p --databases zabbix > zabbix.sql

#开始直接想到的是直接更改数据库编码为utf8,登录数据库
mysql -uroot -p 
#查看数据库编码
MySQL [(none)]> show create database zabbix;
+----------+--------------------------------------------------------------------+
| Database | Create Database                                                    |
+----------+--------------------------------------------------------------------+
| zabbix   | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+--------------------------------------------------------------------+
1 row in set (0.001 sec)

#更改数据库编码为utf8mb4
MySQL [(none)]> alter database zabbix character set utf8;
Query OK, 1 row affected (0.005 sec)

MySQL [(none)]> show create database zabbix;
+----------+-----------------------------------------------------------------+
| Database | Create Database                                                 |
+----------+-----------------------------------------------------------------+
| zabbix   | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+-----------------------------------------------------------------+
1 row in set (0.002 sec)
刷新zabbix web页面,发现提示以下错误
Unsupported charset or collation for tables: acknowledges, actions, alerts, application_discovery, application_prototype, applications, auditlog, auditlog_details, autoreg_host, conditions, config, config_autoreg_tls, corr_condition_tag, corr_condition_tagpair, corr_condition_tagvalue, correlation, dashboard, dchecks, drules, dservices, event_tag, events, expressions, functions, globalmacro, graph_theme, graphs, graphs_items, group_discovery, group_prototype, history_log, history_str, history_text, host_discovery, host_inventory, host_tag, hostmacro, hosts, housekeeper, hstgrp, httpstep, httpstep_field, httptest, httptest_field, icon_map, icon_mapping, ids, images, interface, interface_snmp, item_condition, item_discovery, item_preproc, item_rtdata, items, lld_macro_path, lld_override, lld_override_condition, lld_override_operation, lld_override_ophistory, lld_override_opperiod, lld_override_optag, lld_override_optrends, maintenance_tag, maintenances, mappings, media, media_type, media_type_message, media_type_param, module, opcommand, opconditions, operations, opmessage, problem, problem_tag, profiles, proxy_autoreg_host, proxy_dhistory, proxy_history, regexps, screens, screens_items, scripts, services, services_times, sessions, slides, slideshows, sysmap_element_url, sysmap_shape, sysmap_url, sysmaps, sysmaps_elements, sysmaps_link_triggers, sysmaps_links, tag_filter, task_data, task_remote_command, task_remote_command_result, task_result, trigger_tag, triggers, users, usrgrp, valuemaps, widget, widget_field.
这个错误是由于之前创建的数据库编码是utf8mb4,直接更改为utf8的话会有个问题,旧的数据的编码并没有发生改变,所以无法识别出来
#解决方法,将导出的zabbix数据库的sql数据文件中的utf8mb4字符修改成utf8之后再导入到zabbix数据库中
cp zabbix.sql zabbix.sql.bak
sed -i 's/utf8mb4/utf8/g' zabbix.sql
注意以下utf8_0900_ai_ci需要仔细查询下,
 sed -i 's/utf8_0900_ai_ci/utf8_bin/g' zabbix.sql
 mysql> show create database zabbix;
+----------+---------------------------------------------------------------------------------------------------------------------+
| Database | Create Database                                                                                                     |
+----------+---------------------------------------------------------------------------------------------------------------------+
| zabbix   | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */ /*!80016 DEFAULT ENCRYPTION='N' */ |
+----------+---------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> 

#导入数据库
MySQL [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

sDatabase changed
MySQL [zabbix]> source zabbix.sql
.....................................

Query OK, 0 rows affected (0.001 sec)

Query OK, 0 rows affected (0.001 sec)
导入完成后再次刷新页面发现错误提示消失,故障解决。


第六页

最好重新创建库 ,因此上边通过修改之后,发现出现报错dbversion

这是之前的备份
cp zabbix.sql zabbix.sql.bak
sed -i 's/utf8mb4/utf8/g' zabbix.sql
注意以下utf8_0900_ai_ci需要仔细查询下,
 sed -i 's/utf8_0900_ai_ci/utf8_bin/g' zabbix.sql
 mysql> show create database zabbix;
 然后再点击下一步

Please create database manually, and set the configuration parameters for connection to this database. Press “Next step” button when done.
问题来源:连接mariadb的时候总是连接不上
解决方法:创建zabbix数据库的时候应该这样创建:create database zabbix character set utf8 collate utf8_bin;

CREATE DATABASE `zabbix`  DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
然后导入
create.sql
然后执行分区等操作。

第七页

第八页

第九页

第十页

登陆网页

http://10.10.10.203/zabbix
账号Admin 
密码zabbix

zabbix的配置文件

[root@zabbix-server1 ~]# egrep -v "^$|^#" /etc/zabbix/zabbix_server.conf 
SourceIP=10.10.10.205
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=10.10.10.201 
DBName=zabbix
DBUser=zabbix
DBPassword=Root@123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

[root@zabbix-server1 ~]# grep SourceIP /etc/zabbix/zabbix_server.conf
Option: SourceIP
#SourceIP=
SourceIP=10.10.10.205  #VIP地址

报错集锦

https://my.oschina.net/u/4847173/blog/4735064