Mattermostは、オープンソースの自己ホスト型Slack代替手段です。最も重要なのは、ファイアウォールの背後にある最新の通信です。
独自のSaaSメッセージングの代替として、Mattermostは、チームのすべてのコミュニケーションを1つの場所にまとめ、どこからでも検索およびアクセスできるようにします。
最も重要なのは「Slackと互換性があり、Slackに制限されていない」ことで、既存のSlack統合との互換性を含め、Slackの着信および発信Webhook統合のスーパーセットをサポートします。既存のSlackチームから、ユーザー、公開チャンネルの履歴、さらにはテーマ設定の色をMattermostにインポートできます。
このハウツー内で使用される名前、変数、およびアカウント
local IP of server : 192.168.2.100
FQDN of server : mattermost.example.com
Name of mattermost database : mattermost
User to access mattermost database : mmuser
Password for mmuser within database: DBAss47slX3
このハウツーでは、データベースバックエンドとしてPostgreSQLを使用したCentOS7へのMattermostのインストールについて説明します。このガイドでは、すべてを1台のサーバーにインストールすることを前提としていますが、経験豊富なユーザーの場合、パーツを分解して各コンポーネント(データベースサーバーなど)を別のマシンにインストールするのは簡単です。インストールはユーザーrootで行われました。 ただし、もちろん、sudo対応ユーザーを使用することもできます。 、も。
また、サーバーのIPアドレスは 192.168.2.100であると想定しています。 そのDNSはmattermost.example.comに解決されます 。したがって、このハウツーのどこで 192.168.2.100を読んだか またはmattermost.example.com サーバーのIPアドレスに置き換えてください。
開始する前に、CentOS7の最小インストールが必要です。インストール後、システムが電子メールを送信できるように(たとえば、スマートホストまたは同様のソリューションを介して)、電子メールを正しく設定していることを確認してください(postfix構成)。
続行する前に、いくつかの小さなチェックを行ってください:
サーバー上の端末からメールを送信してみてください:
[[email protected] ~]echo -en "Subject: Testmail\n\nThis is a test\n" | sendmail [email protected]
([メール保護]を、サーバーが送信できるはずのメールアドレスに置き換えます)。システムからメールを受け取ったことを確認してください!
mattermost.example.comの名前解決を確認する
別のコンピューター(セットアップしようとしているサーバーではない)から、mattermost.example.comにpingを実行してみてください。良い結果が得られるはずです:
C:\>ping mattermost.example.com
Pinging mattermost.witron.com [192.168.2.100] with 32 bytes of data:
Reply from 192.168.2.100: bytes=32 time<1ms TTL=64
Reply from 192.168.2.100: bytes=32 time<1ms TTL=64
Reply from 192.168.2.100: bytes=32 time<1ms TTL=64
Reply from 192.168.2.100: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.2.100:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
インターネット接続を確認する
次に、パッケージwgetをインストールします(後で必要になります)。
[[email protected] ~] yum -y install wget
それを使用してパブリックIPを決定します。これで、インターネット接続を確認できます。
[[email protected] ~] wget http://ipinfo.io/ip -qO -
46.101.122.124
結果はパブリックIPアドレスになります。
ファイアウォールのステータスを確認して、今は無効にしてください
CentOS7のインストールにfirewalldがあるかどうかを確認してください 有効。これを確認するには、次のように入力します
[[email protected] ~] systemctl status firewalld
のようなものが表示された場合
アクティブ:アクティブ(実行中)以降...
オフにして、この2つのコマンドで無効にしてください。
[[email protected] ~] systemctl stop firewalld
[[email protected] ~] systemctl disable firewalld
このチュートリアルの最後に、firewalldを再度有効にする方法と、Mattermostで動作するように正しく設定する方法が記載されています。
上記のすべてのチェックに合格した場合、またはこのチュートリアルに使用できるシステムがあることがわかっている場合は、今すぐ続行できます。
PostgreSQLデータベースサーバーをインストールします
MattermostのデータベースバックエンドとしてPostgreSQLを使用します。次のコマンドでインストールします:
[[email protected] ~] yum -y install postgresql-server postgresql-contrib
インストール後、データベースを初期化する必要があります。
[[email protected] ~] postgresql-setup initdb
Initializing database ... OK
次に、PostgreSQLを起動し、自動起動を有効にします。
[[email protected] ~]# systemctl start postgresql
[[email protected] ~]# systemctl enable postgresql
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to /usr/lib/systemd/system/postgresql.service.
実行してPostgreSQLが実行されていることを確認してください。
[[email protected] ~]# systemctl status postgresql
これに似たものを報告する必要があります(アクティブ:アクティブ(実行中)があることを確認してください テキストのどこかにあります。
? postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2016-03-04 11:37:50 CET; 44s ago
Main PID: 17660 (postgres)
CGroup: /system.slice/postgresql.service
??17660 /usr/bin/postgres -D /var/lib/pgsql/data -p 5432
??17661 postgres: logger process
??17663 postgres: checkpointer process
??17664 postgres: writer process
??17665 postgres: wal writer process
??17666 postgres: autovacuum launcher process
??17667 postgres: stats collector process
Mar 04 11:37:48 mattermost systemd[1]: Starting PostgreSQL database server...
Mar 04 11:37:50 mattermost systemd[1]: Started PostgreSQL database server.
Mar 04 11:37:59 mattermost systemd[1]: Started PostgreSQL database server.
PostgreSQLは、 postgresという名前のユーザーとグループを自動的に作成しました。 。ユーザーpostgresを使用します データベースエンジンに接続し、データベースとそれにアクセスできるユーザーを設定します。
ユーザーとしてプロンプトを開始しますpostgres :
[[email protected] ~]# sudo -i -u postgres
プロンプトが次のように変わります:
-bash-4.2$
それでは、データベースサーバーに接続しましょう。
-bash-4.2$ psql
psql (9.2.15)
Type "help" for help.
postgres=#
PostgreSQLプロンプト内に、「mattermost」という名前のデータベースを作成します。
postgres=# CREATE DATABASE mattermost;
CREATE DATABASE
次に、ユーザー' mmuserを作成します。 'パスワード付き'DBAss47slX 3'。
postgres=# CREATE USER mmuser WITH PASSWORD 'DBAss47slX3';
CREATE ROLE
次のように入力して、ユーザーにMattermostデータベースへのアクセスを許可します。
postgres=# GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;
GRANT
postgres=#
その後、PostgreSQLプロンプトを終了できます。 次のように入力します:
postgres=# \q
-bash-4.2$
次に、ユーザーとして開始したシェルを終了します' postgres 'with。
-bash-4.2$ exit
logout
[[email protected] ~]#
後で、私たちの最も重要なインスタンスはPostgreSQLデータベースと通信し、ユーザー名とパスワードで認証したいと考えています。これを可能にするには、PostgreSQLの構成を少し変更する必要があります。ファイルを開きます:
vi /var/lib/pgsql/data/pg_hba.conf
viやnanoのようなエディターを使用して、行を変更します:
host all all 127.0.0.1/32 ident
宛先:
host all all 127.0.0.1/32 md5
ファイルを保存してから、Postgresqlを再起動します。
[[email protected] ~]# systemctl restart postgresql
以前に作成したユーザーとパスワードを使用してデータベースサーバーに接続することにより、これが正しく行われたことを確認する必要があります(サーバーで別のパスワードを使用した場合はパスワードを使用してください):
[[email protected] ~]# psql --host=127.0.0.1 --dbname=mattermost --username=mmuser --password
Password for user mmuser:
psql (9.2.15)
Type "help" for help.
mattermost=> \q
[[email protected] ~]#
これで、PostgreSQLサーバーとデータベースでMattermostの準備が整いました!
wgetを使用して、Githubリポジトリ(このチュートリアルバージョンの作成時はv2.0.0が現在のバージョンでした)からMattermostサーバーディレクトリのコピーをダウンロードしてみましょう。
[[email protected] ~]# cd
[[email protected] ~]# wget -q "https://github.com/mattermost/platform/releases/download/v2.0.0/mattermost.tar.gz" -O mattermost.tar.gz
次に、アーカイブを抽出し、抽出したファイルをターゲットの場所に配置します(この場合は/ opt / mattermostを使用します)。
[[email protected] ~]# tar -xvzf mattermost.tar.gz
[[email protected] ~]# mv mattermost /opt
Mattermostのインストール
Mattermostデーモンを実行するユーザーを作成します
後でMattermostをデーモンとして実行します。したがって、システムに「 mattermost」という名前の新しいユーザーを設定します。 '。後で最も重要なインスタンスを実行します。次のコマンドを実行して、システムユーザーとグループを作成します'最も重要 ':
[[email protected] ~]# useradd -r mattermost -U -s /sbin/nologin
Mattermostのデータストレージフォルダーを作成します
Mattermostは、データの一部を保存したいと考えています。アップロードしたファイルなどをフォルダに保存します。したがって、そのフォルダを作成する必要があります。ハードドライブのどこにあってもかまいませんが、ユーザーがアクセスできる必要があります' '。 '/ opt / mattermost/data'を使用することにしました。次のコマンドでフォルダを作成します:
[[email protected] ~]# mkdir -p /opt/mattermost/data
ここで、最も重要なディレクトリのグループと所有者を、以前に作成したユーザーとグループに設定します。
[[email protected] ~]# chown -R mattermost:mattermost /opt/mattermost
[[email protected] ~]# chmod -R g+w /opt/mattermost
MattermostにPostgreSQLデータベースへの接続方法を指示するには、構成ファイルを編集する必要があります。
/opt/mattermost/config/config.json
' SqlSettingsセクションを見つけてください 'そしてそれを私たちのニーズに合わせて変更します:
前
"SqlSettings": {
"DriverName": "mysql",
"DataSource": "mmuser:[email protected](dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8",
"DataSourceReplicas": [],
"MaxIdleConns": 10,
"MaxOpenConns": 10,
"Trace": false,
"AtRestEncryptKey": "7rAh6iwQCkV4cA1Gsg3fgGOXJAQ43QVg"
},
後
"SqlSettings": {
"DriverName": "postgres",
"DataSource": "postgres://mmuser:[email protected]:5432/mattermost?sslmode=disable&connect_timeout=10",
"DataSourceReplicas": [],
"MaxIdleConns": 10,
"MaxOpenConns": 10,
"Trace": false,
"AtRestEncryptKey": "7rAh6iwQCkV4cA1Gsg3fgGOXJAQ43QVg"
},
AtRestEncryptKeyを離れることができます そのまま!
ここでも、構成ファイルを編集する必要があります
/opt/mattermost/config/config.json
「EmailSettings」セクションを見つけて、必要に応じて変更します:
前
"EmailSettings": {
"EnableSignUpWithEmail": true,
"EnableSignInWithEmail": true,
"EnableSignInWithUsername": false,
"SendEmailNotifications": false,
"RequireEmailVerification": false,
"FeedbackName": "",
"FeedbackEmail": "",
"SMTPUsername": "",
"SMTPPassword": "",
"SMTPServer": "",
"SMTPPort": "",
"ConnectionSecurity": "",
"InviteSalt": "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS",
"PasswordResetSalt": "vZ4DcKyVVRlKHHJpexcuXzojkE5PZ5eL",
"SendPushNotifications": false,
"PushNotificationServer":
},
後
"EmailSettings": {
"EnableSignUpWithEmail": true,
"EnableSignInWithEmail": true,
"EnableSignInWithUsername": false,
"SendEmailNotifications": false,
"RequireEmailVerification": false,
"FeedbackName": "",
"FeedbackEmail": "",
"SMTPUsername": "",
"SMTPPassword": "",
"SMTPServer": "127.0.0.1",
"SMTPPort": "25",
"ConnectionSecurity": "",
"InviteSalt": "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS",
"PasswordResetSalt": "vZ4DcKyVVRlKHHJpexcuXzojkE5PZ5eL",
"SendPushNotifications": false,
"PushNotificationServer": ""
},
127.0.0.1を使用します およびポート25 外部に電子メールを送信できるようにすでに構成されているローカルのpostfixインストールを使用しているためです。ここで設定が異なる場合は、正しい値を設定する必要があります!
内部インターフェイス(127.0.0.1)でのみリッスンするようにmattermostを構成します
デフォルトでは、Mattermostサーバーインスタンスはポート8065(:8065)のすべてのインターフェイスでリッスンします。 Nginx-Serverを最も重要なものの前に置きたいので、ローカルホスト(127.0.0.1:8065)でのみリッスンするようにこの動作を変更します。
行を変更するだけです
"ListenAddress": ":8065",
に
"ListenAddress": "127.0.0.1:8065",
config.jsonファイル内。
これで、コマンドラインから実行することで最も重要なサーバーが起動するかどうかをテストできます。必ず、これをユーザー「mattermost」として実行してください。誤ってこれを「root」として行った場合は、最も重要なフォルダーのアクセス許可を再度修正する必要があります!
[[email protected] ~]# su - mattermost -s /bin/bash
Last login: Fri Mar 4 12:47:52 CET 2016 on pts/0
su: warning: cannot change directory to /home/mattermost: No such file or directory
-bash-4.2$
次に、最も重要なインストールディレクトリに移動します:
-bash-4.2$ cd /opt/mattermost/bin/
そして、コマンドラインから最も重要なことを実行します:
-bash-4.2$ ./platform
出力は次のようになります。
[2016/03/04 13:00:10 CET] [INFO] Loaded system translations for 'en' from '/opt/mattermost/i18n/en.json'
[2016/03/04 13:00:10 CET] [INFO] Current version is 2.0.0 (5950/Sat Feb 13 15:42:01 UTC 2016/c71c5cef632c7dc68072167c6fe091a60835fa02)
[2016/03/04 13:00:10 CET] [INFO] Enterprise Enabled: false
[2016/03/04 13:00:10 CET] [INFO] Current working directory is /opt/mattermost/bin
[2016/03/04 13:00:10 CET] [INFO] Loaded config file from /opt/mattermost/config/config.json
[2016/03/04 13:00:10 CET] [INFO] Server is initializing...
[2016/03/04 13:00:10 CET] [INFO] Pinging sql master database
[2016/03/04 13:00:10 CET] [INFO] Pinging sql replica-0 database
[2016/03/04 13:00:10 CET] [DEBG] Deleting any unused pre-release features
[2016/03/04 13:00:10 CET] [INFO] The database schema has been set to version 2.0.0
[2016/03/04 13:00:10 CET] [DEBG] Initializing user api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing team api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing channel api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing post api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing web socket api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing file api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing command api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing admin api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing oauth api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing webhook api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing preference api routes
[2016/03/04 13:00:10 CET] [DEBG] Initializing license api routes
[2016/03/04 13:00:10 CET] [DEBG] Parsing server templates at /opt/mattermost/api/templates/
[2016/03/04 13:00:10 CET] [DEBG] Initializing web routes
[2016/03/04 13:00:10 CET] [DEBG] Using static directory at /opt/mattermost/web/static/
[2016/03/04 13:00:10 CET] [DEBG] Parsing templates at /opt/mattermost/web/templates/
[2016/03/04 13:00:10 CET] [INFO] Starting Server...
[2016/03/04 13:00:10 CET] [INFO] Server is listening on 127.0.0.1:8065
[2016/03/04 13:00:10 CET] [INFO] RateLimiter is enabled
[2016/03/04 13:00:10 CET] [DEBG] Checking for security update from Mattermost
[2016/03/04 13:00:10 CET] [EROR] Failed to get security update information from Mattermost.
Ctrl + C
で最も重要なサーバーを停止します次に、ユーザー「mattermost」として開始したシェルを次のように終了します:
-bash-4.2$ exit
logout
[[email protected] ~]#
最も重要なインスタンスが起動しない場合は、出力を注意深く読んでください。 config.jsonの単純なコンマを忘れたため、多くの問題が発生しました。また、dbuserのパスワードに特殊文字を使用しないように注意してください。特に' @は使用しないでください。 ' サイン。それは最初は私を奇妙にさせました!
上記のコマンドを誤って'rootとして実行した場合 'そしてそれもうまくいくかもしれませんが、最も重要なフォルダの権限を再修正する必要があります。この間違いに遭遇した場合は、次のコマンドを使用してください:
[[email protected] ~]# chown -R mattermost:mattermost /opt/mattermost
すべてがうまくいけば、続行できます。
Mattermostをデーモンとして設定するには、ファイルを作成します
/etc/systemd/system/mattermost.service
次の内容で:
[Unit]
Description=Mattermost
After=syslog.target network.target
[Service]
Type=simple
WorkingDirectory=/opt/mattermost/bin
User=mattermost
ExecStart=/opt/mattermost/bin/platform
PIDFile=/var/spool/mattermost/pid/master.pid
[Install]
WantedBy=multi-user.target
次に、デーモンファイルを次のようにリロードします。
[[email protected] ~]# systemctl daemon-reload
これで、開始/停止/有効化/無効化できます このサービスは、私たちが慣れ親しんでいるものです。
それでは、Mattermostを起動し、そのステータスを取得してから、サービスとして有効にします(自動開始)。
最も重要なデーモンを起動する
[[email protected] ~]# systemctl start mattermost.service
最も重要なステータスを確認する
[[email protected] ~]# systemctl status mattermost.service
? mattermost.service - Mattermost
Loaded: loaded (/etc/systemd/system/mattermost.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2016-03-04 14:03:40 CET; 4s ago
Main PID: 18573 (platform)
CGroup: /system.slice/mattermost.service
??18573 /opt/mattermost/bin/platform
...
...
アクティブ(実行中)であることを確認してください !
デーモンの自動起動を有効にする
[[email protected] ~]# systemctl enable mattermost.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mattermost.service to /etc/systemd/system/mattermost.service.
ここで、次のコマンドを実行して、Mattermostが127.0.0.1:8065をリッスンしているかどうかをテストします。
[[email protected] config]# curl -s "http://127.0.0.1:8065" | grep -b "2015 Mattermost"
'2015Mattermost'を含む1行を取得する必要があります。
11343: <span class="pull-right footer-link copyright">© 2015 Mattermost, Inc.</span>
もしそうなら、Mattermostサーバーインスタンスが実行されていることを確認でき、続行できます。
SELinux関連のパーミッションの問題を修正
CentOS7では、SELinuxはデフォルトで有効になっています。完全にオフにすることもできますが、再構成してMattermostサーバーを実行できるようにすることをお勧めします。
次の2つのコマンドを入力するだけで、SELinuxのアクセス許可を修正できます。
[[email protected] config]# chcon -Rt httpd_sys_content_t /opt/mattermost/
[[email protected] config]# setsebool -P httpd_can_network_connect 1
Nginxサーバーのセットアップ
NginxサーバーをMattermostサーバーインスタンスの前に配置します。
主な利点は次のとおりです。
- ポートマッピング:80から:8065
- 標準のリクエストログ
- 後でSSLに切り替える際のその他のオプション
epel-repositoryを有効にする
NginxはCentOSのデフォルトのリポジトリにはありません。したがって、最初にepelリポジトリを有効にする必要があります。これは簡単な作業です。次のように入力してください。
[[email protected] config]# yum -y install epel-release && yum update
epel-releaseを有効にした後、次のコマンドを使用してnginxをインストールできます。
[[email protected] config]# yum -y install nginx
これにより、nginxとそのすべての依存関係がインストールされます。
Nginxを構成する方法はたくさんあります。このチュートリアルでは、ポート80でMattermostサーバーをホストするだけのNginxの非常に簡単なセットアップを作成する方法を示します。
Nginxのデフォルト構成ファイルを変更する
現在のnginx.confのバックアップを作成します 実行することにより:
[[email protected] config]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
次に、 /etc/nginx/nginx.confを置き換えます このコンテンツで:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
server_name mattermost.example.com;
location / {
client_max_body_size 50M;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://127.0.0.1:8065;
}
}
}
このドキュメントで前述したように、正しいホスト名を使用していることを確認してください。
構成ファイルに構文エラーがないことを確認するには、次のコマンドを実行して構文を確認します。
[[email protected] config]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
デーモンとしてNginxを起動して有効にします
Nginxを起動
[[email protected] config]# systemctl start nginx
ステータスを確認する
[[email protected] config]# systemctl status nginx
少なくとも次の行を出力することを確認してください:
...
Active: active (running)...
...
デーモンとして有効にする
[[email protected] config]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
すべてがうまくいけば、Nginxの背後で動作するMattermostインストールが実行されているはずです。ブラウザで次のURLを開いて確認します:
http://mattermost.example.com
Mattermostログイン画面が表示されます!
これで、メールアドレスを入力してアカウントを作成することで、Mattermostインストールのセットアップを続行できます。
このチュートリアルの前半で、firewalldを無効にしました。再度有効にしたいが、ポート80を開いたままにしておきたい場合(現在、Nginx経由でMattermostに使用しています)、次のようにします。
Firewalldを起動して再度有効にします
[[email protected] config]# systemctl start firewalld
[[email protected] config]# systemctl enable firewalld
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/basic.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
ファイアウォールでポート80を開く
[[email protected] config]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[[email protected] config]# firewall-cmd --reload
success
これで、Firewalldが実行されていても、Mattermostインストールにアクセスできるはずです!
このチュートリアルがお役に立てば幸いです。本番環境では、Mattermostウェブサイトの証明書を作成/使用し、Nginxを介してhttpsを有効にする必要があります。これは、このハウツーを少し変更することで簡単に実現できます。