申し訳無かったのですが、日々慌ただしく過ごしていて、
これまでMySQL Fabricについて理解仕切れてない部分もあり、
自信をもって話す事が出来なかった。

反省の意味も含めて、きちんとMySQL Fabricを理解する為に検証してみた。
丁度、スウェーデンから来た仲間から、色々とMySQL Fabricの詳細を教えて頂き、
短時間でかなり理解が深まり非常に助かりました。 Thank you very much!!

もう少し検証して、これからMySQL Fabricを使う皆さんに情報提供出来ればと思います。
Fabricはネット企業でMySQL Replicationを運用していた自分からすると、
かなり便利な機能だと思います。 GTIDも良い機能で運用を楽にしてくれましたが、
MySQL Fabricはそれにも増して良い機能です。
実際に開発、ステージング環境で利用して頂き、運用に慣れて頂いたら、
是非本番環境でも利用して頂き、マスターの冗長化、スケールアウトに使ってみて頂ければと思います。
コネクターは、今後更に増えて行く予定です。

connector

mysqlfabricコマンドリスト

-bash-4.2$ mysqlfabric --version
mysqlfabric 1.5.3
-bash-4.2$ mysqlfabric help commands
statistics node             Retrieve statistics on the Fabric node.
statistics group            Retrieve statistics on Procedures.
statistics procedure        Retrieve statistics on Procedures.
group activate              Activate failure detector for server(s) in a group.
group description           Update group's description.
group deactivate            Deactivate failure detector for server(s) in a group.
group create                Create a group.
group remove                Remove a server from a group.
group add                   Add a server into group.
group health                Check if any server within a group has failed and report health
                            information.
group lookup_servers        Return information on existing server(s) in a group.
group destroy               Remove a group.
group demote                Demote the current master if there is one.
group promote               Promote a server into master.
group lookup_groups         Return information on existing group(s).
dump fabric_nodes           Return a list of Fabric servers.
dump shard_index            Return information about the index for all mappings matching any of
                            the patterns provided.
dump sharding_information   Return all the sharding information about the tables passed as
                            patterns.
dump servers                Return information about servers.
dump shard_tables           Return information about all tables belonging to mappings matching any
                            of the provided patterns.
dump shard_maps             Return information about all shard mappings matching any of the
                            provided patterns.
manage teardown             Teardown Fabric Storage System.
manage stop                 Stop the Fabric server.
manage setup                Setup Fabric Storage System.
manage ping                 Check whether Fabric server is running or not.
manage start                Start the Fabric server.
manage logging_level        Set logging level.
server set_mode             Set a server's mode.
server clone                Clone the objects of a given server into a destination server.
server list                 Return information on existing machine(s) created by a provider.
server set_weight           Set a server's weight.
server lookup_uuid          Return server's uuid.
server set_status           Set a server's status.
server destroy              Destroy a virtual machine instance.
server create               Create a virtual machine instance:  mysqlfabric server create provider
                            --image name=image-mysql         --flavor
                            name=vm-template --meta db=mysql --meta
                            version=5.
role list                   List roles and associated permissions
user roles                  Change roles for a Fabric user  * protocol: Protocol of the user (for
                            example 'xmlrpc') * roles: Comma separated
                            list of roles, IDs or names (see `role
                            list`)
user usercommand            Base class for all user commands
user list                   List users and their roles
user add                    Add a new Fabric user.
user password               Change password of a Fabric user.
user delete                 Delete a Fabric user.
threat report_error         Report a server error.
threat report_failure       Report with certantity that a server has failed or is unreachable.
provider unregister         Unregister a provider.
provider register           Register a provider.
provider list               Return information on existing provider(s).
sharding list_definitions   Lists all the shard mapping definitions.
sharding remove_definition  Remove the shard mapping definition represented by the Shard Mapping
                            ID.
sharding move_shard         Move the shard represented by the shard_id to the destination group.
sharding disable_shard      Disable a shard.
sharding remove_table       Remove the shard mapping represented by the Shard Mapping object.
sharding split_shard        Split the shard represented by the shard_id into the destination
                            group.
sharding create_definition  Define a shard mapping.
sharding add_shard          Add a shard.
sharding add_table          Add a table to a shard mapping.
sharding lookup_table       Fetch the shard specification mapping for the given table
sharding enable_shard       Enable a shard.
sharding remove_shard       Remove a Shard.
sharding list_tables        Returns all the shard mappings of a particular sharding_type.
sharding prune_shard        Given the table name prune the tables according to the defined
                            sharding specification for the table.
