diff --git a/oam/install_scripts/module_installer.sh b/oam/install_scripts/module_installer.sh index 3a690a229..8910cca7f 100755 --- a/oam/install_scripts/module_installer.sh +++ b/oam/install_scripts/module_installer.sh @@ -63,10 +63,18 @@ if [ $cloud = "amazon-ec2" ] || [ $cloud = "amazon-vpc" ]; then if [ $module = "pm" ]; then if test -f $COLUMNSTORE_INSTALL_DIR/local/etc/pm1/fstab ; then echo "Setup fstab on Module" - touch /etc/fstab - rm -f /etc/fstab.columnstoreSave - cp /etc/fstab /etc/fstab.columnstoreSave - cat $COLUMNSTORE_INSTALL_DIR/local/etc/pm1/fstab >> /etc/fstab + if [ $user = "root" ]; then + touch /etc/fstab + rm -f /etc/fstab.columnstoreSave + cp /etc/fstab /etc/fstab.columnstoreSave + cat $COLUMNSTORE_INSTALL_DIR/local/etc/pm1/fstab >> /etc/fstab + else + sudo touch /etc/fstab + sudo chmod 666 /etc/fstab + sudo rm -f /etc/fstab.columnstoreSave + sudo cp /etc/fstab /etc/fstab.columnstoreSave + sudo cat $COLUMNSTORE_INSTALL_DIR/local/etc/pm1/fstab >> /etc/fstab + fi fi fi fi @@ -85,8 +93,13 @@ if [ $module = "um" ]; then echo "Setup UM Volume Mount" device=`$COLUMNSTORE_INSTALL_DIR/bin/getConfig Installation UMVolumeDeviceName$mid` mkdir -p $COLUMNSTORE_INSTALL_DIR/mysql/db > /dev/null 2>&1 - mount $device $COLUMNSTORE_INSTALL_DIR/mysql/db -t ext2 -o noatime,nodiratime,noauto - chown mysql:mysql -R $COLUMNSTORE_INSTALL_DIR/mysql > /dev/null 2>&1 + if [ $user = "root" ]; then + mount $device $COLUMNSTORE_INSTALL_DIR/mysql/db -t ext2 -o noatime,nodiratime,noauto + chown mysql:mysql -R $COLUMNSTORE_INSTALL_DIR/mysql > /dev/null 2>&1 + else + sudo mount $device $COLUMNSTORE_INSTALL_DIR/mysql/db -t ext2 -o noatime,nodiratime,noauto,user + sudo chown $user:$user -R $COLUMNSTORE_INSTALL_DIR/mysql > /dev/null 2>&1 + fi fi fi fi @@ -148,18 +161,16 @@ if [ $module = "um" ] || ( [ $module = "pm" ] && [ $PMwithUM = "y" ] ) || [ $Ser fi fi -if [ $user == "root" ]; then - $COLUMNSTORE_INSTALL_DIR/bin/syslogSetup.sh check > /tmp/syslogSetup-check.log 2>&1 - if [ $? -ne 0 ]; then - # try setup again - $COLUMNSTORE_INSTALL_DIR/bin/syslogSetup.sh install > /tmp/syslogSetup-install.log 2>&1 - if [ $? -ne 0 ]; then - echo "WARNING: syslogSetup.sh check failed: check /tmp/syslogSetup-check.log" - exit 2 - fi - fi +$COLUMNSTORE_INSTALL_DIR/bin/syslogSetup.sh check > /tmp/syslogSetup-check.log 2>&1 +if [ $? -ne 0 ]; then + # try setup again + $COLUMNSTORE_INSTALL_DIR/bin/syslogSetup.sh install > /tmp/syslogSetup-install.log 2>&1 + if [ $? -ne 0 ]; then + echo "WARNING: syslogSetup.sh check failed: check /tmp/syslogSetup-check.log" + exit 2 + fi fi - + #setup rc.local if [ -f /etc/rc.d ]; then RCFILE=/etc/rc.d/rc.local @@ -168,9 +179,40 @@ else fi touch $RCFILE +echo "add deadline to rc.local" +if [ $module = "um" ]; then + if [ $user = "root" ]; then + echo "for scsi_dev in \`mount | awk '/mnt\\/tmp/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'\`; do" >> $RCFILE + echo "echo deadline > /sys/block/$scsi_dev/queue/scheduler" >> $RCFILE + echo "done" >> $RCFILE + else + sudo echo "for scsi_dev in \`mount | awk '/mnt\\/tmp/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'\`; do" >> $RCFILE + sudo echo "echo deadline > /sys/block/$scsi_dev/queue/scheduler" >> $RCFILE + sudo echo "done" >> $RCFILE + fi +else + if [ $user = "root" ]; then + echo "for scsi_dev in \`mount | awk '/mnt\\/tmp/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'\`; do" >> $RCFILE + echo "echo deadline > /sys/block/$scsi_dev/queue/scheduler" >> $RCFILE + echo "done" >> $RCFILE + + echo "for scsi_dev in \`mount | awk '/columnstore\\/data/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'\`; do" >> $RCFILE + echo "echo deadline > /sys/block/$scsi_dev/queue/scheduler" >> $RCFILE + echo "done" >> $RCFILE + else + sudo echo "for scsi_dev in \`mount | awk '/mnt\\/tmp/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'\`; do" >> $RCFILE + sudo echo "echo deadline > /sys/block/$scsi_dev/queue/scheduler" >> $RCFILE + sudo echo "done" >> $RCFILE + + sudo echo "for scsi_dev in \`mount | awk '/columnstore\\/data/ {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'\`; do" >> $RCFILE + sudo echo "echo deadline > /sys/block/$scsi_dev/queue/scheduler" >> $RCFILE + sudo echo "done" >> $RCFILE + fi +fi + if [ $user != "root" ]; then echo "uncomment runuser in rc.local" - sed -i -e 's/#MCS//g' /etc/rc.d/rc.local >/dev/null 2>&1 + sudo sed -i -e 's/#sudo runuser/sudo runuser/g' $RCFILE >/dev/null 2>&1 fi echo "!!!Module Installation Successfully Completed!!!" diff --git a/oam/install_scripts/post-install b/oam/install_scripts/post-install index 8ec75a9ba..5a61a9074 100755 --- a/oam/install_scripts/post-install +++ b/oam/install_scripts/post-install @@ -8,6 +8,10 @@ prefix=/usr/local installdir=$prefix/mariadb/columnstore rpmmode=install user=`whoami 2>/dev/null` +SUDO=" " +if [ $user != "root" ]; then + SUDO="sudo " +fi quiet=0 @@ -89,53 +93,53 @@ if [ -f libstdc++.so.6.0.14 ]; then fi # softlink for libperl.sp, used by cplogger -ln -s /usr/lib64/perl5/CORE/libperl.so /usr/lib64/libperl.so >/dev/null 2>&1 +$SUDO ln -s /usr/lib64/perl5/CORE/libperl.so /usr/lib64/libperl.so >/dev/null 2>&1 + +#setup profile files +profileFileAlias=/etc/profile.d/columnstoreAlias.sh +profileFileEnv=/etc/profile.d/columnstoreEnv.sh if [ $installdir != "/usr/local/mariadb/columnstore" ]; then sed -i -e s@/usr/local/mariadb/columnstore@$installdir@g $installdir/bin/columnstoreAlias fi if [ $user != "root" ]; then - profileFile=$prefix/.bash_profile - - if [ ! -f ${profileFile}_backup ]; then - cp $profileFile ${profileFile}_backup - fi - - egrep -qs 'MariaDB Columnstore Non-Root Environment Variables' ${profileFile} + sudo rm -f $profileFileEnv + sudo rm -f $profileFileAlias + + sudo touch $profileFileEnv + sudo chmod 666 $profileFileEnv + egrep -qs 'MariaDB Columnstore Non-Root' ${profileFileEnv} rc1=$? if [ $rc1 -ne 0 ]; then - echo " " >> ${profileFile} - echo "# MariaDB Columnstore Non-Root Environment Variables" >> ${profileFile} - echo "export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR" >> ${profileFile} - echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$COLUMNSTORE_INSTALL_DIR/lib:$COLUMNSTORE_INSTALL_DIR/mysql/lib" >> ${profileFile} + sudo echo " " >> ${profileFileEnv} + sudo echo "# MariaDB Columnstore Non-Root Environment Variables" >> ${profileFileEnv} + sudo echo "export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR" >> ${profileFileEnv} + sudo echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$COLUMNSTORE_INSTALL_DIR/lib:$COLUMNSTORE_INSTALL_DIR/mysql/lib" >> ${profileFileEnv} + . ${profileFileEnv} fi - egrep -qs 'MariaDB Columnstore Non-Root Alias Variables' ${profileFile} - rc1=$? - if [ $rc1 -ne 0 ]; then - echo " " >> ${profileFile} - echo "# MariaDB Columnstore Non-Root Alias Variables" >> ${profileFile} - cat $installdir/bin/columnstoreAlias >> ${profileFile} - fi - - #source the file - . ${profileFile} + sudo /bin/cp -f $installdir/bin/columnstoreAlias $profileFileAlias + sudo chmod 666 $profileFileAlias else - /bin/cp -f $installdir/bin/columnstoreAlias /etc/profile.d/columnstoreAlias.sh - chmod 644 /etc/profile.d/columnstoreAlias.sh >/dev/null 2>&1 + /bin/cp -f $installdir/bin/columnstoreAlias $profileFileAlias + chmod 644 $profileFileAlias fi cd / -test -d /var/log/mariadb || mkdir /var/log/mariadb >/dev/null 2>&1 -test -d /var/log/mariadb/columnstore || mkdir /var/log/mariadb/columnstore >/dev/null 2>&1 +test -d /var/log/mariadb || $SUDO mkdir /var/log/mariadb >/dev/null 2>&1 +test -d /var/log/mariadb/columnstore || $SUDO mkdir /var/log/mariadb/columnstore >/dev/null 2>&1 + +if [ $user != "root" ]; then + $SUDO chmod -R 777 /var/log/mariadb >/dev/null 2>&1 + $SUDO chown -R $user:$user /var/log/mariadb >/dev/null 2>&1 +fi + test -d /var/log/mariadb/columnstore/archive || mkdir /var/log/mariadb/columnstore/archive >/dev/null 2>&1 test -d /var/log/mariadb/columnstore/corefiles || mkdir /var/log/mariadb/columnstore/corefiles >/dev/null 2>&1 test -d /var/log/mariadb/columnstore/trace || mkdir /var/log/mariadb/columnstore/trace >/dev/null 2>&1 test -h /var/log/mariadb/columnstore/data && rm -f /var/log/mariadb/columnstore/data -chmod 755 /var/log/mariadb/columnstore/corefiles > /dev/null 2>&1 - # make sure trace dir is world-writable and sticky test -d $installdir/data || mkdir $installdir/data test -d $installdir/data1 || mkdir $installdir/data1 @@ -158,8 +162,13 @@ rm -f $installdir/data/bulk/tmpjob/* >/dev/null 2>&1 #create columnstore temp file directory mkdir -p /tmp/columnstore_tmp_files >/dev/null 2>&1 +#setup core file directory and link +mkdir /var/log/mariadb/columnstore/corefiles > /dev/null 2>&1 +chmod 777 /var/log/mariadb/columnstore/corefiles > /dev/null 2>&1 + #create mount directories mkdir /mnt/tmp > /dev/null 2>&1 +mkdir /var/log/mariadb/columnstore/data/archive > /dev/null 2>&1 # remove mysql archive log test -d $installdir/mysql/db || mkdir -p $installdir/mysql/db @@ -168,6 +177,7 @@ rm -rf $installdir/mysql/db/columnstore_log_archive > /dev/null 2>&1 # delete Columnstore shared memory segments $installdir/bin/clearShm > /dev/null 2>&1 +systemctl=`which systemctl 2>/dev/null` #check and create rc.local file if missing if [ -f /etc/rc.d ]; then @@ -180,16 +190,22 @@ if [ $user = "root" ]; then touch $RCFILE chmod +x $RCFILE else - printf '%s\n' '#!/bin/bash' "#" | tee -a $RCFILE > /dev/null 2>&1 + $SUDO touch $RCFILE + $SUDO chmod 777 $RCFILE + $SUDO printf '%s\n' '#!/bin/bash' "#" | $SUDO tee -a $RCFILE > /dev/null 2>&1 + + if [ -n "$systemctl" ]; then + $SUDO systemctl start rc-local >/dev/null 2>&1 + $SUDO systemctl enable rc-local >/dev/null 2>&1 + fi fi -if [ $user = "root" ]; then - #setup the columnstore service script - rm -f /etc/init.d/columnstore >/dev/null 2>&1 - rm -f /etc/init.d/mysql-Columnstore >/dev/null 2>&1 - rm -f /etc/default/columnstore - systemctl=`which systemctl 2>/dev/null` +#setup the columnstore service script +rm -f /etc/init.d/columnstore >/dev/null 2>&1 +rm -f /etc/init.d/mysql-Columnstore >/dev/null 2>&1 + +if [ $user = "root" ]; then if [ -n "$systemctl" ]; then chmod 644 $installdir/bin/columnstore.service @@ -219,46 +235,30 @@ fi if [ $user = "root" ]; then $installdir/bin/syslogSetup.sh install > /tmp/syslog_install.log 2>&1 - - #check if MariaDB Columnstore system logging was setup - cat /tmp/syslog_install.log | grep 'No System Logging' >/dev/null 2>&1 - if [ $? -eq 0 ]; then - cat /tmp/syslog_install.log - fi + rm -f /etc/default/columnstore else sed -i -e s@/usr/local/mariadb/columnstore@$installdir@g $installdir/bin/columnstore.def sed -i -e s@/usr/local/mariadb/columnstore@$installdir@g $installdir/bin/columnstoreLogRotate - cp $installdir/bin/columnstore.def /etc/default/columnstore + $SUDO cp $installdir/bin/columnstore.def /etc/default/columnstore sed -i -e s@prefix=/home/guest@prefix=$prefix@g $installdir/bin/* - chown $user:$user $installdir/etc/Columnstore.xml - - echo "" - echo "NOTE: For non-root install, you will need to run the following command as root user to" - echo " setup the MariaDB ColumnStore System Logging" - echo "" - echo " $installdir/bin/syslogSetup.sh --installdir=$installdir --user=$user install" - echo "" + $SUDO chmod 777 /tmp + $installdir/bin/syslogSetup.sh --installdir=$installdir install > /tmp/syslog_install.log 2>&1 + $SUDO chown $user:$user $installdir/etc/Columnstore.xml + $SUDO mkdir /var/lock/subsys > /dev/null 2>&1 + $SUDO chmod 777 /var/lock/subsys > /dev/null 2>&1 + $SUDO rm -f /var/lock/subsys/mysql-Columnstore + $SUDO chmod 666 /etc/fstab fi -#determine lock file directory - -# Lock directory for root user -lockdir='/var/lock/subsys' -if [ $user != "root" ];then - # Lock directory for non-root user - lockdir=$prefix/.lock +#check if MariaDB Columnstore system logging was setup +cat /tmp/syslog_install.log | grep 'No System Logging' >/dev/null 2>&1 +if [ $? -eq 0 ]; then + cat /tmp/syslog_install.log fi -$installdir/bin/setConfig -d Installation LockFileDirectory $lockdir - -mkdir $lockdir >/dev/null 2>&1 - -rm -f $lockdir/mysql-Columnstore -rm -f $lockdir/columnstore - #backup copy of Alarm Config File /bin/cp -f $installdir/etc/AlarmConfig.xml $installdir/etc/AlarmConfig.xml.installSave > /dev/null 2>&1 @@ -275,7 +275,6 @@ if [ $user = "root" ]; then else LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$installdir/lib $installdir/bin/cplogger -i 19 "***** MariaDB Columnstore Installed *****" fi - #setup hadoop hadoop=`which hadoop 2>/dev/null` if [ -z "$hadoop" ]; then diff --git a/oamapps/alarmmanager/alarmmanager.cpp b/oamapps/alarmmanager/alarmmanager.cpp index 1775bafc7..37acc7c1e 100644 --- a/oamapps/alarmmanager/alarmmanager.cpp +++ b/oamapps/alarmmanager/alarmmanager.cpp @@ -463,7 +463,7 @@ void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int st int pid = getpid(); int tid = gettid(); - // get reporting Pprocess Name + // get reporting Process Name string processName; if ( repProcessName.empty()) @@ -505,8 +505,39 @@ void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int st // shutdown connection procmgr.shutdown(); } + catch (std::runtime_error& e) + { + LoggingID lid(11); + MessageLog ml(lid); + Message msg; + Message::Args args; + args.add("sendAlarmReport error:"); + args.add(e.what()); + msg.format(args); + ml.logDebugMessage(msg); + } + catch (std::exception& e) + { + LoggingID lid(11); + MessageLog ml(lid); + Message msg; + Message::Args args; + args.add("sendAlarmReport error:"); + args.add(e.what()); + msg.format(args); + ml.logDebugMessage(msg); + } catch (...) - {} + { + LoggingID lid(11); + MessageLog ml(lid); + Message msg; + Message::Args args; + args.add("sendAlarmReport error:"); + args.add("general failure"); + msg.format(args); + ml.logDebugMessage(msg); + } return; #endif //SKIP_ALARM diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index c53b0c971..2a737861c 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02110-1301, USA. */ + MA 02110-1301, USA. */ /****************************************************************************************** * $Id: postConfigure.cpp 64 2006-10-12 22:21:51Z dhill $ @@ -99,6 +99,14 @@ typedef struct Performance_Module_struct typedef std::vector PerformanceModuleList; +typedef struct ModuleIP_struct +{ + std::string IPaddress; + std::string moduleName; +} ModuleIP; + +typedef std::vector ModuleIpList; + void offLineAppCheck(); bool setOSFiles(string parentOAMModuleName, int serverTypeInstall); bool checkSaveConfigFile(); @@ -121,12 +129,6 @@ void remoteInstallThread(void*); bool glusterSetup(string password); -typedef struct ModuleIP_struct -{ - std::string IPaddress; - std::string moduleName; -} ModuleIP; - std::string launchInstance(ModuleIP moduleip); string columnstorePackage; @@ -150,7 +152,6 @@ string PMVolumeType = "standard"; string PMVolumeIOPS = oam::UnassignedName; string UMVolumeIOPS = oam::UnassignedName; - int DBRootCount; string deviceName; @@ -185,6 +186,10 @@ string MySQLRep = "y"; string PMwithUM = "n"; bool amazonInstall = false; bool nonDistribute = false; +bool nonDistributeFlag = false; +bool single_server_quick_install = false; +bool multi_server_quick_install = false; +bool amazon_quick_install = false; string DataFileEnvFile; @@ -220,6 +225,9 @@ int main(int argc, char* argv[]) noPrompting = false; string password; string cmd; + string pmIpAddrs = ""; + string umIpAddrs = ""; + // struct sysinfo myinfo; // hidden options @@ -278,74 +286,88 @@ int main(int argc, char* argv[]) if (p && *p) HOME = p; } + for ( int i = 1; i < argc; i++ ) { - if ( string("-h") == argv[i] ) - { + if( string("-h") == argv[i] ) + { cout << endl; cout << "This is the MariaDB ColumnStore System Configuration and Installation tool." << endl; cout << "It will Configure the MariaDB ColumnStore System based on Operator inputs and" << endl; cout << "will perform a Package Installation of all of the Modules within the" << endl; cout << "System that is being configured." << endl; cout << endl; - cout << "IMPORTANT: This tool should only be run on a Performance Module Server," << endl; - cout << " preferably Module #1" << endl; + cout << "IMPORTANT: This tool is required to run on a Performance Module #1 (pm1) Server." << endl; cout << endl; cout << "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; cout << endl; - cout << "Usage: postConfigure [-h][-c][-u][-p][-s][-port][-i][-n]" << endl; + cout << "Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-qa][-port][-i][-n][-d][-sn][-pm-ip-addrs][-um-ip-addrs][-pm-count][-um-count]" << endl; cout << " -h Help" << endl; cout << " -c Config File to use to extract configuration data, default is Columnstore.xml.rpmsave" << endl; cout << " -u Upgrade, Install using the Config File from -c, default to Columnstore.xml.rpmsave" << endl; cout << " If ssh-keys aren't setup, you should provide passwords as command line arguments" << endl; cout << " -p Unix Password, used with no-prompting option" << endl; - cout << " -s Single Threaded Remote Install" << endl; + cout << " -qs Quick Install - Single Server" << endl; + cout << " -qm Quick Install - Multi Server" << endl; cout << " -port MariaDB ColumnStore Port Address" << endl; cout << " -i Non-root Install directory, Only use for non-root installs" << endl; - cout << " -n Non-distributed install, meaning it will not install the remote nodes" << endl; + cout << " -n Non-distributed install, meaning postConfigure will not install packages on remote nodes" << endl; + cout << " -d Distributed install, meaning postConfigure will install packages on remote nodes" << endl; + cout << " -sn System Name" << endl; + cout << " -pm-ip-addrs Performance Module IP Addresses xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx" << endl; + cout << " -um-ip-addrs User Module IP Addresses xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx" << endl; exit (0); } - else if ( string("-s") == argv[i] ) - thread_remote_installer = false; + 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("-qa") == argv[i] ) + { + amazon_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] ) - { + else if( string("-c") == argv[i] ) + { i++; - - if (i >= argc ) + if (i >= argc ) { cout << " ERROR: Config File not provided" << endl; exit (1); } oldFileName = argv[i]; - - if ( oldFileName.find("Columnstore.xml") == string::npos ) + 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] ) - { + else if( string("-p") == argv[i] ) + { i++; - - if (i >= argc ) + if (i >= argc ) { cout << " ERROR: Password not provided" << endl; exit (1); } password = argv[i]; - - if ( password.find("-") != string::npos ) + if ( password.find("-") != string::npos ) { cout << " ERROR: Valid Password not provided" << endl; exit (1); @@ -355,12 +377,19 @@ int main(int argc, char* argv[]) noPrompting = true; // for backward compatibility else if ( string("-n") == argv[i] ) + { nonDistribute = true; - else if ( string("-port") == argv[i] ) - { + nonDistributeFlag = true; + } + else if( string("-d") == argv[i] ) + { + nonDistribute = false; + nonDistributeFlag = true; + } + else if( string("-port") == argv[i] ) + { i++; - - if (i >= argc ) + if (i >= argc ) { cout << " ERROR: MariaDB ColumnStore Port ID not supplied" << endl; exit (1); @@ -374,11 +403,10 @@ int main(int argc, char* argv[]) exit (1); } } - else if ( string("-i") == argv[i] ) + else if( string("-i") == argv[i] ) { i++; - - if (i >= argc ) + if (i >= argc ) { cout << " ERROR: Path not provided" << endl; exit (1); @@ -386,11 +414,83 @@ int main(int argc, char* argv[]) installDir = argv[i]; } + 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 { cout << " ERROR: Invalid Argument = " << argv[i] << endl; - cout << " Usage: postConfigure [-h][-c][-u][-p][-s][-port][-i]" << endl; - exit (1); + cout << " Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-qa][-port][-i][-n][-d][-sn][-pm-ip-addrs][-um-ip-addrs][-pm-count][-um-count]" << endl; + exit (1); + } + } + + //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); } } @@ -409,42 +509,43 @@ int main(int argc, char* argv[]) cout << "Installation of all of the Servers within the System that is being configured." << endl; cout << endl; - cout << "IMPORTANT: This tool should only be run on the Parent OAM Module" << endl; - cout << " which is a Performance Module, preferred Module #1" << endl; + cout << "IMPORTANT: This tool requires to run on the Performance Module #1" << endl; cout << endl; - 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; + 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; + 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 ); - } + 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()) { @@ -458,45 +559,43 @@ int main(int argc, char* argv[]) cout << "ERROR: Configuration File not setup" << endl; exit(1); } - + //determine package type string EEPackageType; - if (!rootUser) - EEPackageType = "binary"; - else - { - int rtnCode = system("rpm -qi mariadb-columnstore-platform > /tmp/columnstore.txt 2>&1"); + if (!rootUser) + EEPackageType = "binary"; + else + { + int rtnCode = system("rpm -qi mariadb-columnstore-platform > /tmp/columnstore.txt 2>&1"); - if (WEXITSTATUS(rtnCode) == 0) - EEPackageType = "rpm"; - else - { - rtnCode = system("dpkg -s mariadb-columnstore-platform > /tmp/columnstore.txt 2>&1"); + if (WEXITSTATUS(rtnCode) == 0) + EEPackageType = "rpm"; + else { + rtnCode = system("dpkg -s mariadb-columnstore-platform > /tmp/columnstore.txt 2>&1"); - if (WEXITSTATUS(rtnCode) == 0) - EEPackageType = "deb"; - else - EEPackageType = "binary"; - } - } + if (WEXITSTATUS(rtnCode) == 0) + EEPackageType = "deb"; + else + EEPackageType = "binary"; + } + } - try - { - sysConfig->setConfig(InstallSection, "EEPackageType", EEPackageType); - } - catch (...) - { - cout << "ERROR: Problem setting EEPackageType from the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } + try { + sysConfig->setConfig(InstallSection, "EEPackageType", EEPackageType); + } + catch(...) + { + cout << "ERROR: Problem setting EEPackageType 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); } - + //check for local ip address as pm1 ModuleConfig moduleconfig; @@ -598,7 +697,6 @@ int main(int argc, char* argv[]) catch (...) {} - // run my.cnf upgrade script if ( reuseConfig == "y" ) { @@ -649,16 +747,25 @@ int main(int argc, char* argv[]) } //check for non-Distributed Install - if ( nonDistribute ) - { - try - { - oam.setSystemConfig("DistributedInstall", "n"); - } - catch (...) {} - } - else - { + if ( nonDistributeFlag ) + { + if ( nonDistribute ) + { + try { + oam.setSystemConfig("DistributedInstall", "n"); + } + catch(...) {} + } + else + { + try { + oam.setSystemConfig("DistributedInstall", "y"); + } + catch(...) {} + } + } + else + { //get Distributed Install try { @@ -672,211 +779,290 @@ int main(int argc, char* argv[]) } cout << endl; + + if (single_server_quick_install) + { + cout << "===== Quick Install Single-Server Configuration =====" << endl << endl; - cout << "===== Setup System Server Type Configuration =====" << endl << endl; + cout << "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; + + singleServerInstall = "1"; + } + else if (multi_server_quick_install) + { + cout << "===== Quick Install Multi-Server Configuration =====" << endl << endl; + + singleServerInstall = "2"; + } + else if (amazon_quick_install) + { + cout << "===== Quick Install Amazon Configuration =====" << endl << endl; + + singleServerInstall = "2"; + } + else + { + cout << "===== Setup System Server Type Configuration =====" << endl << endl; - 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; + 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; - string temp; try { - temp = sysConfig->getConfig(InstallSection, "SingleServerInstall"); - } - catch (...) - {} + temp = sysConfig->getConfig(InstallSection, "SingleServerInstall"); + } + catch(...) + {} - if ( temp == "y" ) - singleServerInstall = "1"; - else - singleServerInstall = "2"; + if ( temp == "y" ) + singleServerInstall = "1"; + else + singleServerInstall = "2"; - while (true) - { - prompt = "Select the type of System Server install [1=single, 2=multi] (" + singleServerInstall + ") > "; - pcommand = callReadline(prompt.c_str()); - string temp; + 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; + if (strlen(pcommand) > 0) + temp = pcommand; + else + temp = singleServerInstall; + + callFree(pcommand); - callFree(pcommand); + if (temp == "1") { + singleServerInstall = temp; + + cout << endl << "Performing the Single Server Install." << endl; - if (temp == "1") - { - singleServerInstall = temp; - cout << endl << "Performing the Single Server Install." << endl; + break; + } + else + { + if (temp == "2") { + singleServerInstall = temp; + break; + } + } - if ( reuseConfig == "n" ) - { - //setup to Columnstore.xml file for single server + cout << "Invalid Entry, please re-enter (1 or 2)" << endl; + if ( noPrompting ) + exit(1); + } + } + } + + if (singleServerInstall == "1") + { + if ( reuseConfig == "n" ) { + //setup to use the single server Columnstore.xml file - try - { - sysConfig->setConfig("ExeMgr1", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("ExeMgr1", "Module", "pm1"); - sysConfig->setConfig("ProcMgr", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("ProcMgr_Alarm", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("ProcStatusControl", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("pm1_ProcessMonitor", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("pm1_ServerMonitor", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("pm1_WriteEngineServer", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("DDLProc", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("DMLProc", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS1", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS2", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS3", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS4", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS5", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS6", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS7", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS8", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS9", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS10", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS11", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS12", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS13", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS14", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS15", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS16", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS17", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS18", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS19", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS20", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS21", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS22", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS23", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS24", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS25", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS26", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS27", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS28", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS29", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS30", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS31", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("PMS32", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("SystemModuleConfig", "ModuleCount2", "0"); - sysConfig->setConfig("SystemModuleConfig", "ModuleIPAddr1-1-3", "127.0.0.1"); - sysConfig->setConfig("SystemModuleConfig", "ModuleHostName1-1-3", "localhost"); - sysConfig->setConfig("DBRM_Controller", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("DBRM_Worker1", "IPAddr", "127.0.0.1"); - sysConfig->setConfig("DBRM_Worker1", "Module", "pm1"); - sysConfig->setConfig("DBBC", "NumBlocksPct", "50"); - sysConfig->setConfig("Installation", "InitialInstallFlag", "y"); - sysConfig->setConfig("Installation", "SingleServerInstall", "y"); - sysConfig->setConfig("HashJoin", "TotalUmMemory", "25%"); - } + // we know that our Config instance just timestamped itself in the getConfig + // call above. if postConfigure is running non-interactively we may get here + // within the same second which means the changes that are about to happen + // when Columnstore.xml gets overwritten will be ignored because of the Config + // instance won't know to reload + sleep(1); - catch (...) - { - cout << "ERROR: Problem setting for Single Server in the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } + cmd = "rm -f " + installDir + "/etc/Columnstore.xml.installSave > /dev/null 2>&1"; + system(cmd.c_str()); + cmd = "mv -f " + installDir + "/etc/Columnstore.xml " + installDir + "/etc/Columnstore.xml.installSave > /dev/null 2>&1"; + system(cmd.c_str()); + cmd = "/bin/cp -f " + installDir + "/etc/Columnstore.xml.singleserver " + installDir + "/etc/Columnstore.xml > /dev/null 2>&1"; + system(cmd.c_str()); } - setSystemName(); - cout << endl; + setSystemName(); - system(cmd.c_str()); + if (!single_server_quick_install) + { + cout << endl; - // setup storage - if (!storageSetup(false)) - { - cout << "ERROR: Problem setting up storage" << endl; - exit(1); - } + // setup storage + if (!storageSetup(false)) + { + cout << "ERROR: Problem setting up storage" << endl; + exit(1); + } - if (hdfs || !rootUser) - if ( !updateBash() ) - cout << "updateBash error" << endl; + // setup storage + if (!singleServerDBrootSetup()) + { + cout << "ERROR: Problem setting up DBRoot IDs" << endl; + exit(1); + } - // setup storage - if (!singleServerDBrootSetup()) - { - cout << "ERROR: Problem setting up DBRoot IDs" << endl; - exit(1); - } + //set system DBRoot count and check 'files per parition' with number of dbroots + 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); + } - //set system DBRoot count and check 'files per parition' with number of dbroots - 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 if dbrm data resides in older directory path and inform user if it does + dbrmDirCheck(); - //check if dbrm data resides in older directory path and inform user if it does - dbrmDirCheck(); + if (startOfflinePrompt) + offLineAppCheck(); + } - if (startOfflinePrompt) - offLineAppCheck(); + checkMysqlPort(mysqlPort, sysConfig); - checkMysqlPort(mysqlPort, sysConfig); + if (hdfs || !rootUser) + if( !updateBash() ) + cout << "updateBash error" << endl; - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update 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 << "===== Performing Configuration Setup and MariaDB ColumnStore Startup =====" << endl; + cout << endl << "===== Performing Configuration Setup and MariaDB ColumnStore Startup =====" << endl; - cmd = installDir + "/bin/installer dummy.rpm dummy.rpm dummy.rpm dummy.rpm dummy.rpm initial dummy " + reuseConfig + " --nodeps ' ' 1 " + installDir; - system(cmd.c_str()); - exit(0); - } - else - { - if (temp == "2") - { - singleServerInstall = temp; - break; - } - } + cmd = installDir + "/bin/installer dummy.rpm dummy.rpm dummy.rpm dummy.rpm dummy.rpm initial dummy " + reuseConfig + " --nodeps ' ' 1 " + installDir; + system(cmd.c_str()); + exit(0); + } - cout << "Invalid Entry, please re-enter" << endl; + try { + sysConfig->setConfig(InstallSection, "SingleServerInstall", "n"); + } + catch(...) + { + cout << "ERROR: Problem setting SingleServerInstall from the MariaDB ColumnStore System Configuration file" << endl; + exit(1); + } - if ( noPrompting ) - exit(1); + if ( !writeConfig(sysConfig) ) { + cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; + exit(1); + } - continue; - } + // + // Multi-server install + // + + ModuleIP InputModuleIP; + ModuleIpList InputModuleIPList; - break; - } + int MaxNicID = oam::MAX_NIC; - try - { - sysConfig->setConfig(InstallSection, "SingleServerInstall", "n"); - } - catch (...) - { - cout << "ERROR: Problem setting SingleServerInstall from the MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } + 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); - if ( !writeConfig(sysConfig) ) - { - cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl; - exit(1); - } + 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); - // - // Multi-server install - // + 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 @@ -938,9 +1124,8 @@ int main(int argc, char* argv[]) exit(1); } - switch ( IserverTypeInstall ) - { - case (oam::INSTALL_COMBINE_DM_UM_PM): // combined #1 - dm/um/pm on a single server + 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; @@ -1096,8 +1281,8 @@ int main(int argc, char* argv[]) if ( answer == "y" ) { - mysqlRep = true; - MySQLRep = "y"; + mysqlRep = true; + MySQLRep = "y"; } else { @@ -1135,24 +1320,45 @@ int main(int argc, char* argv[]) //amazon install setup check bool amazonInstall = false; string cloud = oam::UnassignedName; - system("aws --version > /tmp/amazon.log 2>&1"); + + if (!multi_server_quick_install) + { + system("aws --version > /tmp/amazon.log 2>&1"); - ifstream in("/tmp/amazon.log"); + ifstream in("/tmp/amazon.log"); - in.seekg(0, std::ios::end); - int size = in.tellg(); + in.seekg(0, std::ios::end); + int size = in.tellg(); - if ( size == 0 || oam.checkLogStatus("/tmp/amazon.log", "not found")) - // not running on amazon with ec2-api-tools - amazonInstall = false; - else - { - if ( size == 0 || oam.checkLogStatus("/tmp/amazon.log", "not installed")) - amazonInstall = false; - else - amazonInstall = true; - } + if ( size == 0 || oam.checkLogStatus("/tmp/amazon.log", "not found")) + { + // not running on amazon with ec2-api-tools + if (amazon_quick_install) + { + cout << "ERROR: Amazon Quick Installer was specified, bu the AMazon CLI API packages isnt installed, exiting" << endl; + exit(1); + } + amazonInstall = false; + } + else + { + if ( size == 0 || oam.checkLogStatus("/tmp/amazon.log", "not installed")) + { + // not running on amazon with ec2-api-tools + if (amazon_quick_install) + { + cout << "ERROR: Amazon Quick Installer was specified, bu the AMazon CLI API packages isnt installed, exiting" << endl; + exit(1); + } + + amazonInstall = false; + } + else + amazonInstall = true; + } + } + try { cloud = sysConfig->getConfig(InstallSection, "Cloud"); @@ -1190,7 +1396,7 @@ int main(int argc, char* argv[]) try { - sysConfig->setConfig(InstallSection, "Cloud", "disable"); + sysConfig->setConfig(InstallSection, "Cloud", "disable"); } catch (...) {}; @@ -1238,7 +1444,8 @@ int main(int argc, char* argv[]) // setup to start on reboot, for non-root amazon installs if ( !rootUser ) { - system("sed -i -e 's/#MCS//g' /etc/rc.d/rc.local >/dev/null 2>&1"); + system("sudo sed -i -e 's/#sudo runuser/sudo runuser/g' /etc/rc.d/rc.local >/dev/null 2>&1"); + system("sudo chmod 666 /etc/fstab >/dev/null 2>&1"); } if ( !writeConfig(sysConfig) ) @@ -1633,6 +1840,14 @@ int main(int argc, char* argv[]) 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 ) @@ -1737,7 +1952,7 @@ int main(int argc, char* argv[]) //clear any Equipped Module IP addresses that aren't in current ID range for ( int j = 0 ; j < listSize ; j++ ) { - for ( unsigned int k = 1 ; k < MAX_NIC + 1 ; k++) + for ( unsigned int k = 1 ; k < MaxNicID+1 ; k++) { string ModuleIPAddr = "ModuleIPAddr" + oam.itoa(j + 1) + "-" + oam.itoa(k) + "-" + oam.itoa(i + 1); @@ -1792,43 +2007,68 @@ int main(int argc, char* argv[]) moduleDisableState = oam::ENABLEDSTATE; //setup HostName/IPAddress for each NIC - for ( unsigned int nicID = 1 ; nicID < MAX_NIC + 1 ; nicID++ ) - { - string moduleHostName = oam::UnassignedName; - string moduleIPAddr = oam::UnassignedIpAddr; + + string moduleHostName = oam::UnassignedName; + string moduleIPAddr = oam::UnassignedIpAddr; - DeviceNetworkList::iterator listPT = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.begin(); + 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; + } + } + } + + unsigned int nicID=1; + for( ; nicID < MaxNicID +1 ; nicID++ ) + { + if ( !found ) + { + moduleHostName = oam::UnassignedName; + moduleIPAddr = oam::UnassignedIpAddr; - for ( ; listPT != sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.end() ; listPT++) - { - if (newModuleName == (*listPT).DeviceName) - { - if ( nicID == 1 ) - { - moduleDisableState = (*listPT).DisableState; + DeviceNetworkList::iterator listPT = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.begin(); - if ( moduleDisableState.empty() || - moduleDisableState == oam::UnassignedName || - moduleDisableState == oam::AUTODISABLEDSTATE ) - moduleDisableState = oam::ENABLEDSTATE; - } + for( ; listPT != sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.end() ; listPT++) + { + if (newModuleName == (*listPT).DeviceName) + { + if ( nicID == 1 ) + { + moduleDisableState = (*listPT).DisableState; - HostConfigList::iterator pt1 = (*listPT).hostConfigList.begin(); + 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 ) - { + 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"; @@ -1927,6 +2167,7 @@ int main(int argc, char* argv[]) break; } + bool moduleHostNameFound = true; if (moduleHostName.empty()) @@ -1971,28 +2212,30 @@ int main(int argc, char* argv[]) //check if need to create instance or user enter ID string create = "y"; - while (true) - { - pcommand = callReadline("Create Instance for " + newModuleName + " [y,n] (y) > "); + if ( !amazon_quick_install ) + { + while(true) + { + pcommand = callReadline("Create Instance for " + newModuleName + " [y,n] (y) > "); - if (pcommand) - { - if (strlen(pcommand) > 0) create = pcommand; + if (pcommand) + { + if (strlen(pcommand) > 0) create = pcommand; - callFree(pcommand); - } + callFree(pcommand); + } - if ( create == "y" || create == "n" ) - break; - else - cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl; + 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); - } + create = "y"; + if ( noPrompting ) + exit(1); + } + } if ( create == "y" ) { @@ -2638,32 +2881,37 @@ int main(int argc, char* argv[]) string dbrootList; - for ( unsigned int id = 1 ; id < count + 1 ; ) - { - string moduledbrootid = "ModuleDBRootID" + oam.itoa(moduleID) + "-" + oam.itoa(id) + "-" + oam.itoa(i + 1); + 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); - try - { - string dbrootid = sysConfig->getConfig(ModuleSection, moduledbrootid); - - if ( dbrootid != oam::UnassignedName) + if ( dbrootid != oam::UnassignedName) { - sysConfig->setConfig(ModuleSection, moduledbrootid, 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); - } - } + 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; @@ -3198,8 +3446,9 @@ int main(int argc, char* argv[]) //check if dbrm data resides in older directory path and inform user if it does dbrmDirCheck(); - if ( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM && pmNumber == 1) - { + 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 << endl; @@ -3207,7 +3456,57 @@ int main(int argc, char* argv[]) // call the mysql setup scripts mysqlSetup(); - sleep(5); + 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 your password or you can default to using a ssh key" << endl; + cout << "If using a password, the password needs to be the same on all Servers." << endl << endl; + + if ( noPrompting ) { + cout << "Enter password, hit 'enter' to default to using a ssh key, or 'exit' > " << endl; + password = "ssh"; + } + else + { + while(true) + { + char *pass1, *pass2; + + pass1=getpass("Enter password, hit 'enter' to default to using a 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 + "'"; + } + + } + } } int thread_id = 0; @@ -3282,74 +3581,8 @@ int main(int argc, char* argv[]) if ( !pkgCheck(columnstorePackage) ) exit(1); - 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 a 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 a ssh key, or 'exit' > " << endl; - - if ( password.empty() ) - password = "ssh"; - - break; - } - - //check for command line option password - if ( !password.empty() ) - break; - - pass1 = getpass("Enter password, hit 'enter' to default to using a ssh key, or 'exit' > "); - - if ( strcmp(pass1, "") == 0 ) - { - password = "ssh"; - break; - } - - if ( pass1 == "exit") - 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" ) - { - password = "'" + password + "'"; - } - checkSystemMySQLPort(mysqlPort, sysConfig, USER, password, childmodulelist, IserverTypeInstall, pmwithum); - if ( ( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) || - ( (IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM) && pmwithum ) ) - { - cout << endl << "===== Running the MariaDB ColumnStore MariaDB ColumnStore setup scripts =====" << endl << endl; - - // call the mysql setup scripts - mysqlSetup(); - sleep(5); - } - string AmazonInstall = "0"; if ( amazonInstall ) @@ -3554,19 +3787,7 @@ int main(int argc, char* argv[]) cout << " DONE" << endl; } } - else - { - if ( ( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) || - ( (IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM) && pmwithum ) ) - { - cout << endl << "===== Running the MariaDB ColumnStore MariaDB ColumnStore setup scripts =====" << endl << endl; - - // call the mysql setup scripts - mysqlSetup(); - sleep(5); - } - } - + //configure data redundancy if (DataRedundancy) { @@ -3659,7 +3880,17 @@ int main(int argc, char* argv[]) //check if local MariaDB ColumnStore system logging is working cout << endl << "===== Checking MariaDB ColumnStore System Logging Functionality =====" << endl << endl; - cmd = installDir + "/bin/syslogSetup.sh status > /dev/null 2>&1"; + if ( rootUser) + cmd = installDir + "/bin/syslogSetup.sh install > /dev/null 2>&1"; + else + cmd = "sudo " + installDir + "/bin/syslogSetup.sh --installdir=" + installDir + " install > /dev/null 2>&1"; + + system(cmd.c_str()); + + if ( rootUser) + cmd = installDir + "/bin/syslogSetup.sh status > /dev/null 2>&1"; + else + cmd = "sudo " + installDir + "/bin/syslogSetup.sh --installdir=" + installDir + " status > /dev/null 2>&1"; int ret = system(cmd.c_str()); @@ -3799,9 +4030,6 @@ int main(int argc, char* argv[]) } //set mysql replication, if wasn't setup before on system -// if ( ( mysqlRep && pmwithum ) || -// ( mysqlRep && (umNumber > 1) ) || -// ( mysqlRep && (pmNumber > 1) && (IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM) ) ) if ( mysqlRep ) { cout << endl << "Run MariaDB ColumnStore Replication Setup.. "; @@ -3824,7 +4052,10 @@ int main(int argc, char* argv[]) cout << "Enter the following command to define MariaDB ColumnStore Alias Commands" << endl << endl; - cout << ". " + installDir + "/bin/columnstoreAlias" << endl << endl; + if ( !rootUser ) + cout << ". /etc/profile.d/columnstoreEnv.sh" << endl; + + cout << ". /etc/profile.d/columnstoreAlias.sh" << endl << endl; cout << "Enter 'mcsmysql' to access the MariaDB ColumnStore SQL console" << endl; cout << "Enter 'mcsadmin' to access the MariaDB ColumnStore Admin console" << endl << endl; @@ -3841,7 +4072,10 @@ int main(int argc, char* argv[]) cout << "Enter the following command to define MariaDB ColumnStore Alias Commands" << endl << endl; - cout << ". " + installDir + "/bin/columnstoreAlias" << endl << endl; + if ( !rootUser ) + cout << ". /etc/profile.d/columnstoreEnv.sh" << endl; + + cout << ". /etc/profile.d/columnstoreAlias.sh" << endl << endl; cout << "Enter 'mcsmysql' to access the MariaDB ColumnStore SQL console" << endl; cout << "Enter 'mcsadmin' to access the MariaDB ColumnStore Admin console" << endl << endl; @@ -3867,16 +4101,25 @@ bool checkSaveConfigFile() //check if Columnstore.xml.rpmsave exist ifstream File (oldFileName.c_str()); - if (!File) - { - if ( noPrompting ) - { - cout << endl << "Old Config File not found '" + oldFileName + "', exiting" << endl; - exit(1); - } - - return true; - } + if (!File) { + if (single_server_quick_install || multi_server_quick_install || amazon_quick_install) + { + return true; + } + if ( noPrompting ) { + cout << endl << "Old Config File not found '" + oldFileName + "', exiting" << endl; + exit(1); + } + return true; + } + else + { + if (single_server_quick_install || multi_server_quick_install || amazon_quick_install) + { + cout << endl << "Quick Install is for fresh installs only, '" + oldFileName + "' exist, exiting" << endl; + exit(1); + } + } File.close(); @@ -3966,7 +4209,19 @@ bool checkSaveConfigFile() string cmd; if ( reuseConfig == "y" ) + { + if ( singleServerInstall == "1") + { + cmd = "rm -f " + installDir + "/etc/Columnstore.xml.installSave > /dev/null 2>&1"; + system(cmd.c_str()); + cmd = "mv -f " + installDir + "/etc/Columnstore.xml " + installDir + "/etc/Columnstore.xml.installSave > /dev/null 2>&1"; + system(cmd.c_str()); + cmd = "/bin/cp -f " + installDir + "/etc/Columnstore.xml.singleserver " + installDir + "/etc/Columnstore.xml > /dev/null 2>&1"; + system(cmd.c_str()); + } + break; + } if ( reuseConfig == "n" ) { @@ -4093,13 +4348,22 @@ bool setOSFiles(string parentOAMModuleName, int serverTypeInstall) //make a backup copy before changing string cmd = "rm -f " + fileName + ".columnstoreSave"; + if ( !rootUser ) + cmd = "sudo rm -f " + fileName + ".columnstoreSave"; + system(cmd.c_str()); cmd = "cp " + fileName + " " + fileName + ".columnstoreSave > /dev/null 2>&1"; + if ( !rootUser ) + cmd = "sudo cp " + fileName + " " + fileName + ".columnstoreSave > /dev/null 2>&1"; + system(cmd.c_str()); - cmd = "cat " + installDir + "/local/etc/" + parentOAMModuleName + "/" + files[i] + ".calpont >> " + fileName; + if ( rootUser ) + cmd = "cat " + installDir + "/local/etc/" + parentOAMModuleName + "/" + files[i] + ".calpont >> " + fileName; + else + cmd = "sudo bash -c 'sudo cat " + installDir + "/local/etc/" + parentOAMModuleName + "/" + files[i] + ".calpont >> " + fileName + "'"; int rtnCode = system(cmd.c_str()); @@ -4300,9 +4564,6 @@ bool uncommentCalpontXml( string entry) */ bool makeRClocal(string moduleType, string moduleName, int IserverTypeInstall) { - - return true; - vector lines; string mount1; @@ -4404,7 +4665,7 @@ bool createDbrootDirs(string DBRootStorageType) if ( !rootUser) { - cmd = "chown -R " + USER + ":" + USER + " " + installDir + "/data1 > /dev/null"; + cmd = "sudo chown -R " + USER + ":" + USER + " " + installDir + "/data1 > /dev/null"; system(cmd.c_str()); } @@ -4864,7 +5125,10 @@ bool storageSetup(bool amazonInstall) //check if gluster is installed int rtnCode = 1; - rtnCode = system("gluster --version > /tmp/gluster.log 2>&1"); + if (rootUser) + rtnCode = system("gluster --version > /tmp/gluster.log 2>&1"); + else + rtnCode = system("sudo gluster --version > /tmp/gluster.log 2>&1"); if (rtnCode == 0) { @@ -5459,28 +5723,34 @@ void setSystemName() Oam oam; //setup System Name - try - { - systemName = sysConfig->getConfig(SystemSection, "SystemName"); - } - catch (...) - { - systemName = oam::UnassignedName; - } - + + if ( systemName.empty() ) + { + try { + systemName = sysConfig->getConfig(SystemSection, "SystemName"); + } + catch(...) + { + systemName = oam::UnassignedName; + } + } + if ( systemName.empty() ) - systemName = oam::UnassignedName; + systemName = "columnstore-1"; - prompt = "Enter System Name (" + systemName + ") > "; - pcommand = callReadline(prompt.c_str()); + if (!single_server_quick_install || !multi_server_quick_install) + { + prompt = "Enter System Name (" + systemName + ") > "; + pcommand = callReadline(prompt.c_str()); - if (pcommand) - { - if (strlen(pcommand) > 0) systemName = pcommand; - - callFree(pcommand); - } + if (pcommand) + { + if (strlen(pcommand) > 0) systemName = pcommand; + callFree(pcommand); + } + } + try { sysConfig->setConfig(SystemSection, "SystemName", systemName); @@ -5550,7 +5820,10 @@ bool updateBash() string cmd = "echo . " + installDir + "/bin/" + DataFileEnvFile + " >> " + fileName; system(cmd.c_str()); - cmd = "su - hdfs -c 'hadoop fs -mkdir -p " + installDir + ";hadoop fs -chown root:root " + installDir + "' >/dev/null 2>&1"; + if ( rootUser) + cmd = "su - hdfs -c 'hadoop fs -mkdir -p " + installDir + ";hadoop fs -chown root:root " + installDir + "' >/dev/null 2>&1"; + else + cmd = "sudo su - hdfs -c 'hadoop fs -mkdir -p " + installDir + ";hadoop fs -chown " + USER + ":" + USER + " " + installDir + "' >/dev/null 2>&1"; system(cmd.c_str()); } @@ -6438,7 +6711,67 @@ bool glusterSetup(string password) cout << "ERROR: failed to make directory(" << DataRedundancyConfigs[pm].pmIpAddr << "): '" << command << "'" << endl; exit(1); } - } + + /* + if (dataRedundancyStorage == 2) + { + //walk data storage locations and modify fstab to reflect the storage locations entered by user + vector::iterator storageSetupIter=DataRedundancyConfigs[pm].storageLocations.begin(); + for (; storageSetupIter < DataRedundancyConfigs[pm].storageLocations.end(); storageSetupIter++ ) + { + if (rootUser) + { + command = remoteCommand + DataRedundancyConfigs[pm].pmIpAddr + " " + password + + " 'echo " + (*storageSetupIter).storageLocation + " " + + installDir + "/gluster/brick" + oam.itoa(brick) + " " + + (*storageSetupIter).storageFilesytemType + " defaults 1 2 >> /etc/fstab'"; + } + else + { + command = remoteCommand + DataRedundancyConfigs[pm].pmIpAddr + " " + password + + " 'sudo bash -c `sudo echo " + (*storageSetupIter).storageLocation + " " + + installDir + "/gluster/brick" + oam.itoa(brick) + " " + + (*storageSetupIter).storageFilesytemType + " defaults 1 2 >> /etc/fstab`'"; + } + status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + cout << "ERROR: command failed: " << command << endl; + exit(1); + } + if (rootUser) + { + command = remoteCommand + DataRedundancyConfigs[pm].pmIpAddr + " " + password + + " 'mount " + installDir + "/gluster/brick" + oam.itoa(brick) + "'"; + } + else + { + command = remoteCommand + DataRedundancyConfigs[pm].pmIpAddr + " " + password + + " 'sudo bash -c `sudo mount " + installDir + "/gluster/brick" + oam.itoa(brick) + "`'"; + } + status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + cout << "ERROR: command failed: " << command << endl; + exit(1); + } + if (!rootUser) + { + int user; + user = getuid(); + command = remoteCommand + DataRedundancyConfigs[pm].pmIpAddr + " " + password + + "'sudo bash -c `sudo chown -R " + oam.itoa(user) + ":" + oam.itoa(user) + " " + installDir + "/gluster/brick" + oam.itoa(brick) + "`'"; + status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + cout << "ERROR(" << status <<"): command failed: " << command << endl; + } + } + + } + } + */ + } string errmsg1; string errmsg2; @@ -6452,7 +6785,14 @@ bool glusterSetup(string password) sleep(5); - command = "gluster peer status >> /tmp/glusterCommands.txt 2>&1"; + if (rootUser) + { + command = "gluster peer status >> /tmp/glusterCommands.txt 2>&1"; + } + else + { + command = "sudo gluster peer status >> /tmp/glusterCommands.txt 2>&1"; + } status = system(command.c_str()); @@ -6477,7 +6817,14 @@ bool glusterSetup(string password) { int dbrootID = db + 1; - command = "gluster volume create dbroot" + oam.itoa(dbrootID) + " transport tcp replica " + oam.itoa(dataRedundancyCopies) + " "; + if (rootUser) + { + command = "gluster volume create dbroot" + oam.itoa(dbrootID) + " transport tcp replica " + oam.itoa(dataRedundancyCopies) + " "; + } + else + { + command = "sudo gluster volume create dbroot" + oam.itoa(dbrootID) + " transport tcp replica " + oam.itoa(dataRedundancyCopies) + " "; + } vector::iterator dbrootPmIter = dbrootPms[db].begin(); @@ -6536,7 +6883,7 @@ bool glusterSetup(string password) { int user = getuid(); int group = getgid(); - command = "gluster volume set dbroot" + oam.itoa(dbrootID) + " storage.owner-uid " + oam.itoa(user) + " >> /tmp/glusterCommands.txt 2>&1";; + command = "sudo gluster volume set dbroot" + oam.itoa(dbrootID) + " storage.owner-uid " + oam.itoa(user) + " >> /tmp/glusterCommands.txt 2>&1";; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -6545,7 +6892,7 @@ bool glusterSetup(string password) exit(1); } - command = "gluster volume set dbroot" + oam.itoa(dbrootID) + " storage.owner-gid " + oam.itoa(group) + " >> /tmp/glusterCommands.txt 2>&1";; + command = "sudo gluster volume set dbroot" + oam.itoa(dbrootID) + " storage.owner-gid " + oam.itoa(group) + " >> /tmp/glusterCommands.txt 2>&1";; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -6554,7 +6901,7 @@ bool glusterSetup(string password) exit(1); } - command = "gluster volume start dbroot" + oam.itoa(dbrootID) + " >> /tmp/glusterCommands.txt 2>&1"; + command = "sudo gluster volume start dbroot" + oam.itoa(dbrootID) + " >> /tmp/glusterCommands.txt 2>&1"; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) diff --git a/procmon/main.cpp b/procmon/main.cpp index 73de5c0fa..eb2e6dd1f 100644 --- a/procmon/main.cpp +++ b/procmon/main.cpp @@ -338,11 +338,12 @@ int main(int argc, char** argv) // check if standby never replied, if so, shutdown if ( count >= 120 ) { - log.writeLog(__LINE__, "Standby PM not responding, columnstore shutting down", LOG_TYPE_CRITICAL); - //Set the alarm, commented out. alarm require ProcMgr - //aMonitor.sendAlarm(config.moduleName().c_str(), STARTUP_DIAGNOTICS_FAILURE, SET); - sleep (1); - string cmd = startup::StartUp::installDir() + "/bin/columnstore stop > /dev/null 2>&1"; + log.writeLog(__LINE__, "Standby PM not responding, infinidb shutting down", LOG_TYPE_CRITICAL); + //Set the alarm + // aMonitor.sendAlarm(config.moduleName().c_str(), STARTUP_DIAGNOTICS_FAILURE, SET); + // sleep (1); + + string cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /dev/null 2>&1"; system(cmd.c_str()); } @@ -369,8 +370,7 @@ int main(int argc, char** argv) sysConfig->setConfig("ProcMgr_Alarm", "IPAddr", IPaddr); log.writeLog(__LINE__, "set ProcMgr IPaddr to Old Standby Module: " + IPaddr, LOG_TYPE_DEBUG); - - //update Calpont Config table + //update MariaDB ColumnStore Config table try { sysConfig->write(); @@ -437,7 +437,7 @@ int main(int argc, char** argv) } catch (...) { - log.writeLog(__LINE__, "waiting for good return from getModuleStatus", LOG_TYPE_DEBUG); + log.writeLog(__LINE__, "wating for good return from getModuleStatus", LOG_TYPE_DEBUG); sleep (1); } } @@ -553,9 +553,9 @@ int main(int argc, char** argv) if ( retry == 20 ) { log.writeLog(__LINE__, "Check DB mounts failed, shutting down", LOG_TYPE_CRITICAL); - //Set the alarm, commented out. alarm require ProcMgr - //aMonitor.sendAlarm(config.moduleName().c_str(), STARTUP_DIAGNOTICS_FAILURE, SET); - sleep (1); + //Set the alarm + // aMonitor.sendAlarm(config.moduleName().c_str(), STARTUP_DIAGNOTICS_FAILURE, SET); + // sleep (1); string cmd = startup::StartUp::installDir() + "/bin/columnstore stop > /dev/null 2>&1"; system(cmd.c_str()); } @@ -582,7 +582,7 @@ int main(int argc, char** argv) while (!mainResumeFlag) { - log.writeLog(__LINE__, "WAITING FOR mainResumeFlag to be set", LOG_TYPE_DEBUG); + log.writeLog(__LINE__, "WATING FOR mainResumeFlag to be set", LOG_TYPE_DEBUG); sleep(1); } @@ -774,11 +774,11 @@ int main(int argc, char** argv) if ( ret != 0 ) log.writeLog(__LINE__, "pthread_create failed, return code = " + oam.itoa(ret), LOG_TYPE_ERROR); - //mysql status monitor thread - if ( ( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM ) || - (PMwithUM == "y") ) + //mysqld status monitor thread + if ( config.moduleType() == "um" || + ( config.moduleType() == "pm" && config.ServerInstallType() == oam::INSTALL_COMBINE_DM_UM_PM ) || + ( config.moduleType() == "pm" && PMwithUM == "y") ) { - pthread_t mysqlThread; ret = pthread_create (&mysqlThread, NULL, (void* (*)(void*)) &mysqlMonitorThread, NULL); @@ -1131,6 +1131,9 @@ static void messageThread(MonitorConfig config) string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1"; + if ( !rootUser) + cmd = "sudo fuser -k " + port + "/tcp >/dev/null 2>&1"; + system(cmd.c_str()); for (;;) @@ -1223,7 +1226,7 @@ static void mysqlMonitorThread(MonitorConfig config) catch (...) {} - sleep(10); + sleep(5); } } @@ -1460,7 +1463,7 @@ static void chldHandleThread(MonitorConfig config) (*listPtr).processID != 0 ) || ( (*listPtr).state == oam::ACTIVE && (*listPtr).processID == 0 ) ) { - log.writeLog(__LINE__, "*****Calpont Process Restarting: " + (*listPtr).ProcessName + ", old PID = " + oam.itoa((*listPtr).processID), LOG_TYPE_CRITICAL); + log.writeLog(__LINE__, "*****MariaDB ColumnStore Process Restarting: " + (*listPtr).ProcessName + ", old PID = " + oam.itoa((*listPtr).processID), LOG_TYPE_CRITICAL); if ( (*listPtr).dieCounter >= processRestartCount || processRestartCount == 0) @@ -1520,7 +1523,7 @@ static void chldHandleThread(MonitorConfig config) {} // check if process failover is needed due to process outage - aMonitor.checkProcessFailover((*listPtr).ProcessName); + aMonitor.checkModuleFailover((*listPtr).ProcessName); //check the db health if (DBFunctionalMonitorFlag == "y" ) @@ -1602,7 +1605,7 @@ static void chldHandleThread(MonitorConfig config) (*listPtr).processID = 0; // check if process failover is needed due to process outage - aMonitor.checkProcessFailover((*listPtr).ProcessName); + aMonitor.checkModuleFailover((*listPtr).ProcessName); break; } else @@ -1678,7 +1681,7 @@ static void chldHandleThread(MonitorConfig config) } //Log this event - log.writeLog(__LINE__, "Calpont Process " + (*listPtr).ProcessName + restartStatus, LOG_TYPE_INFO); + log.writeLog(__LINE__, "MariaDB ColumnStore Process " + (*listPtr).ProcessName + restartStatus, LOG_TYPE_INFO); } } } @@ -2360,7 +2363,10 @@ static void statusControlThread() string port = sysConfig->getConfig(portName, "Port"); string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1"; - system(cmd.c_str()); + if ( !rootUser) + cmd = "sudo fuser -k " + port + "/tcp >/dev/null 2>&1"; + + system(cmd.c_str()); } catch (...) { @@ -2701,6 +2707,9 @@ void processStatusMSG(messageqcpp::IOSocket* cfIos) memcpy(fShmSystemStatus[0].StateChangeDate, oam.getCurrentTime().c_str(), DATESIZE); log.writeLog(__LINE__, "statusControl: REQUEST RECEIVED: Set System State = " + oamState[state], LOG_TYPE_DEBUG); } + + BRM::DBRM dbrm; + dbrm.setSystemQueryReady(true); } } break; diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index 6efb0105c..2eb038189 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -484,7 +484,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO log.writeLog(__LINE__, "MSG RECEIVED: Stop process request on " + processName); int requestStatus = API_SUCCESS; - // check for mysql + // check for mysqld if ( processName == "mysqld" ) { try @@ -553,7 +553,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO msg >> manualFlag; log.writeLog(__LINE__, "MSG RECEIVED: Start process request on: " + processName); - // check for mysql + // check for mysqld if ( processName == "mysqld" ) { try @@ -684,7 +684,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO log.writeLog(__LINE__, "MSG RECEIVED: Restart process request on " + processName); int requestStatus = API_SUCCESS; - // check for mysql restart + // check for mysqld restart if ( processName == "mysqld" ) { try @@ -933,7 +933,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO log.writeLog(__LINE__, "Error running DBRM clearShm", LOG_TYPE_ERROR); } - //stop the mysql daemon + //stop the mysqld daemon try { oam.actionMysqlCalpont(MYSQL_STOP); @@ -1063,21 +1063,14 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO int requestStatus = oam::API_SUCCESS; log.writeLog(__LINE__, "MSG RECEIVED: Start All process request..."); - // change permissions on /dev/shm - string cmd = "chmod 755 /dev/shm >/dev/null 2>&1"; - - if ( !rootUser) - cmd = "chmod 777 /dev/shm >/dev/null 2>&1"; - - system(cmd.c_str()); - - //start the mysql daemon + //start the mysqld daemon try { oam.actionMysqlCalpont(MYSQL_START); } catch (...) { + // mysqld didn't start, return with error // mysql didn't start, return with error log.writeLog(__LINE__, "STARTALL: MySQL failed to start, start-module failure", LOG_TYPE_CRITICAL); @@ -1268,7 +1261,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO // error in launching a process if ( requestStatus == oam::API_FAILURE && (*listPtr).RunType == SIMPLEX) - checkProcessFailover((*listPtr).ProcessName); + checkModuleFailover((*listPtr).ProcessName); else break; } @@ -1366,7 +1359,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO //send down notification oam.sendDeviceNotification(config.moduleName(), MODULE_DOWN); - //stop the mysql daemon and then columnstore + //stop the mysqld daemon and then columnstore try { oam.actionMysqlCalpont(MYSQL_STOP); } @@ -1548,7 +1541,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO } } - // install mysql rpms if being reconfigured as a um + // install mysqld rpms if being reconfigured as a um if ( reconfigureModuleName.find("um") != string::npos ) { string cmd = startup::StartUp::installDir() + "/bin/post-mysqld-install >> /tmp/rpminstall"; @@ -1769,10 +1762,20 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO if (!oam.checkLogStatus("/tmp/umount.txt", "busy")) break; - cmd = "lsof " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; - system(cmd.c_str()); - cmd = "fuser -muvf " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; - system(cmd.c_str()); + if ( rootUser) + { + cmd = "lsof " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; + system(cmd.c_str()); + cmd = "fuser -muvf " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; + system(cmd.c_str()); + } + else + { + cmd = "sudo lsof " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; + system(cmd.c_str()); + cmd = "sudo fuser -muvf " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; + system(cmd.c_str()); + } sleep(2); //Flush the cache @@ -1831,7 +1834,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO if ( !rootUser) { - cmd = "chown -R " + USER + ":" + USER + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > /dev/null"; + cmd = "sudo chown -R " + USER + ":" + USER + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > /dev/null"; system(cmd.c_str()); } @@ -1873,7 +1876,15 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO if (WEXITSTATUS(status) != 0 ) { - cmd = "echo " + entry + " >> /etc/fstab"; + if ( rootUser) + { + cmd = "echo " + entry + " >> /etc/fstab"; + } + else + { + cmd = "sudo echo " + entry + " >> /etc/fstab"; + } + system(cmd.c_str()); log.writeLog(__LINE__, "Add line entry to /etc/fstab : " + entry); @@ -1885,7 +1896,14 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO if (WEXITSTATUS(status) != 0 ) { - cmd = "echo " + entry + " >> " + startup::StartUp::installDir() + "/local/etc/pm1/fstab"; + if ( rootUser) + { + cmd = "echo " + entry + " >> " + startup::StartUp::installDir() + "/local/etc/pm1/fstab"; + } + else + { + cmd = "sudo echo " + entry + " >> " + startup::StartUp::installDir() + "/local/etc/pm1/fstab"; + } system(cmd.c_str()); @@ -1897,7 +1915,14 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO string::size_type pos1 = entry.find(" ", pos + 1); string directory = entry.substr(pos + 1, pos1 - pos); - cmd = "mkdir " + directory; + if ( rootUser) + { + cmd = "mkdir " + directory; + } + else + { + cmd = "sudo mkdir " + directory; + } system(cmd.c_str()); log.writeLog(__LINE__, "create directory: " + directory); @@ -3109,7 +3134,7 @@ int ProcessMonitor::updateLog(std::string action, std::string level) //if non-root, change file permissions so we can update it if ( !rootUser) { - string cmd = "chmod 666 " + fileName + " > /dev/null"; + string cmd = "sudo chmod 666 " + fileName + " > /dev/null"; system(cmd.c_str()); } @@ -4938,20 +4963,19 @@ std::string ProcessMonitor::sendMsgProcMon1( std::string module, ByteStream msg, } /****************************************************************************************** -* @brief checkProcessFailover +* @brief checkModuleFailover * -* purpose: check if process failover is needed due to a process outage +* purpose: check if module failover is needed due to a process outage * ******************************************************************************************/ -void ProcessMonitor::checkProcessFailover( std::string processName) +void ProcessMonitor::checkModuleFailover( std::string processName) { Oam oam; //force failover on certain processes if ( processName == "DDLProc" || - processName == "DMLProc" ) - { - log.writeLog(__LINE__, "checkProcessFailover: process failover, process outage of " + processName, LOG_TYPE_CRITICAL); + processName == "DMLProc" ) { + log.writeLog(__LINE__, "checkModuleFailover: process failover, process outage of " + processName, LOG_TYPE_CRITICAL); try { @@ -4974,27 +4998,36 @@ void ProcessMonitor::checkProcessFailover( std::string processName) systemprocessstatus.processstatus[i].ProcessOpState == oam::FAILED ) { // found a AVAILABLE mate, start it - log.writeLog(__LINE__, "start process on module " + systemprocessstatus.processstatus[i].Module, LOG_TYPE_DEBUG); + log.writeLog(__LINE__, "Change UM Master to module " + systemprocessstatus.processstatus[i].Module, LOG_TYPE_DEBUG); + log.writeLog(__LINE__, "Disable local UM module " + config.moduleName(), LOG_TYPE_DEBUG); + log.writeLog(__LINE__, "Stop local UM module " + config.moduleName(), LOG_TYPE_DEBUG); + log.writeLog(__LINE__, "Disable Local will Enable UM module " + systemprocessstatus.processstatus[i].Module, LOG_TYPE_DEBUG); + + oam::DeviceNetworkConfig devicenetworkconfig; + oam::DeviceNetworkList devicenetworklist; + + devicenetworkconfig.DeviceName = config.moduleName(); + devicenetworklist.push_back(devicenetworkconfig); try { - oam.setSystemConfig("PrimaryUMModuleName", systemprocessstatus.processstatus[i].Module); + oam.stopModule(devicenetworklist, oam::FORCEFUL, oam::ACK_YES); + log.writeLog(__LINE__, "success stopModule on module " + config.moduleName(), LOG_TYPE_DEBUG); - //distribute config file - oam.distributeConfigFile("system"); - sleep(1); - } - catch (...) {} - - try - { - oam.startProcess(systemprocessstatus.processstatus[i].Module, processName, FORCEFUL, ACK_YES); - log.writeLog(__LINE__, "success start process on module " + systemprocessstatus.processstatus[i].Module, LOG_TYPE_DEBUG); - } - catch (exception& e) - { - log.writeLog(__LINE__, "failed start process on module " + systemprocessstatus.processstatus[i].Module, LOG_TYPE_ERROR); + try + { + oam.disableModule(devicenetworklist); + log.writeLog(__LINE__, "success disableModule on module " + config.moduleName(), LOG_TYPE_DEBUG); + } + catch (exception& e) + { + log.writeLog(__LINE__, "failed disableModule on module " + config.moduleName(), LOG_TYPE_ERROR); + } } + catch (exception& e) + { + log.writeLog(__LINE__, "failed stopModule on module " + config.moduleName(), LOG_TYPE_ERROR); + } break; } @@ -5011,9 +5044,6 @@ void ProcessMonitor::checkProcessFailover( std::string processName) // log.writeLog(__LINE__, "EXCEPTION ERROR on getProcessStatus: Caught unknown exception!", LOG_TYPE_ERROR); } } - - return; - } /****************************************************************************************** @@ -5194,10 +5224,16 @@ int ProcessMonitor::changeMyCnf(std::string type) // set owner and permission string cmd = "chmod 664 " + mycnfFile + " >/dev/null 2>&1"; + if ( !rootUser) + cmd = "sudo chmod 644 " + mycnfFile + " >/dev/null 2>&1"; + system(cmd.c_str()); cmd = "chown mysql:mysql " + mycnfFile + " >/dev/null 2>&1"; + if ( !rootUser) + cmd = "sudo chown mysql:mysql " + mycnfFile + " >/dev/null 2>&1"; + system(cmd.c_str()); // restart mysql @@ -5951,7 +5987,10 @@ bool ProcessMonitor::amazonVolumeCheck(int dbrootID) { string cmd; - cmd = "mount " + deviceName + " " + startup::StartUp::installDir() + "/mysql/db -t ext2 -o defaults > /tmp/um_mount.log"; + if ( rootUser) + cmd = "mount " + deviceName + " " + startup::StartUp::installDir() + "/mysql/db -t ext2 -o defaults > /tmp/um_mount.log"; + else + cmd = "sudo mount " + deviceName + " " + startup::StartUp::installDir() + "/mysql/db -t ext2 -o defaults > /tmp/um_mount.log"; system(cmd.c_str()); log.writeLog(__LINE__, "mount cmd: " + cmd, LOG_TYPE_DEBUG); @@ -6360,7 +6399,7 @@ int ProcessMonitor::checkDataMount() if ( !rootUser) { - cmd = "chown -R " + USER + ":" + USER + " " + dbroot + " > /dev/null"; + cmd = "sudo chown -R " + USER + ":" + USER + " " + dbroot + " > /dev/null"; system(cmd.c_str()); } @@ -6534,13 +6573,23 @@ int ProcessMonitor::glusterAssign(std::string dbrootID) moduleIPAddr = sysConfig->getConfig("SystemModuleConfig", dataDupIPaddr); } - command = "mount -tglusterfs -odirect-io-mode=enable " + moduleIPAddr + ":/dbroot" + + if ( rootUser) + { + command = "mount -tglusterfs -odirect-io-mode=enable " + moduleIPAddr + ":/dbroot" + dbrootID + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterAssign.txt 2>&1"; + } + else + { + command = "sudo mount -tglusterfs -odirect-io-mode=enable " + moduleIPAddr + ":/dbroot" + + dbrootID + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterAssign.txt 2>&1"; + } int ret = system(command.c_str()); if ( WEXITSTATUS(ret) != 0 ) { + log.writeLog(__LINE__, "glusterAssign mount failure: dbroot: " + dbrootID + " error: " + oam.itoa(WEXITSTATUS(ret)), LOG_TYPE_ERROR); + ifstream in("/tmp/glusterAssign.txt"); in.seekg(0, std::ios::end); int size = in.tellg(); @@ -6575,12 +6624,21 @@ int ProcessMonitor::glusterUnassign(std::string dbrootID) log.writeLog(__LINE__, "glusterUnassign called: " + dbrootID, LOG_TYPE_DEBUG); - command = "umount -f " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterUnassign.txt 2>&1"; + if ( rootUser) + { + command = "umount -f " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterUnassign.txt 2>&1"; + } + else + { + command = "sudo umount -f " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterUnassign.txt 2>&1"; + } int ret = system(command.c_str()); if ( WEXITSTATUS(ret) != 0 ) { + log.writeLog(__LINE__, "glusterUnassign mount failure: dbroot: " + dbrootID + " error: " + oam.itoa(WEXITSTATUS(ret)), LOG_TYPE_ERROR); + ifstream in("/tmp/glusterUnassign.txt"); in.seekg(0, std::ios::end); int size = in.tellg();