Zabbix Server 6.5の構築メモ

# はじめに
Google Cloud上にZabbixを構築する手順です
元々Zabbix 4.2(GCE+CloudSQL)を構築しており、そちらを移行しました
※DBの移行はまた別途記事を書きます

# 構築
## GCEのデプロイ
Ubuntu 20.04 LTS Minimal
デプロイは割愛
内部IPだけ静的IPを振ります

## Zabbix Serverを作る
### 設定
初期設定
```
# パッケージの最新化
$ sudo apt-get update
$ sudo apt-get upgrade

# ロケールを日本に変更
$ sudo apt-get install locales locales-all
$ sudo localedef -f UTF-8 -i ja_JP ja_JP

# タイムゾーンを日本に変更
$ sudo timedatectl set-timezone Asia/Tokyo
```

パッケージのインストール
```
# apache
$ sudo apt install apache2

# php
$ sudo apt install php php-cgi libapache2-mod-php php-common php-pear php-mbstring

# jq
$ sudo apt install -y jq

# vim
$ sudo apt install -y vim

# zabbix
$ wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
$ sudo dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
$ sudo apt update

$ sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent zabbix-sender zabbix-get
```

PHPの設定
```
$ sudo vi /etc/php/7.4/apache2/php.ini
```

```/etc/php/7.4/apache2/php.ini
# ~ 省略
# 962行目：コメント解除しタイムゾーン設定
date.timezone = "Asia/Tokyo"

# ～ 省略
# 1621行目：コメントを解除するだけ
mbstring.language = Japanese
```

PHPのテストページ作成
```
$ sudo vi /var/www/html/index.php
```

```/var/www/html/index.php
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
<?php
print "PHP Test Page";
?>
</div>
</body>
</html>
```

apache2再起動
```
$ sudo systemctl restart apache2
$ sudo systemctl status apache2
```

PHPページの確認	http://外部IPアドレス/index.php

### Zabbix Serverの設定
```
$ sudo vi /etc/zabbix/zabbix_server.conf 
```

```/etc/zabbix/zabbix_server.conf
DBHost=Cloud SQLのプライベートIPアドレス
DBName=zabbix
DBUser=zabbix
DBPassword=各DBパスワード
～他は各々の環境に合わせる～
```

### DB関連
rootアカウントでDBに接続する
```
$ mysql --host=IPアドレス --user=root --password
```

Zabbixユーザ作る
```
> CREATE USER zabbix@localhost IDENTIFIED BY 'パスワード';
> CREATE USER zabbix@'%' IDENTIFIED BY 'パスワード';
> GRANT ALL ON zabbix.* TO zabbix@localhost;
> GRANT ALL ON zabbix.* TO zabbix@'%';
> flush privileges;
```

文字コード変換
※zabbix4.2のDBを再活用するのでやります。通常は要らないはず
```
ALTER TABLE zabbix.acknowledges CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.actions CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.alerts CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.application_discovery CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.application_prototype CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.application_template CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.applications CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.auditlog CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.auditlog_details CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.autoreg_host CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.conditions CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.config CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.config_autoreg_tls CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.corr_condition CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.corr_condition_group CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.corr_condition_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.corr_condition_tagpair CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.corr_condition_tagvalue CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.corr_operation CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.correlation CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.dashboard CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.dashboard_user CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.dashboard_usrgrp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.dbversion CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.dchecks CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.dhosts CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.drules CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.dservices CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.escalations CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.event_recovery CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.event_suppress CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.event_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.events CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.expressions CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.functions CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.globalmacro CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.globalvars CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.graph_discovery CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.graph_theme CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.graphs CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.graphs_items CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.group_discovery CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.group_prototype CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.history CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.history_log CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.history_str CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
```
```
ALTER TABLE zabbix.history_text CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.history_uint CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.host_discovery CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.host_inventory CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.host_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.hostmacro CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.hosts CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.hosts_groups CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.hosts_templates CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.housekeeper CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.hstgrp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.httpstep CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.httpstep_field CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.httpstepitem CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.httptest CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.httptest_field CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.httptestitem CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.icon_map CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.icon_mapping CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.ids CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.images CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.interface CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.interface_discovery CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.item_application_prototype CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.item_condition CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.item_discovery CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.item_preproc CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.item_rtdata CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.items CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.items_applications CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.lld_macro_path CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.maintenance_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.maintenances CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.maintenances_groups CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.maintenances_hosts CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.maintenances_windows CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.mappings CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.media CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.media_type CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.media_type_param CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.opcommand CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.opcommand_grp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.opcommand_hst CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.opconditions CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.operations CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.opgroup CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.opinventory CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.opmessage CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.opmessage_grp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.opmessage_usr CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.optemplate CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.problem CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.problem_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.profiles CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.proxy_autoreg_host CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.proxy_dhistory CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.proxy_history CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.regexps CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.rights CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.screen_user CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.screen_usrgrp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.screens CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.screens_items CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.scripts CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.service_alarms CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.services CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.services_links CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.services_times CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sessions CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.slides CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.slideshow_user CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.slideshow_usrgrp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.slideshows CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmap_element_trigger CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmap_element_url CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmap_shape CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmap_url CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmap_user CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmap_usrgrp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmaps CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmaps_elements CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmaps_link_triggers CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmaps_links CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.tag_filter CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.task CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.task_acknowledge CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.task_check_now CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.task_close_problem CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.task_remote_command CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.task_remote_command_result CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.timeperiods CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.trends CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.trends_uint CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.trigger_depends CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.trigger_discovery CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.trigger_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.triggers CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.users CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.users_groups CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.usrgrp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.valuemaps CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.widget CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.widget_field CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
```
```
ALTER TABLE zabbix.dashboard_page CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.ha_node CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.httptest_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.interface_snmp CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.item_parameter CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.item_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.lld_override CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.lld_override_condition CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.lld_override_operation CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.lld_override_ophistory CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.lld_override_opperiod CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.lld_override_optag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.lld_override_optrends CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.media_type_message CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.module CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.report CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.report_param CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.role CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.role_rule CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.script_param CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.service_problem_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.service_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sla CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sla_excluded_downtime CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sla_service_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.sysmaps_element_tag CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.task_data CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.task_result CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.token CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.valuemap CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE zabbix.valuemap_mapping CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
```

zabbix serverを起動する
```
$ sudo systemctl restart zabbix-server
```

### GUI初期設定
`http://外部IPアドレス/zabbix/index.php` にアクセス

各項目設定する

Zabbix管理コンソールにログイン(初期はAdmin/zabbixだけど、DB移行しているので作成済のユーザでログインできるはず)

色々確認する

# 新旧Zabbix Serverの切り替え
会社がけちんぼでDNS用意してくれてなかったので既存GCEの静的外部IPを剥奪します

新旧Zabbix Serverを停止します。

旧GCEを編集状態にし、外部IPを静的→エフェメタルに変更します。

新GCEを編集状態にし、外部IPをエフェメタル→静的にします。旧GCEの静的IPを付与します。

新GCEを起動します。

Zabbix管理コンソールにログインします。

Agentから情報収集ができていることを確認します。

# primary keys 関連のエラー

こちらのURLの
MariaDB/MySQL 8.0+ without mysqlsh　を実施
https://www.zabbix.com/documentation/current/en/manual/appendix/install/db_primary_keys

# 文字コード関連のエラー
Cloud SQLのDatabase Flagを変更してあげないとダメだった
https://cloud.google.com/sql/docs/mysql/flags?hl=ja#mysql-c
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/47012/85a8e0f4-9956-3453-9208-a4d68870e97a.png)