LoginSignup
1
1

More than 5 years have passed since last update.

FreeNAS 9.3 jail に MariaDB をインストール

Last updated at Posted at 2015-12-30

NL54L + FreeNAS に jail を新しく作って、そこに MariaDB をインストールしました。詳細はわかりませんが MySQL より MariaDB の方が良さそうですので。 ownCloud 動くといいなぁ…

参考文献

FreeBSD 10.0にMariaDB 10をインストールする(pkg install使用)
この通りにやります。

インストール

まずパッケージを確認します。

# pkg search mariadb
mariadb100-client-10.0.22
mariadb100-server-10.0.22
mariadb55-client-5.5.47
mariadb55-server-5.5.47

pkg search の実行直後に、大量の警告メッセージが流れた気がしますが、見なかった事にします☆(jail構築後最初の pkg なので、pkg 自身の設定更新などなどで最初はちょっと小うるさくなるようです)

調べると MariaDB のバージョンは、 5.* の次が 10.0 にジャンプしてるらしいですな。とりあえず最新版を入れましょう。

# pkg install mariadb100-server-10.0.22
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        mariadb100-server: 10.0.22
        libexecinfo: 1.1_3
        mariadb100-client: 10.0.22

The process will require 200 MiB more space.
23 MiB to be downloaded.

Proceed with this action? [y/N]: y

そしてインストール最後に表示されるメッセージはこれ。

Message from mariadb100-server-10.0.22:
************************************************************************

Remember to run mysql_upgrade (with the optional --datadir=<dbdir> flag)
the first time you start the MySQL server after an upgrade from an
earlier version.

MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
my.cnf. Please move existing my.cnf files from those paths to
/usr/local/etc and /usr/local/etc/mysql.

This port does NOT include the mytop perl script, this is included in
the MariaDB tarball but the most recent version can be found in the
databases/mytop port

************************************************************************

起動用の設定。rc.conf 末尾に下記の1行を追加。

/etc/rc.conf
mysql_enable="YES"

起動と設定

# /usr/local/etc/rc.d/mysql-server start
《膨大な起動時メッセージが出るが盛大に省略》
Starting mysql.

ユーザ root パスワード無し が最初のデフォルト設定の模様。そして言語設定を調べてみます。

# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.0.22-MariaDB FreeBSD Ports

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show variables like "char%";
+--------------------------+----------------------------------+
| Variable_name            | Value                            |
+--------------------------+----------------------------------+
| character_set_client     | utf8                             |
| character_set_connection | utf8                             |
| character_set_database   | latin1                           |
| character_set_filesystem | binary                           |
| character_set_results    | utf8                             |
| character_set_server     | latin1                           |
| character_set_system     | utf8                             |
| character_sets_dir       | /usr/local/share/mysql/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.01 sec)

MariaDB [(none)]> quit
Bye

latin1 が混ざってます。これを全部 utf8 に揃えます。個人的には utf8 嫌いなんですが:confounded:(嫌いな理由を語り始めると長くなるので省略)

元設定は my-medium.cnf を選択します。使用メモリを抑制したいので。さすがに my-small.cnf は小さ過ぎるかな。メモリ消費量の目安はヘッダコメントの最初に書いてあります。

# cp /usr/local/share/mysql/my-medium.cnf /usr
/local/etc/my.cnf
# vi /usr/local/etc/my.cnf
《変更内容は下記diff参照》
# diff -U0 /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf
--- /usr/local/share/mysql/my-medium.cnf        2015-12-18 19:00:50.000000000 +0
900
+++ /usr/local/etc/my.cnf       2015-12-30 20:55:48.982741558 +0900
@@ -23,0 +24 @@
+default-character-set=utf8
@@ -30,0 +32,2 @@
+character-set-server=utf8
+skip-character-set-client-handshake

MariaDB を再起動して、設定の反映を確認。

# /usr/local/etc/rc.d/mysql-server restart
Stopping mysql.
Waiting for PIDS: 80261.
Starting mysql.
# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.0.22-MariaDB-log FreeBSD Ports

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show variables like "char%";
+--------------------------+----------------------------------+
| Variable_name            | Value                            |
+--------------------------+----------------------------------+
| character_set_client     | utf8                             |
| character_set_connection | utf8                             |
| character_set_database   | utf8                             |
| character_set_filesystem | binary                           |
| character_set_results    | utf8                             |
| character_set_server     | utf8                             |
| character_set_system     | utf8                             |
| character_sets_dir       | /usr/local/share/mysql/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.00 sec)

MariaDB [(none)]> quit
Bye

綺麗に utf8 で揃いました。やった!:thumbsup:

マシン名設定

MariaDB と直接の関係はありませんが、外部からアクセスできるように名前を与えます。我が家のDNSサーバ環境はこちら。マシン名は maria.machine.example.com にしました。各設定ファイルに下記のように追記します。

(dns.example.com)/etc/namedb/master/machine.example.com
《既存マシンの設定などは省略》
maria   A  《maria のIPアドレス》
(dns.example.com)/etc/namedb/master/named.local
《既存マシンの設定などは省略》
《maria のIPアドレスの4バイト目》 PTR  maria.machine.example.com.

zoneファイル修正後は bind 再起動を忘れずに。

# /etc/rc.d/named restart
1
1
1

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
1
1