LoginSignup
0
1

More than 1 year has passed since last update.

DockerのコンテナにHinemosマネージャを入れて動かしてみる

Last updated at Posted at 2022-05-08

背景・目的・読み手

 ちょっと Hinemos を使った監視環境を構築することになったので素振りしてみた。Docker のコンテナにマネージャ入れてみようと思いたち試してみたものの結構苦労したので、試行錯誤の記録を整理して残して置くことにした。
 基本的に自分用メモ。

Docker Desktopのインストール

 Docker Desktopを作業用PCにインストールします。
Windows10 に Docker Desktop をインストールして遊ぶ - Qiita

Hinemos マネージャ用 CentOSコンテナの作成

CentOS コンテナの作成

 Hinemosの動作環境を見るに、CentOSが手頃なため、今回はこれで試してみる。そのためそのコンテナを作りマネージャを導入していく。

 CentOSイメージからコンテナを作成。イメージがなければ、PowerShellでdocker pull centosする。なお、コンテナをいい加減に作ると Hinemosマネジャーを起動させるための systemctl コマンドが動作しないなど、終盤でハマります。
 runコマンドのオプションのポイントは次の通り

  • —privileged をつける
  • /sbin/init で起動
  • 上記に合わせ、-itではなく-dで起動。その後にexecする
  • Webクライアント用にポートを開けておく
イメージ作成コマンド例
docker run -d --privileged --name hinemos_manager -p 80:80 -v ~/share_folder:/var/share_folder:rw centos:latest /sbin/init
docker exec -it hinemos_manager /bin/bash

 上記コマンドを実行するとそのままPowerShellのプロンプトでコンテナの操作ができるようになるため、引き続き初期設定をしていく。

初期設定
OS確認
# cat /etc/redhat-release
CentOS Linux release 8.4.2105

TimeZoneをAsia/Tokyoにしておく
# timedatectl set-timezone Asia/Tokyo
# timedatectl status
               Local time: Sun 2022-05-08 00:53:20 JST
           Universal time: Sat 2022-05-07 15:53:20 UTC
                 RTC time: Sat 2022-05-07 15:53:20
                Time zone: Asia/Tokyo (JST, +0900)
System clock synchronized: no
              NTP service: n/a
          RTC in local TZ: no

コンテナの場合SELinux無効化…は不要な模様
# getenforce
bash: getenforce: command not found     ※SELinux入ってない?

必要なモジュールを導入していく、

モジュール導入
java-1.8.0-openjdk 入っているか確認
# rpm -qa | grep java-1.8.0-openjdk
#                        ※入ってない。

java-1.8.0-openjdk導入前にリポジトリの設定
# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
# dnf clean all
(中略)
# dnf update
(中略:リポジトリが結構ダウンロードされる)

java-1.8.0-openjdk のインストール
# yum install java-1.8.0-openjdk
(中略)
# rpm -qa | grep java-1.8.0-openjdk
java-1.8.0-openjdk-headless-1.8.0.312.b07-2.el8_5.x86_64
java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64

vim-common のインストール
# yum install vim-common
(中略)
# rpm -qa | grep vim-common
vim-common-8.0.1763-16.el8.x86_64

unzipのインストール
# yum install unzip
(中略)
# rpm -qa | grep unzip
unzip-6.0-45.el8_4.x86_64

epelのインストール(vlgothic-p-fonts(日本語環境で必須のフォント)のインストールに必要)
# dnf install epel-release elrepo-release -y

インストール後、以下ファイルのパラメータ確認
 /etc/yum.repos.d/epel.repo  [epel] に enabled=1 と priority=10 がなければ追記
 /etc/yum.repos.d/elrepo.repo [elrepo] に enabled=1 と priority=10 がなければ追記

vlgothic-p-fontsのインストール
# dnf check-update;LANG=C dnf grouplist > grouplist;LANG=C dnf list > dnflist
# dnf -y update
# dnf -y install langpacks-ja
# dnf -y install vlgothic-fonts vlgothic-p-fonts 
# # rpm -qa | grep vlgothic-p-fonts
vlgothic-p-fonts-20141206-15.el8.1.noarch

java-1.8.0-openjdk-develのインストール
# yum install java-1.8.0-openjdk-devel
# rpm -qa | grep java-1.8.0-openjdk-devel
java-1.8.0-openjdk-devel-1.8.0.312.b07-2.el8_5.x86_64

net-snmp-utilsのインストール
# yum install net-snmp-utils
# rpm -qa | grep net-snmp-utils
net-snmp-utils-5.8-22.el8.x86_64

systatのインストール
# yum install sysstat
# rpm -qa | grep sysstat
sysstat-11.7.3-6.el8.x86_64

