| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | ################################################################################################### |
|---|
| 4 | # # |
|---|
| 5 | # This code is released under the GNU General Public License, Version 3, see for details: # |
|---|
| 6 | # http://www.gnu.org/licenses/gpl-3.0.txt # |
|---|
| 7 | # # |
|---|
| 8 | # Commercial licenses can be acquired by contacting info@www.jimdowling.info # |
|---|
| 9 | # # |
|---|
| 10 | # Copyright (c) Jim Dowling, 2007. # |
|---|
| 11 | # All Rights Reserved. # |
|---|
| 12 | # # |
|---|
| 13 | ################################################################################################### |
|---|
| 14 | |
|---|
| 15 | ################################################################################################### |
|---|
| 16 | # # |
|---|
| 17 | # ####### # # # ####### ######## ###### ###### # |
|---|
| 18 | # # # # # # # # # # # |
|---|
| 19 | # # # # # ####### # ##### ##### # |
|---|
| 20 | # # # # # # # # # # # |
|---|
| 21 | # ####### ###### ####### ####### # ###### # # # |
|---|
| 22 | # # |
|---|
| 23 | # # # # ####### ######## ###### # # ###### ###### # |
|---|
| 24 | # # ## # # # # # # # # # # # |
|---|
| 25 | # # # # # ####### # ###### # # ##### ##### # |
|---|
| 26 | # # # ## # # # # # # # # # # |
|---|
| 27 | # # # # ####### # # # ###### ###### ###### # # # |
|---|
| 28 | # # |
|---|
| 29 | ################################################################################################### |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | ################################################################################################### |
|---|
| 34 | # NDB VERSION AND MIRROR CONFIG OPTIONS |
|---|
| 35 | ################################################################################################### |
|---|
| 36 | |
|---|
| 37 | NDB_INSTALLER_VERSION="Ndb Installer Version 0.2 \n\nCopyright (c) Jim Dowling, 2007." |
|---|
| 38 | |
|---|
| 39 | PRODUCT="MySQL Cluster" |
|---|
| 40 | PLATFORM="linux" |
|---|
| 41 | CPU= |
|---|
| 42 | RELEASE="-telco" |
|---|
| 43 | |
|---|
| 44 | MYSQL_VERSION_MAJOR="5" |
|---|
| 45 | MYSQL_VERSION_MINOR="1" |
|---|
| 46 | MYSQL_VERSION_REV="24" |
|---|
| 47 | |
|---|
| 48 | NDB_VERSION_MAJOR="6" |
|---|
| 49 | NDB_VERSION_MINOR="3" |
|---|
| 50 | NDB_VERSION_REV="16" |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | # |
|---|
| 56 | # ftp://ftp.mysql.com/pub/mysql/download/cluster_telco/mysql-5.1.24-ndb-6.3.16/mysql-5.1.24-ndb-6.3.16-telco.tar.gz |
|---|
| 57 | # |
|---|
| 58 | # E.g., VERSION="mysql-5.1.22-beta-linux-i686"; used for myql directory name |
|---|
| 59 | # Version numbers are constructed to look like (eg) 'mysql-5.1.24-ndb-6.2.15-telco.tar.gz' |
|---|
| 60 | #VERSION="mysql-${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_REV} |
|---|
| 61 | # ${NDB_VERSION_MAJOR}.${NDB_VERSION_MINOR}.${NDB_VERSION_REV}-${RELEASE}-${PLATFORM}-$CPU$" |
|---|
| 62 | VERSION= |
|---|
| 63 | # NDB_VERSION used for ndb directory name |
|---|
| 64 | #NDB_VERSION="-ndb-${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_REV}${RELEASE}" |
|---|
| 65 | #" -${PLATFORM}-$CPU" |
|---|
| 66 | NDB_VERSION= |
|---|
| 67 | |
|---|
| 68 | # Where to download mysql binaries from |
|---|
| 69 | MIRROR="ftp://ftp.mysql.com/pub/mysql/download/cluster_telco/" |
|---|
| 70 | |
|---|
| 71 | MIRROR1="/from/http://www.mirrorservice.org/sites/ftp.mysql.com/" |
|---|
| 72 | MIRROR2="/from/http://ftp.heanet.ie/mirrors/www.mysql.com/" |
|---|
| 73 | MIRROR3="/from/2http://mysql.he.net/" |
|---|
| 74 | MIRROR4="/from/http://mysql.orst.edu/" |
|---|
| 75 | MIRROR5="/from/http://mirror.switch.ch/ftp/mirror/mysql/" |
|---|
| 76 | |
|---|
| 77 | # This is bash-only |
|---|
| 78 | #MIRRORS=( $MIRROR1 $MIRROR2 $MIRROR3 $MIRROR4 $MIRROR5 ) |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | ################################################################################################### |
|---|
| 82 | # Default Install Directories. Note these are changed in check_usesrid() |
|---|
| 83 | # if the user does not run the script as root. |
|---|
| 84 | ################################################################################################### |
|---|
| 85 | NDB_INSTALL_DIR=/var/lib/mysql-cluster |
|---|
| 86 | NDB_DIR=/var/lib/mysql-cluster |
|---|
| 87 | MYSQL_INSTALL_DIR= |
|---|
| 88 | #/usr/local |
|---|
| 89 | MYSQL_BASE_DIR= |
|---|
| 90 | NDB_DATADIR=ndb_data |
|---|
| 91 | MGM_DATADIR=mgmd1 |
|---|
| 92 | MYSQL_BINARIES_DIR= |
|---|
| 93 | NDB_LOGS_DIR= |
|---|
| 94 | MYSQL_NUM=mysql_1 |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | ################################################################################################### |
|---|
| 98 | # NDB Data Node hostnames |
|---|
| 99 | ################################################################################################### |
|---|
| 100 | # declare an array of nodes |
|---|
| 101 | # Max Number of Hosts set to 16. You can add more entries here. |
|---|
| 102 | # TODO: change this from bash (arrays) to no arrays (csh) |
|---|
| 103 | #declare -a NDB_HOST |
|---|
| 104 | #NDB_HOST[0]="localhost" |
|---|
| 105 | #NDB_HOST[1]="localhost" |
|---|
| 106 | #NDB_HOST[2]="localhost" |
|---|
| 107 | #NDB_HOST[3]="localhost" |
|---|
| 108 | |
|---|
| 109 | NDB_HOST=('localhost' |
|---|
| 110 | 'localhost' |
|---|
| 111 | 'localhost' |
|---|
| 112 | 'localhost' |
|---|
| 113 | 'localhost' |
|---|
| 114 | 'localhost' |
|---|
| 115 | 'localhost' |
|---|
| 116 | 'localhost' |
|---|
| 117 | 'localhost' |
|---|
| 118 | 'localhost' |
|---|
| 119 | 'localhost' |
|---|
| 120 | 'localhost' |
|---|
| 121 | 'localhost' |
|---|
| 122 | 'localhost' |
|---|
| 123 | 'localhost' |
|---|
| 124 | 'localhost' |
|---|
| 125 | 'localhost' |
|---|
| 126 | ) |
|---|
| 127 | if [ $? -ne 0 ] ; then |
|---|
| 128 | exit_error "Arrays not supported in your shell version" |
|---|
| 129 | fi |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | ######################################################## |
|---|
| 133 | # NDB Default Configuration # |
|---|
| 134 | ######################################################## |
|---|
| 135 | |
|---|
| 136 | # The 'M' is appended to DataMemory and IndexMemory sizes later in script |
|---|
| 137 | DATA_MEMORY=80 |
|---|
| 138 | INDEX_MEMORY=18 |
|---|
| 139 | |
|---|
| 140 | # Extra config.ini default values |
|---|
| 141 | STRING_MEMORY=25 |
|---|
| 142 | MAX_NO_OF_TABLES=4096 |
|---|
| 143 | MAX_NO_OF_ORDERED_INDEXES=2048 |
|---|
| 144 | MAX_NO_OF_UNIQUE_HASH_INDEXES=4096 |
|---|
| 145 | MAX_NO_OF_ATTRIBUTES=24576 |
|---|
| 146 | MAX_NO_OF_CONCURRENT_SCANS=256 |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | # Redo Log file Default Size |
|---|
| 150 | NUM_FRAGMENT_LOGFILES=6 |
|---|
| 151 | FRAGMENT_LOGFILE_SIZE=256M |
|---|
| 152 | |
|---|
| 153 | # Default Number of Replicas |
|---|
| 154 | NUM_REPLICAS=2 |
|---|
| 155 | |
|---|
| 156 | # Default hostname for Mgm Server |
|---|
| 157 | MGM_HOST=$LOCALHOST |
|---|
| 158 | |
|---|
| 159 | # Disk write b/w used for checkpoints |
|---|
| 160 | DISK_CHECKPOINT_SPEED=10 |
|---|
| 161 | |
|---|
| 162 | # Disk write b/w for checkpoints when restarting a node |
|---|
| 163 | DISK_CHECKPOINT_SPEED_IN_RESTART=100 |
|---|
| 164 | |
|---|
| 165 | # Disk Buffer used when writing checkpoints |
|---|
| 166 | DISK_SYNC_SIZE=4 |
|---|
| 167 | |
|---|
| 168 | # Size of the Redo Log Buffer |
|---|
| 169 | REDO_BUFFER=32 |
|---|
| 170 | |
|---|
| 171 | # This parameter states the maximum time that is permitted to lapse |
|---|
| 172 | # between operations in the same transaction before the transaction is aborted. |
|---|
| 173 | TRANSACTION_INACTIVE_TIMEOUT=2000 |
|---|
| 174 | |
|---|
| 175 | # Time for master to ping all ndbds |
|---|
| 176 | TIME_BETWEEN_GLOBAL_CHECKPOINTS=1000 |
|---|
| 177 | |
|---|
| 178 | # Amount of Bytes in 2^N before local checkpoint is started |
|---|
| 179 | # 20 is the default value, where 4MB of writes need to be executed before a |
|---|
| 180 | # Local Checkpoint (LCP) is performed. If you set to '21', it's 8MB of writes, etc. |
|---|
| 181 | TIME_BETWEEN_LOCAL_CHECKPOINTS=20 |
|---|
| 182 | |
|---|
| 183 | # Time between replication events |
|---|
| 184 | TIME_BETWEEN_EPOCHS=100 |
|---|
| 185 | |
|---|
| 186 | # Memory Usage Reports Entered into the cluster log every X/2 minutes |
|---|
| 187 | MEMORY_REPORT_FREQUENCY=10 |
|---|
| 188 | |
|---|
| 189 | # Backup reports entered into cluster log every X/2 minutes |
|---|
| 190 | BACKUP_REPORT_FREQUENCY=5 |
|---|
| 191 | |
|---|
| 192 | # Prevents cluster db from being swapped to disk |
|---|
| 193 | LOCK_PAGES_IN_MAIN_MEMORY=1 |
|---|
| 194 | |
|---|
| 195 | # Name of clusterlog file |
|---|
| 196 | CLUSTER_LOG_FILENAME=cluster.log |
|---|
| 197 | |
|---|
| 198 | # Node-ID for the Management Server |
|---|
| 199 | MGMD_ID=63 |
|---|
| 200 | |
|---|
| 201 | ######################################################## |
|---|
| 202 | # MySQL Server Default Configuration # |
|---|
| 203 | ######################################################## |
|---|
| 204 | |
|---|
| 205 | # Default values for my.cnf configuration variables |
|---|
| 206 | MYSQL_PID= |
|---|
| 207 | DEFAULT_MGM_PORT=1186 |
|---|
| 208 | MGM_PORT=$DEFAULT_MGM_PORT |
|---|
| 209 | MYSQL_PORT=3306 |
|---|
| 210 | MYSQL_SOCK=/tmp/mysql.sock |
|---|
| 211 | SKIP_INNODB= #"skip-plugin-innodb" |
|---|
| 212 | MYSQL_HOST="127.0.0.1" #localhost |
|---|
| 213 | REPLICATION_MASTER= |
|---|
| 214 | BINARY_LOG= |
|---|
| 215 | SERVER_ID= |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | ######################################################## |
|---|
| 219 | # ndbinstaller.sh SCRIPT PARAMETERS # |
|---|
| 220 | ######################################################## |
|---|
| 221 | |
|---|
| 222 | FORCE_GENERATE_SSH_KEY=0 |
|---|
| 223 | PARAM_NUM_NODES= |
|---|
| 224 | PARAM_CONFIG_DEFAULT=0 |
|---|
| 225 | PARAM_NODEID= |
|---|
| 226 | PARAM_USERNAME=0 |
|---|
| 227 | NDBD_PARAM_NO=0 |
|---|
| 228 | MGM_HOST_NOT_SET=1 |
|---|
| 229 | MGM_PORT_NOT_SET=1 |
|---|
| 230 | PARAM_DEFAULT_INSTALL_NDB_DIR=0 |
|---|
| 231 | PARAM_DEFAULT_INSTALL_MYSQL_DIR=0 |
|---|
| 232 | PARAM_DEFAULT_MYSQL_SETTINGS=0 |
|---|
| 233 | |
|---|
| 234 | ######################################################## |
|---|
| 235 | # Script Internal Configuration Params # |
|---|
| 236 | ######################################################## |
|---|
| 237 | |
|---|
| 238 | LOCALHOST="localhost" #127.0.0.1 |
|---|
| 239 | |
|---|
| 240 | |
|---|
| 241 | # Default values for user install actions |
|---|
| 242 | SYSTEM_INSTALL=1 |
|---|
| 243 | SYMBOLIC_LINK=1 |
|---|
| 244 | INSTALL_DB=1 |
|---|
| 245 | GET_BINARIES=1 |
|---|
| 246 | UNTAR=1 |
|---|
| 247 | DEBUG=0 |
|---|
| 248 | INITIAL=0 |
|---|
| 249 | USERNAME=mysql |
|---|
| 250 | HOMEDIR= |
|---|
| 251 | INSTALL_BINARIES=1 |
|---|
| 252 | REMOVE_EXPANDED_BINARIES_AFTER_INSTALL=0 |
|---|
| 253 | START_WITH_SSH=0 |
|---|
| 254 | ADD_MYSQLD=0 |
|---|
| 255 | |
|---|
| 256 | # failure codes returned by script |
|---|
| 257 | SUCCESS=0 |
|---|
| 258 | FAILURE=-1 |
|---|
| 259 | DIR_NOT_FOUND=-2 |
|---|
| 260 | CONFIG_ERROR=-3 |
|---|
| 261 | COULD_NOT_START_NDBS=-4 |
|---|
| 262 | EXIT_SIGNAL_CAUGHT=-5 |
|---|
| 263 | COULD_NOT_CREATE_USER=-6 |
|---|
| 264 | COULD_NOT_CHANGE_PASSWD=-7 |
|---|
| 265 | |
|---|
| 266 | SCRIPTNAME=`basename $0` |
|---|
| 267 | |
|---|
| 268 | # Default values for the generated startup scripts |
|---|
| 269 | NO_DAEMON= |
|---|
| 270 | NO_DAEMON_LAUNCH= |
|---|
| 271 | |
|---|
| 272 | # Script names |
|---|
| 273 | INIT_START=init-start-cluster |
|---|
| 274 | NORMAL_START=start-noinit-cluster |
|---|
| 275 | CLUSTER_START=node.sh |
|---|
| 276 | NDBD_INIT=init-start-ndbd |
|---|
| 277 | NDBD_START=start-noinit-ndbd |
|---|
| 278 | CLUSTER_SHUTDOWN=shutdown-cluster.sh |
|---|
| 279 | MGM_CLIENT_START=mgm-client.sh |
|---|
| 280 | ROLLING_RESTART=rolling-restart |
|---|
| 281 | MGMD_START=mgm-server-start |
|---|
| 282 | START_BACKUP=start-backup.sh |
|---|
| 283 | NDB_RESTORE=ndb-restore.sh |
|---|
| 284 | ENTER_SINGLE_USER_MODE=enter-singleuser-mode.sh |
|---|
| 285 | EXIT_SINGLE_USER_MODE=exit-singleuser-mode.sh |
|---|
| 286 | MEMORY_USAGE_SCRIPT=memory-usage.sh |
|---|
| 287 | |
|---|
| 288 | # Temporary Scripts for Patching |
|---|
| 289 | MYSQLSTART_TMP="/tmp/mysql-start.sh" |
|---|
| 290 | MYSQL_SHUTDOWN_TMP="/tmp/mysql-shutdown.sh" |
|---|
| 291 | |
|---|
| 292 | # Default values for cluster startup from script |
|---|
| 293 | MGM_STARTUP_TIME=15 |
|---|
| 294 | NDB_WAIT=40 # 20 seconds =4 minutes to wait for NDBDs to be started |
|---|
| 295 | NDB_START_WAIT=60 # 1 minute max |
|---|
| 296 | NUM_NODES_TO_START=2 |
|---|
| 297 | NUM_MYSQLS=0 |
|---|
| 298 | NUM_MYSQL_BINS=0 |
|---|
| 299 | # Num seconds to wait when testing to see if a cluster is already running |
|---|
| 300 | WAIT_CLUSTER_ALREADY_RUNNING=2 |
|---|
| 301 | # Time to wait for a NDBD to restart during a rolling restart |
|---|
| 302 | NDBD_RESTART_TIMEOUT=300 |
|---|
| 303 | |
|---|
| 304 | # User Installation Options Variables |
|---|
| 305 | NUM_NODES=4 |
|---|
| 306 | INSTALL_LOG="cluster_"installation-${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_REV}".log" |
|---|
| 307 | |
|---|
| 308 | # Used by 'wget' to download binaries |
|---|
| 309 | HTTP_PROXY= |
|---|
| 310 | HTTP_USER= |
|---|
| 311 | HTTP_PASS= |
|---|
| 312 | PROXY= |
|---|
| 313 | |
|---|
| 314 | # Script-Internal Installation Variables |
|---|
| 315 | NDB_NUM= |
|---|
| 316 | FINISHED_INSTALLDIRS=0 |
|---|
| 317 | MOVE_BINARIES=0 |
|---|
| 318 | START_SCRIPTS= |
|---|
| 319 | NDB_HOME= |
|---|
| 320 | MYSQL_DATA_DIR= |
|---|
| 321 | CHANGE_PORT_SCRIPT= |
|---|
| 322 | CHANGE_SOCKET_SCRIPT= |
|---|
| 323 | INSTALL_AS_DAEMON_HELP= |
|---|
| 324 | MYSQL_INSTALLED= |
|---|
| 325 | MYSQL_BINARIES_INSTALLED= |
|---|
| 326 | MYSQLD_STARTER= |
|---|
| 327 | MYSQLD_STOPPER= |
|---|
| 328 | LINUX_DISTRIBTUION= |
|---|
| 329 | |
|---|
| 330 | # Install action options |
|---|
| 331 | #INSTALL_COMPILE=0 |
|---|
| 332 | INSTALL_LOCALHOST=1 |
|---|
| 333 | INSTALL_MGM=2 |
|---|
| 334 | INSTALL_NDB=3 |
|---|
| 335 | INSTALL_MYSQLD=4 |
|---|
| 336 | INSTALL_ANOTHER_MYSQLD_LOCALHOST=5 |
|---|
| 337 | INSTALL_LOCALHOST_MYSQLD=6 |
|---|
| 338 | INSTALL_ANOTHER_MYSQLD=7 |
|---|
| 339 | INSTALL_ACTION= |
|---|
| 340 | NODEID= |
|---|
| 341 | |
|---|
| 342 | ################################################################################################### |
|---|
| 343 | # Sanity check for the script's current PATH |
|---|
| 344 | ################################################################################################### |
|---|
| 345 | |
|---|
| 346 | # Get the PATH where this script is stored |
|---|
| 347 | # If script ran as: ./$SCRIPT_NAME, then it's the working directory |
|---|
| 348 | CWD=`dirname $0` |
|---|
| 349 | if [ "$CWD" = "." ] ; then |
|---|
| 350 | CWD=`pwd` |
|---|
| 351 | fi |
|---|
| 352 | |
|---|
| 353 | i=0 |
|---|
| 354 | i=$(($i+`echo "$CWD" | grep -c \ `)) |
|---|
| 355 | i=$(($i+`echo "$CWD" | grep -c \*`)) |
|---|
| 356 | i=$(($i+`echo "$CWD" | grep -c \\\\\\\\`)) |
|---|
| 357 | i=$(($i+`echo "$CWD" | grep -c \"`)) |
|---|
| 358 | i=$(($i+`echo "$CWD" | grep -c \'`)) |
|---|
| 359 | i=$(($i+`echo "$CWD" | grep -c \\\``)) |
|---|
| 360 | if [ $i -ne 0 ]; |
|---|
| 361 | then |
|---|
| 362 | echo "Path to current working directory contains critical characters" |
|---|
| 363 | echo "like an asterisk, backslash, quotes or spaces. Since some system" |
|---|
| 364 | echo "tools will not cope with such characters this script will abort now." |
|---|
| 365 | echo "Unable to determine XFree86 Version. Stopping now." |
|---|
| 366 | echo "" |
|---|
| 367 | exit 1 |
|---|
| 368 | fi |
|---|
| 369 | |
|---|
| 370 | #################################################################################################### |
|---|
| 371 | # HELP STRINGS |
|---|
| 372 | #################################################################################################### |
|---|
| 373 | |
|---|
| 374 | README=" |
|---|
| 375 | README for MySQL Cluster installed using ndbinstaller.\n |
|---|
| 376 | \n |
|---|
| 377 | NDBINSTALLER SCRIPTS\n |
|---|
| 378 | Bash shell scripts for starting, stopping, accessing and administering\n |
|---|
| 379 | your MySQL Cluster are located in:\n |
|---|
| 380 | ./ndb/scripts\n |
|---|
| 381 | \n |
|---|
| 382 | Please read all of this README before starting/stopping your cluster,\n |
|---|
| 383 | as there are different scripts for the first startup of cluster,\n |
|---|
| 384 | and subsequent startups. Use the --help switch to find out more\n |
|---|
| 385 | information about the different scripts.\n |
|---|
| 386 | \n |
|---|
| 387 | \n |
|---|
| 388 | 1.\n |
|---|
| 389 | move to the scripts directory:\n |
|---|
| 390 | cd ndb/scripts\n |
|---|
| 391 | \n |
|---|
| 392 | 1. FIRST TIME START OF MYSQL CLUSTER \n |
|---|
| 393 | To start a 2-node cluster for the first time:\n |
|---|
| 394 | ./init-start-cluster-2node.sh\n |
|---|
| 395 | \n |
|---|
| 396 | If instead, you want to start a 4-node cluster (for the first time) use:\n |
|---|
| 397 | ./init-start-cluster-4node.sh\n |
|---|
| 398 | \n |
|---|
| 399 | These scripts perform an \"initial start\", where the contents of the\n |
|---|
| 400 | database are deleted. Be care not to call these scripts if you\n |
|---|
| 401 | have important data stored in the database.\n |
|---|
| 402 | \n |
|---|
| 403 | 2. USE MGM CLIENT TO SEE IF CLUSTER IS WORKING PROPERLY\n |
|---|
| 404 | ./mgm-client.sh -e show\n |
|---|
| 405 | \n |
|---|
| 406 | This should show you the following (2 ndbd nodes running, 1 mgmd running,\n |
|---|
| 407 | and a MySQL server connected to the cluster):\n |
|---|
| 408 | Connected to Management Server at: localhost:1186\n |
|---|
| 409 | Cluster Configuration\n |
|---|
| 410 | ---------------------\n |
|---|
| 411 | [ndbd(NDB)] 2 node(s)\n |
|---|
| 412 | id=1 @127.0.0.1 (mysql-5.1.24 ndb-6.3.16, Nodegroup: 0, Master)\n |
|---|
| 413 | id=2 @127.0.0.1 (mysql-5.1.24 ndb-6.3.16, Nodegroup: 0)\n |
|---|
| 414 | \n |
|---|
| 415 | [ndb_mgmd(MGM)] 1 node(s)\n |
|---|
| 416 | id=63 @127.0.0.1 (mysql-5.1.24 ndb-6.3.16)\n |
|---|
| 417 | \n |
|---|
| 418 | [mysqld(API)] 9 node(s)\n |
|---|
| 419 | id=3 @127.0.0.1 (mysql-5.1.24 ndb-6.3.16)\n |
|---|
| 420 | \n |
|---|
| 421 | If this step failed, there was a problem starting your cluster.\n |
|---|
| 422 | \n |
|---|
| 423 | \n |
|---|
| 424 | 3. CREATE A TABLE USING THE MYSQL CLIENT \n |
|---|
| 425 | ./mysql-client-1.sh test\n |
|---|
| 426 | \n |
|---|
| 427 | mysql> create table test_ndb (id int) engine=ndbcluster;\n |
|---|
| 428 | \n |
|---|
| 429 | mysql> insert into test_ndb values (1),(2);\n |
|---|
| 430 | \n |
|---|
| 431 | mysql> show create table test_ndb\G\n |
|---|
| 432 | *************************** 1. row ***************************\n |
|---|
| 433 | Table: test_ndb\n |
|---|
| 434 | Create Table: CREATE TABLE test_ndb (\n |
|---|
| 435 | id int(11) DEFAULT NULL\n |
|---|
| 436 | ) ENGINE=ndbcluster DEFAULT CHARSET=latin1\n |
|---|
| 437 | 1 row in set (0.00 sec)\n |
|---|
| 438 | \n |
|---|
| 439 | # The above showed that we successfully created a ndb table \n |
|---|
| 440 | \n |
|---|
| 441 | 4. SHUTTING DOWN MYSQL CLUSTER\n |
|---|
| 442 | ./shutdown-cluster.sh\n |
|---|
| 443 | \n |
|---|
| 444 | This stops the ndbd nodes, the ndb_mgmd node and the mysqld node.\n |
|---|
| 445 | You can skip stopping the mysqld node using a switch.\n |
|---|
| 446 | \n |
|---|
| 447 | 5. SUBSEQUENT STARTS OF MYSQL CLUSTER (after 1st time)\n |
|---|
| 448 | Non-first-time start of a 2-node cluster is performed using:\n |
|---|
| 449 | ./start-noinit-cluster-2node.sh\n |
|---|
| 450 | \n |
|---|
| 451 | This script performs a \"normal start\", where the contents of the\n |
|---|
| 452 | database are not deleted. \n |
|---|
| 453 | \n |
|---|
| 454 | ---------------------\n |
|---|
| 455 | AUTHOR Jim Dowling \n |
|---|
| 456 | Date: Sept 1, 2008\n |
|---|
| 457 | " |
|---|
| 458 | |
|---|
| 459 | USE_BINARIES_HELP=" |
|---|
| 460 | Use Existing Binaries Help\n |
|---|
| 461 | =========================================================================== |
|---|
| 462 | \n |
|---|
| 463 | You can use the existing MySQL binaries that are installed on this machine\n |
|---|
| 464 | to run a Data Node, Management Server or MySQL Server.\n |
|---|
| 465 | Data Nodes and MySQL Servers will install their own data directory, under\n |
|---|
| 466 | the \$NDB_HOME directory. So each Data Node or MySQL Server has its own\n |
|---|
| 467 | data directory, but Data Nodes and MySQL Servers can share the same copy of\n |
|---|
| 468 | the MySQL binaries.\n |
|---|
| 469 | \n |
|---|
| 470 | Use the existing binaries for this installation?" |
|---|
| 471 | |
|---|
| 472 | CPU_HELP=" |
|---|
| 473 | Which CPU Version Help\n |
|---|
| 474 | =========================================================================== |
|---|
| 475 | \n |
|---|
| 476 | To find out the CPU type of this machine, type 'less /proc/cpuinfo'.\n |
|---|
| 477 | Data nodes and management servers must have the same type of CPU architecture.\n |
|---|
| 478 | So, you cannot mix x86 and powerpc nodes in a cluster.\n |
|---|
| 479 | It is not recommended to mix 32-bit and 64-bit data nodes in the same cluster.\n |
|---|
| 480 | Requirements: this installer expects that you have libc version 2.3 installed." |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | |
|---|
| 484 | get_install_option_help() |
|---|
| 485 | { |
|---|
| 486 | if [ $ROOTUSER -eq 1 ] ; then |
|---|
| 487 | INSTALL_AS_DAEMON_HELP="You are installing cluster as root user. The ndb_mgmd and\n ndbd processes will start as daemon processes." |
|---|
| 488 | else |
|---|
| 489 | INSTALL_AS_DAEMON_HELP="You are installing cluster as normal (non-root) user. The ndb_mgmd and\n ndbd processes will start as user-level processes in '--no-daemon' mode." |
|---|
| 490 | fi |
|---|
| 491 | |
|---|
| 492 | INSTALL_OPTION_HELP=" |
|---|
| 493 | Install Options Help\n |
|---|
| 494 | ===========================================================================\n |
|---|
| 495 | A MySQL Cluster consists of up to 63 nodes: 1 or more Management Server, \n |
|---|
| 496 | (ndb_mgmd), Data Nodes (ndbd), and Clients (MySQL Servers and/or NDBAPI apps).\n |
|---|
| 497 | $INSTALL_AS_DAEMON_HELP\n |
|---|
| 498 | \n |
|---|
| 499 | (1) Setup and start a localhost cluster. The cluster will run on this machine. \n |
|---|
| 500 | \t1 ndb_mgmd, 2/4 ndbds, and 1 mysqld will be configured.\n |
|---|
| 501 | \tScripts will generated that allow you to stop/start the cluster.\n |
|---|
| 502 | \tYou can start the cluster running at the end of the installation.\n |
|---|
| 503 | (2) Add a MySQL Server ('mysqld') to an installed localhost cluster.\n |
|---|
| 504 | \tRequirement: You have run installation step (1).\n |
|---|
| 505 | (3) Setup a distributed cluster. Installs a Management Server on the current\n |
|---|
| 506 | \thost. This is the first step in installing a distributed cluster.\n |
|---|
| 507 | (4) Add a data node (the 'ndbd' process) to a distributed cluster.\n |
|---|
| 508 | \tRequirement: You have run installation step (3) on this or another host.\n |
|---|
| 509 | \tRequirement: You know the 'connectstring' for the Management Server.\n |
|---|
| 510 | (5) Add a MySQL Server ('mysqld') to an installed distributed cluster.\n |
|---|
| 511 | \tRequirement: You have run installation step (3).\n |
|---|
| 512 | \tRequirement: You know the 'connectstring' for the Management Server." |
|---|
| 513 | |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | |
|---|
| 517 | # \tYou will optionally be asked to install a MySQL Server.\n |
|---|
| 518 | # \tData nodes store data in the Network Database (NDB).\n |
|---|
| 519 | REPLICA_HELP=" |
|---|
| 520 | Number of Replicas Help\n |
|---|
| 521 | =========================================================================== |
|---|
| 522 | \n |
|---|
| 523 | A replica is a copy of a partition in the cluster.\n |
|---|
| 524 | So, '2' replicas means '2' copies of the partition are stored in the cluster\n |
|---|
| 525 | (not 2 extra copies of an existing copy).\n |
|---|
| 526 | \n |
|---|
| 527 | The number of Replicas is currently 2. Accept?" |
|---|
| 528 | |
|---|
| 529 | |
|---|
| 530 | NODEID_HELP="The NodeID is a number that is assigned to a [NDBD] entry in the \$NDB_HOME/config-<NoOfNodes>Node.ini file. \n |
|---|
| 531 | Select the NodeID that matches the HostName on which you are trying to start the ndbd." |
|---|
| 532 | |
|---|
| 533 | USERNAME_HELP=" |
|---|
| 534 | UID (user id) for Running MySQL Cluster Help\n |
|---|
| 535 | =========================================================================== |
|---|
| 536 | \n |
|---|
| 537 | The MySQL and NDB processes will be started and run with this user ID (uid). \n |
|---|
| 538 | \n |
|---|
| 539 | The default username that processes will be run as is '$USERNAME'.\n |
|---|
| 540 | Accept?" |
|---|
| 541 | |
|---|
| 542 | DATA_MEMORY_HELP=" |
|---|
| 543 | DataMemory Help\n |
|---|
| 544 | =========================================================================== |
|---|
| 545 | \n |
|---|
| 546 | Reference:\n |
|---|
| 547 | \n |
|---|
| 548 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html \n |
|---|
| 549 | You need enough free RAM to store Data Memory, Index Memory for all replicas.\n |
|---|
| 550 | Leave spare RAM (overhead) for other operating system processes.\n |
|---|
| 551 | \n |
|---|
| 552 | For example: \n |
|---|
| 553 | On a host with 2GB of RAM, as part of a 2-node cluster with 2 Replicas:\n |
|---|
| 554 | Data Memory could be 750MB, Index Memory could be 150MB.\n |
|---|
| 555 | This would leave 200MB overhead for Operating System and other processes.\n |
|---|
| 556 | \n |
|---|
| 557 | Note: if you want to do an online alter table, after entering single-user mode,\n |
|---|
| 558 | you will need enough spare memory to make a copy of your table in memory.\n |
|---|
| 559 | \n |
|---|
| 560 | Size of Data Memory for NDB nodes is 80MB.\n |
|---|
| 561 | Accept?" |
|---|
| 562 | |
|---|
| 563 | index_memory_help_setup() |
|---|
| 564 | { |
|---|
| 565 | |
|---|
| 566 | INDEX_MEMORY_HELP=" |
|---|
| 567 | IndexMemory Help\n |
|---|
| 568 | =========================================================================== |
|---|
| 569 | \n |
|---|
| 570 | Reference:\n |
|---|
| 571 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 572 | \n |
|---|
| 573 | You need enough free RAM to store Data Memory, Index Memory for all replicas.\n |
|---|
| 574 | Leave spare RAM (overhead) for other operating system processes.\n |
|---|
| 575 | \n |
|---|
| 576 | For example:\n |
|---|
| 577 | On a host with 2GB of RAM, as part of a 2-node cluster with 2 Replicas:\n |
|---|
| 578 | Data Memory could be 750MB, Index Memory could be 150MB.\n |
|---|
| 579 | This would leave 200MB overhead for Operating System and other processes.\n |
|---|
| 580 | \n |
|---|
| 581 | Note: if you want to do an online alter table, after entering single-user mode,\n |
|---|
| 582 | you will need enough spare memory to make a copy of your table in memory.\n |
|---|
| 583 | \n |
|---|
| 584 | Size of Index Memory for NDB nodes is $INDEX_MEMORY MB.\n |
|---|
| 585 | Accept?" |
|---|
| 586 | } |
|---|
| 587 | |
|---|
| 588 | num_fragment_logfiles_help_setup() |
|---|
| 589 | { |
|---|
| 590 | NUM_FRAGMENT_LOGFILES_HELP=" |
|---|
| 591 | NoOfFragmentLogFiles Help\n |
|---|
| 592 | =========================================================================== |
|---|
| 593 | \n |
|---|
| 594 | References:\n |
|---|
| 595 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 596 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-config-lcp-params.html\n |
|---|
| 597 | \n |
|---|
| 598 | The Redo Log is used when a node crashes to recover most its data.\n |
|---|
| 599 | The size of the Redo Log is configured by changing the 'NoOfFragmentLogFiles'. \n |
|---|
| 600 | The Redo Log is allocated in chunks of 64MB Fragment Log Files on local disk.\n |
|---|
| 601 | The default value for NoOfFragmentLogFiles is '8'.\n |
|---|
| 602 | This means 8 sets of four 16MB files (i.e., 8*64MB) for a total of 512MB. \n |
|---|
| 603 | That is, you need to have 512MB of free disk space.\n |
|---|
| 604 | If you have very high update rates (lots of writes/updates), you may need\n |
|---|
| 605 | to set NoFragmentLogFiles substantially higher, e.g., up to a value of 300.\n |
|---|
| 606 | \n |
|---|
| 607 | The NumberOfFragmentLogFiles is $NUM_FRAGMENT_LOGFILES (64*$NUM_FRAGMENT_LOGFILES = $REDO_LOG_SIZE MB)\n |
|---|
| 608 | Accept?" |
|---|
| 609 | } |
|---|
| 610 | |
|---|
| 611 | DISK_CHECKPOINT_SPEED_HELP=" |
|---|
| 612 | DiskCheckpointSpeed Help\n |
|---|
| 613 | =========================================================================== |
|---|
| 614 | \n |
|---|
| 615 | References:\n |
|---|
| 616 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 617 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 618 | \n |
|---|
| 619 | The amount of data,in bytes per second, that is sent to disk during a \n |
|---|
| 620 | local checkpoint.\n |
|---|
| 621 | You can check how fast your hard disk can write to disk by checking the\n |
|---|
| 622 | manufacturer's specification for you hard disk or by using a program\n |
|---|
| 623 | such as Bonnie++. For debian/ubutunu:\n |
|---|
| 624 | >apt-get install bonnie++ >bonnie++\n |
|---|
| 625 | \n |
|---|
| 626 | In any case, the algorithms for writing the local checkpoint will adapt\n |
|---|
| 627 | the speed of writing to load on the cluster.\n |
|---|
| 628 | \n |
|---|
| 629 | The default value is 10M (10 megabytes per second).\n |
|---|
| 630 | Accept?" |
|---|
| 631 | |
|---|
| 632 | |
|---|
| 633 | DISK_CHECKPOINT_SPEED_IN_RESTART_HELP=" |
|---|
| 634 | DiskCheckpointSpeedInRestart Help\n |
|---|
| 635 | =========================================================================== |
|---|
| 636 | \n |
|---|
| 637 | References:\n |
|---|
| 638 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 639 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 640 | \n |
|---|
| 641 | |
|---|
| 642 | The amount of data, in bytes per second, that is sent to disk during a \n |
|---|
| 643 | local checkpoint that is performed when a node restarts.\n |
|---|
| 644 | \n |
|---|
| 645 | You can check how fast your hard disk can write to disk by checking the\n |
|---|
| 646 | manufacturer's specification for you hard disk or by using a program\n |
|---|
| 647 | such as Bonnie++. For debian/ubutunu: >apt-get install bonnie++\n |
|---|
| 648 | \n |
|---|
| 649 | In any case, the algorithms for writing the local checkpoint will adapt\n |
|---|
| 650 | the speed of writing to load on the cluster.\n |
|---|
| 651 | \n |
|---|
| 652 | The default value is ${DISK_CHECKPOINT_SPEED_IN_RESTART}M (${DISK_CHECKPOINT_SPEED_IN_RESTART} megabytes per second).\n |
|---|
| 653 | Accept?" |
|---|
| 654 | |
|---|
| 655 | |
|---|
| 656 | DISK_SYNC_SIZE_HELP=" |
|---|
| 657 | DiskSyncSize Help\n |
|---|
| 658 | =========================================================================== |
|---|
| 659 | \n |
|---|
| 660 | References:\n |
|---|
| 661 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 662 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 663 | \n |
|---|
| 664 | This is the maximum number of bytes to store in the Redo Buffer before\n |
|---|
| 665 | flushing the buffer to a local checkpoint file.\n |
|---|
| 666 | \n |
|---|
| 667 | If your hard disk is a bottleneck, then increasing the size of this parameter\n |
|---|
| 668 | may help throughput when writing to disk.\n |
|---|
| 669 | However, in the event of a node crash, the transactions in the Redo Buffer\n |
|---|
| 670 | that were not written to disk will be lost (although they will be available in\n |
|---|
| 671 | replica nodes).\n |
|---|
| 672 | \n |
|---|
| 673 | The default value is 4M (4 megabytes).\n |
|---|
| 674 | Accept?" |
|---|
| 675 | |
|---|
| 676 | REDO_BUFFER_HELP=" |
|---|
| 677 | RedoBuffer Help\n |
|---|
| 678 | =========================================================================== |
|---|
| 679 | \n |
|---|
| 680 | References:\n |
|---|
| 681 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 682 | http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-ndbd-definition.html\n |
|---|
| 683 | \n |
|---|
| 684 | If you have a write-intensive database or a slow disk subsystem, it is\n |
|---|
| 685 | recommended that you increase the size of the redo buffer from the default\n |
|---|
| 686 | value of 8Mb to 16Mb.\n |
|---|
| 687 | \n |
|---|
| 688 | The RedoBuffer sets the size of the buffer in which the REDO log is written.\n |
|---|
| 689 | This buffer is used as a front end to the file system when writing REDO log\n |
|---|
| 690 | records to disk. If this buffer is too small, the NDB storage engine issues\n |
|---|
| 691 | error code 1221 (REDO log buffers overloaded).\n |
|---|
| 692 | \n |
|---|
| 693 | The default value is 8M (8 megabytes).\n |
|---|
| 694 | Accept?" |
|---|
| 695 | |
|---|
| 696 | |
|---|
| 697 | |
|---|
| 698 | DELETE_DIR_HELP=" |
|---|
| 699 | \nAbove Directory already exists.\n |
|---|
| 700 | \n |
|---|
| 701 | You have already installed the NDB files or MySQL Binaries in this directory.\n |
|---|
| 702 | \n |
|---|
| 703 | If you have already installed a Mmgmt Server, and you want to install a\n |
|---|
| 704 | Data Node, you can install it in this directory - do not delete it.\n |
|---|
| 705 | \n |
|---|
| 706 | Otherwise, do not delete this directory if you have important data here. \n |
|---|
| 707 | For example, if you have already installed a Management Server,\n |
|---|
| 708 | and have stored important data in it, this step may\n |
|---|
| 709 | cause you to lose that data.\n |
|---|
| 710 | If you delete this directory, you will do a clean install.\n |
|---|
| 711 | \n |
|---|
| 712 | Delete this directory?\n |
|---|
| 713 | $FULL_DIR" |
|---|
| 714 | |
|---|
| 715 | MYSQL_PORT_HELP=" |
|---|
| 716 | MySQL Port Help\n |
|---|
| 717 | ===========================================================================\n |
|---|
| 718 | A port can be used to connect to a MySQL server.\n |
|---|
| 719 | \n |
|---|
| 720 | For example:\n |
|---|
| 721 | mysql --protocol=tcp --port=3306 -u root -p\n |
|---|
| 722 | \n |
|---|
| 723 | The port number for the mysqld is set to default (port $MYSQL_PORT).\n |
|---|
| 724 | Accept?" |
|---|
| 725 | |
|---|
| 726 | MYSQL_SOCKET_HELP=" |
|---|
| 727 | MySQL Socket Help\n |
|---|
| 728 | ===========================================================================\n |
|---|
| 729 | The socket can be used to connect to a MySQL server.\n |
|---|
| 730 | For example:\n |
|---|
| 731 | mysql -S /tmp/mysql.sock -u root -p\n |
|---|
| 732 | \n |
|---|
| 733 | The default location for the MySQL socket is:\n |
|---|
| 734 | $MYSQL_SOCK\n |
|---|
| 735 | Accept?" |
|---|
| 736 | |
|---|
| 737 | BINARY_LOG_HELP=" |
|---|
| 738 | MySQL Binary Log Help\n |
|---|
| 739 | ===========================================================================\n |
|---|
| 740 | A binary log of updates to this MySQL server is required to support\n |
|---|
| 741 | replication from this server. This server will be a Replication Master.\n |
|---|
| 742 | \n |
|---|
| 743 | The binary log will be stored in the MySQL server's data directory and will\n |
|---|
| 744 | consume an increasing amount of disk space over time. You will need to\n |
|---|
| 745 | write/download a script to rotate the binary logs to prevent them growing\n |
|---|
| 746 | over time.\n |
|---|
| 747 | \n |
|---|
| 748 | \n |
|---|
| 749 | Should binary logging be enabled for this MySQL Server?\n |
|---|
| 750 | Accept?" |
|---|
| 751 | |
|---|
| 752 | |
|---|
| 753 | SSH_HELP=" |
|---|
| 754 | SSH Help\n |
|---|
| 755 | ===========================================================================\n |
|---|
| 756 | Requirements: \n |
|---|
| 757 | These programs must installed on all hosts:\n |
|---|
| 758 | ssh-keygen, scp, ssh.\n |
|---|
| 759 | \n |
|---|
| 760 | Generating a ssh-key makes it easier to initialise or start the cluster.\n |
|---|
| 761 | Instead of having to logon to all hosts in the cluster and run the init or\n |
|---|
| 762 | start scripts for all Data Nodes and Management Servers in the cluster, you\n |
|---|
| 763 | will only need to run a single init or start script from the Management Server\n |
|---|
| 764 | Host.\n |
|---|
| 765 | \n |
|---|
| 766 | A ssh-key is used to run a program on a remote host under a specified\n |
|---|
| 767 | username. The ssh-key is used to allow you run a single script on the\n |
|---|
| 768 | management server to initialise or start the management server (on the same\n |
|---|
| 769 | host), and all the Data Nodes (on remote hosts) in the cluster. To start the\n |
|---|
| 770 | Data Nodes, the single startup script calls the data node startup scripts on\n |
|---|
| 771 | the remote hosts using ssh. The single scripts require that the ssh-key for\n |
|---|
| 772 | the management server is installed on the Data Nodes.\n |
|---|
| 773 | \n |
|---|
| 774 | Do you want to generate a ssh-key?" |
|---|
| 775 | |
|---|
| 776 | AUTHORIZED_KEYS_HELP=" |
|---|
| 777 | SSH Authorized Keys Help\n |
|---|
| 778 | ===========================================================================\n |
|---|
| 779 | An authorized_keys file should have been installed on the management server host under\n |
|---|
| 780 | a user account. Normally, it is stored in the path:\n |
|---|
| 781 | /home/\$USERNAME/.ssh/authorized_keys\n |
|---|
| 782 | The authorized_keys file ensures that the \$USERNAME on the management\n |
|---|
| 783 | can call scripts that start Data Nodes on remote hosts.\n |
|---|
| 784 | \n |
|---|
| 785 | Is /home/\$USERNAME/.ssh/authorized_keys the correct path for the authorized_keys file?" |
|---|
| 786 | |
|---|
| 787 | |
|---|
| 788 | #################################################################################################### |
|---|
| 789 | # Replication Strings |
|---|
| 790 | #################################################################################################### |
|---|
| 791 | |
|---|
| 792 | |
|---|
| 793 | binary_log_enable() |
|---|
| 794 | { |
|---|
| 795 | |
|---|
| 796 | BINARY_LOG="log-bin=mysql-bin" |
|---|
| 797 | |
|---|
| 798 | # generate a server-id between 0 and 4,999 for the master |
|---|
| 799 | # generate a server-id between 5,000 and 10,000 for the slave |
|---|
| 800 | MASTER_ID=`expr $RANDOM % 5000` |
|---|
| 801 | SLAVE_ID=`expr $RANDOM % 10000` |
|---|
| 802 | SLAVE_ID=`expr $SLAVE_ID + 5000` |
|---|
| 803 | SERVER_ID="server-id=$MASTER_ID" |
|---|
| 804 | |
|---|
| 805 | } |
|---|
| 806 | |
|---|
| 807 | replication_init() |
|---|
| 808 | { |
|---|
| 809 | #Create a slave account on the master (cluster) MySQL Server with the appropriate privileges |
|---|
| 810 | # ${MYSQL_HOST} |
|---|
| 811 | # ${MGM_HOST} |
|---|
| 812 | # run this on the master |
|---|
| 813 | REPLICATION_MASTER= |
|---|
| 814 | "log-bin=mysql-bin |
|---|
| 815 | server-id=1111 |
|---|
| 816 | " |
|---|
| 817 | REPLICATION_ACCOUNT_CREATE=" |
|---|
| 818 | GRANT REPLICATION SLAVE ON *.* TO '$USERID'@'$MYSQL_MASTER' IDENTIFIED BY '$PASSWORD';" |
|---|
| 819 | |
|---|
| 820 | # Write a warning that the my.cnf file is written in cleartext to a file in the MySQL Server's data directory |
|---|
| 821 | REPLICATION_SLAVE=" |
|---|
| 822 | server-id=2222 |
|---|
| 823 | |
|---|
| 824 | master-host=$MYSQL_MASTER |
|---|
| 825 | master-port=3306 |
|---|
| 826 | master-user=$USERID |
|---|
| 827 | master-password=$PASSWORD |
|---|
| 828 | " |
|---|
| 829 | } |
|---|
| 830 | |
|---|
| 831 | #################################################################################################### |
|---|
| 832 | # Test for user-id (if root) for generated cluster startup scripts |
|---|
| 833 | #################################################################################################### |
|---|
| 834 | |
|---|
| 835 | #TODO: make this a shell script in util dir |
|---|
| 836 | test_userid() |
|---|
| 837 | { |
|---|
| 838 | TEST_USERID=" |
|---|
| 839 | USERID=\`id | sed -e 's/).*//; s/^.*(//;'\` |
|---|
| 840 | if [ \"X\$USERID\" != \"X$USERNAME\" ]; then |
|---|
| 841 | if [ \"X\$USERID\" = \"Xroot\" ]; then |
|---|
| 842 | echo \"\" |
|---|
| 843 | echo \"You started cluster as user: 'root'.\" |
|---|
| 844 | echo \"You should start cluster as user: '$USERNAME'.\" |
|---|
| 845 | echo \"If you continue, you will change ownership of database files\" |
|---|
| 846 | echo \"from '$USERNAME' to 'root'.\" |
|---|
| 847 | # TODO: return -2 |
|---|
| 848 | else |
|---|
| 849 | echo \"\" |
|---|
| 850 | echo \"You started the cluster as user: '\$USERID'.\" |
|---|
| 851 | echo \"You should start the cluster as user: '$USERNAME'.\" |
|---|
| 852 | echo \"If you continue, you will change ownership of database files\" |
|---|
| 853 | echo \"from '$USERNAME' to '\$USERID'.\" |
|---|
| 854 | # TODO: return -2 |
|---|
| 855 | fi |
|---|
| 856 | |
|---|
| 857 | echo \"\" |
|---|
| 858 | start_as_wrong_user() |
|---|
| 859 | { |
|---|
| 860 | echo -n \"Do you really want to start the cluster as user '$USERID'? y/n/h(help) \" |
|---|
| 861 | read ACCEPT |
|---|
| 862 | case \$ACCEPT in |
|---|
| 863 | y | Y) |
|---|
| 864 | ;; |
|---|
| 865 | n | N) |
|---|
| 866 | echo \"\" |
|---|
| 867 | echo \"Bye..\" |
|---|
| 868 | echo \"\" |
|---|
| 869 | exit 1 |
|---|
| 870 | ;; |
|---|
| 871 | *) |
|---|
| 872 | echo \"\" |
|---|
| 873 | echo -n \"Please enter 'y' or 'n'.\" |
|---|
| 874 | start_as_wrong_user |
|---|
| 875 | ;; |
|---|
| 876 | esac |
|---|
| 877 | } |
|---|
| 878 | start_as_wrong_user |
|---|
| 879 | |
|---|
| 880 | |
|---|
| 881 | fi" |
|---|
| 882 | } |
|---|
| 883 | |
|---|
| 884 | already_running() |
|---|
| 885 | { |
|---|
| 886 | ALREADY_RUNNING_CLUSTER=" |
|---|
| 887 | echo \"\" |
|---|
| 888 | echo \"Testing to see if a cluster is already running on host '$CONNECTSTRING' ...\" |
|---|
| 889 | echo \"\" |
|---|
| 890 | ${MYSQL_BINARIES_DIR}/bin/ndb_mgm -c $CONNECTSTRING -t $WAIT_CLUSTER_ALREADY_RUNNING -e show 1> /dev/null |
|---|
| 891 | |
|---|
| 892 | if [ \$? -eq 0 ] ; then |
|---|
| 893 | echo \"\" |
|---|
| 894 | echo \"A management server is already running on $CONNECTSTRING\" |
|---|
| 895 | echo \"\" |
|---|
| 896 | exit 2 |
|---|
| 897 | fi |
|---|
| 898 | " |
|---|
| 899 | } |
|---|
| 900 | |
|---|
| 901 | |
|---|
| 902 | get_connectstring_skip_mysqlds() |
|---|
| 903 | { |
|---|
| 904 | |
|---|
| 905 | GET_CONNECTSTRING_SKIP_MYSQLDS=" |
|---|
| 906 | MGM_CONN=$CONNECTSTRING |
|---|
| 907 | SKIP_MYSQLDS=0 |
|---|
| 908 | |
|---|
| 909 | while [ \$# -gt 0 ]; do |
|---|
| 910 | case \"\$1\" in |
|---|
| 911 | -h|--help) |
|---|
| 912 | echo \"usage: <prog> [ -c | --connectstring MGMD_HOST:MGMD_PORT ] [ -s|--skip-mysqlds ]\" |
|---|
| 913 | echo \"\" |
|---|
| 914 | echo \"connectstring is set to $CONNECTSTRING\" |
|---|
| 915 | exit 0 |
|---|
| 916 | ;; |
|---|
| 917 | -c|--connectstring) |
|---|
| 918 | shift |
|---|
| 919 | MGM_CONN=\$1 |
|---|
| 920 | break |
|---|
| 921 | ;; |
|---|
| 922 | -s|--skip-mysqlds) |
|---|
| 923 | SKIP_MYSQLDS=1 |
|---|
| 924 | ;; |
|---|
| 925 | * ) |
|---|
| 926 | echo \"Unknown option '\$1'\" |
|---|
| 927 | exit -1 |
|---|
| 928 | esac |
|---|
| 929 | shift |
|---|
| 930 | done |
|---|
| 931 | " |
|---|
| 932 | } |
|---|
| 933 | |
|---|
| 934 | get_connectstring() |
|---|
| 935 | { |
|---|
| 936 | |
|---|
| 937 | GET_CONNECTSTRING=" |
|---|
| 938 | MGM_CONN=$CONNECTSTRING |
|---|
| 939 | while [ \$# -gt 0 ]; do |
|---|
| 940 | case \"\$1\" in |
|---|
| 941 | -h|--help) |
|---|
| 942 | echo \"usage: <prog> [ -c | --connectstring MGMD_HOST:MGMD_PORT ] \" |
|---|
| 943 | echo \"\" |
|---|
| 944 | echo \"connectstring is set to $CONNECTSTRING\" |
|---|
| 945 | exit 0 |
|---|
| 946 | ;; |
|---|
| 947 | -c|--connectstring) |
|---|
| 948 | shift |
|---|
| 949 | MGM_CONN=\$1 |
|---|
| 950 | break |
|---|
| 951 | ;; |
|---|
| 952 | * ) |
|---|
| 953 | echo \"Unknown option '\$1'\" |
|---|
| 954 | exit -1 |
|---|
| 955 | esac |
|---|
| 956 | shift |
|---|
| 957 | done |
|---|
| 958 | " |
|---|
| 959 | } |
|---|
| 960 | |
|---|
| 961 | get_mgm_client_connectstring() |
|---|
| 962 | { |
|---|
| 963 | |
|---|
| 964 | MGM_CLIENT_CONNECTSTRING=" |
|---|
| 965 | MGM_CONN=$CONNECTSTRING |
|---|
| 966 | PARAMS= |
|---|
| 967 | EXEC= |
|---|
| 968 | while [ \$# -gt 0 ]; do |
|---|
| 969 | case \"\$1\" in |
|---|
| 970 | -h|--help) |
|---|
| 971 | echo \"usage: <prog> [ -c | --connectstring MGMD_HOST:MGMD_PORT ] ] [ -e [command] ] \" |
|---|
| 972 | echo \"\" |
|---|
| 973 | echo \"Default connectstring parameter = $CONNECTSTRING\" |
|---|
| 974 | echo \"\" |
|---|
| 975 | echo \"To view the state of the cluster (which nodes are connected), type:\" |
|---|
| 976 | echo \"./mgm-client.sh -e show\" |
|---|
| 977 | echo \"\" |
|---|
| 978 | exit 0 |
|---|
| 979 | ;; |
|---|
| 980 | -e) |
|---|
| 981 | shift |
|---|
| 982 | EXEC=\"-e\" |
|---|
| 983 | while [ \$# -gt 0 ]; do |
|---|
| 984 | PARAMS=\"\$PARAMS \$1\" |
|---|
| 985 | shift |
|---|
| 986 | done |
|---|
| 987 | break |
|---|
| 988 | ;; |
|---|
| 989 | -c|--connectstring) |
|---|
| 990 | shift |
|---|
| 991 | MGM_CONN=\$1 |
|---|
| 992 | break |
|---|
| 993 | ;; |
|---|
| 994 | * ) |
|---|
| 995 | echo \"Unknown option '\$1'\" |
|---|
| 996 | exit -1 |
|---|
| 997 | esac |
|---|
| 998 | shift |
|---|
| 999 | done |
|---|
| 1000 | " |
|---|
| 1001 | } |
|---|
| 1002 | |
|---|
| 1003 | |
|---|
| 1004 | ################################################################################################### |
|---|
| 1005 | # INTERRUPT HANDLER FUNCTIONS |
|---|
| 1006 | ################################################################################################### |
|---|
| 1007 | |
|---|
| 1008 | # called by TrapBreak if interrupt signal is handled |
|---|
| 1009 | CleanUpTempFiles() |
|---|
| 1010 | { |
|---|
| 1011 | |
|---|
| 1012 | case $INSTALL_ACTION in |
|---|
| 1013 | $INSTALL_MYSQLD|$INSTALL_ANOTHER_MYSQLD_LOCALHOST|$INSTALL_LOCALHOST_MYSQLD|$INSTALL_ANOTHER_MYSQLD) |
|---|
| 1014 | if [ -d $MYSQL_DATA_DIR ] ; then |
|---|
| 1015 | echo "" |
|---|
| 1016 | echo "Cleaning up...." |
|---|
| 1017 | echo "Removing the mysql data directory:" |
|---|
| 1018 | echo "$MYSQL_INSTALL_DIR" |
|---|
| 1019 | echo "" |
|---|
| 1020 | # The install directory is the parent directory that needs to be removed |
|---|
| 1021 | rm -rf ${MYSQL_INSTALL_DIR} |
|---|
| 1022 | fi |
|---|
| 1023 | ;; |
|---|
| 1024 | esac |
|---|
| 1025 | echo "" |
|---|
| 1026 | |
|---|
| 1027 | test -e $MYSQLSTART_TMP && rm -rf $MYSQLSTART_TMP |
|---|
| 1028 | test -e $MYSQL_SHUTDOWN_TMP && rm -rf $MYSQL_SHUTDOWN_TMP |
|---|
| 1029 | |
|---|
| 1030 | } |
|---|
| 1031 | |
|---|
| 1032 | # called if interrupt signal is handled |
|---|
| 1033 | TrapBreak() |
|---|
| 1034 | { |
|---|
| 1035 | trap "" HUP INT TERM |
|---|
| 1036 | # if ndbd or ndb_mgmd or mysqld are still running, kill them |
|---|
| 1037 | # [ -n "$MYSQL_PID" ] && kill -TERM "$MYSQL_PID" 2>/dev/null |
|---|
| 1038 | # [ -n "$pid" ] && killall "ndbd" 2>/dev/null |
|---|
| 1039 | |
|---|
| 1040 | echo -e "\n\nInstallation cancelled by user!" |
|---|
| 1041 | exit_error $EXIT_SIGNAL_CAUGHT |
|---|
| 1042 | } |
|---|
| 1043 | |
|---|
| 1044 | |
|---|
| 1045 | ################################################################################################### |
|---|
| 1046 | # USER INPUT HANDLER FUNCTIONS |
|---|
| 1047 | ################################################################################################### |
|---|
| 1048 | |
|---|
| 1049 | # Takes help strings as parameter |
|---|
| 1050 | # $1 = "Is this |
|---|
| 1051 | entry_ok() |
|---|
| 1052 | { |
|---|
| 1053 | echo -n " y/n/h(help) " |
|---|
| 1054 | read ACCEPT |
|---|
| 1055 | case $ACCEPT in |
|---|
| 1056 | y | Y | yes | Yes | YES) |
|---|
| 1057 | return 1 |
|---|
| 1058 | ;; |
|---|
| 1059 | n | N | no | No | NO) |
|---|
| 1060 | return 0 |
|---|
| 1061 | ;; |
|---|
| 1062 | h | H | help | Help | HELP) |
|---|
| 1063 | # add escaped new-line characters |
|---|
| 1064 | if [ $# -eq 0 ] ; then |
|---|
| 1065 | echo -e "\nThere is no help available for this installation step." |
|---|
| 1066 | else |
|---|
| 1067 | clear |
|---|
| 1068 | echo -en $@ |
|---|
| 1069 | fi |
|---|
| 1070 | entry_ok $@ |
|---|
| 1071 | return $? |
|---|
| 1072 | ;; |
|---|
| 1073 | *) |
|---|
| 1074 | echo -n "Please enter 'y', 'n', or 'h (help)'." $ECHO_OUT |
|---|
| 1075 | entry_ok $@ |
|---|
| 1076 | ;; |
|---|
| 1077 | esac |
|---|
| 1078 | |
|---|
| 1079 | return 1 |
|---|
| 1080 | } |
|---|
| 1081 | |
|---|
| 1082 | # $1 = accept phrase (what to accept) |
|---|
| 1083 | # caller reads $ENTERED_STRING global variable for result |
|---|
| 1084 | enter_string() |
|---|
| 1085 | { |
|---|
| 1086 | echo "$1" $ECHO_OUT |
|---|
| 1087 | read ENTERED_STRING |
|---|
| 1088 | } |
|---|
| 1089 | |
|---|
| 1090 | ################################################################################################### |
|---|
| 1091 | # SCREEN CLEAR FUNCTIONS |
|---|
| 1092 | ################################################################################################### |
|---|
| 1093 | |
|---|
| 1094 | clear_screen() |
|---|
| 1095 | { |
|---|
| 1096 | echo "" $ECHO_OUT |
|---|
| 1097 | echo "Press ENTER to continue" $ECHO_OUT |
|---|
| 1098 | read cont < /dev/tty |
|---|
| 1099 | clear |
|---|
| 1100 | } |
|---|
| 1101 | |
|---|
| 1102 | clear_screen_no_skipline() |
|---|
| 1103 | { |
|---|
| 1104 | echo "Press ENTER to continue" $ECHO_OUT |
|---|
| 1105 | read cont < /dev/tty |
|---|
| 1106 | clear |
|---|
| 1107 | } |
|---|
| 1108 | |
|---|
| 1109 | ################################################################################################### |
|---|
| 1110 | # ERROR HANDLER FUNCTIONS |
|---|
| 1111 | ################################################################################################### |
|---|
| 1112 | |
|---|
| 1113 | # $1 = String describing error |
|---|
| 1114 | mkdir_error() |
|---|
| 1115 | { |
|---|
| 1116 | echo "" $ECHO_OUT |
|---|
| 1117 | echo "Failure: couldn't create the directory:" $ECHO_OUT |
|---|
| 1118 | echo "$1" $ECHO_OUT |
|---|
| 1119 | echo "This script does not perform recursive directory creation. " $ECHO_OUT |
|---|
| 1120 | echo "Do not use '~/' as a path, use the full path (e.g., /home/user/..). " $ECHO_OUT |
|---|
| 1121 | echo "Exiting...." $ECHO_OUT |
|---|
| 1122 | echo "" $ECHO_OUT |
|---|
| 1123 | exit_error |
|---|
| 1124 | } |
|---|
| 1125 | |
|---|
| 1126 | # $1 = String describing error |
|---|
| 1127 | exit_error() |
|---|
| 1128 | { |
|---|
| 1129 | #CleanUpTempFiles |
|---|
| 1130 | |
|---|
| 1131 | echo "" $ECHO_OUT |
|---|
| 1132 | echo "Error number: $1" $ECHO_OUT |
|---|
| 1133 | echo "Exiting $PRODUCT $VERSION installer." $ECHO_OUT |
|---|
| 1134 | echo "" $ECHO_OUT |
|---|
| 1135 | exit 1 |
|---|
| 1136 | } |
|---|
| 1137 | |
|---|
| 1138 | # fix format of dir string, if necessary |
|---|
| 1139 | # $1=directory to be fixed |
|---|
| 1140 | fix_dir () { |
|---|
| 1141 | FIXDIR="$1" |
|---|
| 1142 | FIRSTCHAR=`expr "$FIXDIR" : '\(.\).*'` |
|---|
| 1143 | if [ "$FIRSTCHAR" != '/' ]; then |
|---|
| 1144 | currentdir=`pwd` |
|---|
| 1145 | echo "$currentdir/$FIXDIR" $ECHO_OUT |
|---|
| 1146 | else |
|---|
| 1147 | echo "$1" $ECHO_OUT |
|---|
| 1148 | fi |
|---|
| 1149 | } |
|---|
| 1150 | |
|---|
| 1151 | |
|---|
| 1152 | ##################################################################################################### |
|---|
| 1153 | # INSTALLER FUNCTIONS |
|---|
| 1154 | ##################################################################################################### |
|---|
| 1155 | |
|---|
| 1156 | # download binaries from MySQL mirror site |
|---|
| 1157 | download_binaries() |
|---|
| 1158 | { |
|---|
| 1159 | cd $CWD |
|---|
| 1160 | |
|---|
| 1161 | FINISHED=0 |
|---|
| 1162 | while [ $# -ne 0 ] && [ $FINISHED = 0 ] |
|---|
| 1163 | do |
|---|
| 1164 | echo "" $ECHO_OUT |
|---|
| 1165 | echo "Trying to download the MySQL binaries from the mirror:" $ECHO_OUT |
|---|
| 1166 | echo "$1" $ECHO_OUT |
|---|
| 1167 | echo "" $ECHO_OUT |
|---|
| 1168 | echo "Executing (proxy = ${http_proxy}):" $ECHO_OUT |
|---|
| 1169 | |
|---|
| 1170 | |
|---|
| 1171 | # mysql-5.1.24-ndb-6.3.16/mysql-5.1.24-ndb-6.3.16-telco.tar.gz |
|---|
| 1172 | # ftp://ftp.mysql.com/pub/mysql/download/cluster_telco/mysql-5.1.24-ndb-6.3.16/mysql-5.1.24-ndb-6.3.16-telco.tar.gz |
|---|
| 1173 | # -${TELCO} |
|---|
| 1174 | |
|---|
| 1175 | BASE_VER="mysql-${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_REV}-ndb-${NDB_VERSION_MAJOR}.${NDB_VERSION_MINOR}.${NDB_VERSION_REV}" |
|---|
| 1176 | |
|---|
| 1177 | echo "wget $PROXY $HTTP_USER $HTTP_PASS $MIRROR${BASE_VER}/${VERSION}.tar.gz" $ECHO_OUT |
|---|
| 1178 | wget $PROXY $HTTP_USER $HTTP_PASS ${MIRROR}/${BASE_VER}/$VERSION.tar.gz |
|---|
| 1179 | |
|---|
| 1180 | # update version to the filename of the distro: mysql-5.1.24-ndb-6.3.16-telco |
|---|
| 1181 | |
|---|
| 1182 | if [ $? -eq 0 ] ; then |
|---|
| 1183 | FINISHED=1 |
|---|
| 1184 | else |
|---|
| 1185 | echo "" $ECHO_OUT |
|---|
| 1186 | echo "Could not download the MySQL binaries from the mirror $1" $ECHO_OUT |
|---|
| 1187 | echo "" $ECHO_OUT |
|---|
| 1188 | if [ $# -gt 1 ] ; then |
|---|
| 1189 | echo "Trying next mirror...." $ECHO_OUT |
|---|
| 1190 | fi |
|---|
| 1191 | fi |
|---|
| 1192 | shift |
|---|
| 1193 | done |
|---|
| 1194 | |
|---|
| 1195 | if [ $FINISHED -eq 0 ] ; then |
|---|
| 1196 | echo "" $ECHO_OUT |
|---|
| 1197 | echo "Failure. Could not download the MySQL binaries from the following mirrors:" $ECHO_OUT |
|---|
| 1198 | # for i in ${MIRRORS[@]} ; do |
|---|
| 1199 | # echo "${i}" |
|---|
| 1200 | # done |
|---|
| 1201 | echo "" $ECHO_OUT |
|---|
| 1202 | echo "Try downloading the binaries using your Browser to: $CWD" $ECHO_OUT |
|---|
| 1203 | echo "Then re-run ./$SCRIPTNAME" $ECHO_OUT |
|---|
| 1204 | echo "" $ECHO_OUT |
|---|
| 1205 | echo "Exiting......." $ECHO_OUT |
|---|
| 1206 | exit_error |
|---|
| 1207 | fi |
|---|
| 1208 | |
|---|
| 1209 | |
|---|
| 1210 | #if [ "$INSTALL_ACTION" = "$INSTALL_COMPILE" ] ; then |
|---|
| 1211 | echo "" $ECHO_OUT |
|---|
| 1212 | echo "You now need to build the binaries from the sources just downloaded." $ECHO_OUT |
|---|
| 1213 | echo "" $ECHO_OUT |
|---|
| 1214 | #fi |
|---|
| 1215 | |
|---|
| 1216 | |
|---|
| 1217 | } |
|---|
| 1218 | |
|---|
| 1219 | # |
|---|
| 1220 | # Generic function to create the installation directories (ndb, mysql) for root/normal-user |
|---|
| 1221 | # Very hacked function - needs to know what you're installing ndb, mysql data, mysql binaries |
|---|
| 1222 | # |
|---|
| 1223 | # $1=$NDB_DIR or $MYSQL_BINARIES_DIR or $MYSQL_INSTALL_DIR |
|---|
| 1224 | # $2=$NDB_INSTALL_DIR or $MYSQL_INSTALL_DIR or $MYSQL_DATA_DIR |
|---|
| 1225 | # $3=informational text |
|---|
| 1226 | # $4=$NDB_VERSION or $VERSION |
|---|
| 1227 | # $5=Accept default directory |
|---|
| 1228 | # |
|---|
| 1229 | install_dir() { |
|---|
| 1230 | |
|---|
| 1231 | FULL_DIR=$1 |
|---|
| 1232 | INSTALL_DIR=$2 |
|---|
| 1233 | |
|---|
| 1234 | FINISHED_INSTALLDIRS=0 |
|---|
| 1235 | while [ $FINISHED_INSTALLDIRS -eq 0 ] ; do |
|---|
| 1236 | |
|---|
| 1237 | echo "" $ECHO_OUT |
|---|
| 1238 | echo "The name of the $3 directory must be:" $ECHO_OUT |
|---|
| 1239 | echo "$4" $ECHO_OUT |
|---|
| 1240 | echo "" $ECHO_OUT |
|---|
| 1241 | echo "We recommend installing this directory in the following path:" $ECHO_OUT |
|---|
| 1242 | echo "$FULL_DIR" $ECHO_OUT |
|---|
| 1243 | |
|---|
| 1244 | if [ "$5" != "1" ] ; then |
|---|
| 1245 | echo -n "Do you agree to install in the above path?" |
|---|
| 1246 | entry_ok "The $3 files will be installed to directory:\n $FULL_DIR/$4\n\nIn a later step of this installation, you will be able to create a shorter directory name using a symbolic link to the $3 directory.\n\nDo you agree to install in the above path?\n" |
|---|
| 1247 | |
|---|
| 1248 | if [ $? -eq 0 ] ; then |
|---|
| 1249 | echo "" $ECHO_OUT |
|---|
| 1250 | echo "Enter the complete installation path. Do not use ~/ in the path!" $ECHO_OUT |
|---|
| 1251 | echo "" $ECHO_OUT |
|---|
| 1252 | if [ $ROOTUSER -eq 1 ] ; then |
|---|
| 1253 | echo "E.g., '/usr/local' installs the distribution in" $ECHO_OUT |
|---|
| 1254 | echo " '/usr/local/$VERSION'" $ECHO_OUT |
|---|
| 1255 | else |
|---|
| 1256 | echo "E.g., '/home/YOUR_USERNAME/.mysql' installs the distribution in" $ECHO_OUT |
|---|
| 1257 | echo " '/home/YOUR_USERNAME/.mysqld/$VERSION'" $ECHO_OUT |
|---|
| 1258 | fi |
|---|
| 1259 | echo "" $ECHO_OUT |
|---|
| 1260 | printf 'Enter installation path: ' |
|---|
| 1261 | read dir |
|---|
| 1262 | INSTALL_DIR=$dir |
|---|
| 1263 | fi |
|---|
| 1264 | fi |
|---|
| 1265 | if [ $ROOTUSER -eq 1 ] ; then |
|---|
| 1266 | # root users must enter a full pathname |
|---|
| 1267 | FULL_DIR=$INSTALL_DIR/$4 |
|---|
| 1268 | else |
|---|
| 1269 | # fix the user-level dir if necessary |
|---|
| 1270 | FULL_DIR=`fix_dir "$INSTALL_DIR"` |
|---|
| 1271 | FULL_DIR=$FULL_DIR/$4 |
|---|
| 1272 | fi |
|---|
| 1273 | |
|---|
| 1274 | # set return value using global variable |
|---|
| 1275 | WHICH_INSTALL=$4 |
|---|
| 1276 | # compare version start string with "mysql" |
|---|
| 1277 | TO_UPDATE=${WHICH_INSTALL:0:5} |
|---|
| 1278 | |
|---|
| 1279 | if [ "$TO_UPDATE" = "mysql" ] ; then |
|---|
| 1280 | MYSQL_INSTALL_DIR=$INSTALL_DIR |
|---|
| 1281 | MYSQL_BINARIES_DIR=$FULL_DIR |
|---|
| 1282 | fi |
|---|
| 1283 | |
|---|
| 1284 | TO_UPDATE=${WHICH_INSTALL:0:3} |
|---|
| 1285 | if [ "$TO_UPDATE" = "ndb" ] ; then |
|---|
| 1286 | NDB_INSTALL_DIR=$INSTALL_DIR |
|---|
| 1287 | NDB_DIR=$FULL_DIR |
|---|
| 1288 | fi |
|---|
| 1289 | |
|---|
| 1290 | TO_UPDATE=${WHICH_INSTALL:0:6} |
|---|
| 1291 | if [ "$TO_UPDATE" = "var" ] ; then |
|---|
| 1292 | MYSQL_INSTALL_DIR=$INSTALL_DIR |
|---|
| 1293 | fi |
|---|
| 1294 | |
|---|
| 1295 | |
|---|
| 1296 | # Now create directory if it doesn't exist |
|---|
| 1297 | # MYSQL_INSTALL_DIR is the parent of MYSQL_BINARIES_DIR |
|---|
| 1298 | if [ ! -d $INSTALL_DIR ] ; then |
|---|
| 1299 | |
|---|
| 1300 | if [ "$5" != "1" ] ; then |
|---|
| 1301 | echo "" $ECHO_OUT |
|---|
| 1302 | echo "Directory : $INSTALL_DIR" $ECHO_OUT |
|---|
| 1303 | echo -n "Create this directory?" $ECHO_OUT |
|---|
| 1304 | entry_ok "Directory does not exist: \n $INSTALL_DIR \n It is recommended that you create it." |
|---|
| 1305 | |
|---|
| 1306 | if [ $? -eq 1 ] ; then |
|---|
| 1307 | FINISHED_INSTALLDIRS=1 |
|---|
| 1308 | mkdir $INSTALL_DIR |
|---|
| 1309 | if [ $? -ne 0 ] ; then |
|---|
| 1310 | mkdir_error $INSTALL_DIR |
|---|
| 1311 | fi |
|---|
| 1312 | else |
|---|
| 1313 | FINISHED_INSTALLDIRS=0 |
|---|
| 1314 | fi |
|---|
| 1315 | else |
|---|
| 1316 | mkdir $INSTALL_DIR |
|---|
| 1317 | if [ $? -ne 0 ] ; then |
|---|
| 1318 | mkdir_error $INSTALL_DIR |
|---|
| 1319 | fi |
|---|
| 1320 | FINISHED_INSTALLDIRS=1 |
|---|
| 1321 | fi |
|---|
| 1322 | else |
|---|
| 1323 | FINISHED_INSTALLDIRS=1 |
|---|
| 1324 | fi |
|---|
| 1325 | |
|---|
| 1326 | # FULLDIR IS THE CONVENTION NAME FOR THE INSTALL (mysql-version, ndb-version, data) |
|---|
| 1327 | if [ -d $FULL_DIR ] ; then |
|---|
| 1328 | echo "" $ECHO_OUT |
|---|
| 1329 | echo "WARNING: this install directory already exists:" $ECHO_OUT |
|---|
| 1330 | echo "$FULL_DIR" $ECHO_OUT |
|---|
| 1331 | |
|---|
| 1332 | echo "" $ECHO_OUT |
|---|
|
|---|