├── LICENSE ├── README.md ├── hosts ├── centos-6.8 │ └── Dockerfile └── ubuntu-14.04 │ └── Dockerfile ├── mysql-cluster ├── cluster.py ├── data-node │ ├── Dockerfile │ └── run.sh ├── management-node │ ├── .gitignore │ ├── Dockerfile │ ├── config.ini.in │ └── run.sh └── sql-node │ ├── Dockerfile │ ├── my.cnf │ └── run.sh ├── mysql-repo-server-5.6-centos-6.8 ├── Dockerfile ├── my.cnf ├── mysql-init └── mysql-start ├── mysql-repo-server-5.6-ubuntu-14.04 ├── Dockerfile ├── my.cnf ├── mysql-init └── mysql-start └── sysbench-0.5 └── Dockerfile /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | mysql-docker 2 | ============ 3 | 4 | Docker configurations for running MySQL deployments. 5 | 6 | ## MySQL Flavors 7 | 8 | All MySQL instances are configured to listen on port 3306 (the default), with the following users able to connect from all hosts: 9 | 10 | * root / mysql (the default SUPER user) 11 | * repl / repl (a replication user) 12 | * mem / mem (a MySQL Enterprise Monitor user) 13 | 14 | ### mysql-cluster 15 | 16 | Sets up a MySQL Cluster using the latest Oracle Linux and MySQL Cluster 7.5.4. 17 | 18 | A wrapper script is included that allows you to build and start the cluster: 19 | 20 | ``` 21 | $ cluster.py -h 22 | usage: cluster.py [-h] [--debug] {build,start,stop,clean} ... 23 | 24 | Create a test MySQL Cluster deployment in docker 25 | 26 | positional arguments: 27 | {build,start,stop,clean} 28 | build Build the cluster containers 29 | start Start up the cluster containers 30 | stop Stop the cluster containers for the specified network 31 | clean Stop and remove the cluster containers 32 | 33 | optional arguments: 34 | -h, --help show this help message and exit 35 | --debug Whether to print debug info (default: false) 36 | ``` 37 | 38 | The script takes care of creating the cluster.ini file (using the config.ini.in file as a base template) in the build stage, and then starts up the cluster using the same configuration in the start stage. You must therefore invoke cluster.py with both the build and start corresponding arguments being the same, as the initial number of ndb nodes must be as configured , before the cluster will complete initialization. 39 | 40 | For a simple installation test environment this is as simple as: 41 | 42 | ``` 43 | $ cluster.py build 44 | 2016-10-28T09:05:57.051000: Running: docker build -t markleith/mysql-cluster-mgmd:7.5 -f management-node/Dockerfile management-node 45 | 2016-10-28T09:06:06.495000: Running: docker build -t markleith/mysql-cluster-ndbmtd:7.5 -f data-node/Dockerfile data-node 46 | 2016-10-28T09:06:06.751000: Running: docker build -t markleith/mysql-cluster-sql:7.5 -f sql-node/Dockerfile sql-node 47 | 48 | $ cluster.py start 49 | 2016-10-28T09:06:25.565000: Running: docker network ls 50 | 2016-10-28T09:06:25.622000: Info: mycluster network not found, creating 51 | 2016-10-28T09:06:25.624000: Running: docker network create --subnet=172.18.0.0/16 mycluster 52 | 2016-10-28T09:06:26.031000: Running: docker ps -q -a --filter "name=mycluster-mgmd49" 53 | 2016-10-28T09:06:26.087000: Running: docker run -d -P --net mycluster --name mycluster-mgmd49 --ip 172.18.0.149 -e NODE_ID=49 -e NOWAIT=50 -e CONNECTSTRING= markleith/mysql-cluster-mgmd:7.5 54 | 2016-10-28T09:06:27.585000: Running: docker port mycluster-mgmd49 1186/tcp 55 | 2016-10-28T09:06:27.653000: Running: docker ps -q -a --filter "name=mycluster-mgmd50" 56 | 2016-10-28T09:06:27.706000: Running: docker run -d -P --net mycluster --name mycluster-mgmd50 --ip 172.18.0.150 -e NODE_ID=50 -e NOWAIT=49 -e CONNECTSTRING=mycluster-mgmd49:1186 markleith/mysql-cluster-mgmd:7.5 57 | 2016-10-28T09:06:29.083000: Running: docker port mycluster-mgmd50 1186/tcp 58 | 2016-10-28T09:06:29.146000: Running: docker ps -q -a --filter "name=mycluster-ndbmtd1" 59 | 2016-10-28T09:06:29.203000: Running: docker run -d -P --net mycluster --name mycluster-ndbmtd1 --ip 172.18.0.11 -e NODE_ID=1 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 60 | 2016-10-28T09:06:30.657000: Running: docker port mycluster-ndbmtd1 11860/tcp 61 | 2016-10-28T09:06:30.719000: Running: docker ps -q -a --filter "name=mycluster-ndbmtd2" 62 | 2016-10-28T09:06:30.773000: Running: docker run -d -P --net mycluster --name mycluster-ndbmtd2 --ip 172.18.0.12 -e NODE_ID=2 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 63 | 2016-10-28T09:06:32.729000: Running: docker port mycluster-ndbmtd2 11860/tcp 64 | 2016-10-28T09:06:32.796000: Running: docker ps -q -a --filter "name=mycluster-ndbmtd3" 65 | 2016-10-28T09:06:33.064000: Running: docker run -d -P --net mycluster --name mycluster-ndbmtd3 --ip 172.18.0.13 -e NODE_ID=3 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 66 | 2016-10-28T09:06:34.660000: Running: docker port mycluster-ndbmtd3 11860/tcp 67 | 2016-10-28T09:06:34.723000: Running: docker ps -q -a --filter "name=mycluster-ndbmtd4" 68 | 2016-10-28T09:06:34.790000: Running: docker run -d -P --net mycluster --name mycluster-ndbmtd4 --ip 172.18.0.14 -e NODE_ID=4 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 69 | 2016-10-28T09:06:36.343000: Running: docker port mycluster-ndbmtd4 11860/tcp 70 | 2016-10-28T09:06:36.403000: Running: docker ps -q -a --filter "name=mycluster-sql51" 71 | 2016-10-28T09:06:36.473000: Running: docker run -d -P --net mycluster --name mycluster-sql51 --ip 172.18.0.151 -e NODE_ID=51 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-sql:7.5 72 | 2016-10-28T09:06:45.207000: Running: docker port mycluster-sql51 3306/tcp 73 | 2016-10-28T09:06:45.270000: Running: docker ps -q -a --filter "name=mycluster-sql52" 74 | 2016-10-28T09:06:45.419000: Running: docker run -d -P --net mycluster --name mycluster-sql52 --ip 172.18.0.152 -e NODE_ID=52 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-sql:7.5 75 | 2016-10-28T09:06:47.762000: Running: docker port mycluster-sql52 3306/tcp 76 | 2016-10-28T09:06:47.983000: Info: Started: [ "node" : { "name" : "mycluster-mgmd49", "bound_port" : 33036, "node_type" : "mgmd" } , "node" : { "name" : "mycluster-mgmd50", "bound_port" : 33037, "node_type" : "mgmd" } , "node" : { "name" : "mycluster-ndbmtd1", "bound_port" : 33038, "node_type" : "ndbmtd" } , "node" : { "name" : "mycluster-ndbmtd2", "bound_port" : 33039, "node_type" : "ndbmtd" } , "node" : { "name" : "mycluster-ndbmtd3", "bound_port" : 33040, "node_type" : "ndbmtd" } , "node" : { "name" : "mycluster-ndbmtd4", "bound_port" : 33041, "node_type" : "ndbmtd" } , "node" : { "name" : "mycluster-sql51", "bound_port" : 33042, "node_type" : "sql" } , "node" : { "name" : "mycluster-sql52", "bound_port" : 33043, "node_type" : "sql" } ] 77 | ``` 78 | 79 | By default cluster.py builds and starts a docker network called `mycluster`, and within it a cluster containing 2 management nodes, 4 data nodes and 2 SQL nodes. 80 | 81 | #### Starting multiple clusters 82 | 83 | To start multiple clusters on the same host, we need to have a unique naming scheme for the container names, and a unique network IP range to run each cluster network over. These are provided by the `--name` and `--base-network` parameters (or `-n` and `-b`). 84 | 85 | As long as you provide unique values for the `--base-network` parameter when running both the `build` and `start` commands, and a unique `--name` whilst using `start`, then you can run two clusters of any shape relatively easily: 86 | 87 | ``` 88 | $ cluster.py build --base-network 172.18 --management-nodes 1 --data-nodes 2 --sql-nodes 1 89 | 2016-10-28T10:06:23.308000: Running: docker build -t markleith/mysql-cluster-mgmd:7.5 -f management-node/Dockerfile management-node 90 | 2016-10-28T10:06:32.208000: Running: docker build -t markleith/mysql-cluster-ndbmtd:7.5 -f data-node/Dockerfile data-node 91 | 2016-10-28T10:06:32.539000: Running: docker build -t markleith/mysql-cluster-sql:7.5 -f sql-node/Dockerfile sql-node 92 | 93 | $ cluster.py start --name myc1 --base-network 172.18 --management-nodes 1 --data-nodes 2 --sql-nodes 1 94 | 2016-10-28T10:06:46.656000: Running: docker network ls 95 | 2016-10-28T10:06:46.712000: Info: myc1 network not found, creating 96 | 2016-10-28T10:06:46.714000: Running: docker network create --subnet=172.18.0.0/16 myc1 97 | 2016-10-28T10:06:47.132000: Running: docker ps -q -a --filter "name=myc1-mgmd49" 98 | 2016-10-28T10:06:47.202000: Running: docker run -d -P --net myc1 --name myc1-mgmd49 --ip 172.18.0.149 -e NODE_ID=49 -e NOWAIT=50 -e CONNECTSTRING= markleith/mysql-cluster-mgmd:7.5 99 | 2016-10-28T10:06:48.550000: Running: docker port myc1-mgmd49 1186/tcp 100 | 2016-10-28T10:06:48.619000: Running: docker ps -q -a --filter "name=myc1-ndbmtd1" 101 | 2016-10-28T10:06:48.670000: Running: docker run -d -P --net myc1 --name myc1-ndbmtd1 --ip 172.18.0.11 -e NODE_ID=1 -e CONNECTSTRING=myc1-mgmd49:1186 markleith/mysql-cluster-ndbmtd:7.5 102 | 2016-10-28T10:06:50.211000: Running: docker port myc1-ndbmtd1 11860/tcp 103 | 2016-10-28T10:06:50.298000: Running: docker ps -q -a --filter "name=myc1-ndbmtd2" 104 | 2016-10-28T10:06:50.359000: Running: docker run -d -P --net myc1 --name myc1-ndbmtd2 --ip 172.18.0.12 -e NODE_ID=2 -e CONNECTSTRING=myc1-mgmd49:1186 markleith/mysql-cluster-ndbmtd:7.5 105 | 2016-10-28T10:06:51.838000: Running: docker port myc1-ndbmtd2 11860/tcp 106 | 2016-10-28T10:06:51.889000: Running: docker ps -q -a --filter "name=myc1-sql51" 107 | 2016-10-28T10:06:51.945000: Running: docker run -d -P --net myc1 --name myc1-sql51 --ip 172.18.0.151 -e NODE_ID=51 -e CONNECTSTRING=myc1-mgmd49:1186 markleith/mysql-cluster-sql:7.5 108 | 2016-10-28T10:06:53.389000: Running: docker port myc1-sql51 3306/tcp 109 | 2016-10-28T10:06:53.448000: Info: Started: [ "node" : { "name" : "myc1-mgmd49", "bound_port" : 33052, "node_type" : "mgmd" } , "node" : { "name" : "myc1-ndbmtd1", "bound_port" : 33053, "node_type" : "ndbmtd" } , "node" : { "name" : "myc1-ndbmtd2", "bound_port" : 33054, "node_type" : "ndbmtd" } , "node" : { "name" : "myc1-sql51", "bound_port" : 33055, "node_type" : "sql" } ] 110 | 111 | $ cluster.py build --base-network 172.19 --management-nodes 2 --data-nodes 2 --sql-nodes 2 112 | 2016-10-28T10:07:23.486000: Running: docker build -t markleith/mysql-cluster-mgmd:7.5 -f management-node/Dockerfile management-node 113 | 2016-10-28T10:07:42.201000: Running: docker build -t markleith/mysql-cluster-ndbmtd:7.5 -f data-node/Dockerfile data-node 114 | 2016-10-28T10:07:42.482000: Running: docker build -t markleith/mysql-cluster-sql:7.5 -f sql-node/Dockerfile sql-node 115 | 116 | $ cluster.py start --name myc2 --base-network 172.19 --management-nodes 2 --data-nodes 2 --sql-nodes 2 117 | 2016-10-28T10:07:56.739000: Running: docker network ls 118 | 2016-10-28T10:07:56.798000: Info: myc2 network not found, creating 119 | 2016-10-28T10:07:56.800000: Running: docker network create --subnet=172.19.0.0/16 myc2 120 | 2016-10-28T10:07:57.432000: Running: docker ps -q -a --filter "name=myc2-mgmd49" 121 | 2016-10-28T10:07:57.592000: Running: docker run -d -P --net myc2 --name myc2-mgmd49 --ip 172.19.0.149 -e NODE_ID=49 -e NOWAIT=50 -e CONNECTSTRING= markleith/mysql-cluster-mgmd:7.5 122 | 2016-10-28T10:07:59.850000: Running: docker port myc2-mgmd49 1186/tcp 123 | 2016-10-28T10:07:59.903000: Running: docker ps -q -a --filter "name=myc2-mgmd50" 124 | 2016-10-28T10:07:59.954000: Running: docker run -d -P --net myc2 --name myc2-mgmd50 --ip 172.19.0.150 -e NODE_ID=50 -e NOWAIT=49 -e CONNECTSTRING=myc2-mgmd49:1186 markleith/mysql-cluster-mgmd:7.5 125 | 2016-10-28T10:08:02.066000: Running: docker port myc2-mgmd50 1186/tcp 126 | 2016-10-28T10:08:02.120000: Running: docker ps -q -a --filter "name=myc2-ndbmtd1" 127 | 2016-10-28T10:08:02.187000: Running: docker run -d -P --net myc2 --name myc2-ndbmtd1 --ip 172.19.0.11 -e NODE_ID=1 -e CONNECTSTRING=myc2-mgmd49:1186,myc2-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 128 | 2016-10-28T10:08:04.644000: Running: docker port myc2-ndbmtd1 11860/tcp 129 | 2016-10-28T10:08:04.700000: Running: docker ps -q -a --filter "name=myc2-ndbmtd2" 130 | 2016-10-28T10:08:04.758000: Running: docker run -d -P --net myc2 --name myc2-ndbmtd2 --ip 172.19.0.12 -e NODE_ID=2 -e CONNECTSTRING=myc2-mgmd49:1186,myc2-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 131 | 2016-10-28T10:08:08.152000: Running: docker port myc2-ndbmtd2 11860/tcp 132 | 2016-10-28T10:08:08.232000: Running: docker ps -q -a --filter "name=myc2-sql51" 133 | 2016-10-28T10:08:08.281000: Running: docker run -d -P --net myc2 --name myc2-sql51 --ip 172.19.0.151 -e NODE_ID=51 -e CONNECTSTRING=myc2-mgmd49:1186,myc2-mgmd50:1186 markleith/mysql-cluster-sql:7.5 134 | 2016-10-28T10:08:17.201000: Running: docker port myc2-sql51 3306/tcp 135 | 2016-10-28T10:08:17.283000: Running: docker ps -q -a --filter "name=myc2-sql52" 136 | 2016-10-28T10:08:17.348000: Running: docker run -d -P --net myc2 --name myc2-sql52 --ip 172.19.0.152 -e NODE_ID=52 -e CONNECTSTRING=myc2-mgmd49:1186,myc2-mgmd50:1186 markleith/mysql-cluster-sql:7.5 137 | 2016-10-28T10:08:29.808000: Running: docker port myc2-sql52 3306/tcp 138 | 2016-10-28T10:08:30.127000: Info: Started: [ "node" : { "name" : "myc2-mgmd49", "bound_port" : 33056, "node_type" : "mgmd" } , "node" : { "name" : "myc2-mgmd50", "bound_port" : 33057, "node_type" : "mgmd" } , "node" : { "name" : "myc2-ndbmtd1", "bound_port" : 33058, "node_type" : "ndbmtd" } , "node" : { "name" : "myc2-ndbmtd2", "bound_port" : 33059, "node_type" : "ndbmtd" } , "node" : { "name" : "myc2-sql51", "bound_port" : 33060, "node_type" : "sql" } , "node" : { "name" : "myc2-sql52", "bound_port" : 33061, "node_type" : "sql" } ] 139 | 140 | $ docker ps 141 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 142 | e32d4ae024fc markleith/mysql-cluster-sql:7.5 "/home/mysql/run-mysq" 21 seconds ago Up 9 seconds 0.0.0.0:33061->3306/tcp myc2-sql52 143 | 038ce476e860 markleith/mysql-cluster-sql:7.5 "/home/mysql/run-mysq" 30 seconds ago Up 20 seconds 0.0.0.0:33060->3306/tcp myc2-sql51 144 | 32d202bd5d2d markleith/mysql-cluster-ndbmtd:7.5 "/home/mysql/run-data" 34 seconds ago Up 29 seconds 0.0.0.0:33059->11860/tcp myc2-ndbmtd2 145 | 0b8f06de740a markleith/mysql-cluster-ndbmtd:7.5 "/home/mysql/run-data" 36 seconds ago Up 32 seconds 0.0.0.0:33058->11860/tcp myc2-ndbmtd1 146 | 83bd9674e339 markleith/mysql-cluster-mgmd:7.5 "/home/mysql/run-mgmd" 39 seconds ago Up 35 seconds 0.0.0.0:33057->1186/tcp myc2-mgmd50 147 | 36cea82543f0 markleith/mysql-cluster-mgmd:7.5 "/home/mysql/run-mgmd" 41 seconds ago Up 37 seconds 0.0.0.0:33056->1186/tcp myc2-mgmd49 148 | 613b6c18ebd6 markleith/mysql-cluster-sql:7.5 "/home/mysql/run-mysq" About a minute ago Up About a minute 0.0.0.0:33055->3306/tcp myc1-sql51 149 | 31b739edcdb4 markleith/mysql-cluster-ndbmtd:7.5 "/home/mysql/run-data" About a minute ago Up About a minute 0.0.0.0:33054->11860/tcp myc1-ndbmtd2 150 | 18e19136accb markleith/mysql-cluster-ndbmtd:7.5 "/home/mysql/run-data" About a minute ago Up About a minute 0.0.0.0:33053->11860/tcp myc1-ndbmtd1 151 | 721b3abb7140 a62fba3c15f2 "/home/mysql/run-mgmd" About a minute ago Up About a minute 0.0.0.0:33052->1186/tcp myc1-mgmd49 152 | 153 | ``` 154 | 155 | #### `build` command: 156 | 157 | ##### Options 158 | 159 | ``` 160 | usage: cluster.py build [-h] [-b BASE_NETWORK] [-m MANAGEMENT_NODES] 161 | [-d DATA_NODES] [-s SQL_NODES] 162 | 163 | optional arguments: 164 | -h, --help show this help message and exit 165 | -b BASE_NETWORK, --base-network BASE_NETWORK 166 | The base IP network range (default: 172.18) 167 | -m MANAGEMENT_NODES, --management-nodes MANAGEMENT_NODES 168 | Number of Management nodes to run (default: 2; max: 2) 169 | -d DATA_NODES, --data-nodes DATA_NODES 170 | Number of NDB nodes to run (default: 4; max: 48) 171 | -s SQL_NODES, --sql-nodes SQL_NODES 172 | Number of SQL nodes to run (default: 2) 173 | ``` 174 | 175 | ##### Example 176 | 177 | ``` 178 | $ cluster.py build 179 | 2016-10-28T09:05:57.051000: Running: docker build -t markleith/mysql-cluster-mgmd:7.5 -f management-node/Dockerfile management-node 180 | 2016-10-28T09:06:06.495000: Running: docker build -t markleith/mysql-cluster-ndbmtd:7.5 -f data-node/Dockerfile data-node 181 | 2016-10-28T09:06:06.751000: Running: docker build -t markleith/mysql-cluster-sql:7.5 -f sql-node/Dockerfile sql-node 182 | ``` 183 | 184 | #### `start` command: 185 | 186 | ##### Options 187 | 188 | ``` 189 | usage: cluster.py start [-h] [-n NAME] [-b BASE_NETWORK] [-m MANAGEMENT_NODES] 190 | [-d DATA_NODES] [-s SQL_NODES] 191 | 192 | optional arguments: 193 | -h, --help show this help message and exit 194 | -n NAME, --name NAME The prefix to use for managing the network and 195 | containers (default: mycluster) 196 | -b BASE_NETWORK, --base-network BASE_NETWORK 197 | The base IP network range (default: 172.18) 198 | -m MANAGEMENT_NODES, --management-nodes MANAGEMENT_NODES 199 | Number of Management nodes to run (default: 2; max: 2) 200 | -d DATA_NODES, --data-nodes DATA_NODES 201 | Number of NDB nodes to run (default: 4; max: 48) 202 | -s SQL_NODES, --sql-nodes SQL_NODES 203 | Number of SQL nodes to run (default: 2) 204 | ``` 205 | 206 | ``` 207 | $ cluster.py start 208 | 2016-10-28T09:06:25.565000: Running: docker network ls 209 | 2016-10-28T09:06:25.622000: Info: mycluster network not found, creating 210 | 2016-10-28T09:06:25.624000: Running: docker network create --subnet=172.18.0.0/16 mycluster 211 | 2016-10-28T09:06:26.031000: Running: docker ps -q -a --filter "name=mycluster-mgmd49" 212 | 2016-10-28T09:06:26.087000: Running: docker run -d -P --net mycluster --name mycluster-mgmd49 --ip 172.18.0.149 -e NODE_ID=49 -e NOWAIT=50 -e CONNECTSTRING= markleith/mysql-cluster-mgmd:7.5 213 | 2016-10-28T09:06:27.585000: Running: docker port mycluster-mgmd49 1186/tcp 214 | 2016-10-28T09:06:27.653000: Running: docker ps -q -a --filter "name=mycluster-mgmd50" 215 | 2016-10-28T09:06:27.706000: Running: docker run -d -P --net mycluster --name mycluster-mgmd50 --ip 172.18.0.150 -e NODE_ID=50 -e NOWAIT=49 -e CONNECTSTRING=mycluster-mgmd49:1186 markleith/mysql-cluster-mgmd:7.5 216 | 2016-10-28T09:06:29.083000: Running: docker port mycluster-mgmd50 1186/tcp 217 | 2016-10-28T09:06:29.146000: Running: docker ps -q -a --filter "name=mycluster-ndbmtd1" 218 | 2016-10-28T09:06:29.203000: Running: docker run -d -P --net mycluster --name mycluster-ndbmtd1 --ip 172.18.0.11 -e NODE_ID=1 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 219 | 2016-10-28T09:06:30.657000: Running: docker port mycluster-ndbmtd1 11860/tcp 220 | 2016-10-28T09:06:30.719000: Running: docker ps -q -a --filter "name=mycluster-ndbmtd2" 221 | 2016-10-28T09:06:30.773000: Running: docker run -d -P --net mycluster --name mycluster-ndbmtd2 --ip 172.18.0.12 -e NODE_ID=2 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 222 | 2016-10-28T09:06:32.729000: Running: docker port mycluster-ndbmtd2 11860/tcp 223 | 2016-10-28T09:06:32.796000: Running: docker ps -q -a --filter "name=mycluster-ndbmtd3" 224 | 2016-10-28T09:06:33.064000: Running: docker run -d -P --net mycluster --name mycluster-ndbmtd3 --ip 172.18.0.13 -e NODE_ID=3 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 225 | 2016-10-28T09:06:34.660000: Running: docker port mycluster-ndbmtd3 11860/tcp 226 | 2016-10-28T09:06:34.723000: Running: docker ps -q -a --filter "name=mycluster-ndbmtd4" 227 | 2016-10-28T09:06:34.790000: Running: docker run -d -P --net mycluster --name mycluster-ndbmtd4 --ip 172.18.0.14 -e NODE_ID=4 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-ndbmtd:7.5 228 | 2016-10-28T09:06:36.343000: Running: docker port mycluster-ndbmtd4 11860/tcp 229 | 2016-10-28T09:06:36.403000: Running: docker ps -q -a --filter "name=mycluster-sql51" 230 | 2016-10-28T09:06:36.473000: Running: docker run -d -P --net mycluster --name mycluster-sql51 --ip 172.18.0.151 -e NODE_ID=51 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-sql:7.5 231 | 2016-10-28T09:06:45.207000: Running: docker port mycluster-sql51 3306/tcp 232 | 2016-10-28T09:06:45.270000: Running: docker ps -q -a --filter "name=mycluster-sql52" 233 | 2016-10-28T09:06:45.419000: Running: docker run -d -P --net mycluster --name mycluster-sql52 --ip 172.18.0.152 -e NODE_ID=52 -e CONNECTSTRING=mycluster-mgmd49:1186,mycluster-mgmd50:1186 markleith/mysql-cluster-sql:7.5 234 | 2016-10-28T09:06:47.762000: Running: docker port mycluster-sql52 3306/tcp 235 | 2016-10-28T09:06:47.983000: Info: Started: [ "node" : { "name" : "mycluster-mgmd49", "bound_port" : 33036, "node_type" : "mgmd" } , "node" : { "name" : "mycluster-mgmd50", "bound_port" : 33037, "node_type" : "mgmd" } , "node" : { "name" : "mycluster-ndbmtd1", "bound_port" : 33038, "node_type" : "ndbmtd" } , "node" : { "name" : "mycluster-ndbmtd2", "bound_port" : 33039, "node_type" : "ndbmtd" } , "node" : { "name" : "mycluster-ndbmtd3", "bound_port" : 33040, "node_type" : "ndbmtd" } , "node" : { "name" : "mycluster-ndbmtd4", "bound_port" : 33041, "node_type" : "ndbmtd" } , "node" : { "name" : "mycluster-sql51", "bound_port" : 33042, "node_type" : "sql" } , "node" : { "name" : "mycluster-sql52", "bound_port" : 33043, "node_type" : "sql" } ] 236 | ``` 237 | 238 | #### `stop` command: 239 | 240 | ##### Options 241 | 242 | ``` 243 | usage: cluster.py stop [-h] [-n NAME] 244 | 245 | optional arguments: 246 | -h, --help show this help message and exit 247 | -n NAME, --name NAME The prefix to use for managing the network and 248 | containers (default: mycluster) 249 | ``` 250 | 251 | ##### Example 252 | 253 | ``` 254 | $ cluster.py stop 255 | 2016-10-28T09:29:38.076000: Running: docker network ls 256 | 2016-10-28T09:29:38.391000: Running: docker network inspect --format="{{range $i, $c := .Containers}}{{$i}},{{end}}" mycluster 257 | 2016-10-28T09:29:38.456000: Running: docker stop 3c781c3517a2 41c3bfcba7d1 4210e83036a3 66289dc0b529 7bb378282d22 afd8d427c751 f021167e7be7 fc0de2b342ff 258 | 2016-10-28T09:31:03.673000: Info: Stopping containers done 259 | ``` 260 | 261 | #### `clean` command: 262 | 263 | ##### Options 264 | 265 | ``` 266 | usage: cluster.py clean [-h] [-n NAME] [-i] [-d] 267 | 268 | optional arguments: 269 | -h, --help show this help message and exit 270 | -n NAME, --name NAME The prefix to use for managing the network and 271 | containers (default: mycluster) 272 | -i, --images Delete markleith/mysql-cluster docker images (default: 273 | false) 274 | -d, --dangling Delete dangling docker images (default: false) 275 | ``` 276 | 277 | ##### Example 278 | 279 | ``` 280 | $ cluster.py clean 281 | 2016-10-28T09:54:31.418000: Running: docker ps -a --filter "ancestor=markleith/mysql-cluster-mgmd:7.5" --format "{{.ID}}" 282 | 2016-10-28T09:54:31.499000: Running: docker ps -a --filter "ancestor=markleith/mysql-cluster-ndbmtd:7.5" --format "{{.ID}}" 283 | 2016-10-28T09:54:31.565000: Running: docker ps -a --filter "ancestor=markleith/mysql-cluster-sql:7.5" --format "{{.ID}}" 284 | 2016-10-28T09:54:31.626000: Running: docker stop 66289dc0b529 3c781c3517a2 afd8d427c751 7bb378282d22 f021167e7be7 41c3bfcba7d1 fc0de2b342ff 4210e83036a3 285 | 2016-10-28T09:55:53.496000: Running: docker rm 66289dc0b529 3c781c3517a2 afd8d427c751 7bb378282d22 f021167e7be7 41c3bfcba7d1 fc0de2b342ff 4210e83036a3 286 | 2016-10-28T09:55:55.302000: Running: docker network ls 287 | 2016-10-28T09:55:55.404000: Running: docker network rm mycluster 288 | 2016-10-28T09:55:56.036000: Running: docker network ls 289 | ``` 290 | 291 | #### Connecting 292 | 293 | You can use the exposed ports to connect directly to a SQL node from the docker host OS, such as taking the exposed port for mysqlndb52 above (33043): 294 | 295 | ``` 296 | $ mysql -u root -pmysql -h 127.0.0.1 -P 33043 297 | mysql: [Warning] Using a password on the command line interface can be insecure. 298 | Welcome to the MySQL monitor. Commands end with ; or \g. 299 | Your MySQL connection id is 4 300 | Server version: 5.7.16-ndb-7.5.4-cluster-gpl MySQL Cluster Community Server (GPL) 301 | 302 | Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. 303 | 304 | Oracle is a registered trademark of Oracle Corporation and/or its 305 | affiliates. Other names may be trademarks of their respective 306 | owners. 307 | 308 | Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 309 | 310 | mysql> show tables from ndbinfo; 311 | +---------------------------------+ 312 | | Tables_in_ndbinfo | 313 | +---------------------------------+ 314 | | arbitrator_validity_detail | 315 | | arbitrator_validity_summary | 316 | | blocks | 317 | | cluster_locks | 318 | | cluster_operations | 319 | | cluster_transactions | 320 | | config_params | 321 | | config_values | 322 | | counters | 323 | | cpustat | 324 | | cpustat_1sec | 325 | | cpustat_20sec | 326 | | cpustat_50ms | 327 | | dict_obj_info | 328 | | dict_obj_types | 329 | | disk_write_speed_aggregate | 330 | | disk_write_speed_aggregate_node | 331 | | disk_write_speed_base | 332 | | diskpagebuffer | 333 | | locks_per_fragment | 334 | | logbuffers | 335 | | logspaces | 336 | | membership | 337 | | memory_per_fragment | 338 | | memoryusage | 339 | | nodes | 340 | | operations_per_fragment | 341 | | resources | 342 | | restart_info | 343 | | server_locks | 344 | | server_operations | 345 | | server_transactions | 346 | | table_distribution_status | 347 | | table_fragments | 348 | | table_info | 349 | | table_replicas | 350 | | tc_time_track_stats | 351 | | threadblocks | 352 | | threads | 353 | | threadstat | 354 | | transporters | 355 | +---------------------------------+ 356 | 41 rows in set (0.00 sec) 357 | 358 | mysql> desc ndbinfo.memoryusage; 359 | +-------------+------------------+------+-----+---------+-------+ 360 | | Field | Type | Null | Key | Default | Extra | 361 | +-------------+------------------+------+-----+---------+-------+ 362 | | node_id | int(10) unsigned | YES | | NULL | | 363 | | memory_type | varchar(512) | YES | | NULL | | 364 | | used | decimal(62,0) | YES | | NULL | | 365 | | used_pages | decimal(42,0) | YES | | NULL | | 366 | | total | decimal(62,0) | YES | | NULL | | 367 | | total_pages | decimal(42,0) | YES | | NULL | | 368 | +-------------+------------------+------+-----+---------+-------+ 369 | 6 rows in set (0.10 sec) 370 | 371 | mysql> select node_id, memory_type, sys.format_bytes(used) used, sys.format_bytes(total) total from ndbinfo.memoryusage; 372 | +---------+---------------------+------------+-----------+ 373 | | node_id | memory_type | used | total | 374 | +---------+---------------------+------------+-----------+ 375 | | 1 | Data memory | 704.00 KiB | 80.00 MiB | 376 | | 1 | Index memory | 104.00 KiB | 18.25 MiB | 377 | | 1 | Long message buffer | 384.00 KiB | 32.00 MiB | 378 | | 2 | Data memory | 704.00 KiB | 80.00 MiB | 379 | | 2 | Index memory | 104.00 KiB | 18.25 MiB | 380 | | 2 | Long message buffer | 256.00 KiB | 32.00 MiB | 381 | | 3 | Data memory | 704.00 KiB | 80.00 MiB | 382 | | 3 | Index memory | 104.00 KiB | 18.25 MiB | 383 | | 3 | Long message buffer | 256.00 KiB | 32.00 MiB | 384 | | 4 | Data memory | 704.00 KiB | 80.00 MiB | 385 | | 4 | Index memory | 104.00 KiB | 18.25 MiB | 386 | | 4 | Long message buffer | 256.00 KiB | 32.00 MiB | 387 | +---------+---------------------+------------+-----------+ 388 | 12 rows in set (0.42 sec) 389 | ``` 390 | 391 | ### mysql-repo-server-5.6-centos-6.8 392 | 393 | Sets up CentOS 6.8 with SSH and MySQL started. 394 | 395 | MySQL is installed from the [MySQL Yum repository](http://dev.mysql.com/downloads/repo/yum/). 396 | 397 | #### Build: 398 | 399 | ``` 400 | cd ./hosts/centos-6.8 401 | docker build -t markleith/centos-6.8 . 402 | cd ../../mysql-repo-server-5.6-centos-6.8 403 | docker build -t markleith/mysql-repo-server-5.6-centos-6.8 . 404 | ``` 405 | 406 | #### Run: 407 | ``` 408 | docker run -d -P --name my56centos68 markleith/mysql-repo-server-5.6-centos-6.8 409 | ``` 410 | 411 | ### mysql-repo-server-5.6-ubuntu-14.04 412 | 413 | Sets up Ubuntu 14.04 with SSH and MySQL started. 414 | 415 | MySQL is installed from the [MySQL Apt Repository](http://dev.mysql.com/downloads/repo/apt/). 416 | 417 | #### Build: 418 | 419 | ``` 420 | cd ./hosts/ubuntu-14.04 421 | docker build -t markleith/ubuntu-14.04 . 422 | cd ../mysql-repo-server-5.6-ubuntu-14.04 423 | docker build -t markleith/mysql-repo-server-5.6-ubuntu-14.04 . 424 | ``` 425 | 426 | #### Run: 427 | ``` 428 | docker run -d -P --name my56ubuntu1404 markleith/mysql-repo-server-5.6-ubuntu-14.04 429 | ``` 430 | 431 | ## Sysbench 0.5 432 | 433 | There is a generic container available to run sysbench benchmarks from. This builds sysbench directly from the Launchpad bzr tree. 434 | 435 | It can be used to run any sysbench and allows spinning up multiple docker containers to drive benchmark load. 436 | 437 | To point to another container on the same host, use the "Network Gateway" address from `docker inspect`, as well as the port that is exposed for 3306. 438 | 439 | Linking, or running against non-docker MySQL hosts is also of course feasible. The containers will shut down as soon as their benchmarks are complete. 440 | 441 | #### Run: 442 | 443 | ``` 444 | $ docker run -i -t --name=sysb01 markleith/sysbench-0.5 /usr/local/bin/sysbench \ 445 | > --test=/sysbench/sysbench/tests/db/oltp_simple.lua --mysql-table-engine=InnoDB \ 446 | > --mysql-user=root --mysql-password=mysql --mysql-host=172.17.42.1 --mysql-port=49189 \ 447 | > --num-threads=8 --max-requests=20000 --report-interval=1 run 448 | sysbench 0.5: multi-threaded system evaluation benchmark 449 | 450 | Running the test with following options: 451 | Number of threads: 8 452 | Report intermediate results every 1 second(s) 453 | Random number generator seed is 0 and will be ignored 454 | 455 | 456 | Threads started! 457 | 458 | [ 1s] threads: 8, tps: 0.00, reads/s: 2799.35, writes/s: 0.00, response time: 5.99ms (95%) 459 | [ 2s] threads: 8, tps: 0.00, reads/s: 2808.92, writes/s: 0.00, response time: 5.66ms (95%) 460 | [ 3s] threads: 8, tps: 0.00, reads/s: 2437.41, writes/s: 0.00, response time: 8.89ms (95%) 461 | [ 4s] threads: 8, tps: 0.00, reads/s: 2824.45, writes/s: 0.00, response time: 7.14ms (95%) 462 | [ 5s] threads: 8, tps: 0.00, reads/s: 2907.49, writes/s: 0.00, response time: 6.58ms (95%) 463 | [ 6s] threads: 8, tps: 0.00, reads/s: 2924.48, writes/s: 0.00, response time: 5.54ms (95%) 464 | [ 7s] threads: 8, tps: 0.00, reads/s: 2396.74, writes/s: 0.00, response time: 11.32ms (95%) 465 | OLTP test statistics: 466 | queries performed: 467 | read: 20000 468 | write: 0 469 | other: 0 470 | total: 20000 471 | transactions: 0 (0.00 per sec.) 472 | deadlocks: 0 (0.00 per sec.) 473 | read/write requests: 20000 (2727.52 per sec.) 474 | other operations: 0 (0.00 per sec.) 475 | 476 | General statistics: 477 | total time: 7.3327s 478 | total number of events: 20000 479 | total time taken by event execution: 57.9213s 480 | response time: 481 | min: 0.00ms 482 | avg: 2.90ms 483 | max: 69.77ms 484 | approx. 95 percentile: 7.02ms 485 | 486 | Threads fairness: 487 | events (avg/stddev): 2500.0000/179.43 488 | execution time (avg/stddev): 7.2402/0.02 489 | ``` 490 | 491 | 492 | ## Base Hosts 493 | 494 | Each of the base hosts install a certain set of base packages (vim, git, gdb, open-ssh). 495 | 496 | SSH is configured so that you can log in to each container, and debug MySQL issues locally (such as being able to also run in gdb). 497 | 498 | Supported hosts are: 499 | 500 | * CentOS 6.8 501 | * Ubuntu 14.04 502 | 503 | All host root passwords are set to root. 504 | -------------------------------------------------------------------------------- /hosts/centos-6.8/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:6.8 2 | 3 | MAINTAINER Mark Leith (mark@markleith.co.uk) 4 | 5 | RUN yum -y install vim git bzr gdb openssh-server openssh-clients libaio 6 | RUN yum -y update 7 | 8 | RUN echo 'root:root' | chpasswd 9 | RUN mkdir -p /var/run/sshd 10 | RUN ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key && ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key 11 | RUN sed -ri 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config 12 | RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config 13 | RUN sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config 14 | 15 | EXPOSE 22 16 | 17 | CMD /usr/sbin/sshd -D 18 | 19 | -------------------------------------------------------------------------------- /hosts/ubuntu-14.04/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | 3 | MAINTAINER Mark Leith (mark@markleith.co.uk) 4 | 5 | RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q vim bzr git gdb openssh-server 6 | 7 | RUN echo 'root:root' | chpasswd 8 | RUN mkdir -p /var/run/sshd 9 | 10 | RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config 11 | RUN sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config 12 | RUN sed -ri 's/PermitRootLogin without-password/PermitRootLogin yes/g' /etc/ssh/sshd_config 13 | 14 | EXPOSE 22 15 | 16 | CMD /usr/sbin/sshd -D 17 | -------------------------------------------------------------------------------- /mysql-cluster/cluster.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; version 2 of the License. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | # 18 | 19 | import argparse 20 | import datetime 21 | import os 22 | import platform 23 | import shutil 24 | import subprocess 25 | import sys 26 | 27 | REPO = "markleith/mysql-cluster" 28 | VERSION = "7.5" 29 | 30 | NAME = "mycluster" 31 | BASE_NETWORK = "172.18" 32 | 33 | NDBD = "ndbmtd" 34 | NDBD_BASE_IMAGE = REPO+"-"+NDBD 35 | NDBD_BASE_ID = 1 36 | 37 | MGMD = "mgmd" 38 | MGMD_BASE_IMAGE = REPO+"-"+MGMD 39 | MGMD_BASE_ID = 49 40 | 41 | API = "sql" 42 | API_BASE_IMAGE = REPO+"-"+API 43 | API_BASE_ID = 51 44 | 45 | QUOTE = "\"" if platform.system() == "Windows" else "'" 46 | 47 | SCRIPTDIR = os.path.dirname(os.path.realpath(sys.argv[0])) 48 | 49 | CONFIG_INI = SCRIPTDIR+"/management-node/config.ini" 50 | 51 | nodes=[] 52 | 53 | class Node: 54 | def __init__(self, name, port, node_type): 55 | self.name = name 56 | self.port = port 57 | self.node_type = node_type 58 | 59 | def __str__(self): 60 | return(' "node" : { "name" : "'+str(self.name)+'", "bound_port" : '+str(self.port)+', "node_type" : "'+str(self.node_type)+'" } ') 61 | 62 | def __repr__(self): 63 | return str(self) 64 | 65 | def add_node(nodeName, node_type): 66 | if node_type == MGMD: 67 | port = cmd("docker port {0} 1186/tcp".format(nodeName)) 68 | elif node_type == NDBD: 69 | port = cmd("docker port {0} 11860/tcp".format(nodeName)) 70 | elif node_type == API: 71 | port = cmd("docker port {0} 3306/tcp".format(nodeName)) 72 | node = Node(nodeName, port.strip().split(":",1)[1], node_type) 73 | nodes.append(node) 74 | debug("Added: {0}".format(node)) 75 | 76 | def ts(): 77 | return datetime.datetime.utcnow().isoformat()+": " 78 | 79 | def log(msg): 80 | print ts()+msg 81 | 82 | def debug(msg): 83 | if args.debug: print "{0}Debug: {1}".format(ts(), msg) 84 | 85 | def cmd(cmd): 86 | log("Running: " + cmd) 87 | return subprocess.check_output(cmd, shell=True) 88 | 89 | def ip(nodeid): 90 | return "{0}.0.1{1}".format(args.base_network, nodeid) 91 | 92 | def node_name(nodeid, node_type): 93 | return "{0}-{1}{2}".format(args.name, node_type, nodeid) 94 | 95 | def write_ini_section(file, header, nodeid): 96 | file.write("\n["+header+"]\n") 97 | file.write("NodeId={0}\n".format(nodeid)) 98 | file.write("HostName={0}\n".format(ip(nodeid))) 99 | 100 | def build_config_ini(): 101 | try: 102 | cfgtmpl = SCRIPTDIR+"/management-node/config.ini.in" 103 | shutil.copy(cfgtmpl, CONFIG_INI) 104 | except shutil.Error as e: 105 | print('Error: %s' % e) 106 | except IOError as e: 107 | print('Error: %s' % e.strerror) 108 | with open(CONFIG_INI, "ab") as f: 109 | nodeid = MGMD_BASE_ID 110 | for i in range(args.management_nodes): 111 | write_ini_section(f, "NDB_MGMD", nodeid) 112 | nodeid += 1 113 | nodeid = NDBD_BASE_ID 114 | for i in range(args.data_nodes): 115 | write_ini_section(f, "NDBD", nodeid) 116 | nodeid += 1 117 | nodeid = API_BASE_ID 118 | for i in range(args.sql_nodes): 119 | write_ini_section(f, "MYSQLD", nodeid) 120 | nodeid += 1 121 | 122 | def build(args): 123 | build_config_ini() 124 | cmd('docker build -t {0}:{1} -f {2}/management-node/Dockerfile {2}/management-node'.format(MGMD_BASE_IMAGE, VERSION, SCRIPTDIR)) 125 | cmd('docker build -t {0}:{1} -f {2}/data-node/Dockerfile {2}/data-node'.format(NDBD_BASE_IMAGE, VERSION, SCRIPTDIR)) 126 | cmd('docker build -t {0}:{1} -f {2}/sql-node/Dockerfile {2}/sql-node'.format(API_BASE_IMAGE, VERSION, SCRIPTDIR)) 127 | 128 | def get_container(name): 129 | container = cmd('docker ps -q -a --filter {0}name={1}{0}'.format(QUOTE, name)).rstrip(",\n") 130 | debug("Found container id {0}".format(container)) 131 | if len(container) and container != "": 132 | return container 133 | else: 134 | return None 135 | 136 | def network_exists(network): 137 | networks = cmd("docker network ls") 138 | if networks.find(network) != -1: 139 | return True 140 | else: 141 | return False 142 | 143 | def connected_containers(network): 144 | containers = cmd( 145 | 'docker network inspect --format={0}{{{{range $i, $c := .Containers}}}}{{{{$i}}}},{{{{end}}}}{0} {1}'.format(QUOTE, network) 146 | ).rstrip(",\n").split(',') 147 | containers = [x[0:12] for x in containers] 148 | return containers 149 | 150 | def connected_networks(container): 151 | return cmd( 152 | 'docker inspect --format {0}{{{{range $i, $n := .NetworkSettings.Networks}}}}{{{{$i}}}},{{{{end}}}}{0} {1}'.format(QUOTE, container) 153 | ).rstrip(",\n").split(',') 154 | 155 | def start_container(container, expectedNetwork, name): 156 | networks = connected_networks(container) 157 | debug("Container {0} connected to networks {1}".format(container, " ".join(networks))) 158 | if any(expectedNetwork in n for n in networks): 159 | cmd("docker start {0}".format(container)) 160 | else: 161 | log("Error: Found container {0}, but it wasn't part of the {1} network (it was on {2}), stopping!".format(name, args.name, ",".join(networks))) 162 | sys.exit() 163 | 164 | def connect_string(): 165 | mgmd_nodes = filter(lambda x: x.node_type == MGMD, nodes) 166 | return ",".join(x.name + ":1186" for x in mgmd_nodes) 167 | 168 | def management_nodes_option(x): 169 | x = int(x) 170 | if x > 2: 171 | raise argparse.ArgumentTypeError("Maximum Managment nodes is 2") 172 | return x 173 | 174 | def run_mgmd_nodes(): 175 | nodeid = MGMD_BASE_ID 176 | mgmdSibling = nodeid + 1 177 | for i in range(args.management_nodes): 178 | if i: nodeid, mgmdSibling = mgmdSibling, nodeid 179 | nodeName = node_name(nodeid, MGMD) 180 | container = get_container(nodeName) 181 | if container is not None: 182 | start_container(container, args.name, nodeName) 183 | else: 184 | runCmd = 'docker run -d -P --net {0} --name {1} --ip {2} -e NODE_ID={3} -e NOWAIT={4} -e CONNECTSTRING={5} {6}:{7}' 185 | cmd(runCmd.format(args.name, nodeName, ip(nodeid), nodeid, mgmdSibling, connect_string(), MGMD_BASE_IMAGE, VERSION)) 186 | add_node(nodeName, MGMD) 187 | 188 | def data_nodes_option(x): 189 | x = int(x) 190 | if x > 48: 191 | raise argparse.ArgumentTypeError("Maximum Data nodes is 48") 192 | return x 193 | 194 | def run_data_nodes(): 195 | nodeid = NDBD_BASE_ID 196 | for i in range(args.data_nodes): 197 | nodeName = node_name(nodeid, NDBD) 198 | container = get_container(nodeName) 199 | if container is not None: 200 | start_container(container, args.name, nodeName) 201 | else: 202 | runCmd = 'docker run -d -P --net {0} --name {1} --ip {2} -e NODE_ID={3} -e CONNECTSTRING={4} {5}:{6}' 203 | cmd(runCmd.format(args.name, nodeName, ip(nodeid), nodeid, connect_string(), NDBD_BASE_IMAGE, VERSION)) 204 | add_node(nodeName, NDBD) 205 | nodeid += 1 206 | 207 | def run_sql_nodes(): 208 | nodeid = API_BASE_ID 209 | for i in range(args.sql_nodes): 210 | nodeName = node_name(nodeid, API) 211 | container = get_container(nodeName) 212 | if container is not None: 213 | start_container(container, args.name, nodeName) 214 | else: 215 | runCmd = 'docker run -d -P --net {0} --name {1} --ip {2} -e NODE_ID={3} -e CONNECTSTRING={4} {5}:{6}' 216 | cmd(runCmd.format(args.name, nodeName, ip(nodeid), nodeid, connect_string(), API_BASE_IMAGE, VERSION)) 217 | add_node(nodeName, API) 218 | nodeid += 1 219 | 220 | def start(args): 221 | if not os.path.isfile(CONFIG_INI): 222 | log("Error: management-node/config.ini does not exist, you need to issue the build command first") 223 | sys.exit() 224 | if network_exists(args.name): 225 | log("Info: {0} network found, checking if any containers are already running".format(args.name)) 226 | containers = connected_containers(args.name) 227 | if len(containers) and containers[0] != "": 228 | log("Error: {0} network already has running containers, please fully stop this cluster, or clean, before attempting to start".format(args.name)) 229 | sys.exit() 230 | else: 231 | log("Info: {0} network not found, creating".format(args.name)) 232 | cmd("docker network create --subnet=" + args.base_network + ".0.0/16 " + args.name) 233 | run_mgmd_nodes() 234 | run_data_nodes() 235 | run_sql_nodes() 236 | log("Info: Started: {0}".format(nodes)) 237 | 238 | def stop_containers(containers): 239 | cmd("docker stop {0}".format(" ".join(containers))) 240 | 241 | def stop(args): 242 | if network_exists(args.name): 243 | debug("Found network {0}".format(args.name)) 244 | containers = connected_containers(args.name) 245 | debug("Found containers: {0}".format(containers)) 246 | if len(containers) and containers[0] != "": 247 | stop_containers(containers) 248 | log("Info: Stopping containers done") 249 | else: 250 | log("Info: No containers found running on {0}".format(args.name)) 251 | else: 252 | log("Info: {0} network not found".format(args.name)) 253 | 254 | def find_containers_using_image(name): 255 | containers = cmd( 256 | 'docker ps -a --filter {0}ancestor={1}{0} --format {0}{{{{.ID}}}}{0}'.format(QUOTE, name) 257 | ).rstrip("\n").split('\n') 258 | debug("Found containers: {0}".format(containers)) 259 | return containers 260 | 261 | def remove_containers(containers): 262 | cmd("docker rm {0}".format(" ".join(containers))) 263 | 264 | def find_images(repo_base): 265 | images = cmd( 266 | 'docker images {0}-* --format {1}{{{{.ID}}}}{1}'.format(repo_base, QUOTE) 267 | ).rstrip("\n").split('\n') 268 | debug("Found images: {0}".format(images)) 269 | return images 270 | 271 | def find_dangling_images(): 272 | images = cmd( 273 | 'docker images --filter {0}dangling=true{0} --format {0}{{{{.ID}}}}{0}'.format(QUOTE) 274 | ).rstrip("\n").split('\n') 275 | debug("Found dangling images: {0}".format(images)) 276 | return images 277 | 278 | def remove_images(images): 279 | cmd("docker rmi {0}".format(" ".join(images))) 280 | 281 | def remove_network(network): 282 | cmd("docker network rm {0}".format(network)) 283 | 284 | def clean(args): 285 | containers = [] 286 | containers.extend(find_containers_using_image(MGMD_BASE_IMAGE+":"+VERSION)) 287 | containers.extend(find_containers_using_image(NDBD_BASE_IMAGE+":"+VERSION)) 288 | containers.extend(find_containers_using_image(API_BASE_IMAGE+":"+VERSION)) 289 | debug("Found containers: {0}".format(containers)) 290 | if len(containers) and containers[0] != "": 291 | stop_containers(containers) 292 | remove_containers(containers) 293 | if args.images: 294 | images = find_images(REPO) 295 | if len(images) and images[0] != "": 296 | log("Info: Removing {0}-* images".format(REPO)) 297 | remove_images(images) 298 | if args.dangling: 299 | dangling = find_dangling_images() 300 | if len(dangling) and dangling[0] != "": 301 | log("Info: Removing dangling images") 302 | remove_images(dangling) 303 | if args.name: 304 | if network_exists(args.name): 305 | remove_network(args.name) 306 | if network_exists(NAME): 307 | remove_network(NAME) 308 | if os.path.isfile(CONFIG_INI): 309 | os.remove(CONFIG_INI) 310 | 311 | if __name__ == '__main__': 312 | 313 | parser = argparse.ArgumentParser(description="Create a test MySQL Cluster deployment in docker") 314 | name = argparse.ArgumentParser(add_help=False) 315 | name.add_argument('-n', '--name', default=NAME, help='The prefix to use for managing the network and containers (default: '+NAME+')') 316 | base_network = argparse.ArgumentParser(add_help=False) 317 | base_network.add_argument('-b', '--base-network', default=BASE_NETWORK, help='The base IP network range (default: '+BASE_NETWORK+')') 318 | mgmd_nodes = argparse.ArgumentParser(add_help=False) 319 | mgmd_nodes.add_argument('-m', '--management-nodes', default=2, type=management_nodes_option, help='Number of Management nodes to run (default: 2; max: 2)') 320 | data_nodes = argparse.ArgumentParser(add_help=False) 321 | data_nodes.add_argument('-d', '--data-nodes', default=4, type=data_nodes_option, help='Number of NDB nodes to run (default: 4; max: 48)') 322 | sql_nodes = argparse.ArgumentParser(add_help=False) 323 | sql_nodes.add_argument('-s', '--sql-nodes', default=2, type=int, help='Number of SQL nodes to run (default: 2)') 324 | sp = parser.add_subparsers() 325 | sp_build = sp.add_parser('build', parents=[base_network, mgmd_nodes, data_nodes, sql_nodes], help='Build the cluster containers') 326 | sp_build.set_defaults(func=build) 327 | sp_start = sp.add_parser('start', parents=[name, base_network, mgmd_nodes, data_nodes, sql_nodes], help='Start up the cluster containers') 328 | sp_start.set_defaults(func=start) 329 | sp_stop = sp.add_parser('stop', parents=[name], help='Stop the cluster containers for the specified network') 330 | sp_stop.set_defaults(func=stop) 331 | sp_clean = sp.add_parser('clean', parents=[name], help='Stop and remove the cluster containers') 332 | sp_clean.add_argument('-i', '--images', default=False, action="store_true", help='Delete '+REPO+' docker images (default: false)') 333 | sp_clean.add_argument('-d', '--dangling', default=False, action="store_true", help='Delete dangling docker images (default: false)') 334 | sp_clean.set_defaults(func=clean) 335 | parser.add_argument('--debug', default=False, action="store_true", help='Whether to print debug info (default: false)') 336 | args = parser.parse_args() 337 | 338 | debug("Arguments: {0}".format(args)) 339 | 340 | args.func(args) 341 | -------------------------------------------------------------------------------- /mysql-cluster/data-node/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM oraclelinux:latest 2 | 3 | MAINTAINER Mark Leith (mark@markleith.co.uk) 4 | 5 | RUN yum install -y https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.5/mysql-cluster-community-data-node-7.5.4-1.el7.x86_64.rpm 6 | 7 | RUN mkdir -p /var/lib/ndb/data 8 | 9 | EXPOSE 11860 10 | 11 | ADD run.sh /home/mysql/run-data.sh 12 | RUN chmod +x /home/mysql/run-data.sh 13 | ENTRYPOINT ["/home/mysql/run-data.sh"] 14 | -------------------------------------------------------------------------------- /mysql-cluster/data-node/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | CMD="/usr/sbin/ndbmtd --initial --nodaemon --ndb-nodeid=$NODE_ID --ndb-connectstring=$CONNECTSTRING" 5 | 6 | echo "" 7 | echo "Running $CMD" 8 | echo "" 9 | 10 | exec $CMD 11 | -------------------------------------------------------------------------------- /mysql-cluster/management-node/.gitignore: -------------------------------------------------------------------------------- 1 | config.ini -------------------------------------------------------------------------------- /mysql-cluster/management-node/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM oraclelinux:latest 2 | 3 | MAINTAINER Mark Leith (mark@markleith.co.uk) 4 | 5 | RUN yum install -y https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.5/mysql-cluster-community-management-server-7.5.4-1.el7.x86_64.rpm 6 | 7 | RUN mkdir -p /var/lib/ndb/management 8 | RUN mkdir -p /etc/mysql/cluster 9 | ADD config.ini /etc/mysql/cluster/config.ini 10 | RUN chmod 644 /etc/mysql/cluster/config.ini 11 | 12 | EXPOSE 1186 13 | 14 | ADD run.sh /home/mysql/run-mgmd.sh 15 | RUN chmod +x /home/mysql/run-mgmd.sh 16 | ENTRYPOINT ["/home/mysql/run-mgmd.sh"] 17 | -------------------------------------------------------------------------------- /mysql-cluster/management-node/config.ini.in: -------------------------------------------------------------------------------- 1 | [NDB_MGMD DEFAULT] 2 | Portnumber=1186 3 | DataDir=/var/lib/ndb/management 4 | ArbitrationRank=1 5 | 6 | [TCP DEFAULT] 7 | SendBufferMemory=2M 8 | ReceiveBufferMemory=2M 9 | 10 | [NDBD DEFAULT] 11 | ServerPort=11860 12 | DataDir=/var/lib/ndb/data 13 | MinDiskWriteSpeed=1M 14 | MaxDiskWriteSpeed=2M 15 | BackupMaxWriteSize=256k 16 | BackupDataBufferSize=1M 17 | BackupLogBufferSize=4M 18 | BackupReportFrequency=10 19 | MemReportFrequency=30 20 | LogLevelStartup=15 21 | LogLevelShutdown=15 22 | LogLevelCheckpoint=8 23 | LogLevelNodeRestart=15 24 | MaxNoOfTables=4096 25 | MaxNoOfTriggers=3500 26 | NoOfReplicas=2 27 | StringMemory=25 28 | DiskPageBufferMemory=64M 29 | SharedGlobalMemory=20M 30 | LongMessageBuffer=16M 31 | MaxNoOfConcurrentTransactions=16384 32 | BatchSizePerLocalScan=512 33 | FragmentLogFileSize=64M 34 | NoOfFragmentLogFiles=16 35 | RedoBuffer=8M 36 | MaxNoOfExecutionThreads=2 37 | StopOnError=false 38 | LockPagesInMainMemory=1 39 | TimeBetweenEpochsTimeout=32000 40 | TimeBetweenWatchdogCheckInitial=60000 41 | TransactionInactiveTimeout=60000 42 | HeartbeatIntervalDbDb=15000 43 | HeartbeatIntervalDbApi=15000 44 | 45 | [MYSQLD DEFAULT] 46 | ArbitrationRank=2 47 | -------------------------------------------------------------------------------- /mysql-cluster/management-node/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | CMD="/usr/sbin/ndb_mgmd -f /etc/mysql/cluster/config.ini --initial --nodaemon --ndb-nodeid=$NODE_ID --nowait-nodes=$NOWAIT" 5 | 6 | if [ "$CONNECTSTRING" != '' ]; then 7 | CMD="$CMD --ndb-connectstring=$CONNECTSTRING" 8 | fi 9 | 10 | echo "" 11 | echo "Running $CMD" 12 | echo "" 13 | 14 | exec $CMD 15 | -------------------------------------------------------------------------------- /mysql-cluster/sql-node/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM oraclelinux:latest 2 | 3 | MAINTAINER Mark Leith (mark@markleith.co.uk) 4 | 5 | ENV METHODMAKER_PACKAGE_URL ftp://rpmfind.net/linux/epel/7/x86_64/p/perl-Class-MethodMaker-2.20-1.el7.x86_64.rpm 6 | ENV LIB_PACKAGE_URL https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.5/mysql-cluster-community-libs-7.5.4-1.el7.x86_64.rpm 7 | ENV COMMON_PACKAGE_URL https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.5/mysql-cluster-community-common-7.5.4-1.el7.x86_64.rpm 8 | ENV CLIENT_PACKAGE_URL https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.5/mysql-cluster-community-client-7.5.4-1.el7.x86_64.rpm 9 | ENV SERVER_PACKAGE_URL https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.5/mysql-cluster-community-server-7.5.4-1.el7.x86_64.rpm 10 | 11 | RUN yum install -y libaio $METHODMAKER_PACKAGE_URL $LIB_PACKAGE_URL $COMMON_PACKAGE_URL $CLIENT_PACKAGE_URL $SERVER_PACKAGE_URL 12 | 13 | ADD my.cnf /etc/my.cnf 14 | RUN chmod 644 /etc/my.cnf 15 | 16 | EXPOSE 3306 17 | 18 | ADD run.sh /home/mysql/run-mysqlndb.sh 19 | RUN chmod +x /home/mysql/run-mysqlndb.sh 20 | ENTRYPOINT ["/home/mysql/run-mysqlndb.sh"] 21 | -------------------------------------------------------------------------------- /mysql-cluster/sql-node/my.cnf: -------------------------------------------------------------------------------- 1 | [mysql] 2 | 3 | user = root 4 | socket = /tmp/mysql.sock 5 | 6 | [mysqld] 7 | 8 | ndbcluster 9 | 10 | ndb-use-exact-count = 0 11 | ndb-index-stat-enable = 0 12 | ndb-force-send = 1 13 | 14 | socket = /tmp/mysql.sock 15 | 16 | max_connections = 32 17 | open_files_limit = 128 18 | table_open_cache = 128 19 | table_definition_cache = 128 20 | 21 | innodb_buffer_pool_size = 16M 22 | innodb_log_file_size = 8M 23 | -------------------------------------------------------------------------------- /mysql-cluster/sql-node/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATADIR="$(/usr/sbin/mysqld --verbose --help --log-bin-index=/tmp/tmp.index 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')" 4 | 5 | wait_for_mysql() { 6 | for i in {1..30}; do 7 | mysql -u root -S /tmp/mysql.sock -e "SELECT 1" &> /dev/null 8 | if [[ "$?" == "0" ]] ; then 9 | break 10 | fi 11 | sleep 1 12 | done 13 | if [ "$i" = 0 ]; then 14 | echo "MySQL init process failed!" 15 | exit 1 16 | fi 17 | } 18 | 19 | if [ ! -d "$DATADIR/mysql" ]; then 20 | echo "No database found, initializing..." 21 | /usr/sbin/mysqld --user=mysql --initialize-insecure=on 22 | 23 | echo "Setting credentials..." 24 | /usr/sbin/mysqld --no-defaults --user=mysql --console --skip-networking --socket=/tmp/mysql.sock & 25 | pid="$!" 26 | 27 | wait_for_mysql 28 | 29 | mysql -e " \ 30 | SET @@SESSION.SQL_LOG_BIN=0; \ 31 | DELETE FROM mysql.user WHERE user NOT IN ('mysql.sys', 'mysqlxsys'); \ 32 | CREATE USER 'root'@'%' IDENTIFIED BY 'mysql'; \ 33 | GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION; \ 34 | CREATE USER 'repl'@'%' IDENTIFIED BY 'repl'; \ 35 | GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%'; \ 36 | CREATE USER 'mem'@'%' IDENTIFIED BY 'mem'; \ 37 | GRANT SELECT, SHOW DATABASES, SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mem'@'%'; \ 38 | FLUSH PRIVILEGES;" 39 | 40 | if ! kill -s TERM "$pid" || ! wait "$pid"; then 41 | echo "MySQL init process failed!" 42 | exit 1 43 | fi 44 | fi 45 | 46 | CMD="/usr/sbin/mysqld --user=mysql --ndb-nodeid=$NODE_ID --ndb-connectstring=$CONNECTSTRING --server-id=$NODE_ID" 47 | 48 | echo "Running: $CMD" 49 | 50 | exec $CMD 51 | -------------------------------------------------------------------------------- /mysql-repo-server-5.6-centos-6.8/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM markleith/centos-6.8 2 | 3 | MAINTAINER Mark Leith (mark@markleith.co.uk) 4 | 5 | RUN rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm 6 | RUN yum -y install mysql-community-server 7 | 8 | RUN git clone https://github.com/MarkLeith/mysql-sys.git /tmp/mysql-sys 9 | 10 | ADD mysql-init /usr/bin/mysql-init 11 | RUN chmod +x /usr/bin/mysql-init 12 | RUN /usr/bin/mysql-init 13 | 14 | ADD mysql-start /usr/bin/mysql-start 15 | RUN chmod +x /usr/bin/mysql-start 16 | 17 | ADD my.cnf /etc/my.cnf 18 | 19 | EXPOSE 22 3306 20 | 21 | ENTRYPOINT ["/usr/bin/mysql-start"] 22 | 23 | -------------------------------------------------------------------------------- /mysql-repo-server-5.6-centos-6.8/my.cnf: -------------------------------------------------------------------------------- 1 | [mysql] 2 | 3 | user = root 4 | password = mysql 5 | socket = /var/lib/mysql/mysql.sock 6 | 7 | [mysqld] 8 | 9 | user = mysql 10 | 11 | datadir = /var/lib/mysql 12 | socket = /var/lib/mysql/mysql.sock 13 | 14 | skip-name-resolve 15 | symbolic-links = 0 16 | sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 17 | 18 | max_connections = 32 19 | open_files_limit = 128 20 | table_open_cache = 128 21 | table_definition_cache = 128 22 | 23 | innodb_buffer_pool_size = 32M 24 | innodb_log_file_size = 16M 25 | 26 | log_bin 27 | log_slave_updates 28 | gtid_mode = ON 29 | enforce_gtid_consistency 30 | sync_binlog = 1 31 | 32 | [mysqld_safe] 33 | 34 | log-error = /var/log/mysqld.log 35 | pid-file = /var/run/mysqld/mysqld.pid 36 | 37 | -------------------------------------------------------------------------------- /mysql-repo-server-5.6-centos-6.8/mysql-init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/bin/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf 4 | 5 | /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf & 6 | 7 | sleep 3 8 | 9 | mysql -u root -e " \ 10 | SET PASSWORD = PASSWORD('mysql'); \ 11 | UPDATE mysql.user SET password = PASSWORD('mysql') WHERE user = 'root'; \ 12 | DELETE FROM mysql.user WHERE user = ''; \ 13 | GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION; \ 14 | GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'repl'; \ 15 | GRANT SELECT, SHOW DATABASES, SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mem'@'%' IDENTIFIED BY 'mem'" 16 | 17 | cd /tmp/mysql-sys 18 | mysql -u root -pmysql < sys_56.sql 19 | cd ~ 20 | rm -rf /tmp/mysql-sys 21 | 22 | /usr/bin/mysqladmin -u root -pmysql shutdown 23 | 24 | -------------------------------------------------------------------------------- /mysql-repo-server-5.6-centos-6.8/mysql-start: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/sbin/sshd 4 | 5 | mysqld_safe --defaults-file=/etc/my.cnf 6 | -------------------------------------------------------------------------------- /mysql-repo-server-5.6-ubuntu-14.04/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM markleith/ubuntu-14.04 2 | 3 | MAINTAINER Mark Leith (mark@markleith.co.uk) 4 | 5 | # Latest MySQL from Oracle offical repos 6 | ADD http://dev.mysql.com/get/mysql-apt-config_0.1.5-2ubuntu14.04_all.deb /tmp/ 7 | RUN DEBIAN_FRONTEND=noninteractive dpkg -i /tmp/mysql-apt-config_0.1.5-2ubuntu14.04_all.deb 8 | RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server 9 | 10 | RUN git clone https://github.com/MarkLeith/mysql-sys.git /tmp/mysql-sys 11 | 12 | ADD my.cnf /etc/mysql/my.cnf 13 | 14 | ADD mysql-init /usr/bin/mysql-init 15 | RUN chmod +x /usr/bin/mysql-init 16 | RUN /usr/bin/mysql-init 17 | 18 | ADD mysql-start /usr/bin/mysql-start 19 | RUN chmod +x /usr/bin/mysql-start 20 | 21 | EXPOSE 22 3306 22 | 23 | ENTRYPOINT ["/usr/bin/mysql-start"] 24 | 25 | -------------------------------------------------------------------------------- /mysql-repo-server-5.6-ubuntu-14.04/my.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | port = 3306 3 | socket = /var/run/mysqld/mysqld.sock 4 | 5 | [mysqld_safe] 6 | socket = /var/run/mysqld/mysqld.sock 7 | nice = 0 8 | 9 | [mysqld] 10 | user = mysql 11 | pid-file = /var/run/mysqld/mysqld.pid 12 | socket = /var/run/mysqld/mysqld.sock 13 | port = 3306 14 | basedir = /usr 15 | datadir = /var/lib/mysql 16 | tmpdir = /tmp 17 | 18 | lc-messages-dir = /usr/share/mysql 19 | skip-external-locking 20 | skip-name-resolve 21 | symbolic-links = 0 22 | sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 23 | 24 | max_allowed_packet = 16M 25 | thread_stack = 192K 26 | thread_cache_size = 8 27 | myisam-recover = BACKUP 28 | 29 | log_error = /var/log/mysql/error.log 30 | 31 | max_connections = 32 32 | open_files_limit = 128 33 | table_open_cache = 128 34 | table_definition_cache = 128 35 | 36 | innodb_buffer_pool_size = 32M 37 | innodb_log_file_size = 16M 38 | 39 | log_bin 40 | log_slave_updates 41 | gtid_mode = ON 42 | enforce_gtid_consistency 43 | sync_binlog = 1 44 | expire_logs_days = 10 45 | max_binlog_size = 100M 46 | 47 | [mysqldump] 48 | quick 49 | quote-names 50 | max_allowed_packet = 16M 51 | 52 | !includedir /etc/mysql/conf.d/ 53 | -------------------------------------------------------------------------------- /mysql-repo-server-5.6-ubuntu-14.04/mysql-init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /etc/init.d/mysql start 4 | 5 | sleep 5 6 | 7 | mysql -u root -e " \ 8 | SET PASSWORD = PASSWORD('mysql'); \ 9 | UPDATE mysql.user SET password = PASSWORD('mysql') WHERE user = 'root'; \ 10 | DELETE FROM mysql.user WHERE user = ''; \ 11 | GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION; \ 12 | GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'repl'; \ 13 | GRANT SELECT, SHOW DATABASES, SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mem'@'%' IDENTIFIED BY 'mem'" 14 | 15 | cd /tmp/mysql-sys 16 | mysql -u root -pmysql < sys_56.sql 17 | cd ~ 18 | rm -rf /tmp/mysql-sys 19 | 20 | /etc/init.d/mysql stop 21 | 22 | -------------------------------------------------------------------------------- /mysql-repo-server-5.6-ubuntu-14.04/mysql-start: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/sbin/sshd 4 | 5 | /etc/init.d/mysql start 6 | 7 | tail -f /var/log/mysql/error.log 8 | 9 | -------------------------------------------------------------------------------- /sysbench-0.5/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM markleith/centos-6.8 2 | 3 | MAINTAINER Mark Leith (mark@markleith.co.uk) 4 | 5 | RUN rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm 6 | RUN yum -y install mysql-community-devel mysql-community-client 7 | 8 | RUN yum -y install automake libtool gcc 9 | 10 | RUN bzr branch lp:sysbench 11 | RUN cd sysbench && ./autogen.sh && ./configure --without-drizzle --with-mysql --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib64/mysql && make && make install 12 | 13 | --------------------------------------------------------------------------------