ウェブサイト検索

Mattermost サーバーを Debian 12 に導入する (Bookworm) |


Mattermost サーバーを Debian 12 (Bookworm) に展開する方法に関するこの詳細ガイドへようこそ。しかしその前に、Mattermost とは何かを知る必要があります。

Mattermost は、世界中のほとんどの技術チームと運用チームに好まれているオープンソースのコラボレーション ソフトウェアです。これは、複雑な国家レベルのセキュリティおよび信頼要件がある環境で作業する多数の同時ユーザー向けに設計されています。 Mattermost を使用すると、チャット、音声通話、ビデオ通話を使用して個人間のコミュニケーションを簡単に確立できます。 Mattermost の人気のある競合相手には、MS Teams や Slack があります。

他のツールよりも好まれる理由は、それがもたらす優れた機能です。これらには次のものが含まれます。

  • 完全に拡張可能であり、サードパーティ統合のサポートを提供します。
  • インシデントの解決を迅速かつ時間を節約するインシデント解決
  • ドキュメントストレージをサポート
  • クロスプラットフォームであり、Windows、Android、Linux、Mac オペレーティング システムで実行できます。
  • データのインポートとエクスポートをサポート
  • ドラッグ&ドロップ機能を提供します
  • アプリケーションとネットワークのパフォーマンス監視を提供します。
  • ワークフロー管理とオーケストレーションを提供します。
  • アラート/通知を提供します

インストール要件

このガイドでは、次のものが必要です。

  • Debian 12 (Bookworm)、1 vCPU/コア、2 GB RAM (最大 1,000 ユーザーをサポート)
  • データベースサーバー: PostgreSQL v11+
  • sudo 権限を持つユーザー。
  • 完全修飾ドメイン名 (SSL 証明書の場合はオプション)

Mattermost サーバーを Debian 12 (Bookworm) にデプロイするには、以下の手順に従ってください。

ステップ 1: PostgreSQL データベース サーバーをインストールする

最初に行う必要があるのは、データベース サーバーが Mattermost 用にセットアップされていることを確認することです。 Mattermost に推奨されるデータベース サーバーはPostgreSQL v11 以降です。

インストールするには、次のコマンドを使用します。

sudo apt update
sudo apt install postgresql postgresql-contrib -y

サービスが実行中かどうかを確認します。

$ systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: active (exited) since Mon 2023-08-14 03:49:03 EDT; 29s ago
   Main PID: 63061 (code=exited, status=0/SUCCESS)
        CPU: 1ms

システム起動時にサービスが実行できるように設定されていることを確認してください

sudo systemctl enable postgresql

次のコマンドを使用してシェルにアクセスします。

sudo -u postgres psql

Matermost のデータベースとユーザーを作成します。

CREATE USER mmuser WITH PASSWORD 'P@ssw0rd!';
CREATE DATABASE mattermost OWNER mmuser;
\q

ステップ 2: Mattermost サーバーをインストールする

データベース サーバーをインストールして構成したら、Mattermost サーバーをダウンロードする必要があります。公式 Mattermost ダウンロード ページから利用可能な最新バージョンを入手してください。

利用可能な最新の Tarball をダウンロードします。これは、必要なバージョンをエクスポートすることで実行できます。

VER=8.0.1

以下を使用してアーカイブをプルします。

wget https://releases.mattermost.com/$VER/mattermost-$VER-linux-amd64.tar.gz

ダウンロードしたら、アーカイブを抽出します。

tar -xvzf mattermost*.tar.gz

ファイルを /opt ディレクトリに移動します。

sudo mv mattermost /opt

次に、データを永続化するためのストレージ ディレクトリを作成します。

sudo mkdir /opt/mattermost/data

Mattermost 専用のユーザーとグループを作成します。

sudo useradd --system --user-group mattermost

ディレクトリに必要な権限を設定します。

sudo chown -R mattermost:mattermost /opt/mattermost
sudo chmod -R g+w /opt/mattermost

次に、Mattermost の設定を行います。

sudo vim /opt/mattermost/config/config.json 

ファイルのSqlsettingsセクションに示されているようにデータベース認証情報を追加します。作成したユーザー、パスワード、データベース名を忘れずに指定してください。