sharding lookup_servers     Lookup a shard based on the give sharding key.
snapshot destroy            Destroy snapshot images associated to a machine.
snapshot create             Create a snapshot image from a machine.
event trigger               Trigger an event.
event wait_for_procedures   Wait until procedures, which are identified through their uuid in a
                            list and separated by comma, finish their
                            execution.
-bash-4.2$ 


Fabricで模擬障害を発生させた状態
MySQLFabric

ループさせたスクリプトが数秒で元に戻り、無事にマスターが切り替わっている事を確認出来た
Switch

スレーブの追加

[root@Fabric01 fabric]# mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
1711c4ac-7cd7-11e4-b640-08002766cefe 127.0.0.1:63301   PRIMARY READ_WRITE    1.0
17b7d8c5-7cd7-11e4-b640-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
183d8f8b-7cd7-11e4-b640-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0


[root@Fabric01 fabric]# mysqlfabric group add global 127.0.0.1:63304
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                                uuid finished success result
------------------------------------ -------- ------- ------
5f8a1955-17de-48cf-af49-50a6fe82d08f        1       1      1

state success          when                                                   description
----- ------- ------------- -------------------------------------------------------------
    3       2 1417822757.64 Triggered by <mysql.fabric.events.Event object at 0x2266410>.
    4       2 1417822757.64                               Executing action (_add_server).
    5       2  1417822757.9                                Executed action (_add_server).


[root@Fabric01 fabric]# mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
1711c4ac-7cd7-11e4-b640-08002766cefe 127.0.0.1:63301   PRIMARY READ_WRITE    1.0
17b7d8c5-7cd7-11e4-b640-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
183d8f8b-7cd7-11e4-b640-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
18da4983-7cd7-11e4-b640-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0


[root@Fabric01 fabric]# 

スレーブ追加後は読み込みも分散されている事を確認出来た。
ノードの追加もスムーズに対応可能

(u'hostname:Fabric01', u'port:63302', u'John:800', u'Doe')
(u'hostname:Fabric01', u'port:63303', u'John:801', u'Doe')
(u'hostname:Fabric01', u'port:63304', u'John:802', u'Doe')

6ノード追加した状態

-bash-4.2$ mysqlfabric group add global 127.0.0.1:63306
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                                uuid finished success result
------------------------------------ -------- ------- ------
5c150bd9-2124-42db-9880-a48099cdb0e6        1       1      1

state success          when                                                   description
----- ------- ------------- -------------------------------------------------------------
    3       2 1418042190.25 Triggered by <mysql.fabric.events.Event object at 0x2a4e410>.
    4       2 1418042190.26                               Executing action (_add_server).
    5       2 1418042190.65                                Executed action (_add_server).


-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
6b22b751-7ed4-11e4-833a-08002766cefe 127.0.0.1:63301   PRIMARY READ_WRITE    1.0
6bb7b696-7ed4-11e4-833a-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
6c57c468-7ed4-11e4-833a-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
6cef3a69-7ed4-11e4-833a-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0
6d8a7a63-7ed4-11e4-833a-08002766cefe 127.0.0.1:63305 SECONDARY  READ_ONLY    1.0
6e2582b7-7ed4-11e4-833a-08002766cefe 127.0.0.1:63306 SECONDARY  READ_ONLY    1.0

-bash-4.2$ 

fabric6

疑似障害でマスターを停止して、Fabricログテーブルを確認してみた

-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
6b22b751-7ed4-11e4-833a-08002766cefe 127.0.0.1:63301   PRIMARY READ_WRITE    1.0
6bb7b696-7ed4-11e4-833a-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
6c57c468-7ed4-11e4-833a-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
6cef3a69-7ed4-11e4-833a-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0
6d8a7a63-7ed4-11e4-833a-08002766cefe 127.0.0.1:63305 SECONDARY  READ_ONLY    1.0
6e2582b7-7ed4-11e4-833a-08002766cefe 127.0.0.1:63306 SECONDARY  READ_ONLY    1.0


