お金をかけずにサーバーの勉強をしよう

Mattermostインストール(Windows)

2023年6月20日

メニューへ戻る

Windows Server 2022に Mattermost Team Editionをインストールします。

ここのホームページでは Linuxを主としてやっているんですが、仕事という面で言うと思いの外オンプレの環境が多く、更には Windowsサーバーが結構多いのです。

Linux(Ubuntu Server)での Mattermostについては「Mattermostインストール」に書いていますが、Windows版は非公式ゆえ、どハマりしながらインストールした手順を備忘録として記しておこうと思います。

決してネタ切れのために同じネタでおかわりをしようというものではありません。

鼻息('oo`)も荒くなったところで、早速インストールしましょう。


Mattermostの本家サイトはこちら。
Mattermost

上記のホームページで扱われているのは有償の Enterprise版なんですが、ここで扱いたいのは無償の Team版というやつです。

ホームページを彷徨っても中々ダウンロードのリンクを見つけられず、一応 Linux版の tar形式のファイルについては以下に書いてあるのを見つけられました。
Mattermost Team Edition

以前は開発者ドキュメントに Windows用サーバーのインストール手順があったような気がするんですが、とうとう見つけられませんでした。

ただ、以下の URLでダウンロードすることができます。
https://releases.mattermost.com/X.X.X/mattermost-team-X.X.X-windows-amd64.zip

[X.X.X] の箇所はダウンロードしたいバージョンにします。
2023年6月19日時点の最新バージョンは 7.10.3でしたので、これを手に入れるには URLは以下になります。
[ https://releases.mattermost.com/7.10.3/mattermost-team-7.10.3-windows-amd64.zip ]

そして何故だか Linux版のダンロードファイルも必要になるのでした。
理由は後述しますが、以下も一緒にダウンロードをしておいて下さい。
[ https://releases.mattermost.com/7.10.3/mattermost-team-7.10.3-linux-amd64.tar.gz ]


使用する環境は以下となります。

VMware Workstation Playerで Windows Server 2022の仮想マシンを作るのは「Windows Server 2022 インストール」に、
PostgreSQLインストールについては「PostgreSQLインストール(Windows)」に、
それぞれ書いています。

Windows Serverに PostgreSQL 15.3がインストールされている状態からスタートします。


1.データベース準備

PostgreSQLの中に専用のデータベースを作ります。
手順は Linuxでのものですが、以下に書いてあります。
Prepare your Mattermost database

これに従ってやってみます。

Windows Server で、PostgreSQLの psqlコマンドを使います。
スタートメニューから [PostgreSQL 15] → [SQL Shell (psql)] を選択します。
PostgreSQLの SQL Shell(psql)

黒い画面が立ち上がりますので以下のようにやっていきます。

管理者ユーザー [postgres] でログインします。

Server [localhost]:Enterキー
Database [postgres]:Enterキー
Port [5432]:Enterキー
Username [postgres]:Enterキー
Client Encoding [SJIS]:Enterキー
ユーザー postgres のパスワード:管理者ユーザー[postgres]のパスワード
psql (15.3)
"help"でヘルプを表示します。

postgres=#

ログインできました。

さて、ここで一つ工夫をしないといけない事があります。
Mattermostのドキュメントではこの後

  1. [mattermost]というデータベースを作る
  2. [mmuser]というユーザーを作る
  3. [mmuser]ユーザーに[mattermost]データベースの[PUBLIC]スキーマへの変更権限を与える

という手順になっていますが、PostgreSQLの 15から [PUBLIC]スキーマへの変更はデータベースのオーナーだけができるという大きな仕様変更が入っているため、この手順([mattermost]データベースのオーナーが [postgres]ユーザーになる)だと Mattermostを開始した時にエラーになってしまいます。

よってここでは、[mattermost]データベースのオーナーを [mmuser]ユーザーにすることにしました。


Mattermost専用の [mmuser] というユーザーを作ります。

postgres=# CREATE USER mmuser WITH PASSWORD 'mmuser-password';  ← 実際はこういうパスワードにするのは止めましょう。
CREATE ROLE

[mattemost] という名前のデータベースを[mmuser]ユーザーをオーナーとして作ります。

postgres=# CREATE DATABASE mattermost WITH OWNER mmuser;
CREATE DATABASE

これでデータベースの準備は完了です。
SQL Shellを終わらせます。

postgres=# \q  ← \はバックスラッシュ(キーボード右下)です。



2.Mattermostインストール

[C:¥work]フォルダをインストール作業用の一時フォルダとして使っています。
実際にダウンロードしたファイルはこれらです。
Mattermost Team Editionのダウンロードファイル

まずは Windows用の圧縮ファイル mattermost-team-7.10.3-windows-amd64.zip] をエクスプローラー上で解凍します。
[mattermost-team-7.10.3-windows-amd64]フォルダができて、その下に [mattermost]フォルダができました。
Mattermostインストール 1

その下の[bin]フォルダの中味はこれらです。
Mattermostインストール 2

しかし [mattermost]フォルダの下のもの、これだけでは Mattermostのセットとしては全然足りません。

少なくとも使用するデータベースに接続する設定をしなければならないはずで、[config.json]ファイルがあるべきなんじゃないかと。

この圧縮ファイルは何かとの差分なのか?
という推測の下、古いバージョンをダウンロードして調べてみましたが、Ver.5の圧縮ファイルの中には他のフォルダも一杯ありました。

あくまで推測ですが、Ver.6からは Linux版と同じものは Windows版の圧縮ファイルには入れなくなったのではないかと思います。

ということは、Linux版のセットとファイルをマージしたフォルダを作れば上手く行くのでは?との思いから、Linux版のファイルもダウンロードしたのでした。

そちらも解凍してみましょう。
[tar.gz]形式ですので、エクスプローラーからは解凍できません。
これを解凍するには、tarコマンドが必要ですが、最近の WindowsOSには [tar.exe]が最初から入っているんですね。

スタートメニューより、[Windows システム ツール] → [コマンド プロンプト]を選択します。

解凍します。

C:\Users\Administrator>cd c:\work

c:\work>tar -xzvf mattermost-team-7.10.3-linux-amd64.tar.gz
x mattermost/
x mattermost/bin/
x mattermost/bin/mattermost
x mattermost/bin/mmctl
x mattermost/logs/

〜〜〜 省略 〜〜〜

x mattermost/client/worktemplates/product_teams/sprint_planning/channel.png
x mattermost/client/worktemplates/product_teams/sprint_planning/sprint_planning.png
x mattermost/MIT-COMPILED-LICENSE.md
x mattermost/NOTICE.txt
x mattermost/README.md
x mattermost/manifest.txt

解凍できました。

こちらの [mattermost]フォルダには、こんなに沢山のものがあります。
Mattermostインストール 3

Windows版の実行ファイルを、Linux版のフォルダにコピってしまいます。
Mattermostインストール 4

その結果、Linux版とWindows版のプログラムが混在するフォルダになりました。
Mattermostインストール 5

次は、PostgreSQLへ接続する設定を書きます。
[c:¥work¥mattermost¥config¥config.json]ファイルをメモ帳で編集します。
Mattermostインストール 6

この箇所を書き換えて下さい。
具体的には、[mmuser]ユーザーのパスワードを正しくするのと、データベース名を [mattermost]にしています。

"SqlSettings": {
    "DriverName": "postgres",
    "DataSource": "postgres://mmuser:mostest@localhost/mattermost_test?sslmode=disable\u0026connect_timeout=10\u0026binary_parameters=yes",

  ↓

"SqlSettings": {
    "DriverName": "postgres",
    "DataSource": "postgres://mmuser:mmuser-password@localhost/mattermost?sslmode=disable\u0026connect_timeout=10\u0026binary_parameters=yes",

書き換えができたら、いよいよ実行です。


3.Mattermost実行

またコマンドプロンプトを使います。
ワーキングフォルダを [C:¥work¥mattermost]フォルダにしていることに注意して下さい。

C:\Users\Administrator>cd c:\work

c:\work\mattermost>.\bin\mattermost.exe server
{"timestamp":"2023-06-19 22:35:36.024 +09:00","level":"info","msg":"Server is initializing...","caller":"platform/service.go:165","go_version":"go1.19.5"}
{"timestamp":"2023-06-19 22:35:36.024 +09:00","level":"info","msg":"Pinging SQL","caller":"sqlstore/store.go:242","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@localhost/mattermost?binary_parameters=yes&connect_timeout=10&sslmode=disable"}
{"timestamp":"2023-06-19 22:35:36.198 +09:00","level":"info","msg":"Starting websocket hubs","caller":"platform/web_hub.go:95","number_of_hubs":8}
{"timestamp":"2023-06-19 22:35:36.198 +09:00","level":"info","msg":"Loaded system translations","caller":"i18n/i18n.go:132","for locale":"en","from locale":"C:\\work\\mattermost\\i18n\\en.json"}
{"timestamp":"2023-06-19 22:35:36.214 +09:00","level":"info","msg":"Ensuring the telemetry ID","caller":"telemetry/telemetry.go:142","id":"wzid75h4rt8f5rxczgbaje58me"}
{"timestamp":"2023-06-19 22:35:36.217 +09:00","level":"error","msg":"SiteURL must be set. Some features will operate incorrectly if the SiteURL is not set. See documentation for details: https://docs.mattermost.com/configure/configuration-settings.html#site-url","caller":"app/server.go:403"}
{"timestamp":"2023-06-19 22:35:36.217 +09:00","level":"info","msg":"Current version is 7.10.3 (7.10.3/Wed Jun 14 12:13:31 UTC 2023/74af1505a69a560085fd609620e3f92123e84536/none)","caller":"app/server.go:412","current_version":"7.10.3","build_number":"7.10.3","build_date":"Wed Jun 14 12:13:31 UTC 2023","build_hash":"74af1505a69a560085fd609620e3f92123e84536","build_hash_enterprise":"none"}
{"timestamp":"2023-06-19 22:35:36.217 +09:00","level":"info","msg":"Team Edition Build","caller":"app/server.go:423","enterprise_build":false}
{"timestamp":"2023-06-19 22:35:36.218 +09:00","level":"info","msg":"Printing current working","caller":"app/server.go:427","directory":"c:\\work\\mattermost"}
{"timestamp":"2023-06-19 22:35:36.218 +09:00","level":"info","msg":"Loaded config","caller":"app/server.go:428","source":"file://c:\\work\\mattermost\\config\\config.json"}
{"timestamp":"2023-06-19 22:35:36.230 +09:00","level":"info","msg":"Starting workers","caller":"jobs/workers.go:48"}
{"timestamp":"2023-06-19 22:35:36.230 +09:00","level":"info","msg":"Starting schedulers.","caller":"jobs/schedulers.go:47"}
{"timestamp":"2023-06-19 22:35:36.392 +09:00","level":"info","msg":"Skipping triggering Elasticsearch channel index fix job as build is not Enterprise ready","caller":"app/migrations.go:570"}
{"timestamp":"2023-06-19 22:35:36.414 +09:00","level":"error","msg":"License key from https://mattermost.com required to unlock enterprise features.","caller":"platform/license.go:101","error":"resource: License id: "}
{"timestamp":"2023-06-19 22:35:36.656 +09:00","level":"info","msg":"Starting up plugins","caller":"app/plugin.go:218"}
{"timestamp":"2023-06-19 22:35:36.662 +09:00","level":"info","msg":"Syncing plugins from the file store","caller":"app/plugin.go:299"}
{"timestamp":"2023-06-19 22:35:39.289 +09:00","level":"error","msg":"Failed to install prepackaged plugin","caller":"app/plugin.go:964","path":"c:\\work\\mattermost\\prepackaged_plugins\\mattermost-plugin-nps-v1.3.1-linux-amd64.tar.gz","error":"Failed to install extracted prepackaged plugin c:\\work\\mattermost\\prepackaged_plugins\\mattermost-plugin-nps-v1.3.1-linux-amd64.tar.gz: installExtractedPlugin: Unable to restart plugin on upgrade., unable to start plugin: com.mattermost.nps: unable to generate plugin checksum: open plugins\\com.mattermost.nps\\server\\dist\\plugin-windows-amd64.exe: The system cannot find the file specified."}
{"timestamp":"2023-06-19 22:35:39.653 +09:00","level":"error","msg":"Failed to install prepackaged plugin","caller":"app/plugin.go:964","path":"c:\\work\\mattermost\\prepackaged_plugins\\mattermost-plugin-apps-v1.2.1-linux-amd64.tar.gz","error":"Failed to install extracted prepackaged plugin c:\\work\\mattermost\\prepackaged_plugins\\mattermost-plugin-apps-v1.2.1-linux-amd64.tar.gz: installExtractedPlugin: Unable to restart plugin on upgrade., unable to start plugin: com.mattermost.apps: unable to generate plugin checksum: open plugins\\com.mattermost.apps\\server\\dist\\plugin-windows-amd64.exe: The system cannot find the file specified."}
{"timestamp":"2023-06-19 22:35:41.133 +09:00","level":"error","msg":"Failed to install prepackaged plugin","caller":"app/plugin.go:964","path":"c:\\work\\mattermost\\prepackaged_plugins\\mattermost-plugin-calls-v0.15.1-linux-amd64.tar.gz","error":"Failed to install extracted prepackaged plugin c:\\work\\mattermost\\prepackaged_plugins\\mattermost-plugin-calls-v0.15.1-linux-amd64.tar.gz: installExtractedPlugin: Unable to restart plugin on upgrade., unable to start plugin: com.mattermost.calls: unable to generate plugin checksum: read plugins\\com.mattermost.calls: The handle is invalid."}
{"timestamp":"2023-06-19 22:35:42.016 +09:00","level":"error","msg":"Failed to install prepackaged plugin","caller":"app/plugin.go:964","path":"c:\\work\\mattermost\\prepackaged_plugins\\mattermost-plugin-playbooks-v1.36.1-linux-amd64.tar.gz","error":"Failed to install extracted prepackaged plugin c:\\work\\mattermost\\prepackaged_plugins\\mattermost-plugin-playbooks-v1.36.1-linux-amd64.tar.gz: installExtractedPlugin: Unable to restart plugin on upgrade., unable to start plugin: playbooks: unable to generate plugin checksum: open plugins\\playbooks\\server\\dist\\plugin-windows-amd64.exe: The system cannot find the file specified."}
{"timestamp":"2023-06-19 22:35:42.492 +09:00","level":"error","msg":"Failed to install prepackaged plugin","caller":"app/plugin.go:964","path":"c:\\work\\mattermost\\prepackaged_plugins\\focalboard-v7.10.4-linux-amd64.tar.gz","error":"Failed to install extracted prepackaged plugin c:\\work\\mattermost\\prepackaged_plugins\\focalboard-v7.10.4-linux-amd64.tar.gz: installExtractedPlugin: Unable to restart plugin on upgrade., unable to start plugin: focalboard: unable to generate plugin checksum: open plugins\\focalboard\\server\\dist\\plugin-windows-amd64.exe: The system cannot find the file specified."}
{"timestamp":"2023-06-19 22:35:42.504 +09:00","level":"error","msg":"Unable to activate plugin","caller":"app/plugin.go:171","plugin_id":"com.mattermost.apps","error":"unable to start plugin: com.mattermost.apps: unable to generate plugin checksum: open plugins\\com.mattermost.apps\\server\\dist\\plugin-windows-amd64.exe: The system cannot find the file specified."}
{"timestamp":"2023-06-19 22:35:42.714 +09:00","level":"error","msg":"Unable to activate plugin","caller":"app/plugin.go:171","plugin_id":"com.mattermost.nps","error":"unable to start plugin: com.mattermost.nps: unable to generate plugin checksum: open plugins\\com.mattermost.nps\\server\\dist\\plugin-windows-amd64.exe: The system cannot find the file specified."}
{"timestamp":"2023-06-19 22:35:42.722 +09:00","level":"error","msg":"Unable to activate plugin","caller":"app/plugin.go:171","plugin_id":"com.mattermost.calls","error":"unable to start plugin: com.mattermost.calls: unable to generate plugin checksum: read plugins\\com.mattermost.calls: The handle is invalid."}
{"timestamp":"2023-06-19 22:35:42.919 +09:00","level":"error","msg":"Unable to activate plugin","caller":"app/plugin.go:171","plugin_id":"playbooks","error":"unable to start plugin: playbooks: unable to generate plugin checksum: open plugins\\playbooks\\server\\dist\\plugin-windows-amd64.exe: The system cannot find the file specified."}
{"timestamp":"2023-06-19 22:35:43.120 +09:00","level":"error","msg":"Unable to activate plugin","caller":"app/plugin.go:171","plugin_id":"focalboard","error":"unable to start plugin: focalboard: unable to generate plugin checksum: open plugins\\focalboard\\server\\dist\\plugin-windows-amd64.exe: The system cannot find the file specified."}
{"timestamp":"2023-06-19 22:35:43.132 +09:00","level":"info","msg":"Starting Server...","caller":"app/server.go:899"}
{"timestamp":"2023-06-19 22:35:43.133 +09:00","level":"info","msg":"Server is listening on [::]:8065","caller":"app/server.go:971","address":"[::]:8065"}

ん〜、何だかプラグイン関連が軒並みエラーになっています。
これは後で問題が出るか?

ただそれでも [8065/tcp] で待ち受けているようです。

Windowsサーバーのファイアウォール」に書いた要領で、[8065/tcp]を開放しました。


4.Mattermostを使ってみる

私がクライアントとして使っている Lubuntu 22.04.2 の Firefoxでアクセスしてみます。
うちの環境だと [http://win2022:8065]になります。

[View in Browser]を選択しました。
Mattermost 1

管理者ユーザーの登録です。
メアドとユーザー名とパスワードを設定し、Create Accountを押します。
Mattermost 2

最初のチームを作ります。
[Create a team]をクリックします。
Mattermost 3

チーム名を入力し、Nextを押します。
Mattermost 4

チームへの URLを決めて入力します。
Finishを押します。
Mattermost 5

Mattermostとして動き出しました。
まずは日本語にしましょう。
歯車のアイコンをクリックします。
Mattermost 6

[Display]を選択して、右に出てくる設定項目の一番下の [Language] の [Edit] をクリックします。
Mattermost 7

[日本語]を選択し、Saveを押します。
Mattermost 8

[×]で閉じます。
Mattermost 9

日本語になりました!(オラァ)\(^o^)/
Mattermost 10


ということで、Windows Server 2022と Windows版の PostgreSQLで Mattermostのサーバーを立ち上げてみました。

Windows版の手順が無いので本当にこれで良いのか分かりませんが…どうにか動くところまでは持っていけました。

しかし、このバージョンはインストール手順書には Windowsは乗っていないのですし、保守のない Team版ということもあり、本気で使う環境から 2段階も下がるものです。

Windowsしか環境がないけど動くだけでも良いから Mattermostを使いたい!

という事情でも無い限りは、せめて Linuxで構築した方が良いと思います。
(作っておいてナンですが)


それではごきげんよう。