tcpdumpのインストール
# yum install tcpdump
# rpm -qa | grep tcpdump
tcpdump-4.9.3-2.el8.x86_64

lsofのインストール
# yum install lsof
# rpm -qa | grep lsof
lsof-4.93.2-1.el8.x86_64

sblim-wbemcliのインストール
# yum install sblim-wbemcli
# rpm -qa | grep sblim-wbemcli
sblim-wbemcli-1.6.3-15.el8.x86_64

wsmancliのインストール
# yum install wsmancli
# rpm -qa | grep wsmancli
wsmancli-2.6.0-8.el8.x86_64

net-snmpのインストール
# yum install net-snmp
# rpm -qa | grep net-snmp
net-snmp-utils-5.8-22.el8.x86_64
net-snmp-5.8-22.el8.x86_64
net-snmp-libs-5.8-22.el8.x86_64
net-snmp-agent-libs-5.8-22.el8.x86_64

 自ホスト名の名前解決の確認をする。ホスト名でPingが通るかどうか確認。通らなければ /etc/hosts に追記。

ホスト名でPing通るか確認
# ping (ホスト名)
PING (ホスト名) (172.17.0.4) 56(84) bytes of data.
64 bytes from (ホスト名) (172.17.0.4): icmp_seq=1 ttl=64 time=0.239 ms

Hinemos マネージャーのインストール

 必要なモジュールをGithubからダウンロードしておく。hinemos/README.jp.md at master · hinemos/hinemosからダウンロード可能。

 今回はRelease Hinemos ver.7.0.0 · hinemos/hinemos の以下モジュールをダウンロード。

  • hinemos-7.0-manager-7.0.0-1.el8.x86_64.rpm
  • hinemos-7.0-web-7.0.0-1.el8.x86_64.rpm

 Hinemosマネージャをインストールする。以下のようにインストールできればOK。

Hinemosマネージャーのインストール

ダウンロードしたモジュールからインストールする。
# rpm -ivh hinemos-7.0-manager-7.0.0-1.el8.x86_64.rpm
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:hinemos-7.0-manager-0:7.0.0-1.el8################################# [100%]
Note: Forwarding request to 'systemctl enable snmpd.service'.
Created symlink /etc/systemd/system/multi-user.target.wants/snmpd.service → /usr/lib/systemd/system/snmpd.service.
/opt/hinemos/sbin/rpm_functions.sh: line 141: service: command not found
Created symlink /etc/systemd/system/multi-user.target.wants/hinemos_manager.service → /usr/lib/systemd/system/hinemos_manager.service.
Created symlink /etc/systemd/system/multi-user.target.wants/hinemos_pg.service → /usr/lib/systemd/system/hinemos_pg.service.

言語設定が日本語かどうか確認
# cat /opt/hinemos/etc/hinemos.cfg | grep "export LANG"
export LANG=en_US.UTF-8
[root@3f180e242e18 /]# vi /opt/hinemos/etc/hinemos.cfg
[root@3f180e242e18 /]# cat /opt/hinemos/etc/hinemos.cfg | grep "export LANG"
export LANG=ja_JP.UTF-8

 インストール後、起動と主要プロセスの稼働確認。