-bash-4.2$ kill 2430
-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
6b22b751-7ed4-11e4-833a-08002766cefe 127.0.0.1:63301    FAULTY READ_WRITE    1.0
6bb7b696-7ed4-11e4-833a-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
6c57c468-7ed4-11e4-833a-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
6cef3a69-7ed4-11e4-833a-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0
6d8a7a63-7ed4-11e4-833a-08002766cefe 127.0.0.1:63305 SECONDARY  READ_ONLY    1.0
6e2582b7-7ed4-11e4-833a-08002766cefe 127.0.0.1:63306 SECONDARY  READ_ONLY    1.0


-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
6b22b751-7ed4-11e4-833a-08002766cefe 127.0.0.1:63301    FAULTY READ_WRITE    1.0
6bb7b696-7ed4-11e4-833a-08002766cefe 127.0.0.1:63302   PRIMARY READ_WRITE    1.0
6c57c468-7ed4-11e4-833a-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
6cef3a69-7ed4-11e4-833a-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0
6d8a7a63-7ed4-11e4-833a-08002766cefe 127.0.0.1:63305 SECONDARY  READ_ONLY    1.0
6e2582b7-7ed4-11e4-833a-08002766cefe 127.0.0.1:63306 SECONDARY  READ_ONLY    1.0


-bash-4.2$ 
 mysql> select * from fabric.log order by reported desc limit 0,20;
+----------------------+----------------------------+----------------------+-------------------------------------------------------------------------------------------------------+----------+------+
| subject              | reported                   | reporter             | message                                                                                               | category | type |
+----------------------+----------------------------+----------------------+-------------------------------------------------------------------------------------------------------+----------+------+
| dump.servers         | 2014-12-08 12:53:36.000000 | mysql.fabric.command | Started command (dump, servers).                                                                      |        1 |    0 |
| dump.servers         | 2014-12-08 12:53:36.000000 | mysql.fabric.command | Finished command (dump, servers).                                                                     |        1 |    1 |
| group.lookup_servers | 2014-12-08 12:52:41.000000 | mysql.fabric.command | Started command (group, lookup_servers).                                                              |        1 |    0 |
| group.lookup_servers | 2014-12-08 12:52:41.000000 | mysql.fabric.command | Finished command (group, lookup_servers).                                                             |        1 |    1 |
| dump.servers         | 2014-12-08 12:52:36.000000 | mysql.fabric.command | Started command (dump, servers).                                                                      |        1 |    0 |
| dump.servers         | 2014-12-08 12:52:36.000000 | mysql.fabric.command | Finished command (dump, servers).                                                                     |        1 |    1 |
| dump.servers         | 2014-12-08 12:52:35.000000 | mysql.fabric.command | Started command (dump, servers).                                                                      |        1 |    0 |
| dump.servers         | 2014-12-08 12:52:35.000000 | mysql.fabric.command | Finished command (dump, servers).                                                                     |        1 |    1 |
| group.lookup_servers | 2014-12-08 12:52:35.000000 | mysql.fabric.command | Started command (group, lookup_servers).                                                              |        1 |    0 |
| group.lookup_servers | 2014-12-08 12:52:35.000000 | mysql.fabric.command | Finished command (group, lookup_servers).                                                             |        1 |    1 |
| dump.servers         | 2014-12-08 12:52:34.000000 | mysql.fabric.command | Started command (dump, servers).                                                                      |        1 |    0 |
| dump.servers         | 2014-12-08 12:52:34.000000 | mysql.fabric.command | Finished command (dump, servers).                                                                     |        1 |    1 |
| global               | 2014-12-08 12:52:33.000000 | mysql.fabric.server  | Master has changed from 6b22b751-7ed4-11e4-833a-08002766cefe to 6bb7b696-7ed4-11e4-833a-08002766cefe. |        3 |    3 |
| dump.servers         | 2014-12-08 12:52:33.000000 | mysql.fabric.command | Started command (dump, servers).                                                                      |        1 |    0 |
| dump.servers         | 2014-12-08 12:52:33.000000 | mysql.fabric.command | Finished command (dump, servers).                                                                     |        1 |    1 |
| dump.servers         | 2014-12-08 12:52:30.000000 | mysql.fabric.command | Started command (dump, servers).                                                                      |        1 |    0 |
| dump.servers         | 2014-12-08 12:52:30.000000 | mysql.fabric.command | Finished command (dump, servers).                                                                     |        1 |    1 |
| dump.servers         | 2014-12-08 12:52:28.000000 | mysql.fabric.command | Started command (dump, servers).                                                                      |        1 |    0 |
| dump.servers         | 2014-12-08 12:52:28.000000 | mysql.fabric.command | Finished command (dump, servers).                                                                     |        1 |    1 |
| dump.servers         | 2014-12-08 12:52:06.000000 | mysql.fabric.command | Started command (dump, servers).                                                                      |        1 |    0 |
+----------------------+----------------------------+----------------------+-------------------------------------------------------------------------------------------------------+----------+------+
20 rows in set (0.00 sec)

mysql> 

動作確認中 [ Promote ] 2014/12/12現在

-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
35c1ed6f-80d4-11e4-9043-08002766cefe 127.0.0.1:63301   PRIMARY READ_WRITE    1.0
360cc0ab-80d4-11e4-9043-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
373d787b-80d4-11e4-9044-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
375c9e12-80d4-11e4-9044-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0


-bash-4.2$ mysqlfabric group promote global --slave_id=375c9e12-80d4-11e4-9044-08002766cefe
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                                uuid finished success result
------------------------------------ -------- ------- ------
267fa866-c5c9-4f5c-a5a4-6a9d90711d90        1       1      1

state success          when                                                   description
----- ------- ------------- -------------------------------------------------------------
    3       2  1418262234.4 Triggered by <mysql.fabric.events.Event object at 0x17c8810>.
    4       2  1418262234.4                      Executing action (_define_ha_operation).
    5       2 1418262234.44                       Executed action (_define_ha_operation).
    3       2 1418262234.41 Triggered by <mysql.fabric.events.Event object at 0x1942bd0>.
    4       2 1418262234.44                   Executing action (_check_candidate_switch).
    5       2 1418262234.73                    Executed action (_check_candidate_switch).
    3       2 1418262234.52 Triggered by <mysql.fabric.events.Event object at 0x1942c10>.
    4       2 1418262234.73                       Executing action (_block_write_switch).
    5       2 1418262234.79                        Executed action (_block_write_switch).
    3       2 1418262234.77 Triggered by <mysql.fabric.events.Event object at 0x1942c50>.
    4       2 1418262234.79                       Executing action (_wait_slaves_switch).
    5       2 1418262234.86                        Executed action (_wait_slaves_switch).
    3       2 1418262234.86 Triggered by <mysql.fabric.events.Event object at 0x1942c90>.
    4       2 1418262234.86                      Executing action (_change_to_candidate).
    5       2 1418262236.49                       Executed action (_change_to_candidate).


-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
35c1ed6f-80d4-11e4-9043-08002766cefe 127.0.0.1:63301 SECONDARY  READ_ONLY    1.0
360cc0ab-80d4-11e4-9043-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
373d787b-80d4-11e4-9044-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
375c9e12-80d4-11e4-9044-08002766cefe 127.0.0.1:63304   PRIMARY READ_WRITE    1.0


-bash-4.2$ 



-bash-4.2$ mysqlfabric group health global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                                uuid is_alive    status is_not_running is_not_configured io_not_running sql_not_running io_error sql_error
------------------------------------ -------- --------- -------------- ----------------- -------------- --------------- -------- ---------
35c1ed6f-80d4-11e4-9043-08002766cefe        1 SECONDARY              0                 0              0               0    False     False
360cc0ab-80d4-11e4-9043-08002766cefe        1 SECONDARY              0                 0              0               0    False     False
373d787b-80d4-11e4-9044-08002766cefe        1 SECONDARY              0                 0              0               0    False     False
375c9e12-80d4-11e4-9044-08002766cefe        1   PRIMARY              0                 0              0               0    False     False

issue
-----


-bash-4.2$ 

スレーブはロードバランサーで分散出来るし、障害も分散されていれば気にしないで良いけど、
MySQL Fabricはマスター障害でも自動でマスターを切り替えてくれるので便利です。
また、マスターサーバーの切り替えもコマンドで出来て、マスターサーバーの入れ替えが楽になりそうです。
これから、また色々と勉強と検証重ねていき、皆さんと共有して行きたいと思います。

Bug #75188 Promoteする場合のアプリケーションユーザー権限に関する留意点

参照: http://www-jp.mysql.com/products/enterprise/fabric.html

Comments are closed.

Post Navigation