====== Azure VM (Ubuntu)にZabbixをインストールする ====== ===== Zabbixリポジトリのインストール ===== wgetでリポジトリを取得する。 # wget https://repo.zabbix.com/zabbix/5.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.4-1+ubuntu20.04_all.deb --2022-02-07 06:10:51-- https://repo.zabbix.com/zabbix/5.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.4-1+ubuntu20.04_all.deb Resolving repo.zabbix.com (repo.zabbix.com)... 178.128.6.101, 2604:a880:2:d0::2062:d001 Connecting to repo.zabbix.com (repo.zabbix.com)|178.128.6.101|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 3468 (3.4K) [application/octet-stream] Saving to: ‘zabbix-release_5.4-1+ubuntu20.04_all.deb’ zabbix-release_5.4-1+ubuntu20.04_all.deb 100%[================================================================================>] 3.39K --.-KB/s in 0s 2022-02-07 06:10:52 (115 MB/s) - ‘zabbix-release_5.4-1+ubuntu20.04_all.deb’ saved [3468/3468] # ls zabbix-release_5.4-1+ubuntu20.04_all.deb # dpkg -i zabbix-release_5.4-1+ubuntu20.04_all.deb Selecting previously unselected package zabbix-release. (Reading database ... 59863 files and directories currently installed.) Preparing to unpack zabbix-release_5.4-1+ubuntu20.04_all.deb ... Unpacking zabbix-release (1:5.4-1+ubuntu20.04) ... Setting up zabbix-release (1:5.4-1+ubuntu20.04) ... root@ubuntu-muranko-1:~# apt update Hit:1 http://azure.archive.ubuntu.com/ubuntu focal InRelease Get:2 http://azure.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Get:3 http://azure.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB] Get:4 http://azure.archive.ubuntu.com/ubuntu focal/universe amd64 Packages [8628 kB] Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Get:6 https://repo.zabbix.com/zabbix/5.4/ubuntu focal InRelease [4958 B] Get:7 http://azure.archive.ubuntu.com/ubuntu focal/universe Translation-en [5124 kB] Get:8 http://azure.archive.ubuntu.com/ubuntu focal/universe amd64 c-n-f Metadata [265 kB] Get:9 http://azure.archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [144 kB] Get:10 http://azure.archive.ubuntu.com/ubuntu focal/multiverse Translation-en [104 kB] Get:11 http://azure.archive.ubuntu.com/ubuntu focal/multiverse amd64 c-n-f Metadata [9136 B] Get:12 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1550 kB] Get:13 http://azure.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [300 kB] Get:14 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [14.7 kB] Get:15 http://azure.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [789 kB] Get:16 http://azure.archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [112 kB] Get:17 http://azure.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 c-n-f Metadata [500 B] Get:18 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [896 kB] Get:19 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [197 kB] Get:20 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [20.0 kB] Get:21 http://azure.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [23.8 kB] Get:22 http://azure.archive.ubuntu.com/ubuntu focal-updates/multiverse Translation-en [7312 B] Get:23 http://azure.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 c-n-f Metadata [580 B] Get:24 http://azure.archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [42.0 kB] Get:25 http://azure.archive.ubuntu.com/ubuntu focal-backports/main Translation-en [10.0 kB] Get:26 http://azure.archive.ubuntu.com/ubuntu focal-backports/main amd64 c-n-f Metadata [864 B] Get:27 http://azure.archive.ubuntu.com/ubuntu focal-backports/restricted amd64 c-n-f Metadata [116 B] Get:28 http://azure.archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [20.8 kB] Get:29 http://azure.archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [14.3 kB] Get:30 http://azure.archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [692 B] Get:31 http://azure.archive.ubuntu.com/ubuntu focal-backports/multiverse amd64 c-n-f Metadata [116 B] Get:32 https://repo.zabbix.com/zabbix/5.4/ubuntu focal/main Sources [1234 B] Get:33 https://repo.zabbix.com/zabbix/5.4/ubuntu focal/main amd64 Packages [3555 B] Get:34 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [1214 kB] Get:35 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [214 kB] Get:36 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [9136 B] Get:37 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [737 kB] Get:38 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [105 kB] Get:39 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 c-n-f Metadata [504 B] Get:40 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [676 kB] Get:41 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [115 kB] Get:42 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [13.0 kB] Get:43 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [20.7 kB] Get:44 http://security.ubuntu.com/ubuntu focal-security/multiverse Translation-en [5196 B] Get:45 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [500 B] Fetched 21.7 MB in 4s (5466 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 10 packages can be upgraded. Run 'apt list --upgradable' to see them. Zabbixサーバ、フロントエンド、エージェントのインストール # apt install zabbix-server-pgsql zabbix-frontend-php php7.4-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: fontconfig-config fonts-dejavu fonts-dejavu-core fonts-dejavu-extra fping libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libmysqlclient21 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libodbc1 libonig5 libopenipmi0 libpq5 libsensors-config libsensors5 libsnmp-base libsnmp35 libtiff5 libwebp6 libxpm4 mysql-common nginx nginx-common nginx-core php-bcmath php-common php-fpm php-gd php-ldap php-mbstring php-xml php7.4-bcmath php7.4-cli php7.4-common php7.4-fpm php7.4-gd php7.4-json php7.4-ldap php7.4-mbstring php7.4-opcache php7.4-readline php7.4-xml snmpd Suggested packages: libgd-tools libmyodbc odbc-postgresql tdsodbc unixodbc-bin lm-sensors snmp-mibs-downloader fcgiwrap nginx-doc ssl-cert php-pear snmptrapd zabbix-apache-conf postgresql-client postgresql The following NEW packages will be installed: fontconfig-config fonts-dejavu fonts-dejavu-core fonts-dejavu-extra fping libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libmysqlclient21 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libodbc1 libonig5 libopenipmi0 libpq5 libsensors-config libsensors5 libsnmp-base libsnmp35 libtiff5 libwebp6 libxpm4 mysql-common nginx nginx-common nginx-core php-bcmath php-common php-fpm php-gd php-ldap php-mbstring php-xml php7.4-bcmath php7.4-cli php7.4-common php7.4-fpm php7.4-gd php7.4-json php7.4-ldap php7.4-mbstring php7.4-opcache php7.4-pgsql php7.4-readline php7.4-xml snmpd zabbix-agent zabbix-frontend-php zabbix-nginx-conf zabbix-server-pgsql zabbix-sql-scripts 0 upgraded, 55 newly installed, 0 to remove and 10 not upgraded. Need to get 21.2 MB of archives. After this operation, 82.9 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 mysql-common all 5.8+1.0.5ubuntu2 [7496 B] Get:2 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 libmysqlclient21 amd64 8.0.28-0ubuntu0.20.04.3 [1292 kB] Get:3 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 libsensors-config all 1:3.6.0-2ubuntu1 [6092 B]                             :                             : Setting up php-gd (2:7.4+75) ... Setting up nginx-core (1.18.0-0ubuntu1.2) ... Setting up nginx (1.18.0-0ubuntu1.2) ... Setting up zabbix-nginx-conf (1:5.4.10-1+ubuntu20.04) ... Processing triggers for ufw (0.36-6ubuntu1) ... Processing triggers for systemd (245.4-4ubuntu3.15) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for libc-bin (2.31-0ubuntu9.2) ... Processing triggers for php7.4-cli (7.4.3-4ubuntu2.8) ... Processing triggers for php7.4-fpm (7.4.3-4ubuntu2.8) ... ===== PostgreSQLのインストール ===== PostgreSQLのインストールを行う。 # sudo apt install postgresql postgresql-contrib : # psql --version psql (PostgreSQL) 12.9 (Ubuntu 12.9-0ubuntu0.20.04.1) ===== PostgreSQLのユーザ作成 ===== sudo -u postgres createuser --pwprompt zabbix Enter password for new role: Enter it again: ↑DBユーザのパスワード入力 ===== PostgreSQLのZabbix用DB作成 ===== sudo -u postgres createdb -O zabbix zabbix ===== PostgreSQLのZabbix用DBデータインポート ===== 初期スキーマとデータをインポートします。新しく作成したパスワードを入力するよう促されます。 # zcat /usr/share/doc/zabbix-sql-scripts/postgresql/create.sql.gz | sudo -u zabbix psql zabbix ===== Zabbixの設定にDBパスワード設定 ===== ファイル /etc/zabbix/zabbix_server.conf を編集します。 DBHost=localhost DBPassword=password DBPort=5432 ===== nginxの設定に変更 ===== /etc/zabbix/nginx.conf ファイルを編集し、listen ディレクティブと server_name ディレクティブのコメントを外します。 # listen 80; # server_name example.com; ===== Zabbixとエージェントの起動 ===== # systemctl restart zabbix-server zabbix-agent nginx php7.4-fpm # systemctl enable zabbix-server zabbix-agent nginx php7.4-fpm ===== ZabbixサーバのIPにブラウザでアクセス ===== {{:zabbix1.png?600|}} \\ あれ、nginxのデフォルト画面が出た・・・ nginxはHTTPヘッダのHostヘッダをみてどの設定ファイルで動作するかを振り分けるため、IPアドレスだとdefaultに飛ばされるので、設定ファイルにdefault_serverを追加してZabbixをデフォルトにしてみる。 /etc/nginx/conf.d/zabbix.conf server { listen 80 default_server; server_name example.com; } /etc/nginx/sites-available/default のdefault_serverは削除した。 server { listen 80; listen [::]:80; nginxをリスタートしてどうなるか・・・ # systemctl restart nginx Zabbixの画面が表示された。 {{:zabbix2.png?600|}} ===== 日本語化 ===== {{:zabbix3.png?600|}} いきなり日本語が選べない。 localeを見てみると日本語がない。 # locale -a C C.UTF-8 POSIX en_US.utf8 以下のコマンドでUbuntuに日本語を追加する。 # apt-get install task-japanese # dpkg-reconfigure locales {{:zabbix4.png?600|}} スクロールし、スペースで日本語(UTF-8)をチェックし、TABキーでOKに移動、エンターで決定。 デフォルトも日本語にした。 タイムゾーンも変更しておく。 # timedatectl set-timezone Asia/Tokyo いろいろリスタートする。 # systemctl restart zabbix-server zabbix-agent nginx php7.4-fpm 日本語が選べるようになった。\\ {{:zabbix5.png?600|}} DBのパスワードを入れて、インストール完了。(サーバのIPはlocalhostのまま次へ) ログイン画面のデフォルトID、パスワードはAdmin、zabbix {{:zabbix6.png?600|}} ===== グラフが文字化けしているので改善 ===== {{:zabbix7.png?600|}} \\ グラフを表示してみると、凡例の文字が豆腐に化けているので日本語フォントを追加する。 # sudo apt-get install -y fonts-vlgothic # sudo ln -s /usr/share/fonts/truetype/vlgothic/VL-PGothic-Regular.ttf /usr/share/zabbix/assets/fonts/VL-PGothic-Regular.ttf # sudo vim /usr/share/zabbix/include/defines.inc.php ↓下記の行を追記・変更(39行目) define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name ↓ //define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name define('ZBX_GRAPH_FONT_NAME', 'VL-PGothic-Regular'); いろいろリスタートする。 # systemctl restart zabbix-server zabbix-agent nginx php7.4-fpm {{:zabbix8.png?600|}} \\ フォントが表示された。