hinemos_manager起動と主要プロセスの稼働確認
hinemos_manager 起動と稼働確認
# systemctl start hinemos_manager
Redirecting to /bin/systemctl start hinemos_manager.service
# systemctl status hinemos_manager
Redirecting to /bin/systemctl status hinemos_manager.service
● hinemos_manager.service - Hinemos Manager
   Loaded: loaded (/usr/lib/systemd/system/hinemos_manager.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2022-05-07 15:17:25 UTC; 2min 13s ago
  Process: 86 ExecStart=/opt/hinemos/bin/jvm_start.sh -W (code=exited, status=0/SUCCESS)
 Main PID: 159 (java)
    Tasks: 77 (limit: 80967)
   Memory: 595.8M
   CGroup: /docker/b000ea5e61378902db9fda0cae47e0a307ff9fa3aa395ab34bfe39ad5b53e3d4/system.slice/hinemos_manager.service
           └─159 /usr/lib/jvm/jre-1.8.0-openjdk/bin/java -Djdk.xml.entityExpansionLimit=0 -javaagent:/opt/hinemos/lib/e>

May 07 15:17:23 b000ea5e6137 systemd[1]: Starting Hinemos Manager...
May 07 15:17:24 b000ea5e6137 jvm_start.sh[86]: sysctl: cannot stat /proc/sys/net/core/rmem_max: No such file or directo>
May 07 15:17:24 b000ea5e6137 jvm_start.sh[86]: sysctl: cannot stat /proc/sys/net/core/rmem_default: No such file or dir>
May 07 15:17:24 b000ea5e6137 jvm_start.sh[86]: sysctl: cannot stat /proc/sys/net/core/wmem_max: No such file or directo>
May 07 15:17:24 b000ea5e6137 jvm_start.sh[86]: sysctl: cannot stat /proc/sys/net/core/wmem_default: No such file or dir>
May 07 15:17:24 b000ea5e6137 jvm_start.sh[86]: waiting for Java Virtual Machine startup...
May 07 15:17:25 b000ea5e6137 jvm_start.sh[86]: Java Virtual Machine started (with -W option)
May 07 15:17:25 b000ea5e6137 systemd[1]: Started Hinemos Manager.

hinemos_pg(PostgreSQL)の稼働確認
# systemctl status hinemos_pg
● hinemos_pg.service - Hinemos PostgreSQL
   Loaded: loaded (/usr/lib/systemd/system/hinemos_pg.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2022-05-07 15:36:44 UTC; 7min ago
  Process: 570 ExecStop=/opt/hinemos/postgresql/bin/pg_ctl stop -w -t ${PGTIMEOUT} -s -D ${PG_DATA} -m ${PGSHUTDOWNMODE>
  Process: 585 ExecStart=/opt/hinemos/postgresql/bin/pg_ctl start -w -t ${PGTIMEOUT} -s -D ${PG_DATA} -l ${PGLOGFILE} (>
 Main PID: 587 (postgres)
(中略)
May 07 15:36:44 b000ea5e6137 systemd[1]: Started Hinemos PostgreSQL.

プロセスの確認。以下2プロセスがあればOK
# ps -ef | grep /opt/hinemos
hinemos      587       1  0 15:36 ?        00:00:00 /opt/hinemos/postgresql/bin/postgres -D /opt/hinemos/var/data
root         668       1 26 15:36 ?        00:02:34 /usr/lib/jvm/jre-1.8.0-openjdk/bin/java -(略)

自動起動確認
# systemctl list-unit-files | grep hinemos
hinemos_manager.service                enabled
hinemos_pg.service                     enabled

Hinemos Webクライアントのインストール

言語設定

「LANG=ja_JP.UTF-8」ではない上に、日本語の言語パッケージすらないので、インストールするところから。

言語設定

現状確認
# localectl status
   System Locale: LANG=en_US.UTF-8
(中略)

ロケールリストにあるかどうか
# localectl list-locales | grep -i ja
(ない)

日本語パッケージのインストールとロケールリストの再確認
# dnf install glibc-langpack-ja
(中略)
# rpm -qa | grep glibc-langpack-ja
glibc-langpack-ja-2.28-164.el8.x86_64
# localectl list-locales | grep -i ja
ja_JP.eucjp
ja_JP.utf8

「LANG=ja_JP.UTF-8」に設定
# localectl set-locale LANG=ja_JP.UTF-8
[root@b000ea5e6137 /]# localectl status
   System Locale: LANG=ja_JP.UTF-8
(中略)

HinemosWebクライアントのインストール~サービス起動

 rpmからインストールし、設定ファイルの言語設定を確認しておく。

HinemosWebクライアントのインストールと言語確認
# rpm -ivh hinemos-7.0-web-7.0.0-1.el8.x86_64.rpm
Verifying...                          ################################# [100%]
warning: Unable to get systemd shutdown inhibition lock: Unit systemd-logind.service is masked.
Preparing...                          ################################# [100%]
Updating / installing...
   1:hinemos-7.0-web-0:7.0.0-1.el8    ################################# [100%]
Created symlink /etc/systemd/system/multi-user.target.wants/hinemos_web.service → /usr/lib/systemd/system/hinemos_web.service.

設定ファイルの言語設定確認
# cat /opt/hinemos_web/conf/hinemos_web.cfg | grep "export LANG"
export LANG=en_US.UTF-8
(該当行を「LANG=ja_JP.UTF-8」に修正)
# cat /opt/hinemos_web/conf/hinemos_web.cfg | grep "export LANG"
export LANG=ja_JP.UTF-8

hinemos_web サービスの起動と確認。以下のような感じで表示されればOK
# systemctl start hinemos_web
# systemctl status hinemos_web
● hinemos_web.service - Hinemos Web
   Loaded: loaded (/usr/lib/systemd/system/hinemos_web.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2022-05-08 09:18:00 JST; 6s ago
  Process: 1073 ExecStart=/opt/hinemos_web/bin/tomcat_start.sh -Wq (code=exited, status=0/SUCCESS)
 Main PID: 1136 (java)
(中略)

プロセスの確認
# ps -ef | grep /opt/hinemos_web
root        1136       1 36 09:18 ?        00:00:48 /usr/lib/jvm/jre-1.8.0-openjdk/bin/java (略)

http://localhost にアクセスし、以下ログイン画面が出れば成功です。

image.png

参考文献

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1