"SqlSettings": {
    "DriverName": "postgres",
    "DataSource": "postgres://mmuser:P@ssw0rd!@localhost/mattermost?sslmode=disable&connect_timeout=10&binary_parameters=yes",
    "DataSourceReplicas": [],
    "DataSourceSearchReplicas": [],
    "MaxIdleConns": 20,
    "ConnMaxLifetimeMilliseconds": 3600000,
    "ConnMaxIdleTimeMilliseconds": 300000,
    "MaxOpenConns": 300,
    "Trace": false,
    "AtRestEncryptKey": "",
    "QueryTimeout": 30,
    "DisableDatabaseSearch": false,
.........
  },

加えた変更を保存し、すべてが問題ないかどうかをテストします。

cd /opt/mattermost
sudo -u mattermost bin/mattermost

サンプル出力:

.......
{"timestamp":"2023-08-14 04:02:16.315 -04:00","level":"info","msg":"rtc: server is listening on udp 127.0.0.1:8443","caller":"app/plugin_api.go:973","plugin_id":"com.mattermost.calls","origin":"main.(*logger).Info log.go:95"}
{"timestamp":"2023-08-14 04:02:16.316 -04:00","level":"info","msg":"rtc: server is listening on udp 192.168.200.56:8443","caller":"app/plugin_api.go:973","plugin_id":"com.mattermost.calls","origin":"main.(*logger).Info log.go:95"}
{"timestamp":"2023-08-14 04:02:16.317 -04:00","level":"info","msg":"rtc: server is listening on udp 192.168.200.175:8443","caller":"app/plugin_api.go:973","plugin_id":"com.mattermost.calls","origin":"main.(*logger).Info log.go:95"}
{"timestamp":"2023-08-14 04:02:16.317 -04:00","level":"info","msg":"rtc: server is listening on udp 10.244.2.1:8443","caller":"app/plugin_api.go:973","plugin_id":"com.mattermost.calls","origin":"main.(*logger).Info log.go:95"}
{"timestamp":"2023-08-14 04:02:16.318 -04:00","level":"info","msg":"Listening TCP on 0.0.0.0:8443","caller":"app/plugin_api.go:973","plugin_id":"com.mattermost.calls","origin":"main.(*logger).Info log.go:95"}
{"timestamp":"2023-08-14 04:02:16.334 -04:00","level":"info","msg":"Starting Server...","caller":"app/server.go:912"}
{"timestamp":"2023-08-14 04:02:16.334 -04:00","level":"info","msg":"Server is listening on [::]:8065","caller":"app/server.go:988","address":"[::]:8065"}

これは、Mattermost が動作し、ポート 8065 (デフォルトのポート) で接続をリッスンしていることを示しています。サービスを停止するには、Ctrl+C を押して次のコマンドを実行します。

sudo killall -9 mattermost

ステップ 3: Mattermost Systemd ユニットを作成する

systemd を使用して Mattermost サービスを管理するには、サービス ファイルを作成する必要があります。

cat <<EOF | sudo tee /lib/systemd/system/mattermost.service 
[Unit]
Description=Mattermost
After=network.target

[Service]
Type=notify
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
KillMode=mixed
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target
EOF

次のコマンドを使用して systemd をリロードします。

sudo systemctl daemon-reload

サービスを開始して有効にします。

sudo systemctl start mattermost.service
sudo systemctl enable mattermost.service

サービスのステータスを確認します。

$ systemctl status mattermost.service 
●mattermost.service - Mattermost
     Loaded: loaded (/lib/systemd/system/mattermost.service; enabled; preset: enabled)
     Active: active (running) since Mon 2023-08-14 04:07:42 EDT; 10s ago
   Main PID: 63819 (mattermost)
      Tasks: 26 (limit: 4623)
     Memory: 290.0M
        CPU: 6.237s
     CGroup: /system.slice/mattermost.service
             ├─63819 /opt/mattermost/bin/mattermost
             ├─63833 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64
             ├─63843 plugins/com.mattermost.calls/server/dist/plugin-linux-amd64
             └─63849 plugins/playbooks/server/dist/plugin-linux-amd64

ファイアウォールを有効にしている場合は、ポートの通過を許可します。

sudo ufw allow 8065

ステップ 4: Mattermost Web インターフェイスにアクセスする

Mattermost がインストールされ、起動されたので、URL http://IP_Address:8065 または http://domain_name:8065 を使用して Web インターフェイスにアクセスできます。

デスクトップ アプリを使用するか、Web インターフェイスを続行するかを選択できます。ここではWeb UIを進めていきます。必要な詳細を入力してユーザー アカウントを作成します。

組織名を設定します

環境で使用するツールを選択してください。

