検索
ホームページデータベースmysql チュートリアルUsing MySQL Sandbox to setup a MySQL Fabric cluster in devel_MySQL

With Fabric's official GA release this week, I thought I would post a spin on how to setup a development environment loosely based on theFabric Quick Start guidein the manual.

The notable change, is the use of MySQL Sandbox for bootstrapping each of the MySQL instances.

Step 1: Install the MySQL Utilities + Python Connector

In my case, I downloaded:

  • mysql-utilities-1.4.3-osx10.7.dmgMac OS X 10.7 (Architecture Independent), DMG Archive
  • mysql-connector-python-1.2.2-osx10.7.dmgMac OS X 10.7 (Architecture Independent), DMG Archive

The GUI install in both cases works as expected. Next, Next, Done!

Step 2: Install MySQL Sandbox

MySQL Sandboxis available viaLaunchpadorCPAN. There isn't a major difference between the two, but I happened to choose CPAN.

The advantage of installing Sandbox over a utility such asmysqld_multi, is that it's much easier to setup and tear down replication.

Step 3: Download a 5.6 tarball

In my case, I downloadedmysql-5.6.17-osx10.7-x86.tar.gzMac OS X 10.7 (x86, 32-bit), Compressed TAR Archive. On Mac OS X it is useful to use Google Chrome rather than Safari, as you do not want the file automatically decompressed.

Important:Download only! MySQL Sandbox does the install in the next step.

Step 4: Setup the Fabric Backing Store

The first copy of MySQL to setup is the MySQL Fabric backing store. This will house thefabricschema which stores configuration data. Here is the setup line I used:

$ <strong>make_sandbox mysql-5.6.17-osx10.7-x86.tar.gz</strong>unpacking /Users/morgo/Downloads/mysql-5.6.17-osx10.7-x86.tar.gzExecuting low_level_make_sandbox --basedir=/Users/morgo/Downloads/5.6.17 /	--sandbox_directory=msb_5_6_17 /	--install_version=5.6 /	--sandbox_port=5617 /	--no_ver_after_name /	--my_clause=log-error=msandbox.err	The MySQL Sandbox,version 3.0.43	(C) 2006-2013 Giuseppe Maxiainstalling with the following parameters:upper_directory				= /Users/morgo/sandboxessandbox_directory			= msb_5_6_17sandbox_port				 = 5617check_port					 =no_check_port				=datadir_from				 = scriptinstall_version				= 5.6basedir						= /Users/morgo/Downloads/5.6.17tmpdir						 =my_file						=operating_system_user		= morgodb_user						= msandboxremote_access				= 127.%bind_address				 = 127.0.0.1ro_user						= msandbox_rorw_user						= msandbox_rwrepl_user					= rsandboxdb_password					= msandboxrepl_password				= rsandboxmy_clause					= log-error=msandbox.errmaster						 =slaveof						=high_performance			 =prompt_prefix				= mysqlprompt_body					=[/h] {/u} (/d) >force						=no_ver_after_name			= 1verbose						=load_grants					= 1no_load_grants				 =no_run						 =no_show						=do you agree? ([Y],n) Yloading grants.. sandbox server startedYour sandbox server was installed in $HOME/sandboxes/msb_5_6_17

Using a configuration similar to the MySQL manual, with the password simply beingsecretI saved the following to/etc/mysql/fabric.cfg:

[DEFAULT]prefix =sysconfdir = /etclogdir = /var/log[storage]address = localhost:5617user = fabricpassword = secretdatabase = fabricauth_plugin = mysql_native_passwordconnection_timeout = 6connection_attempts = 6connection_delay = 1[servers]user = fabricpassword = secret[protocol.xmlrpc]address = localhost:32274threads = 5user = adminpassword = secretdisable_authentication = norealm = MySQL Fabricssl_ca =ssl_cert =ssl_key =[executor]executors = 5[logging]level = INFOurl = file:///var/log/fabric.log[sharding]mysqldump_program = /usr/bin/mysqldumpmysqlclient_program = /usr/bin/mysql[statistics]prune_time = 3600[failure_tracking]notifications = 300notification_clients = 50notification_interval = 60failover_interval = 0detections = 3detection_interval = 6detection_timeout = 1prune_time = 3600[connector]ttl = 1[client]password =

I also need to create the user in MySQL for Fabric to connect as:

