From 7b66bc7eadda3b86595f936cc67e883389dc7f96 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 13 Apr 2020 05:15:44 +0000 Subject: [PATCH] MCOL-3915 Run post-install, postConfigure, and start systemd units during package installation --- .../columnstore-post-install.in | 19 + oamapps/postConfigure/postConfigure.cpp | 3332 +---------------- 2 files changed, 20 insertions(+), 3331 deletions(-) diff --git a/oam/install_scripts/columnstore-post-install.in b/oam/install_scripts/columnstore-post-install.in index f379a72ff..795180ae6 100755 --- a/oam/install_scripts/columnstore-post-install.in +++ b/oam/install_scripts/columnstore-post-install.in @@ -85,6 +85,8 @@ if [ $user = "root" ]; then systemctl=`which systemctl 2>/dev/null` if [ -n "$systemctl" ]; then + cp @ENGINE_SUPPORTDIR@/controllernode.service /usr/lib/systemd/system/. >/dev/null 2>&1 + cp @ENGINE_SUPPORTDIR@/controllernode.service /lib/systemd/system/. >/dev/null 2>&1 cp @ENGINE_SUPPORTDIR@/controllernode.service /usr/lib/systemd/system/. >/dev/null 2>&1 cp @ENGINE_SUPPORTDIR@/controllernode.service /lib/systemd/system/. >/dev/null 2>&1 cp @ENGINE_SUPPORTDIR@/ddlproc.service /usr/lib/systemd/system/. >/dev/null 2>&1 @@ -170,5 +172,22 @@ postConfigure EOD +#postConfigure scripts +#post-mysqld-install --tmpDir=$tmpDir > $tmpDir/post-mysqld-install.log 2>&1 +#post-mysql-install --tmpDir=$tmpDir > $tmpDir/post-mysql-install.log 2>&1 +#columnstore restart > /dev/null 2>&1 +#dbbuilder 7 > $tmpDir/dbbuilder.log 2>&1 + +postConfigure -qs + +PROGS='workernode controllernode PrimProc ExeMgr DMLProc DDLProc mysqld WriteEngineServer' +MCS_INSTALL_DIR=/usr + +kill $(pidof $PROGS) > /dev/null +sleep 3 +kill -9 $(pidof $PROGS) > /dev/null +@ENGINE_BINDIR@/clearShm +systemctl start columnstore + exit 0 diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index a2c73e814..5f36d0dcc 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -355,230 +355,11 @@ int main(int argc, char* argv[]) cout << " -sm-prefix prefix Where storagemanager will store its files" << endl; exit (0); } - else if (strcmp("-sm-bucket", argv[i]) == 0) - { - if (++i == argc) - { - cout << " ERROR: StorageManager bucket not provided" << endl; - exit(1); - } - s3Bucket = argv[i]; - configureS3 = true; - } - else if (strcmp("-sm-region", argv[i]) == 0) - { - if (++i == argc) - { - cout << " ERROR: StorageManager region not provided" << endl; - exit(1); - } - s3Region = argv[i]; - configureS3 = true; - } - else if (strcmp("-sm-id", argv[i]) == 0) - { - if (++i == argc) - { - cout << " ERROR: StorageManager ID not provided" << endl; - exit(1); - } - s3Key = argv[i]; - configureS3 = true; - } - else if (strcmp("-sm-secret", argv[i]) == 0) - { - if (++i == argc) - { - cout << " ERROR: StorageManager secret not provided" << endl; - exit(1); - } - s3Secret = argv[i]; - configureS3 = true; - } - else if (strcmp("-sm-endpoint", argv[i]) == 0) - { - if (++i == argc) - { - cout << " ERROR: StorageManager endpoint not provided" << endl; - exit(1); - } - s3Endpoint = argv[i]; - configureS3 = true; - } - else if (strcmp("-sm-cache", argv[i]) == 0) - { - if (++i == argc) - { - cout << " ERROR: StorageManager cache size not provided" << endl; - exit(1); - } - s3CacheSize = argv[i]; - configureS3 = true; - } - else if (strcmp("-sm-prefix", argv[i]) == 0) - { - if (++i == argc) - { - cout << " ERROR: StorageManager prefix not provided" << endl; - exit(1); - } - s3Location = argv[i]; - configureS3 = true; - } - else if (string("-x") == argv[i]) - { - doNotResolveHostNames = true; - } - else if (string("-xr") == argv[i]) - { - resolveHostNamesToReverseDNSNames = true; - } - else if( string("-qs") == argv[i] ) + else if( string("-qs") == argv[i] ) { single_server_quick_install = true; noPrompting = true; } - else if( string("-qm") == argv[i] ) - { - multi_server_quick_install = true; - noPrompting = true; - } - else if ( string("-f") == argv[i] ) - nodeps = "--nodeps"; - else if ( string("-o") == argv[i] ) - startOfflinePrompt = true; - else if( string("-c") == argv[i] ) - { - i++; - if (i >= argc ) - { - cout << " ERROR: Config File not provided" << endl; - exit (1); - } - - oldFileName = argv[i]; - if ( oldFileName.find("Columnstore.xml") == string::npos ) - { - cout << " ERROR: Config File is not a Columnstore.xml file name" << endl; - exit (1); - } - } - else if( string("-p") == argv[i] ) - { - i++; - if (i >= argc ) - { - cout << " ERROR: Password not provided" << endl; - exit (1); - } - - password = argv[i]; - if ( password.find("-") != string::npos ) - { - cout << " ERROR: Valid Password not provided" << endl; - exit (1); - } - } - else if ( string("-u") == argv[i] ) - noPrompting = true; - // for backward compatibility - else if( string("-port") == argv[i] ) - { - i++; - if (i >= argc ) - { - cout << " ERROR: MariaDB ColumnStore Port ID not supplied" << endl; - exit (1); - } - - mysqlPort = argv[i]; - - if ( atoi(mysqlPort.c_str()) < 1000 || atoi(mysqlPort.c_str()) > 9999) - { - cout << " ERROR: Invalid MariaDB ColumnStore Port ID supplied, must be between 1000-9999" << endl; - exit (1); - } - } - else if( string("-sn") == argv[i] ) - { - i++; - if (i >= argc ) - { - cout << " ERROR: System-name not provided" << endl; - exit (1); - } - systemName = argv[i]; - } - else if( string("-pm-ip-addrs") == argv[i] ) - { - i++; - if (i >= argc ) - { - cout << " ERROR: PM-IP-ADRESSES not provided" << endl; - exit (1); - } - pmIpAddrs = argv[i]; - } - else if( string("-um-ip-addrs") == argv[i] ) - { - i++; - if (i >= argc ) - { - cout << " ERROR: UM-IP-ADRESSES not provided" << endl; - 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 if ( string("-numBlocksPct") == argv[i] ) - { - i++; - if (i >= argc) - { - cout << " ERROR: Memory settings for numBlocksPct not provided" << endl; - exit(1); - } - numBlocksPctParam = argv[i]; - // check that the parameter ends with a number M or G - if (!(isdigit(*numBlocksPctParam.rbegin()) || *numBlocksPctParam.rbegin() == 'M' || *numBlocksPctParam.rbegin() == 'G')) { - cout << " ERROR: Memory settings for numBlocksPct need to end on a digit, M or G" << endl; - exit(1); - } - } - else if (string("-totalUmMemory") == argv[i]) - { - i++; - if (i >= argc) - { - cout << " ERROR: Memory settings for totalUmMemory not provided" << endl; - exit(1); - } - totalUmMemoryParam = argv[i]; - // check that the parameter ends with a %, M, or G - if (!(*totalUmMemoryParam.rbegin() == '%' || *totalUmMemoryParam.rbegin() == 'M' || *totalUmMemoryParam.rbegin() == 'G')) { - cout << " ERROR: Memory settings for totalUmMemory need to end on %, M or G" << endl; - exit(1); - } - } else { cout << " ERROR: Invalid Argument = " << argv[i] << endl; @@ -590,28 +371,6 @@ 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() )) - { - 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 ( oldFileName == oam::UnassignedName ) oldFileName = std::string(MCSSYSCONFDIR) + "/columnstore/Columnstore.xml.rpmsave"; @@ -649,40 +408,6 @@ int main(int argc, char* argv[]) exit(1); } - if (!single_server_quick_install || !multi_server_quick_install || !amazon_quick_install) - { - if (!noPrompting) { - cout << "Prompting instructions:" << endl << endl; - cout << " Press 'enter' to accept a value in (), if available or" << endl; - cout << " Enter one of the options within [], if available, or" << endl; - cout << " Enter a new value" << endl << endl; - } - else - { - //get current time and date - time_t now; - now = time(NULL); - struct tm tm; - localtime_r(&now, &tm); - char timestamp[200]; - strftime (timestamp, 200, "%m:%d:%y-%H:%M:%S", &tm); - string currentDate = timestamp; - - string postConfigureLog = "/var/log/columnstore-postconfigure-" + currentDate; - - cout << "With the no-Prompting Option being specified, you will be required to have the following:" << endl; - cout << endl; - cout << " 1. Root user ssh keys setup between all nodes in the system or" << endl; - cout << " use the password command line option." << endl; - cout << " 2. A Configure File to use to retrieve configure data, default to Columnstore.xml.rpmsave" << endl; - cout << " or use the '-c' option to point to a configuration file." << endl; - cout << endl; - // cout << " Output if being redirected to " << postConfigureLog << endl; - - // redirectStandardOutputToFile(postConfigureLog, false ); - } - } - //check if MariaDB ColumnStore is up and running if (oam.checkSystemRunning()) { @@ -861,18 +586,6 @@ int main(int argc, char* argv[]) catch (...) {} - // run columnstore.cnf upgrade script - if ( reuseConfig == "y" ) - { - cmd = "mycnfUpgrade > " + tmpDir + "/mycnfUpgrade.log 2>&1"; - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - cout << "Error: Problem upgrade columnstore.cnf, check " << tmpDir << "/mycnfUpgrade.log" << endl; - else - cout << "NOTE: columnstore.cnf file was upgraded based on columnstore.cnf.rpmsave" << endl; - } - //check mysql port changes string MySQLPort; @@ -922,84 +635,6 @@ int main(int argc, char* argv[]) singleServerInstall = "1"; } - else if (multi_server_quick_install) - { - cout << "===== Quick Install Multi-Server Configuration =====" << endl << endl; - - cout << "Multi-Server install defaulting to using local storage" << endl; - - singleServerInstall = "2"; - } - else if (amazon_quick_install) - { - cout << "===== Quick Install Amazon Configuration =====" << endl << endl; - - cout << "Amazon AMI EC2 install defaulting to using local storage" << endl; - - singleServerInstall = "2"; - } - else - { - cout << "===== Setup System Server Type Configuration =====" << endl << endl; - - cout << "There are 2 options when configuring the System Server Type: single and multi" << endl << endl; - cout << " 'single' - Single-Server install is used when there will only be 1 server configured" << endl; - cout << " on the system. It can also be used for production systems, if the plan is" << endl; - cout << " to stay single-server." << endl << endl; - cout << " 'multi' - Multi-Server install is used when you want to configure multiple servers now or" << endl; - cout << " in the future. With Multi-Server install, you can still configure just 1 server" << endl; - cout << " now and add on addition servers/modules in the future." << endl << endl; - - string temp; - - try - { - temp = sysConfig->getConfig(InstallSection, "SingleServerInstall"); - } - catch(...) - {} - - if ( temp == "y" ) - singleServerInstall = "1"; - else - singleServerInstall = "2"; - - while(true) - { - string temp = singleServerInstall; - prompt = "Select the type of System Server install [1=single, 2=multi] (" + singleServerInstall + ") > "; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) - temp = pcommand; - else - temp = singleServerInstall; - - callFree(pcommand); - - if (temp == "1") - { - singleServerInstall = "1"; - break; - } - else - { - if (temp == "2") - { - singleServerInstall = "2"; - break; - } - } - - cout << "Invalid Entry, please re-enter" << endl; - - if ( noPrompting ) - exit(1); - } - } - } // perform single server install if (singleServerInstall == "1") @@ -1093,2971 +728,6 @@ int main(int argc, char* argv[]) system(cmd.c_str()); exit(0); } - - // perform multi-node install - - try - { - sysConfig->setConfig(InstallSection, "SingleServerInstall", "n"); - } - catch (...) - { - cout << "ERROR: Problem setting SingleServerInstall from the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - // - // Multi-server install - // - - ModuleIP InputModuleIP; - ModuleIpList InputModuleIPList; - - int MaxNicID = oam::MAX_NIC; - - if (multi_server_quick_install) - { - //set configuarion settings for default setup - try { - sysConfig->setConfig(InstallSection, "MySQLRep", "y"); - } - catch(...) - {} - - if (umIpAddrs == "" ) - { - // set Server Type Installation to combined - try { - sysConfig->setConfig(InstallSection, "ServerTypeInstall", "2"); - } - catch(...) - {} - } - else - { - int id = 1; - boost::char_separator sep(","); - boost::tokenizer< boost::char_separator > tokens(umIpAddrs, sep); - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it, ++id) - { - string module = "um" + oam.itoa(id); - - InputModuleIP.IPaddress = *it; - InputModuleIP.moduleName = module; - InputModuleIPList.push_back(InputModuleIP); - } - - umNumber = id-1; - } - - if (pmIpAddrs != "" ) - { - int id = 1; - boost::char_separator sep(","); - boost::tokenizer< boost::char_separator > tokens(pmIpAddrs, sep); - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it, ++id) - { - string module = "pm" + oam.itoa(id); - - InputModuleIP.IPaddress = *it; - InputModuleIP.moduleName = module; - InputModuleIPList.push_back(InputModuleIP); - } - - pmNumber = id-1; - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - 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 - cmd = "rm -rf /var/lib/columnstore/local/etc > /dev/null 2>&1"; - system(cmd.c_str()); - cmd = "mkdir /var/lib/columnstore/local/etc > /dev/null 2>&1"; - system(cmd.c_str()); - - cout << endl << "===== Setup System Module Type Configuration =====" << endl << endl; - - cout << "There are 2 options when configuring the System Module Type: separate and combined" << endl << endl; - cout << " 'separate' - User and Performance functionality on separate servers." << endl << endl; - cout << " 'combined' - User and Performance functionality on the same server" << endl << endl; - - try - { - serverTypeInstall = sysConfig->getConfig(InstallSection, "ServerTypeInstall"); - } - catch (...) - { - cout << "ERROR: Problem getting ServerTypeInstall from the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - while (true) - { - prompt = "Select the type of System Module Install [1=separate, 2=combined] (" + serverTypeInstall + ") > "; - pcommand = callReadline(prompt.c_str()); - cout << endl; - - if (pcommand) - { - if (strlen(pcommand) > 0) serverTypeInstall = pcommand; - - callFree(pcommand); - } - - if ( serverTypeInstall != "1" && serverTypeInstall != "2" ) - { - cout << "Invalid Entry, please re-enter" << endl << endl; - serverTypeInstall = "1"; - - if ( noPrompting ) - exit(1); - - continue; - } - - IserverTypeInstall = atoi(serverTypeInstall.c_str()); - - // set Server Type Installation Indicator - try - { - sysConfig->setConfig(InstallSection, "ServerTypeInstall", serverTypeInstall); - } - catch (...) - { - cout << "ERROR: Problem setting ServerTypeInstall in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - switch ( IserverTypeInstall ) { - case (oam::INSTALL_COMBINE_DM_UM_PM): // combined #1 - um/pm on a single server - { - cout << "Combined Server Installation will be performed." << endl; - cout << "The Server will be configured as a Performance Module." << endl; - cout << "All MariaDB ColumnStore Processes will run on the Performance Modules." << endl << endl; - - //module ProcessConfig.xml to setup all apps on the pm - if ( !updateProcessConfig() ) - cout << "Update ProcessConfig.xml error" << endl; - - //store local query flag - try - { - sysConfig->setConfig(InstallSection, "PMwithUM", "n"); - } - catch (...) - {} - - pmwithum = false; - - break; - } - - default: // normal, separate UM and PM - { - cout << "Seperate Server Installation will be performed." << endl << endl; - - try - { - PMwithUM = sysConfig->getConfig(InstallSection, "PMwithUM"); - } - catch (...) - {} - - if ( PMwithUM == "y" ) - pmwithum = true; - - string answer = "n"; - - cout << "NOTE: Local Query Feature allows the ability to query data from a single Performance" << endl; - cout << " Module. Check MariaDB ColumnStore Admin Guide for additional information." << endl << endl; - - while (true) - { - if ( pmwithum ) - prompt = "Local Query feature is Enabled, Do you want to disable? [y,n] (n) > "; - else - prompt = "Enable Local Query feature? [y,n] (n) > "; - - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) answer = pcommand; - - callFree(pcommand); - } - - if ( answer == "y" || answer == "n" ) - { - cout << endl; - break; - } - else - cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; - - if ( noPrompting ) - exit(1); - } - - if ( pmwithum ) - { - if ( answer == "y" ) - { - pmwithum = false; - PMwithUM = "n"; - } - } - else - { - if ( answer == "y" ) - { - pmwithum = true; - PMwithUM = "y"; - } - } - - try - { - sysConfig->setConfig(InstallSection, "PMwithUM", PMwithUM); - } - catch (...) - {} - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - break; - } - } - - break; - } - - // check for Schema Schema is Local Query wasnt selected - if (!pmwithum) - { - cout << "NOTE: The MariaDB ColumnStore Schema Sync feature will replicate all of the" << endl; - cout << " schemas and InnoDB tables across the User Module nodes. This feature can be enabled" << endl; - cout << " or disabled, for example, if you wish to configure your own replication post installation." << endl << endl; - - try - { - MySQLRep = sysConfig->getConfig(InstallSection, "MySQLRep"); - } - catch (...) - {} - - if ( MySQLRep == "y" ) - mysqlRep = true; - - string answer = "y"; - - while (true) - { - if ( mysqlRep ) - prompt = "MariaDB ColumnStore Schema Sync feature is Enabled, do you want to leave enabled? [y,n] (y) > "; - else - prompt = "MariaDB ColumnStore Schema Sync feature, do you want to enable? [y,n] (y) > "; - - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) answer = pcommand; - - callFree(pcommand); - } - - if ( answer == "y" || answer == "n" ) - { - cout << endl; - break; - } - else - cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; - - if ( noPrompting ) - exit(1); - } - - if ( answer == "y" ) - { - mysqlRep = true; - MySQLRep = "y"; - } - else - { - mysqlRep = false; - MySQLRep = "n"; - } - - try - { - sysConfig->setConfig(InstallSection, "MySQLRep", MySQLRep); - } - catch (...) - {} - } - else - { - //Schema Sync is default as on when Local Query is Selected - mysqlRep = true; - MySQLRep = "y"; - - try - { - sysConfig->setConfig(InstallSection, "MySQLRep", MySQLRep); - } - catch (...) - {} - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //amazon install setup check - bool amazonInstall = false; - string cloud = oam::UnassignedName; - - #if 0 - if (!multi_server_quick_install) - { - string amazonLog = tmpDir + "/amazon.log"; - string cmd = "aws --version > " + amazonLog + " 2>&1"; - system(cmd.c_str()); - - ifstream in(amazonLog.c_str()); - - in.seekg(0, std::ios::end); - int size = in.tellg(); - - if ( size == 0 || oam.checkLogStatus(amazonLog, "not found")) - { - // not running on amazon with ec2-api-tools - if (amazon_quick_install) - { - cout << "ERROR: Amazon Quick Installer was specified, but the Amazon CLI API packages is not installed, exiting" << endl; - exit(1); - } - - amazonInstall = false; - } - else - { - if ( size == 0 || oam.checkLogStatus(amazonLog, "not installed")) - { - // not running on amazon with ec2-api-tools - if (amazon_quick_install) - { - cout << "ERROR: Amazon Quick Installer was specified, but the Amazon CLI API packages is not installed, exiting" << endl; - exit(1); - } - - amazonInstall = false; - } - else - amazonInstall = true; - } - } - #endif - - try - { - cloud = sysConfig->getConfig(InstallSection, "Cloud"); - } - catch (...) - { - cloud = oam::UnassignedName; - } - - if ( cloud == "disable" ) - amazonInstall = false; - - if ( amazonInstall ) - { - if ( cloud == oam::UnassignedName ) - { - cout << "NOTE: Amazon AWS CLI Tools are installed and allow MariaDB ColumnStore" << endl; - cout << " to create Instances and EBS Volumes" << endl << endl; - - while (true) - { - string enable = "y"; - prompt = "Do you want to have ColumnStore use the Amazon AWS CLI Tools [y,n] (y) > "; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) enable = pcommand; - - callFree(pcommand); - - if (enable == "n") - { - amazonInstall = false; - - try - { - sysConfig->setConfig(InstallSection, "Cloud", "disable"); - } - catch (...) - {}; - - break; - } - } - - if ( enable != "y" ) - { - cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; - - if ( noPrompting ) - exit(1); - } - else - { - try - { - sysConfig->setConfig(InstallSection, "Cloud", "amazon-vpc"); - } - catch (...) - {} - } - - break; - } - } - else - cout << "NOTE: Configured to have ColumnStore use the Amazon AWS CLI Tools" << endl << endl; - - if ( amazonInstall ) - { - string cmd = "MCSgetCredentials.sh >/dev/null 2>&1"; - int rtnCode = system(cmd.c_str()); - - if ( WEXITSTATUS(rtnCode) != 0 ) - { - cout << endl << "Error: No IAM Profile with Security Certificates used or AWS CLI Certificate file configured" << endl; - cout << "Check Amazon Install Documenation for additional information, exiting..." << endl; - exit (1); - } - - // setup to start on reboot, for non-root amazon installs - if ( !rootUser ) - { - system("sudo sed -i -e 's/#runuser/runuser/g' /etc/rc.d/rc.local >/dev/null 2>&1"); - } - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - } - - if ( pmwithum ) - cout << endl << "NOTE: Local Query Feature is enabled" << endl; - - if ( mysqlRep ) - cout << endl << "NOTE: MariaDB ColumnStore Replication Feature is enabled" << endl; - - //Write out Updated System Configuration File - try - { - sysConfig->setConfig(InstallSection, "InitialInstallFlag", "n"); - } - catch (...) - { - cout << "ERROR: Problem setting InitialInstallFlag from the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - cout << endl; - - // prompt for system name - setSystemName(); - - cout << endl; - - oamModuleInfo_t t; - string localModuleName; - - try - { - t = oam.getModuleInfo(); - localModuleName = boost::get<0>(t); - } - catch (exception& e) {} - - //get Parent OAM Module Name - parentOAMModuleName = "pm1"; - - if ( localModuleName != parentOAMModuleName ) - { - cout << endl << endl << "ERROR: exiting, postConfigure can only run executed on " + parentOAMModuleName + ", current module is " << localModuleName << endl; - exit(1); - } - - try - { - sysConfig->setConfig(SystemSection, "ParentOAMModuleName", parentOAMModuleName); - } - catch (...) - { - cout << "ERROR: Problem setting ParentOAMModuleName the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - // set Standby Parent OAM module and IP to unassigned - try - { - sysConfig->setConfig(SystemSection, "StandbyOAMModuleName", oam::UnassignedName); - sysConfig->setConfig("ProcStatusControlStandby", "IPAddr", oam::UnassignedIpAddr); - } - catch (...) - { - cout << "ERROR: Problem setting ParentStandbyOAMModuleName the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //create associated local/etc directory for parentOAMModuleName - cmd = "mkdir /var/lib/columnstore/local/etc/" + parentOAMModuleName + " > /dev/null 2>&1"; - system(cmd.c_str()); - - //setup local module file name - if ( !makeModuleFile(parentOAMModuleName, parentOAMModuleName) ) - { - cout << "makeModuleFile error" << endl; - exit(1); - } - - cout << endl; - - if (startOfflinePrompt) - offLineAppCheck(); - - string parentOAMModuleType = parentOAMModuleName.substr(0, MAX_MODULE_TYPE_SIZE); - int parentOAMModuleID = atoi(parentOAMModuleName.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE).c_str()); - - if ( parentOAMModuleID < 1 ) - { - cout << "ERROR: Invalid Module ID of less than 1" << endl; - exit(1); - } - - //Get list of configured system modules - SystemModuleTypeConfig sysModuleTypeConfig; - - try - { - oam.getSystemConfig(sysModuleTypeConfig); - } - catch (...) - { - cout << "ERROR: Problem reading the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - // - // setup storage - // - - if (!storageSetup(amazonInstall)) - { - cout << "ERROR: Problem setting up storage" << endl; - exit(1); - } - - if (hdfs || !rootUser) - if ( !updateBash() ) - cout << "updateBash error" << endl; - - // - // setup memory paramater settings - // - - cout << endl << "===== Setup Memory Configuration =====" << endl << endl; - - switch ( IserverTypeInstall ) - { - case (oam::INSTALL_COMBINE_DM_UM_PM): // combined #1 - dm/um/pm on a single server - { - // are we using settings from previous config file? - if (reuseConfig == "n") - { - - string numBlocksPct; - - // if numBlocksPct was set as command line parameter use the command line parameter value - if (!numBlocksPctParam.empty()) { - numBlocksPct = numBlocksPctParam; - } - else { - if (!uncommentCalpontXml("NumBlocksPct")) - { - cout << "Update Columnstore.xml NumBlocksPct Section" << endl; - exit(1); - } - - try - { - numBlocksPct = sysConfig->getConfig("DBBC", "NumBlocksPct"); - } - catch (...) - { - } - - if (numBlocksPct == "70" || numBlocksPct.empty()) - { - numBlocksPct = "50"; - - if (hdfs) - numBlocksPct = "25"; - } - } - try - { - sysConfig->setConfig("DBBC", "NumBlocksPct", numBlocksPct); - - if (*numBlocksPct.rbegin() == 'M' || *numBlocksPct.rbegin() == 'G') { - cout << endl << "NOTE: Setting 'NumBlocksPct' to " << numBlocksPct << endl; - } - else { - cout << endl << "NOTE: Setting 'NumBlocksPct' to " << numBlocksPct << "%" << endl; - } - } - catch (...) - { - cout << "ERROR: Problem setting NumBlocksPct in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - - string percent; - - if (!totalUmMemoryParam.empty()) { // if totalUmMemory was set as command line parameter use the command line parameter value - percent = totalUmMemoryParam; - } - else { //otherwise use reasonable defaults - - percent = "25%"; - - if (hdfs) - { - percent = "12%"; - } - } - - cout << " Setting 'TotalUmMemory' to " << percent << endl; - - try - { - sysConfig->setConfig("HashJoin", "TotalUmMemory", percent); - } - catch (...) - { - cout << "ERROR: Problem setting TotalUmMemory in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - } - else - { - try - { - cout << endl; - - if (!numBlocksPctParam.empty()) { // if numBlocksPct was set as command line parameter use the command line parameter value - sysConfig->setConfig("DBBC", "NumBlocksPct", numBlocksPctParam); - if (*numBlocksPctParam.rbegin() == 'M' || *numBlocksPctParam.rbegin() == 'G') { - cout << endl << "NOTE: Setting 'NumBlocksPct' to " << numBlocksPctParam << endl; - } - else { - cout << endl << "NOTE: Setting 'NumBlocksPct' to " << numBlocksPctParam << "%" << endl; - } - } - else { //otherwise use the settings from the previous config file - string numBlocksPct = sysConfig->getConfig("DBBC", "NumBlocksPct"); - - if (numBlocksPct.empty()) - cout << "NOTE: Using the default setting for 'NumBlocksPct' at 70%" << endl; - else - cout << "NOTE: Using previous configuration setting for 'NumBlocksPct' = " << numBlocksPct << "%" << endl; - } - - if (!totalUmMemoryParam.empty()) { // if totalUmMemory was set as command line parameter use the command line parameter value - sysConfig->setConfig("HashJoin", "TotalUmMemory", totalUmMemoryParam); - cout << " Setting 'TotalUmMemory' to " << totalUmMemoryParam << endl; - } - else { //otherwise use the settings from the previous config file - string totalUmMemory = sysConfig->getConfig("HashJoin", "TotalUmMemory"); - cout << " Using previous configuration setting for 'TotalUmMemory' = " << totalUmMemory << endl; - } - } - catch (...) - { - cout << "ERROR: Problem reading/writing NumBlocksPct/TotalUmMemory in/to the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - } - - break; - } - - default: // normal, separate UM and PM - { - // are we using settings from previous config file? - if ( reuseConfig == "n" ) - { - string numBlocksPct; - - // if numBlocksPct was set as command line parameter use the command line parameter value - if (!numBlocksPctParam.empty()) { - numBlocksPct = numBlocksPctParam; - } - else { - try - { - numBlocksPct = sysConfig->getConfig("DBBC", "NumBlocksPct"); - } - catch (...) - { - } - - if (numBlocksPct.empty()) - { - numBlocksPct = "70"; - - if (hdfs) - numBlocksPct = "35"; - } - } - - try - { - sysConfig->setConfig("DBBC", "NumBlocksPct", numBlocksPct); - if (*numBlocksPct.rbegin() == 'M' || *numBlocksPct.rbegin() == 'G') { - cout << endl << "NOTE: Setting 'NumBlocksPct' to " << numBlocksPct << endl; - } - else { - cout << endl << "NOTE: Setting 'NumBlocksPct' to " << numBlocksPct << "%" << endl; - } - } - catch (...) - { - cout << "ERROR: Problem setting NumBlocksPct in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - string percent; - - if (!totalUmMemoryParam.empty()) { // if totalUmMemory was set as command line parameter use the command line parameter value - percent = totalUmMemoryParam; - } - else { //otherwise use reasonable defaults - percent = "50%"; - - if (hdfs) - { - percent = "25%"; - } - } - - cout << " Setting 'TotalUmMemory' to " << percent << endl; - - try - { - sysConfig->setConfig("HashJoin", "TotalUmMemory", percent); - } - catch (...) - { - cout << "ERROR: Problem setting TotalUmMemory in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - } - else - { - try - { - if (!numBlocksPctParam.empty()) { // if numBlocksPct was set as command line parameter use the command line parameter value - sysConfig->setConfig("DBBC", "NumBlocksPct", numBlocksPctParam); - if (*numBlocksPctParam.rbegin() == 'M' || *numBlocksPctParam.rbegin() == 'G') { - cout << endl << "NOTE: Setting 'NumBlocksPct' to " << numBlocksPctParam << endl; - } - else { - cout << endl << "NOTE: Setting 'NumBlocksPct' to " << numBlocksPctParam << "%" << endl; - } - } - else { //otherwise use the settings from the previous config file - string numBlocksPct = sysConfig->getConfig("DBBC", "NumBlocksPct"); - - if (numBlocksPct.empty()) - cout << "NOTE: Using the default setting for 'NumBlocksPct' at 70%" << endl; - else - cout << "NOTE: Using previous configuration setting for 'NumBlocksPct' = " << numBlocksPct << "%" << endl; - } - - if (!totalUmMemoryParam.empty()) { // if totalUmMemory was set as command line parameter use the command line parameter value - sysConfig->setConfig("HashJoin", "TotalUmMemory", totalUmMemoryParam); - cout << " Setting 'TotalUmMemory' to " << totalUmMemoryParam << endl; - } - else { //otherwise use reasonable defaults - string totalUmMemory = sysConfig->getConfig("HashJoin", "TotalUmMemory"); - cout << " Using previous configuration setting for 'TotalUmMemory' = " << totalUmMemory << endl; - } - } - catch (...) - { - cout << "ERROR: Problem reading/writing NumBlocksPct/TotalUmMemory in/to the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - } - - break; - } - } - - //Write out Updated System Configuration File - try - { - sysConfig->setConfig(InstallSection, "InitialInstallFlag", "y"); - } - catch (...) - { - cout << "ERROR: Problem setting InitialInstallFlag from the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - // - // Module Configuration - // - cout << endl << endl; - cout << "===== Setup the Module Configuration =====" << endl << endl; - - if (amazonInstall) - { - cout << "Amazon Install: For Module Configuration, you have the option to provide the" << endl; - cout << "existing Instance IDs or have the Instances created." << endl; - cout << "You will be prompted during the Module Configuration setup section." << endl; - } - - //get OAM Parent Module IP addresses and Host Name, if it exist - for ( unsigned int i = 0 ; i < sysModuleTypeConfig.moduletypeconfig.size(); i++) - { - DeviceNetworkList::iterator listPT = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for ( ; listPT != sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.end() ; listPT++) - { - HostConfigList::iterator pt1 = (*listPT).hostConfigList.begin(); - - if ( (*listPT).DeviceName == parentOAMModuleName ) - { - parentOAMModuleIPAddr = (*pt1).IPAddr; - parentOAMModuleHostName = (*pt1).HostName; - break; - } - } - } - - int maxPMNicCount = 1; - - //configure module type - bool parentOAMmoduleConfig = false; - bool moduleSkip = false; - - for ( unsigned int i = 0 ; i < sysModuleTypeConfig.moduletypeconfig.size(); i++) - { - string moduleType = sysModuleTypeConfig.moduletypeconfig[i].ModuleType; - string moduleDesc = sysModuleTypeConfig.moduletypeconfig[i].ModuleDesc; - int moduleCount = sysModuleTypeConfig.moduletypeconfig[i].ModuleCount; - - if ( moduleType == "dm") - { - moduleCount = 0; - - try - { - string ModuleCountParm = "ModuleCount" + oam.itoa(i + 1); - sysConfig->setConfig(ModuleSection, ModuleCountParm, oam.itoa(moduleCount)); - continue; - } - catch (...) - {} - } - - if ( moduleType == "um") - if ( umNumber != 0 ) - moduleCount = umNumber; - - if ( moduleType == "pm") - if ( pmNumber != 0 ) - moduleCount = pmNumber; - - //verify and setup of modules count - switch ( IserverTypeInstall ) - { - case (oam::INSTALL_COMBINE_DM_UM_PM): - { - if ( moduleType == "um") - { - moduleCount = 0; - - try - { - string ModuleCountParm = "ModuleCount" + oam.itoa(i + 1); - sysConfig->setConfig(ModuleSection, ModuleCountParm, oam.itoa(moduleCount)); - continue; - } - catch (...) - { - cout << "ERROR: Problem setting Module Count in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - } - - break; - } - - default: - break; - } - - cout << endl << "----- " << moduleDesc << " Configuration -----" << endl << endl; - - int oldModuleCount = moduleCount; - - while (true) - { - prompt = "Enter number of " + moduleDesc + "s [1," + oam.itoa(oam::MAX_MODULE) + "] (" + oam.itoa(oldModuleCount) + ") > "; - moduleCount = oldModuleCount; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) moduleCount = atoi(pcommand); - - callFree(pcommand); - } - - if ( moduleCount < 1 || moduleCount > oam::MAX_MODULE ) - { - cout << endl << "ERROR: Invalid Module Count '" + oam.itoa(moduleCount) + "', please re-enter" << endl << endl; - - if ( noPrompting ) - exit(1); - - continue; - } - - if ( parentOAMModuleType == moduleType && moduleCount == 0 ) - { - cout << endl << "ERROR: Parent OAM Module Type is '" + parentOAMModuleType + "', so you have to have at least 1 of this Module Type, please re-enter" << endl << endl; - - if ( noPrompting ) - exit(1); - - continue; - } - - if ( moduleType == "pm" && DataRedundancy && moduleCount == 1) - { - cout << endl << "ERROR: DataRedundancy requires 2 or more " + moduleType + " modules. type to be 2 or greater, please re-enter or restart to select a different data storage type." << endl << endl; - - if ( noPrompting ) - exit(1); - - continue; - } - - //update count - try - { - string ModuleCountParm = "ModuleCount" + oam.itoa(i + 1); - sysConfig->setConfig(ModuleSection, ModuleCountParm, oam.itoa(moduleCount)); - break; - } - catch (...) - { - cout << "ERROR: Problem setting Module Count in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - } - - if ( moduleType == "pm" ) - pmNumber = moduleCount; - - if ( moduleType == "um" ) - umNumber = moduleCount; - - int moduleID = 1; - - int listSize = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.size(); - - //clear any Equipped Module IP addresses that aren't in current ID range - for ( int j = 0 ; j < listSize ; j++ ) - { - for ( int k = 1 ; k < MaxNicID+1 ; k++) - { - string ModuleIPAddr = "ModuleIPAddr" + oam.itoa(j + 1) + "-" + oam.itoa(k) + "-" + oam.itoa(i + 1); - - if ( !(sysConfig->getConfig(ModuleSection, ModuleIPAddr).empty()) ) - { - if ( j + 1 < moduleID || j + 1 > moduleID + (moduleCount - 1) ) - { - string ModuleHostName = "ModuleHostName" + oam.itoa(j + 1) + "-" + oam.itoa(k) + "-" + oam.itoa(i + 1); - - sysConfig->setConfig(ModuleSection, ModuleIPAddr, oam::UnassignedIpAddr); - sysConfig->setConfig(ModuleSection, ModuleHostName, oam::UnassignedName); - } - } - } - } - - //configure module name - string newModuleHostName; - - while (true) - { - int saveModuleID = moduleID; - string moduleDisableState; - int enableModuleCount = moduleCount; - - for ( int k = 0 ; k < moduleCount ; k++, moduleID++) - { - string newModuleName = moduleType + oam.itoa(moduleID); - - if (moduleType == parentOAMModuleType && moduleID != parentOAMModuleID && !parentOAMmoduleConfig) - { - //skip this module for now, need to configure parent OAM Module first - moduleSkip = true; - continue; - } - - if (moduleType == parentOAMModuleType && moduleID == parentOAMModuleID && parentOAMmoduleConfig) - //skip, aleady configured - continue; - - if (moduleType == parentOAMModuleType && moduleID == parentOAMModuleID && !parentOAMmoduleConfig) - parentOAMmoduleConfig = true; - - string moduleNameDesc = moduleDesc + " #" + oam.itoa(moduleID); - PerformanceModule performancemodule; - - if ( newModuleName == parentOAMModuleName ) - cout << endl << "*** Parent OAM Module " << moduleNameDesc << " Configuration ***" << endl << endl; - else - cout << endl << "*** " << moduleNameDesc << " Configuration ***" << endl << endl; - - moduleDisableState = oam::ENABLEDSTATE; - - //setup HostName/IPAddress for each NIC - - string moduleHostName = oam::UnassignedName; - string moduleIPAddr = oam::UnassignedIpAddr; - - bool found = false; - if (multi_server_quick_install) - { - ModuleIpList::iterator pt2 = InputModuleIPList.begin(); - for( ; pt2 != InputModuleIPList.end() ; pt2++) - { - if ( (*pt2).moduleName == newModuleName ) - { - moduleHostName = (*pt2).IPaddress; - moduleIPAddr = (*pt2).IPaddress; - found = true; - break; - } - } - } - int nicID=1; - for( ; nicID < MaxNicID +1 ; nicID++ ) - { - if ( !found ) - { - moduleHostName = oam::UnassignedName; - moduleIPAddr = oam::UnassignedIpAddr; - - DeviceNetworkList::iterator listPT = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.begin(); - - for( ; listPT != sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.end() ; listPT++) - { - if (newModuleName == (*listPT).DeviceName) - { - if ( nicID == 1 ) - { - moduleDisableState = (*listPT).DisableState; - - if ( moduleDisableState.empty() || - moduleDisableState == oam::UnassignedName || - moduleDisableState == oam::AUTODISABLEDSTATE ) - moduleDisableState = oam::ENABLEDSTATE; - { - HostConfigList::iterator pt1 = (*listPT).hostConfigList.begin(); - - for( ; pt1 != (*listPT).hostConfigList.end() ; pt1++) - { - if ((*pt1).NicID == nicID) - { - moduleHostName = (*pt1).HostName; - moduleIPAddr = (*pt1).IPAddr; - break; - } - } - } - } - } - } - } - - if ( nicID == 1 ) - { - if ( moduleDisableState != oam::ENABLEDSTATE ) - { - string disabled = "y"; - - while (true) - { - if ( enableModuleCount > 1 ) - { - prompt = "Module '" + newModuleName + "' is Disabled, do you want to leave it Disabled? [y,n] (y) > "; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) disabled = pcommand; - - callFree(pcommand); - } - - if ( disabled == "y" || disabled == "n" ) - { - cout << endl; - break; - } - else - cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; - - if ( noPrompting ) - exit(1); - - disabled = "y"; - } - else - { - string enable = "y"; - cout << "Module '" + newModuleName + "' is Disabled. It needs to be enabled to startup MariaDB ColumnStore." << endl; - prompt = "Do you want to Enable it or exit? [y,exit] (y) > "; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) enable = pcommand; - - callFree(pcommand); - } - - if ( enable == "y" ) - { - disabled = "n"; - break; - } - else - { - if ( enable == "exit" ) - { - cout << "Exiting postConfigure..." << endl; - exit (1); - } - else - cout << "Invalid Entry, please enter 'y' for yes or 'exit'" << endl; - - if ( noPrompting ) - exit(1); - - enable = "y"; - } - } - } - - if ( disabled == "n" ) - moduleDisableState = oam::ENABLEDSTATE; - else - enableModuleCount--; - } - - //set Module Disable State - string moduleDisableStateParm = "ModuleDisableState" + oam.itoa(moduleID) + "-" + oam.itoa(i + 1); - - try - { - sysConfig->setConfig(ModuleSection, moduleDisableStateParm, moduleDisableState); - } - catch (...) - { - cout << "ERROR: Problem setting ModuleDisableState in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //skip configuration if if DISABLED state - if ( moduleDisableState != oam::ENABLEDSTATE) - break; - } - - - bool moduleHostNameFound = true; - - if (moduleHostName.empty()) - { - moduleHostNameFound = true; - moduleHostName = oam::UnassignedName; - } - - if (moduleIPAddr.empty()) - moduleIPAddr = oam::UnassignedIpAddr; - - string newModuleIPAddr; - - while (true) - { - newModuleHostName = moduleHostName; - - if (amazonInstall) - { - if ( moduleHostName == oam::UnassignedName && - newModuleName == "pm1" && nicID == 1) - { - //get local instance name (pm1) - string localInstance = oam.getEC2LocalInstance(); - - if ( localInstance == "failed" || localInstance.empty() || localInstance == "") - { - moduleHostName = oam::UnassignedName; - prompt = "Enter EC2 Instance ID (" + moduleHostName + ") > "; - } - else - { - newModuleHostName = localInstance; - cout << "EC2 Instance ID for pm1: " + localInstance << endl; - prompt = ""; - } - } - else - { - if ( moduleHostName == oam::UnassignedName ) - { - //check if need to create instance or user enter ID - string create = "y"; - - if ( !amazon_quick_install ) - { - while(true) - { - 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" ) - { - ModuleIP moduleip; - moduleip.moduleName = newModuleName; - - string AmazonVPCNextPrivateIP = "autoassign"; - - try - { - oam.getSystemConfig("AmazonVPCNextPrivateIP", AmazonVPCNextPrivateIP); - } - catch (...) {} - - moduleip.IPaddress = AmazonVPCNextPrivateIP; - - newModuleHostName = launchInstance(moduleip); - - if ( newModuleHostName == oam::UnassignedName ) - { - cout << "launch Instance failed for " + newModuleName << endl; - exit (1); - } - - prompt = ""; - } - else - prompt = "Enter EC2 Instance ID (" + moduleHostName + ") > "; - } - else - prompt = "Enter EC2 Instance ID (" + moduleHostName + ") > "; - } - } - else - { - if ( moduleHostName == oam::UnassignedName && - newModuleName == "pm1" && nicID == 1) - { - char hostname[128]; - gethostname(hostname, sizeof hostname); - moduleHostName = hostname; - } - - prompt = "Enter Nic Interface #" + oam.itoa(nicID) + " Host Name (" + moduleHostName + ") > "; - } - - if ( prompt != "" ) - { - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) - newModuleHostName = pcommand; - else - newModuleHostName = moduleHostName; - - callFree(pcommand); - } - } - - if ( newModuleHostName == oam::UnassignedName && nicID == 1 ) - { - cout << "Invalid Entry, please re-enter" << endl; - - if ( noPrompting ) - exit(1); - } - else - { - if ( newModuleHostName != oam::UnassignedName ) - { - //check and see if hostname already used - bool matchFound = false; - ChildModuleList::iterator list1 = niclist.begin(); - - for (; list1 != niclist.end() ; list1++) - { - if ( newModuleHostName == (*list1).hostName ) - { - cout << "Invalid Entry, already assigned to '" + (*list1).moduleName + "', please re-enter" << endl; - matchFound = true; - - if ( noPrompting ) - exit(1); - - break; - } - } - - if ( matchFound ) - continue; - - //check Instance ID and get IP Address if running - if (amazonInstall) - { - string instanceType = oam.getEC2LocalInstanceType(newModuleHostName); - - if ( moduleType == "pm" ) - { - try - { - sysConfig->setConfig(InstallSection, "PMInstanceType", instanceType); - } - catch (...) - {} - } - else - { - try - { - sysConfig->setConfig(InstallSection, "UMInstanceType", instanceType); - } - catch (...) - {} - } - - cout << "Getting Private IP Address for Instance " << newModuleHostName << ", please wait..." << endl; - newModuleIPAddr = oam.getEC2InstanceIpAddress(newModuleHostName); - - if (newModuleIPAddr == "stopped") - { - cout << "ERROR: Instance " + newModuleHostName + " not running, please start and hit 'enter'" << endl << endl; - - if ( noPrompting ) - exit(1); - - continue; - } - else - { - if (newModuleIPAddr == "terminated") - { - cout << "ERROR: Instance " + newModuleHostName + " doesn't have an Private IP Address, retrying" << endl << endl; - - if ( noPrompting ) - exit(1); - - continue; - } - else - { - cout << "Private IP Address of " + newModuleHostName + " is " + newModuleIPAddr << endl << endl; - - moduleIPAddr = newModuleIPAddr; - break; - } - } - } - - break; - } - - break; - } - } - - //set New Module Host Name - string moduleHostNameParm = "ModuleHostName" + oam.itoa(moduleID) + "-" + oam.itoa(nicID) + "-" + oam.itoa(i + 1); - - try - { - sysConfig->setConfig(ModuleSection, moduleHostNameParm, newModuleHostName); - } - catch (...) - { - cout << "ERROR: Problem setting Host Name in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - if ( newModuleHostName == oam::UnassignedName ) - newModuleIPAddr = oam::UnassignedIpAddr; - else - { - if (!amazonInstall) - { - if ( moduleIPAddr == oam::UnassignedIpAddr ) - { - //get IP Address - string IPAddress; - if (doNotResolveHostNames) - if (resolveHostNamesToReverseDNSNames) { - IPAddress = resolveHostNameToReverseDNSName(newModuleHostName); - } - else { - IPAddress = newModuleHostName; - } - else - IPAddress = oam.getIPAddress( newModuleHostName); - - if ( !IPAddress.empty() ) - newModuleIPAddr = IPAddress; - else - newModuleIPAddr = oam::UnassignedIpAddr; - } - else - newModuleIPAddr = moduleIPAddr; - - if ( newModuleIPAddr == "127.0.0.1") - newModuleIPAddr = "unassigned"; - - //prompt for IP address - while (true) - { - prompt = "Enter Nic Interface #" + oam.itoa(nicID) + " IP Address or hostname of " + newModuleHostName + " (" + newModuleIPAddr + ") > "; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) newModuleIPAddr = pcommand; - - callFree(pcommand); - } - - if (!doNotResolveHostNames) - { - string ugh = oam.getIPAddress(newModuleIPAddr); - if (ugh.length() > 0) - newModuleIPAddr = ugh; - } - - if (newModuleIPAddr == "127.0.0.1" || newModuleIPAddr == "0.0.0.0" || newModuleIPAddr == "128.0.0.1") - { - cout << endl << newModuleIPAddr + " is an Invalid IP Address for a multi-server system, please re-enter" << endl << endl; - newModuleIPAddr = "unassigned"; - - if ( noPrompting ) - exit(1); - - continue; - } - - if (oam.isValidIP(newModuleIPAddr) || doNotResolveHostNames) - { - //check and see if hostname already used - bool matchFound = false; - ChildModuleList::iterator list1 = niclist.begin(); - - for (; list1 != niclist.end() ; list1++) - { - if ( newModuleIPAddr == (*list1).moduleIP ) - { - cout << "Invalid Entry, IP Address already assigned to '" + (*list1).moduleName + "', please re-enter" << endl; - matchFound = true; - - if ( noPrompting ) - exit(1); - - break; - } - } - - if ( matchFound ) - continue; - - // run ping test to validate - string cmdLine = "ping "; - string cmdOption = " -c 1 -w 5 >> /dev/null"; - string cmd = cmdLine + newModuleIPAddr + cmdOption; - int rtnCode = system(cmd.c_str()); - - if ( WEXITSTATUS(rtnCode) != 0 ) - { - //NIC failed to respond to ping - string temp = "2"; - - while (true) - { - cout << endl; - prompt = "IP Address of '" + newModuleIPAddr + "' failed ping test, please validate. Do you want to continue or re-enter [1=continue, 2=re-enter] (2) > "; - - if ( noPrompting ) - exit(1); - - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) temp = pcommand; - - callFree(pcommand); - } - - if ( temp == "1" || temp == "2") - break; - else - { - temp = "2"; - cout << endl << "Invalid entry, please re-enter" << endl; - - if ( noPrompting ) - exit(1); - } - } - - cout << endl; - - if ( temp == "1") - break; - } - else // good ping - break; - } - else - { - cout << endl << "Invalid IP Address format, xxx.xxx.xxx.xxx, please re-enter" << endl << endl; - - if ( noPrompting ) - exit(1); - } - } - } - } - - //set Module IP address - string moduleIPAddrNameParm = "ModuleIPAddr" + oam.itoa(moduleID) + "-" + oam.itoa(nicID) + "-" + oam.itoa(i + 1); - - try - { - sysConfig->setConfig(ModuleSection, moduleIPAddrNameParm, newModuleIPAddr); - } - catch (...) - { - cout << "ERROR: Problem setting IP address in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - if ( newModuleHostName == oam::UnassignedName && moduleHostNameFound ) - // exit out to next module ID - break; - - if (moduleType == "pm" && moduleDisableState == oam::ENABLEDSTATE) - { - - switch (nicID) - { - case 1: - performancemodule.moduleIP1 = newModuleIPAddr; - break; - - case 2: - performancemodule.moduleIP2 = newModuleIPAddr; - break; - - case 3: - performancemodule.moduleIP3 = newModuleIPAddr; - break; - - case 4: - performancemodule.moduleIP4 = newModuleIPAddr; - break; - } - - if ( maxPMNicCount < nicID ) - maxPMNicCount = nicID; - } - - //save Nic host name and IP - childmodule.moduleName = newModuleName; - childmodule.moduleIP = newModuleIPAddr; - childmodule.hostName = newModuleHostName; - niclist.push_back(childmodule); - - if ( nicID > 1 ) - continue; - - //save Child modules - if ( newModuleName != parentOAMModuleName) - { - childmodule.moduleName = newModuleName; - childmodule.moduleIP = newModuleIPAddr; - childmodule.hostName = newModuleHostName; - childmodulelist.push_back(childmodule); - } - - //set port addresses - if ( newModuleName == parentOAMModuleName ) - { - parentOAMModuleHostName = newModuleHostName; - parentOAMModuleIPAddr = newModuleIPAddr; - - //set Parent Processes Port IP Address - string parentProcessMonitor = parentOAMModuleName + "_ProcessMonitor"; - sysConfig->setConfig(parentProcessMonitor, "IPAddr", parentOAMModuleIPAddr); - sysConfig->setConfig(parentProcessMonitor, "Port", "8800"); - sysConfig->setConfig("ProcMgr", "IPAddr", parentOAMModuleIPAddr); - sysConfig->setConfig("ProcHeartbeatControl", "IPAddr", parentOAMModuleIPAddr); - sysConfig->setConfig("ProcMgr_Alarm", "IPAddr", parentOAMModuleIPAddr); - sysConfig->setConfig("ProcStatusControl", "IPAddr", parentOAMModuleIPAddr); - string parentServerMonitor = parentOAMModuleName + "_ServerMonitor"; - sysConfig->setConfig(parentServerMonitor, "IPAddr", parentOAMModuleIPAddr); - string portName = parentOAMModuleName + "_WriteEngineServer"; - sysConfig->setConfig(portName, "IPAddr", parentOAMModuleIPAddr); - sysConfig->setConfig(portName, "Port", "8630"); - - if ( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) - { - - //set User Module's IP Addresses - string Section = "ExeMgr" + oam.itoa(moduleID); - - sysConfig->setConfig(Section, "IPAddr", newModuleIPAddr); - sysConfig->setConfig(Section, "Port", "8601"); - sysConfig->setConfig(Section, "Module", parentOAMModuleName); - - //set Performance Module's IP's to first NIC IP entered - sysConfig->setConfig("DDLProc", "IPAddr", newModuleIPAddr); - sysConfig->setConfig("DMLProc", "IPAddr", newModuleIPAddr); - } - - //set User Module's IP Addresses - if ( pmwithum ) - { - string Section = "ExeMgr" + oam.itoa(moduleID + umNumber); - - sysConfig->setConfig(Section, "IPAddr", newModuleIPAddr); - sysConfig->setConfig(Section, "Port", "8601"); - sysConfig->setConfig(Section, "Module", parentOAMModuleName); - - } - - //setup rc.local file in module tmp dir - if ( !makeRClocal(moduleType, newModuleName, IserverTypeInstall) ) - cout << "makeRClocal error" << endl; - } - else - { - //set child Process Monitor Port IP Address - string portName = newModuleName + "_ProcessMonitor"; - sysConfig->setConfig(portName, "IPAddr", newModuleIPAddr); - - sysConfig->setConfig(portName, "Port", "8800"); - - //set child Server Monitor Port IP Address - portName = newModuleName + "_ServerMonitor"; - sysConfig->setConfig(portName, "IPAddr", newModuleIPAddr); - sysConfig->setConfig(portName, "Port", "8622"); - - //set Performance Module WriteEngineServer Port IP Address - if ( moduleType == "pm" ) - { - portName = newModuleName + "_WriteEngineServer"; - sysConfig->setConfig(portName, "IPAddr", newModuleIPAddr); - sysConfig->setConfig(portName, "Port", "8630"); - } - - //set User Module's IP Addresses - if ( moduleType == "um" || - ( moduleType == "pm" && IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) || - ( moduleType == "um" && IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM ) || - ( moduleType == "pm" && IserverTypeInstall == oam::INSTALL_COMBINE_PM_UM ) || - ( moduleType == "pm" && pmwithum ) ) - { - - string Section = "ExeMgr" + oam.itoa(moduleID); - - if ( moduleType == "pm" && pmwithum ) - Section = "ExeMgr" + oam.itoa(moduleID + umNumber); - - sysConfig->setConfig(Section, "IPAddr", newModuleIPAddr); - sysConfig->setConfig(Section, "Port", "8601"); - sysConfig->setConfig(Section, "Module", newModuleName); - } - - //set Performance Module's IP's to first NIC IP entered - if ( newModuleName == "um1" ) - { - sysConfig->setConfig("DDLProc", "IPAddr", newModuleIPAddr); - sysConfig->setConfig("DMLProc", "IPAddr", newModuleIPAddr); - } - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //create associated local/etc directory for module - string cmd = "mkdir /var/lib/columnstore/local/etc/" + newModuleName + " > /dev/null 2>&1"; - system(cmd.c_str()); - - if ( newModuleName != parentOAMModuleName) - { - //make module file in local/module - if ( !makeModuleFile(newModuleName, parentOAMModuleName) ) - cout << "makeModuleFile error" << endl; - } - - //setup rc.local file in module tmp dir - if ( !makeRClocal(moduleType, newModuleName, IserverTypeInstall) ) - cout << "makeRClocal error" << endl; - - //if cloud, copy fstab in module tmp dir - if ( amazonInstall && moduleType == "pm") - if ( !copyFstab(newModuleName) ) - cout << "copyFstab error" << endl; - - //setup DBRM Processes - if ( newModuleName == parentOAMModuleName ) - sysConfig->setConfig("DBRM_Controller", "IPAddr", newModuleIPAddr); - - if ( moduleDisableState == oam::ENABLEDSTATE ) - { - DBRMworkernodeID++; - string DBRMSection = "DBRM_Worker" + oam.itoa(DBRMworkernodeID); - sysConfig->setConfig(DBRMSection, "IPAddr", newModuleIPAddr); - sysConfig->setConfig(DBRMSection, "Module", newModuleName); - } - - // only support 1 nic ID per Amazon instance - if (amazonInstall) - break; - - } //end of nicID loop - - //enter storage for user module - if ( moduleType == "um" && moduleDisableState == oam::ENABLEDSTATE) - { - //get EC2 volume name and info - if ( UMStorageType == "external" && amazonInstall && - IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM ) - { - - string volumeNameID = "UMVolumeName" + oam.itoa(moduleID); - string volumeName = oam::UnassignedName; - string deviceNameID = "UMVolumeDeviceName" + oam.itoa(moduleID); - string deviceName = oam::UnassignedName; - - // prompt for volume ID - try - { - volumeName = sysConfig->getConfig(InstallSection, volumeNameID); - deviceName = sysConfig->getConfig(InstallSection, deviceNameID); - } - catch (...) - { - string volumeName = oam::UnassignedName; - } - - string create = "n"; - - if ( volumeName == oam::UnassignedName || volumeName.empty() || volumeName == "" ) - { - create = "y"; - - while (true) - { - pcommand = callReadline("Create an EBS volume for " + newModuleName + " ? [y,n] (y) > "); - { - 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 == "n" ) - { - prompt = "Enter Volume ID assigned to module '" + newModuleName + "' (" + volumeName + ") > "; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) volumeName = pcommand; - - callFree(pcommand); - } - - //get amazon device name for UM - deviceName = "/dev/xvdf"; - } - else - { - //create new UM volume - try - { - oam.addUMdisk(moduleID, volumeName, deviceName, UMVolumeSize); - } - catch (...) - { - cout << "ERROR: volume create failed for " + newModuleName << endl; - return false; - } - } - - //write volume and device name - try - { - sysConfig->setConfig(InstallSection, volumeNameID, volumeName); - sysConfig->setConfig(InstallSection, deviceNameID, deviceName); - } - catch (...) - { - cout << "ERROR: Problem setting Volume/Device Names in the MariaDB ColumnStore System Configuration file" << endl; - return false; - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - } - } - - //if upgrade, get list of configure dbroots - DBRootConfigList dbrootConfigList; - - if ( reuseConfig == "y" ) - { - try - { - oam.getSystemDbrootConfig(dbrootConfigList); - } - catch (...) {} - } - - //enter dbroots for performance module - if ( moduleType == "pm" && moduleDisableState == oam::ENABLEDSTATE) - { - //get number of dbroots - string moduledbrootcount = "ModuleDBRootCount" + oam.itoa(moduleID) + "-" + oam.itoa(i + 1); - string tempCount; - - try - { - tempCount = sysConfig->getConfig(ModuleSection, moduledbrootcount); - } - catch (...) - { - cout << "ERROR: Problem setting DBRoot count in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - unsigned int count = 0; - - if (tempCount != oam::UnassignedName ) - count = atoi(tempCount.c_str()); - - string dbrootList; - - if (multi_server_quick_install || amazon_quick_install) - { - dbrootList = oam.itoa(moduleID); - } - else - { - for ( unsigned int id = 1 ; id < count+1 ; ) - { - string moduledbrootid = "ModuleDBRootID" + oam.itoa(moduleID) + "-" + oam.itoa(id) + "-" + oam.itoa(i+1); - try { - string dbrootid = sysConfig->getConfig(ModuleSection, moduledbrootid); - - if ( dbrootid != oam::UnassignedName) - { - sysConfig->setConfig(ModuleSection, moduledbrootid, oam::UnassignedName); - - dbrootList = dbrootList + dbrootid; - id ++; - - if ( id < count+1 ) - dbrootList = dbrootList + ","; - } - } - catch(...) - { - cout << "ERROR: Problem setting DBRoot ID in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - } - } - - vector dbroots; - string tempdbrootList; - - while (true) - { - dbroots.clear(); - bool matchFound = false; - - prompt = "Enter the list (Nx,Ny,Nz) or range (Nx-Nz) of DBRoot IDs assigned to module '" + newModuleName + "' (" + dbrootList + ") > "; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) - { - tempdbrootList = pcommand; - callFree(pcommand); - } - else - tempdbrootList = dbrootList; - } - - if ( tempdbrootList.empty()) - { - if ( noPrompting ) - exit(1); - - continue; - } - - //check for range - int firstID; - int lastID; - string::size_type pos = tempdbrootList.find("-", 0); - - if (pos != string::npos) - { - firstID = atoi(tempdbrootList.substr(0, pos).c_str()); - lastID = atoi(tempdbrootList.substr(pos + 1, 200).c_str()); - - if ( firstID >= lastID ) - { - cout << "Invalid Entry, please re-enter" << endl; - - if ( noPrompting ) - exit(1); - - continue; - } - else - { - for ( int id = firstID ; id < lastID + 1 ; id++ ) - { - dbroots.push_back(oam.itoa(id)); - } - } - } - else - { - boost::char_separator sep(","); - boost::tokenizer< boost::char_separator > tokens(tempdbrootList, sep); - - for ( boost::tokenizer< boost::char_separator >::iterator it = tokens.begin(); - it != tokens.end(); - ++it) - { - dbroots.push_back(*it); - } - } - - //if pm1, make sure DBRoot #1 is in the list - if ( newModuleName == "pm1" ) - { - bool found = false; - std::vector::iterator list = dbroots.begin(); - - for (; list != dbroots.end() ; list++) - { - if ( *list == "1" ) - { - found = true; - break; - } - } - - if ( !found ) - { - cout << endl << "Invalid Entry, Module pm1 has to have DBRoot #1 assigned to it, please re-enter" << endl; - - if ( noPrompting ) - exit(1); - - continue; - } - } - - //check and see if DBRoot ID already used - std::vector::iterator list = dbroots.begin(); - - for (; list != dbroots.end() ; list++) - { - bool inUse = false; - matchFound = false; - DBRootList::iterator list1 = dbrootlist.begin(); - - for (; list1 != dbrootlist.end() ; list1++) - { - if ( *list == (*list1).dbrootID ) - { - cout << "Invalid Entry, DBRoot ID " + *list + " already assigned to '" + (*list1).moduleName + "', please re-enter" << endl; - - if ( noPrompting ) - exit(1); - - inUse = true; - break; - } - } - - if ( inUse) - break; - else - { - // if upgrade, dont allow a new DBRoot id to be entered - if ( reuseConfig == "y" ) - { - DBRootConfigList::iterator pt = dbrootConfigList.begin(); - - for ( ; pt != dbrootConfigList.end() ; pt++) - { - if ( *list == oam.itoa(*pt) ) - { - matchFound = true; - break; - } - } - - if ( !matchFound) - { - //get any unassigned DBRoots - DBRootConfigList undbrootlist; - - try - { - oam.getUnassignedDbroot(undbrootlist); - } - catch (...) {} - - if ( !undbrootlist.empty() ) - { - DBRootConfigList::iterator pt1 = undbrootlist.begin(); - - for ( ; pt1 != undbrootlist.end() ; pt1++) - { - if ( *list == oam.itoa(*pt1) ) - { - matchFound = true; - break; - } - } - } - - if ( !matchFound) - { - cout << "Invalid Entry, DBRoot ID " + *list + " doesn't exist, can't add a new DBRoot during upgrade process, please re-enter" << endl; - - if ( noPrompting ) - exit(1); - - break; - } - } - } - else // new install, set to found - matchFound = true; - } - } - - if ( matchFound ) - break; - } - - int id = 1; - std::vector::iterator it = dbroots.begin(); - - for (; it != dbroots.end() ; it++, ++id) - { - //save Nic host name and IP - dbrootmodule.moduleName = newModuleName; - dbrootmodule.dbrootID = *it; - dbrootlist.push_back(dbrootmodule); - - //store DBRoot ID - string moduledbrootid = "ModuleDBRootID" + oam.itoa(moduleID) + "-" + oam.itoa(id) + "-" + oam.itoa(i + 1); - - try - { - sysConfig->setConfig(ModuleSection, moduledbrootid, *it); - } - catch (...) - { - cout << "ERROR: Problem setting DBRoot ID in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - string DBrootID = "DBRoot" + *it; - string pathID = "/var/lib/columnstore/data" + *it; - - try - { - sysConfig->setConfig(SystemSection, DBrootID, pathID); - } - catch (...) - { - cout << "ERROR: Problem setting DBRoot in the MariaDB ColumnStore System Configuration file" << endl; - return false; - } - - //create data directory - cmd = "mkdir " + pathID + " > /dev/null 2>&1"; - system(cmd.c_str()); - cmd = "chmod 755 " + pathID + " > /dev/null 2>&1"; - system(cmd.c_str()); - - //get EC2 volume name and info - if ( DBRootStorageType == "external" && amazonInstall) - { - cout << endl << "*** Setup External EBS Volume for DBRoot #" << *it << " ***" << endl << endl; - - string volumeNameID = "PMVolumeName" + *it; - string volumeName = oam::UnassignedName; - string deviceNameID = "PMVolumeDeviceName" + *it; - string deviceName = oam::UnassignedName; - string amazonDeviceNameID = "PMVolumeAmazonDeviceName" + *it; - string amazondeviceName = oam::UnassignedName; - - try - { - volumeName = sysConfig->getConfig(InstallSection, volumeNameID); - deviceName = sysConfig->getConfig(InstallSection, deviceNameID); - amazondeviceName = sysConfig->getConfig(InstallSection, amazonDeviceNameID); - } - catch (...) - {} - - if ( reuseConfig == "n" && ( volumeName == oam::UnassignedName || volumeName.empty() || volumeName == "" ) ) - { - string create = "y"; - - cout << "*** NOTE: You have the option to provide an" << endl; - cout << " existing EBS Volume ID or have a Volume created" << endl << endl; - - while (true) - { - pcommand = callReadline("Create a new EBS volume for DBRoot #" + *it + " ? [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 == "n" ) - { - prompt = "Enter Volume ID for '" + DBrootID + "' (" + volumeName + ") > "; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) volumeName = pcommand; - - callFree(pcommand); - } - - //get device name based on DBRoot ID - oam::storageID_t st; - - try - { - st = oam.getAWSdeviceName( atoi((*it).c_str()) ); - } - catch (...) {} - - deviceName = boost::get<0>(st); - amazondeviceName = boost::get<1>(st); - - // update fstabs - string entry = oam.updateFstab( amazondeviceName, *it); - } - else - { - // create amazon ebs DBRoot - try - { - DBRootConfigList dbrootlist; - dbrootlist.push_back(atoi((*it).c_str())); - - oam.addDbroot(1, dbrootlist, PMVolumeSize); - - sleep(2); - - try - { - volumeName = sysConfig->getConfig(InstallSection, volumeNameID); - deviceName = sysConfig->getConfig(InstallSection, deviceNameID); - amazondeviceName = sysConfig->getConfig(InstallSection, amazonDeviceNameID); - } - catch (...) - {} - } - catch (exception& e) - { - cout << endl << "**** addDbroot Failed: " << e.what() << endl; - exit(1); - } - } - } - else - { - prompt = "Enter Volume ID for '" + DBrootID + "' (" + volumeName + ") > "; - pcommand = callReadline(prompt.c_str()); - - if (pcommand) - { - if (strlen(pcommand) > 0) volumeName = pcommand; - - callFree(pcommand); - } - - // update fstabs - string entry = oam.updateFstab( amazondeviceName, *it); - - } - - //write volume and device name - try - { - sysConfig->setConfig(InstallSection, volumeNameID, volumeName); - sysConfig->setConfig(InstallSection, deviceNameID, deviceName); - sysConfig->setConfig(InstallSection, amazonDeviceNameID, amazondeviceName); - } - catch (...) - { - cout << "ERROR: Problem setting Volume/Device Names in the MariaDB ColumnStore System Configuration file" << endl; - return false; - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - // check volume for attach and try to attach if not - if ( !attachVolume(newModuleHostName, volumeName, deviceName, pathID) ) - { - cout << "attachVolume error" << endl; - exit(1); - } - } - } - - //store number of dbroots - moduledbrootcount = "ModuleDBRootCount" + oam.itoa(moduleID) + "-" + oam.itoa(i + 1); - - try - { - sysConfig->setConfig(ModuleSection, moduledbrootcount, oam.itoa(dbroots.size())); - } - catch (...) - { - cout << "ERROR: Problem setting DBRoot count in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //total dbroots on the system - DBRootCount = DBRootCount + dbroots.size(); - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - if (moduleType == "pm" && moduleDisableState == oam::ENABLEDSTATE ) - performancemodulelist.push_back(performancemodule); - } //end of k (moduleCount) loop - - if ( moduleSkip ) - { - moduleSkip = false; - moduleID = saveModuleID; - } - else - break; - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - } //end of i for loop - - try - { - sysConfig->setConfig(SystemSection, "DBRootCount", oam.itoa(DBRootCount)); - } - catch (...) - { - cout << "ERROR: Problem setting DBRoot Count in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //check 'files per parition' with number of dbroots - //checkFilesPerPartion(DBRootCount, sysConfig); - - //setup DBRM Controller - sysConfig->setConfig("DBRM_Controller", "NumWorkers", oam.itoa(DBRMworkernodeID)); - - //set ConnectionsPerPrimProc - try - { - sysConfig->setConfig("PrimitiveServers", "ConnectionsPerPrimProc", oam.itoa(maxPMNicCount * 2)); - } - catch (...) - { - cout << "ERROR: Problem setting ConnectionsPerPrimProc in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //set the PM Ports based on Number of PM modules equipped, if any equipped - int minPmPorts = 32; - sysConfig->setConfig("PrimitiveServers", "Count", oam.itoa(pmNumber)); - - int pmPorts = pmNumber * (maxPMNicCount * 2); - - if ( pmPorts < minPmPorts ) - pmPorts = minPmPorts; - - if ( pmNumber > 0 ) - { - const string PM = "PMS"; - - for ( int pmsID = 1; pmsID < pmPorts + 1 ; ) - { - for (int j = 1 ; j < maxPMNicCount + 1 ; j++) - { - PerformanceModuleList::iterator list1 = performancemodulelist.begin(); - - for (; list1 != performancemodulelist.end() ; list1++) - { - string pmName = PM + oam.itoa(pmsID); - string IpAddr; - - switch (j) - { - case 1: - IpAddr = (*list1).moduleIP1; - break; - - case 2: - IpAddr = (*list1).moduleIP2; - break; - - case 3: - IpAddr = (*list1).moduleIP3; - break; - - case 4: - IpAddr = (*list1).moduleIP4; - break; - } - - if ( !IpAddr.empty() && IpAddr != oam::UnassignedIpAddr ) - { - sysConfig->setConfig(pmName, "IPAddr", IpAddr); - sysConfig->setConfig(pmName, "Port", "8620"); - pmsID++; - - if ( pmsID > pmPorts ) - break; - } - } - - if ( pmsID > pmPorts ) - break; - } - } - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //setup local OS Files - if ( !setOSFiles(parentOAMModuleName, IserverTypeInstall) ) - { - cout << "setOSFiles error" << endl; - exit(1); - } - - //create directories on dbroot1 - if ( !createDbrootDirs(DBRootStorageType, amazonInstall) ) - { - cout << "createDbrootDirs error" << endl; - exit(1); - } - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //check if dbrm data resides in older directory path and inform user if it does - dbrmDirCheck(); - - if ( ( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) || - ( (IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM) && pmwithum ) ) - { - //run the mysql / mysqld setup scripts - cout << endl << "===== Running the MariaDB ColumnStore MariaDB Server setup scripts =====" << endl; - - checkMysqlPort(mysqlPort, sysConfig); - - // call the mysql setup scripts - mysqlSetup(); - sleep(3); - } - - if ( IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM || - pmNumber > 1 ) - { - if ( password.empty() ) - { - cout << endl; - cout << "Next step is to enter the password to access the other Servers." << endl; - cout << "This is either user password or you can default to using an ssh key" << endl; - cout << "If using a user password, the password needs to be the same on all Servers." << endl << endl; - - if ( noPrompting ) { - cout << "Enter password, hit 'enter' to default to using an ssh key, or 'exit' > " << endl; - password = "ssh"; - } - else - { - while(true) - { - char *pass1, *pass2; - - pass1=getpass("Enter password, hit 'enter' to default to using an ssh key, or 'exit' > "); - if ( strcmp(pass1, "") == 0 ) { - password = "ssh"; - break; - } - - string p1 = pass1; - if ( p1 == "exit") - exit(0); - - pass2=getpass("Confirm password > "); - string p2 = pass2; - if ( p1 == p2 ) { - password = p2; - break; - } - else - cout << "Password mismatch, please re-enter" << endl; - } - - //add single quote for special characters - if ( password != "ssh" ) - { - password = "'" + password + "'"; - } - - } - } - } - - string install = "y"; - - if ( IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM || - pmNumber > 1 ) - { - - ChildModuleList::iterator list1 = childmodulelist.begin(); - - for (; list1 != childmodulelist.end() ; list1++) - { - string remoteModuleName = (*list1).moduleName; - string remoteModuleIP = (*list1).moduleIP; - string remoteHostName = (*list1).hostName; - string remoteModuleType = remoteModuleName.substr(0, MAX_MODULE_TYPE_SIZE); - - string debug_logfile; - string logfile; - - if ( remote_installer_debug == "1" ) - { - logfile = tmpDir + "/"; - logfile += remoteModuleName + "_" + EEPackageType + "_install.log"; - debug_logfile = " > " + logfile; - } - - cout << endl << "----- Performing Install on '" + remoteModuleName + " / " + remoteHostName + "' -----" << endl << endl; - if ( remote_installer_debug == "1" ) - cout << "Install log file is located here: " + logfile << endl << endl; - - cmd = "mcs_module_installer.sh " + remoteModuleName + " " + remoteModuleIP + " " + password + " " + remote_installer_debug + " " + debug_logfile; - - int rtnCode = system(cmd.c_str()); - if (WEXITSTATUS(rtnCode) != 0) - { - cout << endl << "Error returned from mcs_module_installer.sh" << endl; - exit(1); - } - } - - //configure data redundancy - if (DataRedundancy) - { - cout << endl; - - //Ask for ssh password or certificate if not already set - bool passwordSetBefore = false; - - if ( password.empty() ) - { - cout << endl; - cout << "Next step is to enter the password to access the other Servers." << endl; - cout << "This is either your password or you can default to using an ssh key" << endl; - cout << "If using a password, the password needs to be the same on all Servers." << endl << endl; - } - - while (true) - { - char* pass1, *pass2; - - if ( noPrompting ) - { - cout << "Enter password, hit 'enter' to default to using an ssh key, or 'exit' > " << endl; - - if ( password.empty() ) - password = "ssh"; - - break; - } - - //check for command line option password - if ( !password.empty() ) - { - passwordSetBefore = true; - break; - } - - pass1 = getpass("Enter password, hit 'enter' to default to using an ssh key, or 'exit' > "); - - if ( strcmp(pass1, "") == 0 ) - { - password = "ssh"; - break; - } - - if ( strncmp(pass1, "exit", 4) ) - { - exit(0); - } - - string p1 = pass1; - pass2 = getpass("Confirm password > "); - string p2 = pass2; - - if ( p1 == p2 ) - { - password = p2; - break; - } - else - cout << "Password mismatch, please re-enter" << endl; - } - - //add single quote for special characters - if ( password != "ssh" && !passwordSetBefore) - { - password = "'" + password + "'"; - } - - - if ( reuseConfig != "y" ) - { - cout << endl << "===== Configuring MariaDB ColumnStore Data Redundancy Functionality =====" << endl << endl; - - if (!glusterSetup(password, doNotResolveHostNames)) - { - cout << "ERROR: Problem setting up ColumnStore Data Redundancy" << endl; - exit(1); - } - - } - } - } - - - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } - - //check if local MariaDB ColumnStore system logging is working - cout << endl << "===== Checking MariaDB ColumnStore System Logging Functionality =====" << endl << endl; - - cmd = "columnstoreSyslogSetup.sh status > /dev/null 2>&1"; - - int ret = system(cmd.c_str()); - - if ( WEXITSTATUS(ret) != 0) - cerr << "WARNING: The MariaDB ColumnStore system logging not correctly setup and working" << endl; - else - cout << "The MariaDB ColumnStore system logging is setup and working on local server" << endl; - - cout << endl << "MariaDB ColumnStore System Configuration and Installation is Completed" << endl; - - // - // startup MariaDB ColumnStore - // - - if (getenv("SKIP_OAM_INIT")) - { - cout << "(1) SKIP_OAM_INIT is set, so will not start ColumnStore or init the system catalog" << endl; - sysConfig->setConfig("Installation", "MySQLRep", "n"); - sysConfig->write(); - exit(0); - } - - if ( IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM || - pmNumber > 1 ) - { - // - // perform MariaDB ColumnStore system startup - // - cout << endl << "===== MariaDB ColumnStore System Startup =====" << endl << endl; - - cout << "System Configuration is complete." << endl; - cout << "Performing System Installation." << endl; - - { - //start MariaDB ColumnStore on local server - cout << endl << "----- Starting MariaDB ColumnStore on local server -----" << endl << endl; - cmd = "columnstore restart > /dev/null 2>&1"; - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - { - cout << "Error Starting MariaDB ColumnStore local module" << endl; - cout << "Installation Failed, exiting" << endl; - exit (1); - } - else - cout << "MariaDB ColumnStore successfully started" << endl; - } - } - else // Single Server start - { - cout << endl << "===== MariaDB ColumnStore System Startup =====" << endl << endl; - - cout << "System Configuration is complete." << endl; - cout << "Performing System Installation." << endl; - - //start MariaDB ColumnStore on local server - cout << endl << "----- Starting MariaDB ColumnStore on local Server '" + parentOAMModuleName + "' -----" << endl << endl; - string cmd = "columnstore restart > /dev/null 2>&1"; - int rtnCode = system(cmd.c_str()); - - if (WEXITSTATUS(rtnCode) != 0) - { - cout << "Error Starting MariaDB ColumnStore local module" << endl; - cout << "Installation Failed, exiting" << endl; - exit (1); - } - else - cout << endl << "MariaDB ColumnStore successfully started" << endl; - } - - cout << endl << "MariaDB ColumnStore Database Platform Starting, please wait ."; - cout.flush(); - - if ( waitForActive() ) - { - cout << " DONE" << endl; - - // IF gluster is enabled we need to modify fstab on remote systems. - if (DataRedundancy ) - { - int numberDBRootsPerPM = DBRootCount / pmNumber; - - for (int pm = 0; pm < pmNumber; pm++) - { - string pmIPaddr = "ModuleIPAddr" + oam.itoa(pm + 1) + "-1-3"; - string moduleIPAddr = sysConfig->getConfig("DataRedundancyConfig", pmIPaddr); - - if ( moduleIPAddr.empty() ) - { - moduleIPAddr = sysConfig->getConfig("SystemModuleConfig", pmIPaddr); - } - - for (int i = 0; i < numberDBRootsPerPM; i++) - { - string ModuleDBRootID = "ModuleDBRootID" + oam.itoa(pm + 1) + "-" + oam.itoa(i + 1) + "-3"; - string dbr = sysConfig->getConfig("SystemModuleConfig", ModuleDBRootID); - string command = "" + moduleIPAddr + - ":/dbroot" + dbr + " /var/lib/columnstore/data" + dbr + - " glusterfs defaults,direct-io-mode=enable 00"; - string toPM = "pm" + oam.itoa(pm + 1); - oam.distributeFstabUpdates(command, toPM); - } - } - } - - string dbbuilderLog = tmpDir + "/dbbuilder.log"; - - cmd = "dbbuilder 7 > " + dbbuilderLog; - - system(cmd.c_str()); - - if (oam.checkLogStatus(dbbuilderLog, "System Catalog created") ) - cout << endl << "System Catalog Successfully Created" << endl; - else - { - if ( oam.checkLogStatus(dbbuilderLog, "System catalog appears to exist") ) - { - cout.flush(); - } - else - { - cout << endl << "System Catalog Create Failure" << endl; - cout << "Check latest log file in " << dbbuilderLog << endl; - cout << " IMPORTANT: Once issue has been resolved, rerun postConfigure" << endl << endl; - - exit (1); - } - } - - //set mysql replication, if wasn't setup before on system - if ( mysqlRep ) - { - cout << endl << "Run MariaDB ColumnStore Replication Setup.. "; - cout.flush(); - - //send message to procmon's to run mysql replication script - int status = sendReplicationRequest(IserverTypeInstall, password, pmwithum); - - if ( status != 0 ) - { - cout << endl << " MariaDB ColumnStore Replication Setup Failed, check logs" << endl << endl; - cout << " IMPORTANT: Once issue has been resolved, rerun postConfigure" << endl << endl; - exit(1); - } - else - cout << " DONE" << endl; - } - - cout << endl << "MariaDB ColumnStore Install Successfully Completed, System is Active" << endl << endl; - - cout << "Enter the following command to define MariaDB ColumnStore Alias Commands" << endl << endl; - - cout << ". " << ProfileFile << endl << endl; - - cout << "Enter 'mariadb' to access the MariaDB ColumnStore SQL console" << endl; - cout << "Enter 'mcsadmin' to access the MariaDB ColumnStore Admin console" << endl << endl; - - cout << "NOTE: The MariaDB ColumnStore Alias Commands are in /etc/profile.d/columnstoreAlias.sh" << endl << endl; - } - else - { - cout << " FAILED" << endl << endl; - - cout << " IMPORTANT: There was a system startup failed, once issue has been resolved, rerun postConfigure" << endl << endl; - - cout << endl << "MariaDB ColumnStore System failed to start, check log files in /var/log/mariadb/columnstore" << endl; - - cout << "Enter the following command to define MariaDB ColumnStore Alias Commands" << endl << endl; - - cout << ". " << ProfileFile << endl << endl; - - cout << "Enter 'mariadb' to access the MariaDB ColumnStore SQL console" << endl; - cout << "Enter 'mcsadmin' to access the MariaDB ColumnStore Admin console" << endl << endl; - - cout << "NOTE: The MariaDB ColumnStore Alias Commands are in /etc/profile.d/columnstoreAlias" << endl << endl; - - exit(1); - } - - exit(0); } /*