メンバーをチームに招待するためのリンクが提供されます。

それだ!これで、Mattermost を使用できるようになりました。

ステップ 5: Let’s Encrypt で Mattermost を保護する

Mattermost を SSL 証明書で保護するには 2 つの方法があります。これらは:

  • Mattermost サーバーで TLS をセットアップします。
  • NGINX などのプロキシを使用し、プロキシ上で TLS を設定します。

このガイドではプロキシを使用します。ユーザーが 200 人を超える場合は、パフォーマンスを向上させるためにプロキシを使用することをお勧めします。この方法では、標準の HTTP 要求ログも提供されます。

次のコマンドを使用して、Debian 12 に Nginx プロキシをインストールします。

sudo apt install nginx -y

インストールしたら、仮想ホスト ファイルを構成します。

sudo vim /etc/nginx/conf.d/mattermost.conf

ファイルに以下の行を追加します。

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  mattermost.computingforgeeks.com;

        location / {
	proxy_pass http://localhost:8065/;
            index  index.html index.htm;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

デフォルトの nginx サイトを無効にします。

sudo rm -rf /etc/nginx/sites-enabled/default

ファイルを保存し、nginx を再起動します。

sudo systemctl restart nginx

仮想ホストを作成したら、Let’s Encrypt で証明書を生成するために必要なツールをインストールします。

sudo apt install certbot python3-certbot-nginx

仮想ホスト ファイルにキャプチャされたドメイン名に対して信頼された SSL 証明書を発行します。

sudo certbot --nginx

次のように続行します。

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): Enter a valid Email address here          

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Account registered.

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: mattermost.computingforgeeks.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1

Requesting a certificate for mattermost.computingforgeeks.com
Performing the following challenges:
http-01 challenge for mattermost.computingforgeeks.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/mattermost.conf
Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/mattermost.conf

Successfully received certificate.
Certificate is saved at: a2enmod ssl
/etc/letsencrypt/live/mattermost.computingforgeeks.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/mattermost.computingforgeeks.com/privkey.pem
This certificate expires on 2022-01-09.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

SSL 証明書が conf ファイルに自動的に追加されます。ファイアウォール経由の HTTPS を許可します。

sudo ufw allow 443

サービスを再起動します。

sudo systemctl restart nginx

次に、URL https://domain_name を使用して HTTPS 経由でサービスにアクセスします。

ステップ 6: Mattermost デスクトップをインストールして使用する

Mattermost には 2 つのアクセス方法が用意されています。デスクトップ アプリをインストールして使用することもできます。 Mattermost デスクトップ アプリ ページにキャプチャされているように、さまざまなオペレーティング システム用のデスクトップ アプリがあります。このガイドでは、Linux システムにアプリをダウンロードしてインストールする方法を説明します。

コマンドを使用して Mattermost デスクトップをインストールします

  • Debian/Ubuntu の場合
curl -o- https://deb.packages.mattermost.com/setup-repo.sh | sudo bash
sudo apt update && sudo apt  install mattermost-desktop -y
  • RHEL/CentOS/Rocky Linux では、最新の RPM パッケージをダウンロードする必要があります。

RPM バージョンをエクスポートします。

VER=5.4.0

RPM パッケージをプルしてインストールします。

##For 64-bit
wget https://releases.mattermost.com/desktop/$VER/mattermost-desktop-$VER-linux-x86_64.rpm
sudo rpm -u mattermost-desktop-$VER-linux-x86_64.rpm

##For 32-Bit
wget https://releases.mattermost.com/desktop/$VER/mattermost-desktop-$VER-linux-i686.rpm
sudo rpm -u mattermost-desktop-$VER-linux-i686.rpm

インストールしたら、[アプリ] メニューからデスクトップ アプリを起動します。

サーバーの URL (HTTPS を推奨) と表示名を指定して、Mattermost サーバーに接続します。

サーバーにログインします。

接続すると、このように表示されます。

出来上がり!

Mattermost サーバーを Debian 12 (Bookworm) にデプロイする方法を説明しました。これがあなたにとって非常に重要なものだったことを願っています。

詳細については、当社のページをご覧ください:

  • Kubernetes クラスターでの Mattermost のインストールと構成
  • DockerコンテナでMattermostサーバーを実行する方法
  • Mattermost サーバーを CentOS 8|RHEL 8 にインストールする
  • Mattermost サーバーを Ubuntu 22.04|20.04|18.04 にインストールする

関連記事: