The announcement of Percona XtraDB Cluster seems to have generated a fair bit of interest : )
Although the documentation contains more formal instructions for setting up a test cluster, I wanted to share a quick way to set up an ad-hoc cluster on a single machine to help people play with this (imho) rather amazing bit of software.
To do this, you will need kewpie (PXC will have kewpie in-tree soon)
cd basedir;
bzr branch lp:kewpie
edit the file kewpie.py like so:
=== modified file 'kewpie.py' --- kewpie.py 2012-01-09 21:17:09 +0000 +++ kewpie.py 2012-01-11 18:32:17 +0000 @@ -49,9 +49,9 @@ from lib.test_mgmt.execution_management # We base / look for a lot of things based on the location of # the kewpie.py file qp_rootdir = os.path.dirname(os.path.abspath(sys.argv[0])) -#project_name = 'percona-xtradb-cluster' +project_name = 'percona-xtradb-cluster' #project_name = 'xtrabackup' -project_name = None +#project_name = None defaults = get_defaults(qp_rootdir,project_name) variables = test_run_options.parse_qp_options(defaults) variables['qp_root'] = qp_rootdir
Or you may branch kewpie anywhere and simply pass appropriate –basedir and –wsrep-provider-path instructions and use –default-server-type=galera
* A default location of /usr/lib/galera/libgalera_smm.so is assumed
To get your cluster, run the tests with –start-and-exit:
./kewpie.py –start-and-exit
This will start up 3 nodes and join them into a cluster:
percona-xtradb-cluster/kewpie$ ./kewpie.py --start-and-exit Setting --no-secure-file-priv=True for randgen usage... 20120113-125552 INFO Using --no-shm, will not link workdir to shm 20120113-125552 INFO Using mysql source tree: 20120113-125552 INFO basedir: /percona-xtradb-cluster 20120113-125552 INFO clientbindir: /percona-xtradb-cluster/client 20120113-125552 INFO testdir: /percona-xtradb-cluster/kewpie 20120113-125552 INFO server_version: 5.5.17 20120113-125552 INFO server_compile_os: Linux 20120113-125552 INFO server_platform: x86_64 20120113-125552 INFO server_comment: (Source distribution wsrep_22.3.r3683) 20120113-125552 INFO Using default-storage-engine: innodb 20120113-125552 INFO Using testing mode: native 20120113-125552 INFO Processing test suites... 20120113-125552 INFO Found 35 test(s) for execution 20120113-125552 INFO Creating 1 bot(s) 20120113-125604 INFO Taking clean db snapshot... 20120113-125610 INFO Taking clean db snapshot... 20120113-125616 INFO Taking clean db snapshot... 20120113-125621 INFO bot0 server: 20120113-125621 INFO NAME: s0 20120113-125621 INFO MASTER_PORT: 9317 20120113-125621 INFO GALERA_LISTEN_PORT: 9318 20120113-125621 INFO GALERA_RECV_PORT: 9319 20120113-125621 INFO SOCKET_FILE: /percona-xtradb-cluster/kewpie/workdir/bot0/var_s0/my.sock 20120113-125621 INFO VARDIR: /percona-xtradb-cluster/kewpie/workdir/bot0/var_s0 20120113-125621 INFO STATUS: 1 20120113-125621 INFO bot0 server: 20120113-125621 INFO NAME: s1 20120113-125621 INFO MASTER_PORT: 9320 20120113-125621 INFO GALERA_LISTEN_PORT: 9321 20120113-125621 INFO GALERA_RECV_PORT: 9322 20120113-125621 INFO SOCKET_FILE: /percona-xtradb-cluster/kewpie/workdir/bot0/var_s1/my.sock 20120113-125621 INFO VARDIR: /percona-xtradb-cluster/kewpie/workdir/bot0/var_s1 20120113-125621 INFO STATUS: 1 20120113-125621 INFO bot0 server: 20120113-125621 INFO NAME: s2 20120113-125621 INFO MASTER_PORT: 9323 20120113-125621 INFO GALERA_LISTEN_PORT: 9324 20120113-125621 INFO GALERA_RECV_PORT: 9325 20120113-125621 INFO SOCKET_FILE: /percona-xtradb-cluster/kewpie/workdir/bot0/var_s2/my.sock 20120113-125621 INFO VARDIR: /percona-xtradb-cluster/kewpie/workdir/bot0/var_s2 20120113-125621 INFO STATUS: 1 20120113-125621 INFO User specified --start-and-exit. kewpie.py exiting and leaving servers running...
Now for some play:
$ mysql -uroot --protocol=tcp --port=9317 test Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.5.17-log Source distribution wsrep_22.3.r3683 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create table t1 (a int not null auto_increment, primary key(a)); Query OK, 0 rows affected (0.11 sec) mysql> insert into t1 values (),(),(),(),(); Query OK, 5 rows affected (0.06 sec) Records: 5 Duplicates: 0 Warnings: 0 mysql> select * from t1; +----+ | a | +----+ | 1 | | 4 | | 7 | | 10 | | 13 | +----+ 5 rows in set (0.00 sec) mysql> exit; Bye $ mysql -uroot --protocol=tcp --port=9320 test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.5.17-log Source distribution wsrep_22.3.r3683 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select * from t1; +----+ | a | +----+ | 1 | | 4 | | 7 | | 10 | | 13 | +----+ 5 rows in set (0.00 sec) mysql> exit Bye $ mysql -uroot --protocol=tcp --port=9323 test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.5.17-log Source distribution wsrep_22.3.r3683 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select * from t1; +----+ | a | +----+ | 1 | | 4 | | 7 | | 10 | | 13 | +----+ 5 rows in set (0.00 sec) mysql> exit Bye
Should you wish to alter the number of nodes or their configuration, you can edit the percona_tests/cluster_basic/suite_config.py file:
server_requirements = [[],[],[]] server_requests = {'join_cluster':[(0,1), (0,2)]} servers = []
Each ‘[]‘ in the server_requirements list is a server. You can add new servers by adding a new list. If you want specific options, put them into the list representing the server:
[['--innodb-file-per-table']]
You will need to add an entry into the server_requests dictionary as well. If you added a new node and want it in the cluster you would simply change it as follows:
server_requests = {‘join_cluster’:[(0,1), (0,2), (0,3)]}
When you are done, you may use mode=cleanup to kill off any servers:
./kewpie.py --mode=cleanup Setting --no-secure-file-priv=True for randgen usage... Setting --start-dirty=True for cleanup mode... 20120113-132229 INFO Using --start-dirty, not attempting to touch directories 20120113-132229 INFO Using mysql source tree: 20120113-132229 INFO basedir: /percona-xtradb-cluster 20120113-132229 INFO clientbindir: /percona-xtradb-cluster/client 20120113-132229 INFO testdir: /percona-xtradb-cluster/kewpie 20120113-132229 INFO server_version: 5.5.17 20120113-132229 INFO server_compile_os: Linux 20120113-132229 INFO server_platform: x86_64 20120113-132229 INFO server_comment: (Source distribution wsrep_22.3.r3683) 20120113-132229 INFO Using default-storage-engine: innodb 20120113-132229 INFO Using testing mode: cleanup 20120113-132229 INFO Killing pid 17040 from /percona-xtradb-cluster/kewpie/workdir/bot0/var_s0/run/my.pid 20120113-132229 INFO Killing pid 17096 from /percona-xtradb-cluster/kewpie/workdir/bot0/var_s2/run/my.pid 20120113-132229 INFO Killing pid 17070 from /percona-xtradb-cluster/kewpie/workdir/bot0/var_s1/run/my.pid 20120113-132229 INFO Stopping all running servers...
Alternately, you can just let the tests run to ensure some basic functionality. I’ll be writing more about these tests and other testing efforts soon, but I wanted to help people get started with their own explorations.
Happy testing and I hope you dig Percona XtraDB Cluster as much as we do : )
PlanetMySQL Voting: Vote UP / Vote DOWN