$ <strong>$HOME/sandboxes/msb_5_6_17/use -uroot</strong>Welcome to the MySQL monitor.Commands end with ; or /g.Your MySQL connection id is 5Server version: 5.6.17 MySQL Community Server (GPL)Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql [localhost] {root} ((none)) > <strong>CREATE USER 'fabric'@'localhost' IDENTIFIED BY 'secret';</strong>Query OK, 0 rows affected (0.01 sec)mysql [localhost] {root} ((none)) > <strong>GRANT ALL ON fabric.* TO 'fabric'@'localhost';</strong>Query OK, 0 rows affected (0.00 sec)

Fabric can then install the system tables, and be started with:

$ <strong>mysqlfabric manage setup</strong>[INFO] 1401222720.664261 - MainThread - Initializing persister: user (fabric), server (localhost:5617), database (fabric).[INFO] 1401222721.245034 - MainThread - Initial password for admin/xmlrpc setPassword set for admin/xmlrpc from configuration file.[INFO] 1401222721.247700 - MainThread - Password set for admin/xmlrpc from configuration file.$ <strong>mysqlfabric manage start</strong>[INFO] 1401222753.862997 - MainThread - Initializing persister: user (fabric), server (localhost:5617), database (fabric).[INFO] 1401222753.867357 - MainThread - Loading Services.[INFO] 1401222753.902501 - MainThread - Fabric node starting.[INFO] 1401222753.910188 - MainThread - Starting Executor.[INFO] 1401222753.910300 - MainThread - Setting 5 executor(s).[INFO] 1401222753.910602 - Executor-0 - Started.[INFO] 1401222753.911354 - Executor-1 - Started.[INFO] 1401222753.912450 - Executor-2 - Started.[INFO] 1401222753.913185 - Executor-3 - Started.[INFO] 1401222753.914456 - Executor-4 - Started.[INFO] 1401222753.914701 - MainThread - Executor started.[INFO] 1401222753.927123 - MainThread - Starting failure detector.[INFO] 1401222753.928365 - XML-RPC-Server - XML-RPC protocol server ('127.0.0.1', 32274) started.[INFO] 1401222753.928731 - XML-RPC-Server - Setting 5 XML-RPC session(s).[INFO] 1401222753.928991 - XML-RPC-Session-0 - Started XML-RPC-Session.[INFO] 1401222753.929455 - XML-RPC-Session-1 - Started XML-RPC-Session.[INFO] 1401222753.930168 - XML-RPC-Session-2 - Started XML-RPC-Session.[INFO] 1401222753.930747 - XML-RPC-Session-3 - Started XML-RPC-Session.[INFO] 1401222753.931320 - XML-RPC-Session-4 - Started XML-RPC-Session.

Step 5: Build out a HA group

The next step is to bootstrap a 3-node replication sandbox, and then add it as a HA Group in Fabric.

First with MySQL Sandbox:

$ <strong>make_replication_sandbox mysql-5.6.17-osx10.7-x86.tar.gz</strong>installing and starting masterinstalling slave 1installing slave 2starting slave 1.. sandbox server startedstarting slave 2.. sandbox server startedinitializing slave 1initializing slave 2replication directory installed in $HOME/sandboxes/rsandbox_mysql-5_6_17$ <strong>$HOME/sandboxes/rsandbox_mysql-5_6_17/m -uroot</strong>Welcome to the MySQL monitor.Commands end with ; or /g.Your MySQL connection id is 5Server version: 5.6.17-log MySQL Community Server (GPL)Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.master [localhost] {root} ((none)) > <strong>GRANT ALL ON *.* TO 'fabric'@'localhost' IDENTIFIED BY 'secret';</strong>Query OK, 0 rows affected (0.01 sec)master [localhost] {root} ((none)) > <strong>SHOW GLOBAL VARIABLES LIKE 'port';</strong>+---------------+-------+| Variable_name | Value |+---------------+-------+| port| 20082 |+---------------+-------+1 row in set (0.00 sec)master [localhost] {root} ((none)) > <strong>exit</strong>Bye

Then with MySQL Fabric:

$ <strong>mysqlfabric group create GLOBAL1</strong>Procedure :{ uuid= 23593cf1-c516-46ef-beaa-516b333353ca,finished= True,success = True,return= True,activities=}$ <strong>mysqlfabric group add GLOBAL1 localhost:20082</strong>Procedure :{ uuid= e72decdf-6524-45b4-9eb6-6d757c0daf3a,finished= True,success = False,return= ServerError: Server (e208ca4a-e5df-11e3-9dd5-4cd7500a4330) does not have the binary log or gtid enabled.,activities=}

An error! What this error is saying, is that Fabric is designed to specifically take advantage of Replication with GTIDs which are designed to handle smoother failover if the topology changes. Thankfully, MySQL Sandbox has an easy way of being able toswitch to GTIDs:

$ <strong>$HOME/sandboxes/rsandbox_mysql-5_6_17/enable_gtid</strong># option 'master-info-repository=table' added to master configuration file# option 'relay-log-info-repository=table' added to master configuration file# option 'gtid_mode=ON' added to master configuration file# option 'log-slave-updates' added to master configuration file# option 'enforce-gtid-consistency' added to master configuration file# option 'master-info-repository=table' added to node1 configuration file# option 'relay-log-info-repository=table' added to node1 configuration file# option 'gtid_mode=ON' added to node1 configuration file# option 'log-slave-updates' added to node1 configuration file# option 'enforce-gtid-consistency' added to node1 configuration file# option 'master-info-repository=table' added to node2 configuration file# option 'relay-log-info-repository=table' added to node2 configuration file# option 'gtid_mode=ON' added to node2 configuration file# option 'log-slave-updates' added to node2 configuration file# option 'enforce-gtid-consistency' added to node2 configuration file# executing "stop" on /Users/morgo/sandboxes/rsandbox_mysql-5_6_17executing "stop" on slave 1executing "stop" on slave 2executing "stop" on master# executing "start" on /Users/morgo/sandboxes/rsandbox_mysql-5_6_17executing "start" on master. sandbox server startedexecuting "start" on slave 1. sandbox server startedexecuting "start" on slave 2. sandbox server started

With this change, adding servers to Fabric will now work:

$ <strong>mysqlfabric group add GLOBAL1 localhost:20082</strong>Procedure :{ uuid= c9da0536-0f3f-4d75-9f29-1ac6c12ff686,finished= True,success = True,return= True,activities=}$ <strong>mysqlfabric group add GLOBAL1 localhost:20083</strong>Procedure :{ uuid= 92b42645-311f-423b-86b4-3a56870db244,finished= True,success = True,return= True,activities=}$ <strong>mysqlfabric group add GLOBAL1 localhost:20084</strong>Procedure :{ uuid= 1f16a586-4a60-4b7d-a339-be3830614984,finished= True,success = True,return= True,activities=}

We can find group commands with:

$ <strong>mysqlfabric group</strong>Commands available in group 'group' are:	group activate group_id[--synchronous]	group description group_id[--description=NONE] [--synchronous]	group deactivate group_id[--synchronous]	group create group_id[--description=NONE] [--synchronous]	group remove group_id server_id[--synchronous]	group add group_id address[--timeout=5] [--update_only] [--synchronous]	group health group_id	group lookup_servers group_id[--server_id=NONE] [--status=NONE] [--mode=NONE]	group destroy group_id[--force] [--synchronous]	group demote group_id[--update_only] [--synchronous]	group promote group_id[--slave_id=NONE] [--update_only] [--synchronous]	group lookup_groups[--group_id=NONE]

Of which the useful option will be to list the servers in our groupGLOBAL1:

$ <strong>mysqlfabric group lookup_servers GLOBAL1</strong>Command :{ success = Truereturn= [{'status': 'SECONDARY', 'server_uuid': 'e208ca4a-e5df-11e3-9dd5-4cd7500a4330', 'mode': 'READ_ONLY', 'weight': 1.0, 'address': 'localhost:20082'}, {'status': 'SECONDARY', 'server_uuid': 'e931694e-e5df-11e3-9dd5-4cd64dfe115b', 'mode': 'READ_ONLY', 'weight': 1.0, 'address': 'localhost:20083'}, {'status': 'SECONDARY', 'server_uuid': 'ea61dfba-e5df-11e3-9dd5-4bd23bb2cbe3', 'mode': 'READ_ONLY', 'weight': 1.0, 'address': 'localhost:20084'}]activities=}

The UUID in use here, is the same one that is used for Replication with GTIDs. To promote the first server as a master:

$ <strong>mysqlfabric group promote GLOBAL1 --slave_id=e208ca4a-e5df-11e3-9dd5-4cd7500a4330</strong>Procedure :{ uuid= be791f70-be3e-4ee9-9872-e1cedce36791,finished= True,success = True,return= True,activities=}$ <strong>mysqlfabric group lookup_servers GLOBAL1</strong>Command :{ success = Truereturn= [{'status': 'PRIMARY', 'server_uuid': 'e208ca4a-e5df-11e3-9dd5-4cd7500a4330', 'mode': 'READ_WRITE', 'weight': 1.0, 'address': 'localhost:20082'}, {'status': 'SECONDARY', 'server_uuid': 'e931694e-e5df-11e3-9dd5-4cd64dfe115b', 'mode': 'READ_ONLY', 'weight': 1.0, 'address': 'localhost:20083'}, {'status': 'SECONDARY', 'server_uuid': 'ea61dfba-e5df-11e3-9dd5-4bd23bb2cbe3', 'mode': 'READ_ONLY', 'weight': 1.0, 'address': 'localhost:20084'}]activities=}

Next steps

This How-to can easily be extended tosetup additional HA groups for shards- MySQL Sandbox really simplifies the setup by bootstrapping replication.

One caveat to be aware of: Each copy ofmysqldrunning can take up quite a bit of RAM. It is possible totune this downusing some steps that I mentioned in an earlier post.

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
DockerでのMySQLメモリの使用を減らしますDockerでのMySQLメモリの使用を減らしますMar 04, 2025 pm 03:52 PM

この記事では、DockerのMySQLメモリ使用量を最適化することを調査します。 監視手法(Docker統計、パフォーマンススキーマ、外部ツール)および構成戦略について説明します。 これらには、Dockerメモリの制限、スワッピング、およびcgroupsが含まれます

mysqlの問題を解決する方法共有ライブラリを開くことができませんmysqlの問題を解決する方法共有ライブラリを開くことができませんMar 04, 2025 pm 04:01 PM

この記事では、MySQLの「共有ライブラリを開くことができない」エラーについて説明します。 この問題は、必要な共有ライブラリ(.so/.dllファイル)を見つけることができないMySQLの障害に起因しています。ソリューションには、システムのパッケージMを介してライブラリのインストールを確認することが含まれます。

Alter Tableステートメントを使用してMySQLのテーブルをどのように変更しますか?Alter Tableステートメントを使用してMySQLのテーブルをどのように変更しますか?Mar 19, 2025 pm 03:51 PM

この記事では、MySQLのAlter Tableステートメントを使用して、列の追加/ドロップ、テーブル/列の名前の変更、列データ型の変更など、テーブルを変更することについて説明します。

Linuxでmysqlを実行します(phpmyAdminを使用してポッドマンコンテナを使用して/なし)Linuxでmysqlを実行します(phpmyAdminを使用してポッドマンコンテナを使用して/なし)Mar 04, 2025 pm 03:54 PM

この記事では、PHPMyAdminの有無にかかわらず、LinuxにMySQLを直接インストールするのとPodmanコンテナを使用します。 それは、各方法のインストール手順を詳述し、孤立、携帯性、再現性におけるポッドマンの利点を強調しますが、

sqliteとは何ですか?包括的な概要sqliteとは何ですか?包括的な概要Mar 04, 2025 pm 03:55 PM

この記事では、自己完結型のサーバーレスリレーショナルデータベースであるSQLiteの包括的な概要を説明します。 SQLiteの利点(シンプルさ、移植性、使いやすさ)と短所(同時性の制限、スケーラビリティの課題)を詳しく説明しています。 c

MACOSで複数のMySQLバージョンを実行する:ステップバイステップガイドMACOSで複数のMySQLバージョンを実行する:ステップバイステップガイドMar 04, 2025 pm 03:49 PM

このガイドは、HomeBrewを使用してMacOSに複数のMySQLバージョンをインストールおよび管理することを示しています。 Homebrewを使用して設置を分離し、紛争を防ぐことを強調しています。 この記事では、インストール、開始/停止サービス、および最高のPRAを詳述しています

MySQL接続用のSSL/TLS暗号化を構成するにはどうすればよいですか?MySQL接続用のSSL/TLS暗号化を構成するにはどうすればよいですか?Mar 18, 2025 pm 12:01 PM

記事では、証明書の生成と検証を含むMySQL用のSSL/TLS暗号化の構成について説明します。主な問題は、セルフ署名証明書のセキュリティへの影響を使用することです。[文字カウント:159]

人気のあるMySQL GUIツール(MySQL Workbench、PhpMyAdminなど)は何ですか?人気のあるMySQL GUIツール(MySQL Workbench、PhpMyAdminなど)は何ですか?Mar 21, 2025 pm 06:28 PM

記事では、MySQLワークベンチやPHPMyAdminなどの人気のあるMySQL GUIツールについて説明し、初心者と上級ユーザーの機能と適合性を比較します。[159文字]

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SecLists

SecLists

SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境

EditPlus 中国語クラック版

EditPlus 中国語クラック版

サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません