From 9d0bb3174b372a106534e5d57e4a213d44bff2af Mon Sep 17 00:00:00 2001 From: david hill Date: Fri, 20 Oct 2017 16:40:00 -0500 Subject: [PATCH] mcol-943 --- VERSION | 4 +- oam/install_scripts/master-rep-columnstore.sh | 2 +- oam/install_scripts/module_installer.sh | 31 +++----- oam/install_scripts/rsync.sh | 27 ++++++- oamapps/mcsadmin/mcsadmin.cpp | 12 +++ oamapps/postConfigure/helpers.cpp | 23 ++++++ oamapps/postConfigure/helpers.h | 1 + oamapps/postConfigure/postConfigure.cpp | 79 ++++++++++++++++++- procmgr/processmanager.cpp | 2 +- 9 files changed, 155 insertions(+), 26 deletions(-) diff --git a/VERSION b/VERSION index dbe1148f8..0a349c477 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ COLUMNSTORE_VERSION_MAJOR=1 COLUMNSTORE_VERSION_MINOR=0 -COLUMNSTORE_VERSION_PATCH=11 -COLUMNSTORE_VERSION_RELEASE=2 +COLUMNSTORE_VERSION_PATCH=12 +COLUMNSTORE_VERSION_RELEASE=1 diff --git a/oam/install_scripts/master-rep-columnstore.sh b/oam/install_scripts/master-rep-columnstore.sh index 9f1e15194..8543f37ae 100644 --- a/oam/install_scripts/master-rep-columnstore.sh +++ b/oam/install_scripts/master-rep-columnstore.sh @@ -47,7 +47,7 @@ password="Calpont1" # echo "Create Replication User $repUser for node $hostipaddr" >>/tmp/master-rep-status-$hostipaddr.log cat >/tmp/idb_master-rep.sql <> ${bashFile} fi -# if um, run mysql install scripts -if [ $module = "um" ] || ( [ $module = "pm" ] && [ $PMwithUM = "y" ] ) || [ $ServerTypeInstall = "2" ]; then - echo "Run post-mysqld-install" - $COLUMNSTORE_INSTALL_DIR/bin/post-mysqld-install --installdir=$COLUMNSTORE_INSTALL_DIR > /tmp/post-mysqld-install.log 2>&1 - if [ $? -ne 0 ]; then - echo "ERROR: post-mysqld-install failed: check /tmp/post-mysqld-install.log" - exit 1 - fi - echo "Run post-mysql-install" - - password=`$COLUMNSTORE_INSTALL_DIR/bin/getMySQLpw` - if [ $password = "unassigned" ]; then - password="" - fi - - $COLUMNSTORE_INSTALL_DIR/bin/post-mysql-install --installdir=$COLUMNSTORE_INSTALL_DIR --password=$password > /tmp/post-mysql-install.log 2>&1 - if [ $? -ne 0 ]; then - echo "ERROR: post-mysql-install failed: check /tmp/post-mysql-install.log" - exit 1 +# if mysqlrep is on and module has a my.cnf file, upgrade it + +MySQLRep=`$COLUMNSTORE_INSTALL_DIR/bin/getConfig Installation MySQLRep` +if [ $MySQLRep = "y" ]; then + if test -f $COLUMNSTORE_INSTALL_DIR/mysql/my.cnf ; then + echo "Run Upgrade on my.cnf on Module" + $COLUMNSTORE_INSTALL_DIR/bin/mycnfUpgrade > /tmp/mycnfUpgrade.log 2>&1 fi fi +if test -f $COLUMNSTORE_INSTALL_DIR/mysql/my.cnf ; then + echo "Run Mysql Port update on my.cnf on Module" + $COLUMNSTORE_INSTALL_DIR/bin/mycnfUpgrade $mysqlPort > /tmp/mycnfUpgrade_port.log 2>&1 +fi + # if um, run mysql install scripts if [ $module = "um" ]; then echo "Run post-mysqld-install" diff --git a/oam/install_scripts/rsync.sh b/oam/install_scripts/rsync.sh index 49f93af69..7bbe29641 100755 --- a/oam/install_scripts/rsync.sh +++ b/oam/install_scripts/rsync.sh @@ -46,13 +46,36 @@ expect { -re "passphrase" { send "$PASSWORD\n" } -re "failed" { send_user " FAILED: Failure, check tmp log\n" ; exit 1 } -re "Permission denied" { send_user " FAILED: Invalid password\n" ; exit 1 } - -re "total size" { exit 0 } + -re "total size" {} abort } expect { -re "failed" { send_user " FAILED: Failure, check tmp log\n" ; exit 1 } -re "Permission denied" { send_user " FAILED: Invalid password\n" ; exit 1 } - -re "total size" { exit 0 } + -re "total size" {} abort } +set HOME "$env(HOME)" + +set COMMAND "rsync -vopgr -e ssh $HOME/.my.cnf $USERNAME@$SERVER:$HOME/" + +# +# run command +# +set timeout 20 +send "$COMMAND\n" +expect { + -re "word: " { send "$PASSWORD\n" } + -re "passphrase" { send "$PASSWORD\n" } + -re "total size" {} abort + -re "failed" { exit 0 } + timeout { exit 0 } +} +expect { + -re "total size" {} abort + -re "failed" { exit 0 } + timeout { exit 0 } +} + + exit 0 diff --git a/oamapps/mcsadmin/mcsadmin.cpp b/oamapps/mcsadmin/mcsadmin.cpp index 119632cd2..836990dc2 100644 --- a/oamapps/mcsadmin/mcsadmin.cpp +++ b/oamapps/mcsadmin/mcsadmin.cpp @@ -4918,6 +4918,12 @@ int processCommand(string* arguments) case 46: // enableReplication { + if ( SingleServerInstall == "y" ) { + // exit out since not on single-server install + cout << endl << "**** enableReplication Failed : not supported on a Single-Server type installs " << endl; + break; + } + string MySQLRep; try { oam.getSystemConfig("MySQLRep", MySQLRep); @@ -5888,6 +5894,12 @@ int processCommand(string* arguments) case 51: // disableReplication { + if ( SingleServerInstall == "y" ) { + // exit out since not on single-server install + cout << endl << "**** disableReplication Failed : not supported on a Single-Server type installs " << endl; + break; + } + string MySQLRep; try { oam.getSystemConfig("MySQLRep", MySQLRep); diff --git a/oamapps/postConfigure/helpers.cpp b/oamapps/postConfigure/helpers.cpp index 444a4d7db..8638bebba 100644 --- a/oamapps/postConfigure/helpers.cpp +++ b/oamapps/postConfigure/helpers.cpp @@ -874,6 +874,29 @@ bool writeConfig( Config* sysConfig ) return false; } +std::string getmysqlpw(std::string logFile) +{ + ifstream oldFile (logFile.c_str()); + if (oldFile) { + char line[200]; + string buf; + while (oldFile.getline(line, 200)) + { + buf = line; + string::size_type pos = buf.find("mysqlpw=",0); + if (pos != string::npos) + { + string mysqlpw = buf.substr(pos+8, 80); +// unlink(logFile); + return mysqlpw; + } + } + } + + return oam::UnassignedName; +} + + } diff --git a/oamapps/postConfigure/helpers.h b/oamapps/postConfigure/helpers.h index 652c86958..61de9bb4b 100644 --- a/oamapps/postConfigure/helpers.h +++ b/oamapps/postConfigure/helpers.h @@ -46,6 +46,7 @@ extern bool writeConfig(Config* sysConfig); extern void checkSystemMySQLPort(std::string& mysqlPort, Config* sysConfig, std::string USER, std::string password, ChildModuleList childmodulelist, int IserverTypeInstall, bool pmwithum); extern const char* callReadline(string prompt); extern void callFree(const char* ); +extern std::string getmysqlpw(std::string logFile); } diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index cbb3bb80d..18d339726 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -187,7 +187,7 @@ string installDir; string HOME = "/root"; extern string pwprompt; -string mysqlpw = oam::UnassignedName; +string mysqlpw = " "; extern const char* pcommand; extern string prompt; @@ -2883,6 +2883,83 @@ int main(int argc, char *argv[]) cout << endl << "Error returned from user_installer.sh" << endl; exit(1); } + + //check for mysql password on remote UM + if ( pwprompt == " " ) { + //start mysqld + cmd = installDir + "/bin/remote_command.sh " + remoteModuleIP + " " + password + " '" + installDir + "/mysql/mysql-Columnstore start'"; + int rtnCode = system(cmd.c_str()); + if (WEXITSTATUS(rtnCode) != 0) { + cout << endl << "Error returned from mysql-Columnstore start" << endl; + exit(1); + } + + //try to login + cmd = installDir + "/bin/remote_command.sh " + remoteModuleIP + " " + password + " '" + installDir + "/mysql/bin/mysql --defaults-file=" + installDir + "/mysql/my.cnf -u root " + pwprompt + " -e status' 1 > /tmp/idbmysql.log 2>&1"; + rtnCode = system(cmd.c_str()); + if (WEXITSTATUS(rtnCode) != 0) { + cout << endl << "Error returned from remote_command.sh" << endl; + exit(1); + } + + if (oam.checkLogStatus("/tmp/idbmysql.log", "ERROR .my.cnf") ) { + // password needed check and get password from remote UM + cmd = installDir + "/bin/remote_command.sh " + remoteModuleIP + " " + password + " '" + installDir + "bin/getMySQLpw > /tmp/mysqlpw.log 2>&1"; + rtnCode = system(cmd.c_str()); + if (WEXITSTATUS(rtnCode) != 0) { + cout << endl << "MariaDB ColumnStore login failure, MySQL Root password is set." << endl; + cout << "Need MariaDB ColumnStore password configuration file " + HOME + "/.my.cnf on " << remoteModuleName << endl; + exit(1); + } + + //get password from local tmp file + mysqlpw = getmysqlpw("/tmp/mysqlpw.log"); + + if ( mysqlpw != oam::UnassignedName ) + { + mysqlpw = "'" + mysqlpw + "'"; + pwprompt = "--password=" + mysqlpw; + } + + cmd = installDir + "/bin/remote_command.sh " + remoteModuleIP + " " + password + " '" + installDir + "/mysql/bin/mysql --defaults-file=" + installDir + "/mysql/my.cnf -u root " + pwprompt + " -e status' 1 > /tmp/idbmysql.log 2>&1"; + rtnCode = system(cmd.c_str()); + if (WEXITSTATUS(rtnCode) != 0) { + cout << endl << "MariaDB ColumnStore login failure, password mismatch in " + HOME + ".my.cnf on " << remoteModuleName << endl; + exit(1); + } + } + else + { + if (!oam.checkLogStatus("/tmp/idbmysql.log", "Columnstore") ) { + cout << endl << "ERROR: MariaDB ColumnStore runtime error, exit..." << endl << endl; + system("cat /tmp/idbmysql.log"); + exit (1); + } + else + { + cout << endl << "Additional MariaDB ColumnStore Installation steps Successfully Completed on '" + remoteModuleName + "'" << endl << endl; + + cmd = installDir + "/bin/remote_command.sh " + remoteModuleIP + " " + password + " '" + installDir + "/mysql/mysql-Columnstore stop'"; + int rtnCode = system(cmd.c_str()); + if (WEXITSTATUS(rtnCode) != 0) { + cout << endl << "Error returned from mysql-Columnstore stop" << endl; + exit(1); + } + unlink("/tmp/idbmysql.log"); + break; + } + } + + //re-run post-mysql-install with password + cmd = installDir + "/bin/remote_command.sh " + remoteModuleIP + " " + password + " '" + installDir + "/bin/post-mysql-install " + pwprompt + "' < /tmp/post-mysql-install.log"; + rtnCode = system(cmd.c_str()); + if (WEXITSTATUS(rtnCode) != 0) { + cout << endl << "Error returned from post-mysql-install, check /tmp/post-mysql-install.log" << endl; + exit(1); + } + else + cout << endl << "post-mysql-install Successfully Completed" << endl; + } } } else diff --git a/procmgr/processmanager.cpp b/procmgr/processmanager.cpp index 1f5bc5933..10a3c5916 100644 --- a/procmgr/processmanager.cpp +++ b/procmgr/processmanager.cpp @@ -2569,7 +2569,7 @@ void processMSG(messageqcpp::IOSocket* cfIos) // target = root password oam::DeviceNetworkList devicenetworklist; - status = processManager.setMySQLReplication(devicenetworklist, oam::UnassignedName, false, true, target, false); + status = processManager.setMySQLReplication(devicenetworklist, oam::UnassignedName, false, false, target, false); log.writeLog(__LINE__, "Disable MySQL Replication status: " + oam.itoa(status) );