diff --git a/oamapps/postConfigure/CMakeLists.txt b/oamapps/postConfigure/CMakeLists.txt index cfe3d700e..4bdbadd1a 100644 --- a/oamapps/postConfigure/CMakeLists.txt +++ b/oamapps/postConfigure/CMakeLists.txt @@ -37,13 +37,13 @@ install(TARGETS getMySQLpw DESTINATION ${ENGINE_BINDIR} COMPONENT platform) ########### next target ############### -set(amazonInstaller_SRCS amazonInstaller.cpp helpers.cpp) +#set(amazonInstaller_SRCS amazonInstaller.cpp helpers.cpp) -add_executable(amazonInstaller ${amazonInstaller_SRCS}) +#add_executable(amazonInstaller ${amazonInstaller_SRCS}) -target_link_libraries(amazonInstaller ${ENGINE_LDFLAGS} readline ncurses ${SNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) +#target_link_libraries(amazonInstaller ${ENGINE_LDFLAGS} readline ncurses ${SNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS}) -install(TARGETS amazonInstaller DESTINATION ${ENGINE_BINDIR} COMPONENT platform) +#install(TARGETS amazonInstaller DESTINATION ${ENGINE_BINDIR} COMPONENT platform) ########### next target ############### @@ -59,5 +59,5 @@ install(TARGETS mycnfUpgrade DESTINATION ${ENGINE_BINDIR} COMPONENT platform) ########### next target ############### -install(PROGRAMS quick_installer_single_server.sh quick_installer_multi_server.sh +install(PROGRAMS quick_installer_single_server.sh quick_installer_multi_server.sh quick_installer_amazon.sh DESTINATION ${ENGINE_BINDIR} COMPONENT platform) diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index 5e3fdd964..98227da9d 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -189,6 +189,7 @@ bool nonDistribute = false; bool nonDistributeFlag = false; bool single_server_quick_install = false; bool multi_server_quick_install = false; +bool amazon_quick_install = false; string DataFileEnvFile; @@ -296,7 +297,7 @@ int main(int argc, char *argv[]) cout << " Enter one of the options within [], if available, or" << endl; cout << " Enter a new value" << endl << endl; cout << endl; - cout << "Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-port][-i][-n][-d][-sn][-pm-ip-addrs][-um-ip-addrs]" << endl; + cout << "Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-qa][-port][-i][-n][-d][-sn][-pm-ip-addrs][-um-ip-addrs][-pm-count][-um-count]" << endl; cout << " -h Help" << endl; cout << " -c Config File to use to extract configuration data, default is Columnstore.xml.rpmsave" << endl; cout << " -u Upgrade, Install using the Config File from -c, default to Columnstore.xml.rpmsave" << endl; @@ -323,6 +324,11 @@ int main(int argc, char *argv[]) multi_server_quick_install = true; noPrompting = true; } + else if( string("-qa") == argv[i] ) + { + amazon_quick_install = true; + noPrompting = true; + } else if( string("-f") == argv[i] ) nodeps = "--nodeps"; else if( string("-o") == argv[i] ) @@ -424,11 +430,31 @@ int main(int argc, char *argv[]) exit (1); } umIpAddrs = argv[i]; + } + else if( string("-pm-count") == argv[i] ) + { + i++; + if (i >= argc ) + { + cout << " ERROR: PM-COUNT not provided" << endl; + exit (1); + } + pmNumber = atoi(argv[i]); + } + else if( string("-um-count") == argv[i] ) + { + i++; + if (i >= argc ) + { + cout << " ERROR: UM-COUNT not provided" << endl; + exit (1); + } + umNumber = atoi(argv[i]); } else { cout << " ERROR: Invalid Argument = " << argv[i] << endl; - cout << " Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-port][-i][-n][-sn][-pm-ip-addrs][-um-ip-addrs]" << endl; + cout << " Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-qa][-port][-i][-n][-d][-sn][-pm-ip-addrs][-um-ip-addrs][-pm-count][-um-count]" << endl; exit (1); } } @@ -436,14 +462,25 @@ int main(int argc, char *argv[]) //check if quick install multi-server has been given ip address if (multi_server_quick_install) { - if ( umIpAddrs.empty() && pmIpAddrs.empty() || - !umIpAddrs.empty() && pmIpAddrs.empty() ) + if ( ( umIpAddrs.empty() && pmIpAddrs.empty() ) || + ( !umIpAddrs.empty() && pmIpAddrs.empty() )) { cout << " ERROR: Multi-Server option entered, but invalid UM/PM IP addresses were provided, exiting" << endl; exit(1); } } + //check if quick install multi-server has been given ip address + if (amazon_quick_install) + { + if ( ( umNumber == 0 && pmNumber == 0 ) || + ( umNumber != 0 && pmNumber == 0 ) ) + { + cout << " ERROR: Amazon option entered, but invalid UM/PM Counts were provided, exiting" << endl; + exit(1); + } + } + if (installDir[0] != '/') { cout << " ERROR: Install dir '" << installDir << "' is not absolute" << endl; @@ -462,7 +499,7 @@ int main(int argc, char *argv[]) cout << "IMPORTANT: This tool requires to run on the Performance Module #1" << endl; cout << endl; - if (!single_server_quick_install || !multi_server_quick_install) + if (!single_server_quick_install || !multi_server_quick_install || !amazon_quick_install) { if (!noPrompting) { cout << "Prompting instructions:" << endl << endl; @@ -723,6 +760,12 @@ int main(int argc, char *argv[]) singleServerInstall = "2"; } + else if (amazon_quick_install) + { + cout << "===== Quick Install Amazon Configuration =====" << endl << endl; + + singleServerInstall = "2"; + } else { cout << "===== Setup System Server Type Configuration =====" << endl << endl; @@ -943,6 +986,42 @@ int main(int argc, char *argv[]) MaxNicID = 1; } + else + { + if (amazon_quick_install) + { + //set configuarion settings for default setup + try { + sysConfig->setConfig(InstallSection, "MySQLRep", "y"); + } + catch(...) + {} + + try { + sysConfig->setConfig(InstallSection, "Cloud", "amazon-vpc"); + } + catch(...) + {} + + if (umNumber == 0 ) + { + // set Server Type Installation to combined + try { + sysConfig->setConfig(InstallSection, "ServerTypeInstall", "2"); + } + catch(...) + {} + } + + if ( !writeConfig(sysConfig) ) + { + cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; + exit(1); + } + + MaxNicID = 1; + } + } cout << endl; //cleanup/create local/etc directory @@ -1174,13 +1253,30 @@ int main(int argc, char *argv[]) in.seekg(0, std::ios::end); int size = in.tellg(); - if ( size == 0 || oam.checkLogStatus("/tmp/amazon.log", "not found")) - // not running on amazon with ec2-api-tools + if ( size == 0 || oam.checkLogStatus("/tmp/amazon.log", "not found")) + { + // not running on amazon with ec2-api-tools + if (amazon_quick_install) + { + cout << "ERROR: Amazon Quick Installer was specified, bu the AMazon CLI API packages isnt installed, exiting" << endl; + exit(1); + } + amazonInstall = false; + } else { - if ( size == 0 || oam.checkLogStatus("/tmp/amazon.log", "not installed")) + if ( size == 0 || oam.checkLogStatus("/tmp/amazon.log", "not installed")) + { + // not running on amazon with ec2-api-tools + if (amazon_quick_install) + { + cout << "ERROR: Amazon Quick Installer was specified, bu the AMazon CLI API packages isnt installed, exiting" << endl; + exit(1); + } + amazonInstall = false; + } else amazonInstall = true; } @@ -1216,7 +1312,7 @@ int main(int argc, char *argv[]) amazonInstall = false; try { - sysConfig->setConfig(InstallSection, "Cloud", "disable"); + sysConfig->setConfig(InstallSection, "Cloud", "disable"); } catch(...) {}; @@ -1674,6 +1770,7 @@ int main(int argc, char *argv[]) exit(1); continue; } + //update count try { string ModuleCountParm = "ModuleCount" + oam.itoa(i+1); @@ -1929,23 +2026,25 @@ int main(int argc, char *argv[]) //check if need to create instance or user enter ID string create = "y"; - while(true) + if ( !amazon_quick_install ) { - pcommand = callReadline("Create Instance for " + newModuleName + " [y,n] (y) > "); - if (pcommand) + while(true) { - if (strlen(pcommand) > 0) create = pcommand; - callFree(pcommand); + pcommand = callReadline("Create Instance for " + newModuleName + " [y,n] (y) > "); + if (pcommand) + { + if (strlen(pcommand) > 0) create = pcommand; + callFree(pcommand); + } + if ( create == "y" || create == "n" ) + break; + else + cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; + create = "y"; + if ( noPrompting ) + exit(1); } - if ( create == "y" || create == "n" ) - break; - else - cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; - create = "y"; - if ( noPrompting ) - exit(1); } - if ( create == "y" ) { ModuleIP moduleip; @@ -2498,7 +2597,7 @@ int main(int argc, char *argv[]) string dbrootList; - if (multi_server_quick_install) + if (multi_server_quick_install || amazon_quick_install) { dbrootList = oam.itoa(moduleID); } @@ -3609,7 +3708,7 @@ bool checkSaveConfigFile() //check if Columnstore.xml.rpmsave exist ifstream File (oldFileName.c_str()); if (!File) { - if (single_server_quick_install || multi_server_quick_install) + if (single_server_quick_install || multi_server_quick_install || amazon_quick_install) { return true; } @@ -3621,7 +3720,7 @@ bool checkSaveConfigFile() } else { - if (single_server_quick_install || multi_server_quick_install) + if (single_server_quick_install || multi_server_quick_install || amazon_quick_install) { cout << endl << "Quick Install is for fresh installs only, '" + oldFileName + "' exist, exiting" << endl; exit(1); diff --git a/oamapps/postConfigure/quick_installer_amazon.sh b/oamapps/postConfigure/quick_installer_amazon.sh new file mode 100644 index 000000000..395a3bf30 --- /dev/null +++ b/oamapps/postConfigure/quick_installer_amazon.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# +# $Id: quick_installer_amazon.sh 3705 2018-07-07 19:47:20Z dhill $ +# +# Poddst- Quick Installer for Amazon MariaDB Columnstore + +pmCount="" +umCount="" +systemName="" + +for arg in "$@"; do + if [ `expr -- "$arg" : '--pm-count='` -eq 11 ]; then + pmCount="`echo $arg | awk -F= '{print $2}'`" + elif [ `expr -- "$arg" : '--um-count='` -eq 11 ]; then + umCount="`echo $arg | awk -F= '{print $2}'`" + elif [ `expr -- "$arg" : '--systemName='` -eq 13 ]; then + systemName="`echo $arg | awk -F= '{print $2}'`" + systemName="-sn "$systemName + elif [ `expr -- "$arg" : '--dist-install'` -eq 14 ]; then + nonDistrubutedInstall=" " + elif [ `expr -- "$arg" : '--help'` -eq 6 ]; then + echo "Usage ./quick_installer_amazon.sh [OPTION]" + echo "" + echo "Quick Installer for an Amazon MariaDB ColumnStore Install" + echo "This requires to be run on a MariaDB ColumnStore AMI" + echo "" + echo "Performace Module (pm) number is required" + echo "User Module (um) number is option" + echo "When only pm counts provided, system is combined setup" + echo "When both pm/um counts provided, system is seperate setup" + echo + echo "--pm-count=x Number of pm instances to create" + echo "--um-count=x Number of um instances to create, optional" + echo "--system-name=nnnn System Name, optional" + echo "" + else + echo "./quick_installer_amazon.sh: unknown argument: $arg, enter --help for help" 1>&2 + exit 1 + fi +done + +if [[ $pmCount = "" ]]; then + echo "" + echo "Performace Module (pm) count is required, exiting" + exit 1 +else + if [[ $umCount = "" ]]; then + echo "" + echo "NOTE: Performing a Multi-Server Combined install with um/pm running on some server" + echo"" + else + echo "" + echo "NOTE: Performing a Multi-Server Seperate install with um and pm running on seperate servers" + echo"" + fi +fi + +if [[ $HOME = "/root" ]]; then + echo "${bold}Run post-install script${normal}" + echo "" + /usr/local/mariadb/columnstore/bin/post-install + echo "${bold}Run postConfigure script${normal}" + echo "" + if [[ $umCount = "" ]]; then + /usr/local/mariadb/columnstore/bin/postConfigure -qa -pm-count $pmCount $systemName + else + /usr/local/mariadb/columnstore/bin/postConfigure -qa -pm-count $pmCount -um-count $umCount $systemName + fi +else + echo "${bold}Run post-install script${normal}" + echo "" + $HOME/mariadb/columnstore/bin/post-install --installdir=$HOME/mariadb/columnstore + echo "${bold}Run postConfigure script${normal}" + echo "" + if [[ $umCount = "" ]]; then + $HOME/mariadb/columnstore/bin/postConfigure -i $HOME/mariadb/columnstore -qa -pm-count $pmCount $systemName + else + $HOME/mariadb/columnstore/bin/postConfigure -i $HOME/mariadb/columnstore -qa -pm-count $pmCount -um-count $umCount $systemName + fi +fi diff --git a/oamapps/postConfigure/quick_installer_multi_server.sh b/oamapps/postConfigure/quick_installer_multi_server.sh index 97aa670bc..1f4e29cd0 100644 --- a/oamapps/postConfigure/quick_installer_multi_server.sh +++ b/oamapps/postConfigure/quick_installer_multi_server.sh @@ -7,32 +7,38 @@ pmIpAddrs="" umIpAddrs="" nonDistrubutedInstall="-n" +systemName="" for arg in "$@"; do if [ `expr -- "$arg" : '--pm-ip-addresses='` -eq 18 ]; then pmIpAddrs="`echo $arg | awk -F= '{print $2}'`" elif [ `expr -- "$arg" : '--um-ip-addresses='` -eq 18 ]; then umIpAddrs="`echo $arg | awk -F= '{print $2}'`" + elif [ `expr -- "$arg" : '--systemName='` -eq 13 ]; then + systemName="`echo $arg | awk -F= '{print $2}'`" + systemName="-sn "$systemName elif [ `expr -- "$arg" : '--dist-install'` -eq 14 ]; then nonDistrubutedInstall=" " elif [ `expr -- "$arg" : '--help'` -eq 6 ]; then echo "Usage ./quick_installer_multi_server.sh [OPTION]" echo "" echo "Quick Installer for a Multi Server MariaDB ColumnStore Install" + echo "" echo "Defaults to non-distrubuted install, meaning MariaDB Columnstore" echo "needs to be preinstalled on all nodes in the system" echo "" - echo "Performace Module (pm) IP addresses required" - echo "User Module (um) IP addresses option" + echo "Performace Module (pm) IP addresses are required" + echo "User Module (um) IP addresses are option" echo "When only pm IP addresses provided, system is combined setup" echo "When both pm/um IP addresses provided, system is seperate setup" echo echo "--pm-ip-addresses=xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx" - echo "--um-ip-addresses=xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx" + echo "--um-ip-addresses=xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx, optional" echo "--dist-install Use Distributed Install Option" + echo "--system-name=nnnn System Name, optional" echo "" else - echo "quick_installer_multi_server.sh: unknown argument: $arg, use --help for help" 1>&2 + echo "quick_installer_multi_server.sh: unknown argument: $arg, enter --help for help" 1>&2 exit 1 fi done @@ -58,11 +64,11 @@ if [[ $HOME = "/root" ]]; then echo "" /usr/local/mariadb/columnstore/bin/post-install echo "${bold}Run postConfigure script${normal}" - echo "" + echo "" if [[ $umIpAddrs = "" ]]; then - /usr/local/mariadb/columnstore/bin/postConfigure -qm -pm-ip-addrs $pmIpAddrs $nonDistrubutedInstall + /usr/local/mariadb/columnstore/bin/postConfigure -qm -pm-ip-addrs $pmIpAddrs $nonDistrubutedInstall $systemName else - /usr/local/mariadb/columnstore/bin/postConfigure -qm -pm-ip-addrs $pmIpAddrs -um-ip-addrs $umIpAddrs $nonDistrubutedInstall + /usr/local/mariadb/columnstore/bin/postConfigure -qm -pm-ip-addrs $pmIpAddrs -um-ip-addrs $umIpAddrs $nonDistrubutedInstall $systemName fi else echo "${bold}Run post-install script${normal}" @@ -71,8 +77,8 @@ else echo "${bold}Run postConfigure script${normal}" echo "" if [[ $umIpAddrs = "" ]]; then - $HOME/mariadb/columnstore/bin/postConfigure -i $HOME/mariadb/columnstore -qm -pm-ip-addrs $pmIpAddrs $nonDistrubutedInstall + $HOME/mariadb/columnstore/bin/postConfigure -i $HOME/mariadb/columnstore -qm -pm-ip-addrs $pmIpAddrs $nonDistrubutedInstall $systemName else - $HOME/mariadb/columnstore/bin/postConfigure -i $HOME/mariadb/columnstore -qm -pm-ip-addrs $pmIpAddrs -um-ip-addrs $umIpAddrs $nonDistrubutedInstall + $HOME/mariadb/columnstore/bin/postConfigure -i $HOME/mariadb/columnstore -qm -pm-ip-addrs $pmIpAddrs -um-ip-addrs $umIpAddrs $nonDistrubutedInstall $systemName fi fi