DRBD9のclient機能を試す
- 2017/09/11
- fumikura
DRBD9の新機能 client機能を試してみました。
client機能は、DRBDストレージを持たないノードに、DRBDリソースをマウントできる機能の様です。
前提
- クライアントノード用にホストmysql01、mysql02を用意する。<\li>
ホストdrbd01~03が持つdrbd領域用のHDDは搭載しない - OS等の構成はホストdrbd01~03と同じ。
- DRBDカーネルモジュール、drbd-util、drbdmanageをインストールしてある状態です。
- 前述の方法にてDRBDリソースmysql-slv(容量10GB)を作成してある。
- mysql01、02にはMariaDBをインストールしてあります。
- mysql01のIPアドレス: 192.168.24.226
- mysql02のIPアドレス: 192.168.24.227
クライアントモードでノードを追加する。
drbd01にて
[root@drbd01 ~]# drbdmanage nmysql01でdrbdmanage で再起動コマンドを実行します。
+----------------------------------------------------------------------------------------+
| Name | Pool Size | Pool Free | | State |
|----------------------------------------------------------------------------------------|
| drbd01 | 51196 | 32092 | | ok |
| drbd02 | 51196 | 32092 | | ok |
| drbd03 | 51196 | 32092 | | ok |
+----------------------------------------------------------------------------------------+
[root@drbd01 ~]# drbdmanage add-node --satellite --no-storage mysql01 192.168.24.226
Operation completed successfully
Operation completed successfully
Host key verification failed.
Give leader time to contact the new node
Operation completed successfully
Operation completed successfully
Join command for node mysql01:
drbdmanage restart
[root@mysql01 ~]# drbdmanage restartdrbd01にて、確認してみると、mysql01がclientとして追加されていることがわかります。サテライトノードとは、DRBDのコントロール用のリソース.drbdctrlを持たないノードの事です。
You are going to shut down the drbdmanaged server process on this node.
Please confirm:
yes/no: yes
Attempting to startup the server through D-Bus activation...
D-Bus connection successful, server is running and reachable
以前のリリースでは、add-nodeサブコマンド実施時に–contorole-nodeオプションにて属するコントロールノードを指定する必要があったようですが、今のリリースでは–contorole-nodeオプションは無くなり、指定する必要がなくなったようです。
ちなみに、–satelliteオプションを利用せずにクライアントノードを追加しようとすると、各ノードでの追加用コマンドを実施した際、.drbdctrlリソース用の領域を作成しようとするので、今回のようにDRBD用の領域を持たないクライアントでは、追加に失敗します。
[root@drbd01 ~]# drbdmanage nクライアントノードへリソースを割り当てるmysql01へDRBDリソースmysql-priを割当ます。
+----------------------------------------------------------------------------------------+
| Name | Pool Size | Pool Free | | State |
|----------------------------------------------------------------------------------------|
| drbd01 | 51196 | 32092 | | ok |
| drbd02 | 51196 | 32092 | | ok |
| drbd03 | 51196 | 32092 | | ok |
| mysql01 | 0 | 0 | | satellite node, no storage |
+----------------------------------------------------------------------------------------+
assignサブコマンドに–clientオプションを付けて実行します。
[root@drbd01 ~]# drbdmanage assign mysql-pri mysql01 --clientクライアントノードでリソースへファイルシステムを作成するmysql01上で、リソースmysql-priにファイルシステムを作成します。
Operation completed successfully
[root@drbd01 ~]# drbdmanage list-assignments
+----------------------------------------------------------------------------------------+
| Node | Resource | Vol ID | | State |
|----------------------------------------------------------------------------------------|
| drbd01 | mysql-pri | * | | ok |
| drbd01 | mysql-slv | * | | ok |
| drbd02 | mysql-pri | * | | ok |
| drbd02 | mysql-slv | * | | ok |
| drbd03 | mysql-pri | * | | ok |
| drbd03 | mysql-slv | * | | ok |
| mysql01 | mysql-pri | * | | client |
+----------------------------------------------------------------------------------------+
リソースの割当まで行うと、mysql01上から、mysql-priのブロックデバイスが参照できます。
list-volumesサブコマンドでブロックデバイスのマイナー番号を確認し、ファイルシステムを作成します。
[root@mysql01 ~]# drbdmanage list-volumesマウントしてMariaDBを起動する。後は、マウントしMariaDBを起動します。
+----------------------------------------------------------------------------------------+
| Name | Vol ID | Size | Minor | | State |
|----------------------------------------------------------------------------------------|
| mysql-pri | 0 | 9.31 GiB | 100 | | ok |
| mysql-slv | 0 | 9.31 GiB | 101 | | ok |
+----------------------------------------------------------------------------------------+
[root@mysql01 ~]# mkfs.xfs /dev/drbd100
meta-data=/dev/drbd100 isize=512 agcount=4, agsize=610352 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=2441406, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
が、/var/lib/mysqlにマウントした場合、ディレクトリのオーナーがmysqlからrootに変わってしまうので、注意してください。
[root@mysql01 ~]# ls -al /var/lib|grep mysqlMariaDBの起動ができました。これでクライアントノードの追加は以上です。
drwxr-xr-x. 2 mysql mysql 6 9月 5 15:55 mysql
[root@mysql01 ~]# mount /dev/drbd100 /var/lib/mysql
[root@mysql01 ~]# ls -al /var/lib|grep mysql
drwxr-xr-x. 2 root root 6 9月 11 09:57 mysql
[root@mysql01 ~]# chown mysql:mysql /var/lib/mysql
[root@mysql01 ~]# systemctl start mariadb
[root@mysql01 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since 月 2017-09-11 10:06:19 JST; 2min 56s ago
Process: 28092 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 28013 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 28091 (mysqld_safe)
CGroup: /system.slice/mariadb.service
tq28091 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mq28249 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin...
9月 11 10:06:13 mysql01 mariadb-prepare-db-dir[28013]: The latest information about ....
9月 11 10:06:13 mysql01 mariadb-prepare-db-dir[28013]: You can find additional infor...:
9月 11 10:06:13 mysql01 mariadb-prepare-db-dir[28013]: http://dev.mysql.com
9月 11 10:06:13 mysql01 mariadb-prepare-db-dir[28013]: Support MariaDB development b...B
9月 11 10:06:13 mysql01 mariadb-prepare-db-dir[28013]: Corporation Ab. You can conta....
9月 11 10:06:13 mysql01 mariadb-prepare-db-dir[28013]: Alternatively consider joinin...:
9月 11 10:06:13 mysql01 mariadb-prepare-db-dir[28013]: http://mariadb.com/kb/en/cont.../
9月 11 10:06:13 mysql01 mysqld_safe[28091]: 170911 10:06:13 mysqld_safe Logging to ...'.
9月 11 10:06:13 mysql01 mysqld_safe[28091]: 170911 10:06:13 mysqld_safe Starting my...ql
9月 11 10:06:19 mysql01 systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@mysql01 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
後は、同様にmysql02のノード追加、mysql-slvのリソース追加を行います。
以上