このページの2つのバージョン間の差分を表示します。
次のリビジョン | 前のリビジョン | ||
azurevmのubuntuにzabbixをインストール [2022/02/07 15:11] muranko 作成 |
azurevmのubuntuにzabbixをインストール [2022/02/07 18:10] (現在) muranko [グラフが文字化けしているので改善] |
||
---|---|---|---|
行 1: | 行 1: | ||
====== Azure VM (Ubuntu)にZabbixをインストールする ====== | ====== Azure VM (Ubuntu)にZabbixをインストールする ====== | ||
+ | |||
+ | ===== Zabbixリポジトリのインストール ===== | ||
+ | wgetでリポジトリを取得する。 | ||
+ | < | ||
+ | # wget https:// | ||
+ | --2022-02-07 06: | ||
+ | Resolving repo.zabbix.com (repo.zabbix.com)... 178.128.6.101, | ||
+ | Connecting to repo.zabbix.com (repo.zabbix.com)|178.128.6.101|: | ||
+ | HTTP request sent, awaiting response... 200 OK | ||
+ | Length: 3468 (3.4K) [application/ | ||
+ | Saving to: ‘zabbix-release_5.4-1+ubuntu20.04_all.deb’ | ||
+ | |||
+ | zabbix-release_5.4-1+ubuntu20.04_all.deb 100%[================================================================================> | ||
+ | |||
+ | 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: | ||
+ | Setting up zabbix-release (1: | ||
+ | |||
+ | root@ubuntu-muranko-1: | ||
+ | Hit:1 http:// | ||
+ | Get:2 http:// | ||
+ | Get:3 http:// | ||
+ | Get:4 http:// | ||
+ | Get:5 http:// | ||
+ | Get:6 https:// | ||
+ | Get:7 http:// | ||
+ | Get:8 http:// | ||
+ | Get:9 http:// | ||
+ | Get:10 http:// | ||
+ | Get:11 http:// | ||
+ | Get:12 http:// | ||
+ | Get:13 http:// | ||
+ | Get:14 http:// | ||
+ | Get:15 http:// | ||
+ | Get:16 http:// | ||
+ | Get:17 http:// | ||
+ | Get:18 http:// | ||
+ | Get:19 http:// | ||
+ | Get:20 http:// | ||
+ | Get:21 http:// | ||
+ | Get:22 http:// | ||
+ | Get:23 http:// | ||
+ | Get:24 http:// | ||
+ | Get:25 http:// | ||
+ | Get:26 http:// | ||
+ | Get:27 http:// | ||
+ | Get:28 http:// | ||
+ | Get:29 http:// | ||
+ | Get:30 http:// | ||
+ | Get:31 http:// | ||
+ | Get:32 https:// | ||
+ | Get:33 https:// | ||
+ | Get:34 http:// | ||
+ | Get:35 http:// | ||
+ | Get:36 http:// | ||
+ | Get:37 http:// | ||
+ | Get:38 http:// | ||
+ | Get:39 http:// | ||
+ | Get:40 http:// | ||
+ | Get:41 http:// | ||
+ | Get:42 http:// | ||
+ | Get:43 http:// | ||
+ | Get:44 http:// | ||
+ | Get:45 http:// | ||
+ | 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' | ||
+ | |||
+ | </ | ||
+ | |||
+ | 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:// | ||
+ | Get:2 http:// | ||
+ | Get:3 http:// | ||
+ | : | ||
+ | : | ||
+ | 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: | ||
+ | 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 / | ||
+ | </ | ||
+ | |||
+ | ===== Zabbixの設定にDBパスワード設定 ===== | ||
+ | ファイル / | ||
+ | < | ||
+ | DBHost=localhost | ||
+ | |||
+ | DBPassword=password | ||
+ | DBPort=5432 | ||
+ | </ | ||
+ | |||
+ | ===== nginxの設定に変更 ===== | ||
+ | / | ||
+ | < | ||
+ | # 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にブラウザでアクセス ===== | ||
+ | {{: | ||
+ | あれ、nginxのデフォルト画面が出た・・・ | ||
+ | |||
+ | |||
+ | nginxはHTTPヘッダのHostヘッダをみてどの設定ファイルで動作するかを振り分けるため、IPアドレスだとdefaultに飛ばされるので、設定ファイルにdefault_serverを追加してZabbixをデフォルトにしてみる。 | ||
+ | / | ||
+ | < | ||
+ | server { | ||
+ | listen | ||
+ | server_name | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | / | ||
+ | < | ||
+ | server { | ||
+ | listen 80; | ||
+ | listen [::]:80; | ||
+ | </ | ||
+ | |||
+ | nginxをリスタートしてどうなるか・・・ | ||
+ | < | ||
+ | # systemctl restart nginx | ||
+ | </ | ||
+ | |||
+ | Zabbixの画面が表示された。 | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===== 日本語化 ===== | ||
+ | |||
+ | {{: | ||
+ | |||
+ | いきなり日本語が選べない。 | ||
+ | |||
+ | localeを見てみると日本語がない。 | ||
+ | < | ||
+ | # locale -a | ||
+ | C | ||
+ | C.UTF-8 | ||
+ | POSIX | ||
+ | en_US.utf8 | ||
+ | </ | ||
+ | |||
+ | 以下のコマンドでUbuntuに日本語を追加する。 | ||
+ | |||
+ | < | ||
+ | # apt-get install task-japanese | ||
+ | # dpkg-reconfigure locales | ||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | スクロールし、スペースで日本語(UTF-8)をチェックし、TABキーでOKに移動、エンターで決定。 | ||
+ | デフォルトも日本語にした。 | ||
+ | |||
+ | タイムゾーンも変更しておく。 | ||
+ | < | ||
+ | # timedatectl set-timezone Asia/Tokyo | ||
+ | </ | ||
+ | |||
+ | いろいろリスタートする。 | ||
+ | < | ||
+ | # systemctl restart zabbix-server zabbix-agent nginx php7.4-fpm | ||
+ | |||
+ | </ | ||
+ | |||
+ | 日本語が選べるようになった。\\ | ||
+ | {{: | ||
+ | |||
+ | |||
+ | DBのパスワードを入れて、インストール完了。(サーバのIPはlocalhostのまま次へ) | ||
+ | |||
+ | ログイン画面のデフォルトID、パスワードはAdmin、zabbix | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===== グラフが文字化けしているので改善 ===== | ||
+ | |||
+ | {{: | ||
+ | グラフを表示してみると、凡例の文字が豆腐に化けているので日本語フォントを追加する。 | ||
+ | |||
+ | < | ||
+ | # sudo apt-get install -y fonts-vlgothic | ||
+ | # sudo ln -s / | ||
+ | # sudo vim / | ||
+ | ↓下記の行を追記・変更(39行目) | ||
+ | define(' | ||
+ | ↓ | ||
+ | // | ||
+ | define(' | ||
+ | </ | ||
+ | |||
+ | いろいろリスタートする。 | ||
+ | < | ||
+ | # systemctl restart zabbix-server zabbix-agent nginx php7.4-fpm | ||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | フォントが表示された。 | ||
+ | |||