はじめに
IT関係の仕事をしていると、ちょっとみんなに相談したいことなんかがあります。メールするほどではないし、グループウェアにチャット機能はないし。でもSlackみたいな外部のサービスは利用できない。
そういう時にSlackみたいなチャットツールのMattermostを知り、構築してみました。
サーバの前提条件
今回は、CentOS7(さくらのVPS)を使用しています。
lxcでコンテナ2個作って、1個はmattermost本体、もう1個がMySQL(MariaDBね)にします。
データベースの構築
DB用のLXCコンテナにyumでMySQL(MariaDB)をインストールします。
これは、コマンド一発でOK
$ sudo yum install -y mariadb mariadb-devel mariadb-server mariadb-libs
文字コードを変更しておきます。
/etc/my.cnf
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
character-set-server=utf8 ←追加
次に、MariaDBを起動します。
$ sudo syatemctl start mariadb
対話型で初期設定を進めます。
$ sudo mysql_secure_installation
次にデータベースの作成して、ユーザ作成と権限の設定
$ mysql -u root -p
Password:
MariaDB[(none)]> create database mattermost
MariaDB[(none)]> create user 'userxxx'@'1.1.1.%' identified by 'passwd';
*userxxxは1.1.1.0/24のマシンから接続を許可し、パスワードはpasswdです
MariaDB[(none)]> grant all privileges on mattermost.* to 'userxxx'@'1.1.1.%';
MySQLはデフォルトのエンジンがInnoDBなんですが、これだとFULLTEXTのIndexができず、matermostインストール時にエラーになります。そこで、FULLTEXTのIndexが可能なMyISAMにエンジンを変更します。
MariaDB[(none)]> use mattermost
MariaDB[(none)]> alter table <テーブル名> engine=myisam;
*変更はテーブル単位で行います。とりあえず、show tables;でテーブル名見ながら地道に変更しました。(ワイルドカードが使えなった・・・)
これでデータベースの準備ができました。