1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

mcol-1009 and mcol-1014

This commit is contained in:
david hill
2017-11-06 17:46:07 -06:00
parent 6062ac034f
commit 4f63212145
13 changed files with 333 additions and 277 deletions

View File

@ -53,7 +53,7 @@ infinidb_compression_type=2
infinidb_stringtable_threshold=20 infinidb_stringtable_threshold=20
# infinidb local query flag # infinidb local query flag
# infinidb_local_query=1 infinidb_local_query=0
infinidb_diskjoin_smallsidelimit=0 infinidb_diskjoin_smallsidelimit=0
infinidb_diskjoin_largesidelimit=0 infinidb_diskjoin_largesidelimit=0

View File

@ -61,7 +61,7 @@ datadir=$basedir/db
# Value here is overriden by value in my.cnf. # Value here is overriden by value in my.cnf.
# 0 means don't wait at all # 0 means don't wait at all
# Negative numbers mean to wait indefinitely # Negative numbers mean to wait indefinitely
service_startup_timeout=30 service_startup_timeout=60
# Lock directory for RedHat / SuSE. # Lock directory for RedHat / SuSE.
lockdir='/var/lock/subsys' lockdir='/var/lock/subsys'
@ -262,6 +262,8 @@ wait_for_gone () {
done done
log_failure_msg log_failure_msg
kill_by_pid
return 1 return 1
} }
@ -310,7 +312,7 @@ fi
kill_by_pid() { kill_by_pid() {
# let's see if we can kill the 2 mysql procs by hand # let's see if we can kill the 2 mysql procs by hand
# get the our mysql from ps # get the our mysql from ps
eval $(ps -ef | grep "$COLUMNSTORE_INSTALL_DIR/mysql//bin/mysqld" | grep -v grep | head -1 | awk '{printf "pid=%d\n", $2}') eval $(ps -ef | grep "$COLUMNSTORE_INSTALL_DIR/mysql/bin/mysqld" | grep -v grep | head -1 | awk '{printf "pid=%d\n", $2}')
if [ -n "$pid" ]; then if [ -n "$pid" ]; then
ppid=$(ps -o ppid= -p $pid) ppid=$(ps -o ppid= -p $pid)
@ -369,6 +371,7 @@ case "$mode" in
wait_for_gone $mysqld_pid "$mysqld_pid_file_path"; return_value=$? wait_for_gone $mysqld_pid "$mysqld_pid_file_path"; return_value=$?
else else
log_failure_msg "MySQL server process #$mysqld_pid is not running!" log_failure_msg "MySQL server process #$mysqld_pid is not running!"
kill_by_pid
rm "$mysqld_pid_file_path" rm "$mysqld_pid_file_path"
fi fi

View File

@ -226,7 +226,7 @@
<SystemConfig> <SystemConfig>
<SystemLang>C</SystemLang> <SystemLang>C</SystemLang>
<SystemName>columnstore-1</SystemName> <SystemName>columnstore-1</SystemName>
<ParentOAMModuleName>unassigned</ParentOAMModuleName> <ParentOAMModuleName>pm1</ParentOAMModuleName>
<StandbyOAMModuleName>unassigned</StandbyOAMModuleName> <StandbyOAMModuleName>unassigned</StandbyOAMModuleName>
<PrimaryUMModuleName>unassigned</PrimaryUMModuleName> <PrimaryUMModuleName>unassigned</PrimaryUMModuleName>
<ModuleHeartbeatPeriod>1</ModuleHeartbeatPeriod> <ModuleHeartbeatPeriod>1</ModuleHeartbeatPeriod>

View File

@ -33,6 +33,7 @@ install(PROGRAMS post-install
myCnf-include-args.text myCnf-include-args.text
myCnf-exclude-args.text myCnf-exclude-args.text
columnstore.service columnstore.service
mariadb-command-line.sh
DESTINATION ${ENGINE_BINDIR} COMPONENT platform) DESTINATION ${ENGINE_BINDIR} COMPONENT platform)
install(FILES module DESTINATION ${ENGINE_LOCALDIR} COMPONENT platform) install(FILES module DESTINATION ${ENGINE_LOCALDIR} COMPONENT platform)

View File

@ -0,0 +1,59 @@
#!/bin/bash
#
# $Id$
#
# generic MariaDB Columnstore Command Line script.
#
# Notes: This script gets run by ProcMon during installs and upgrades:
# check log for error
checkForError() {
grep ERROR /tmp/mariadb-command-line.log > /tmp/error.check
if [ `cat /tmp/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file: /tmp/mariadb-command-line.log"
rm -f /tmp/error.check
exit 1
fi
rm -f /tmp/error.check
}
prefix=/usr/local
installdir=$prefix/mariadb/columnstore
pwprompt=
for arg in "$@"; do
if [ `expr -- "$arg" : '--command='` -eq 10 ]; then
command1="`echo $arg | awk -F= '{print $2}'`"
command2="`echo $arg | awk -F= '{print $3}'`"
command=$command1"="$command2
elif [ `expr -- "$arg" : '--installdir='` -eq 13 ]; then
installdir="`echo $arg | awk -F= '{print $2}'`"
prefix=`dirname $installdir`
elif [ `expr -- "$arg" : '--port='` -eq 7 ]; then
port="`echo $arg | awk -F= '{print $2}'`"
fi
done
test -f $installdir/post/functions && . $installdir/post/functions
>/tmp/mariadb-command-line.log
#
# Run command
#
echo "Run command" >>/tmp/mariadb-command-line.log
cat >/tmp/mariadb-command-line.sql <<EOD
$command;
EOD
cat /tmp/mariadb-command-line.sql >> /tmp/mariadb-command-line.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root \
calpontsys < /tmp/mariadb-command-line.sql >> /tmp/mariadb-command-line.log 2>&1
checkForError
#alls good, 'OK' for success
echo "OK"
exit 0

View File

@ -24,9 +24,6 @@ for arg in "$@"; do
if [ `expr -- "$arg" : '--prefix='` -eq 9 ]; then if [ `expr -- "$arg" : '--prefix='` -eq 9 ]; then
prefix="`echo $arg | awk -F= '{print $2}'`" prefix="`echo $arg | awk -F= '{print $2}'`"
installdir=$prefix/mariadb/columnstore installdir=$prefix/mariadb/columnstore
elif [ `expr -- "$arg" : '--password='` -eq 11 ]; then
password="`echo $arg | awk -F= '{print $2}'`"
pwprompt="--password=$password"
elif [ `expr -- "$arg" : '--installdir='` -eq 13 ]; then elif [ `expr -- "$arg" : '--installdir='` -eq 13 ]; then
installdir="`echo $arg | awk -F= '{print $2}'`" installdir="`echo $arg | awk -F= '{print $2}'`"
prefix=`dirname $installdir` prefix=`dirname $installdir`
@ -54,7 +51,7 @@ EOD
cat /tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log cat /tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log
$installdir/mysql/bin/mysql \ $installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \ --defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \ --user=root \
calpontsys </tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log 2>&1 calpontsys </tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log 2>&1
checkForError checkForError
@ -72,7 +69,7 @@ EOD
cat /tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log cat /tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log
$installdir/mysql/bin/mysql \ $installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \ --defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \ --user=root \
calpontsys </tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log 2>&1 calpontsys </tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log 2>&1
checkForError checkForError
@ -88,7 +85,7 @@ EOD
cat /tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log cat /tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log
$installdir/mysql/bin/mysql \ $installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \ --defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \ --user=root \
calpontsys </tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log 2>&1 calpontsys </tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log 2>&1
checkForError checkForError
@ -101,7 +98,7 @@ EOD
cat /tmp/idb_master-rep.sql >/tmp/show-master-status.log cat /tmp/idb_master-rep.sql >/tmp/show-master-status.log
$installdir/mysql/bin/mysql \ $installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \ --defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \ --user=root \
calpontsys </tmp/idb_master-rep.sql >>/tmp/show-master-status.log calpontsys </tmp/idb_master-rep.sql >>/tmp/show-master-status.log

View File

@ -24,9 +24,6 @@ for arg in "$@"; do
if [ `expr -- "$arg" : '--prefix='` -eq 9 ]; then if [ `expr -- "$arg" : '--prefix='` -eq 9 ]; then
prefix="`echo $arg | awk -F= '{print $2}'`" prefix="`echo $arg | awk -F= '{print $2}'`"
installdir=$prefix/mariadb/columnstore installdir=$prefix/mariadb/columnstore
elif [ `expr -- "$arg" : '--password='` -eq 11 ]; then
password="`echo $arg | awk -F= '{print $2}'`"
pwprompt="--password=$password"
elif [ `expr -- "$arg" : '--installdir='` -eq 13 ]; then elif [ `expr -- "$arg" : '--installdir='` -eq 13 ]; then
installdir="`echo $arg | awk -F= '{print $2}'`" installdir="`echo $arg | awk -F= '{print $2}'`"
prefix=`dirname $installdir` prefix=`dirname $installdir`
@ -59,7 +56,7 @@ EOD
cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log
$installdir/mysql/bin/mysql \ $installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \ --defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \ --user=root \
calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1 calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1
checkForError checkForError
@ -82,7 +79,7 @@ EOD
cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log
$installdir/mysql/bin/mysql \ $installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \ --defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \ --user=root \
calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1 calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1
checkForError checkForError
@ -98,7 +95,7 @@ EOD
cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log
$installdir/mysql/bin/mysql \ $installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \ --defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \ --user=root \
calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1 calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1
checkForError checkForError
@ -114,7 +111,7 @@ EOD
cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log
$installdir/mysql/bin/mysql \ $installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \ --defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \ --user=root \
calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1 calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1
checkForError checkForError

View File

@ -368,7 +368,7 @@ int sendUpgradeRequest(int IserverTypeInstall, bool pmwithum)
* *
* *
******************************************************************************************/ ******************************************************************************************/
int sendReplicationRequest(int IserverTypeInstall, std::string password, std::string port, bool pmwithum) int sendReplicationRequest(int IserverTypeInstall, std::string password, bool pmwithum)
{ {
Oam oam; Oam oam;
@ -459,7 +459,7 @@ int sendReplicationRequest(int IserverTypeInstall, std::string password, std::st
{ // set for slave repl request { // set for slave repl request
// don't do PMs unless PMwithUM flag is set // don't do PMs unless PMwithUM flag is set
string moduleType = (*pt).DeviceName.substr(0,MAX_MODULE_TYPE_SIZE); string moduleType = (*pt).DeviceName.substr(0,MAX_MODULE_TYPE_SIZE);
if ( ( moduleType == "pm" && !pmwithum ) && if ( ( moduleType == "pm" && !pmwithum ) &&
( IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM ) ) { ( IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM ) ) {
pt++; pt++;
@ -476,7 +476,6 @@ int sendReplicationRequest(int IserverTypeInstall, std::string password, std::st
msg << masterLogFile; msg << masterLogFile;
msg << masterLogPos; msg << masterLogPos;
msg << port;
returnStatus = sendMsgProcMon( (*pt).DeviceName, msg, requestID, 30 ); returnStatus = sendMsgProcMon( (*pt).DeviceName, msg, requestID, 30 );

View File

@ -39,7 +39,7 @@ extern void dbrmDirCheck();
extern void mysqlSetup(); extern void mysqlSetup();
extern int sendMsgProcMon( std::string module, ByteStream msg, int requestID, int timeout ); extern int sendMsgProcMon( std::string module, ByteStream msg, int requestID, int timeout );
extern int sendUpgradeRequest(int IserverTypeInstall, bool pmwithum); extern int sendUpgradeRequest(int IserverTypeInstall, bool pmwithum);
extern int sendReplicationRequest(int IserverTypeInstall, std::string password, std::string mysqlPort, bool pmwithum); extern int sendReplicationRequest(int IserverTypeInstall, std::string password, bool pmwithum);
extern void checkFilesPerPartion(int DBRootCount, Config* sysConfig); extern void checkFilesPerPartion(int DBRootCount, Config* sysConfig);
extern void checkMysqlPort( string& mysqlPort, Config* sysConfig); extern void checkMysqlPort( string& mysqlPort, Config* sysConfig);
extern bool writeConfig(Config* sysConfig); extern bool writeConfig(Config* sysConfig);

View File

@ -3497,7 +3497,7 @@ int main(int argc, char *argv[])
cout.flush(); cout.flush();
//send message to procmon's to run mysql replication script //send message to procmon's to run mysql replication script
int status = sendReplicationRequest(IserverTypeInstall, password, mysqlPort, pmwithum); int status = sendReplicationRequest(IserverTypeInstall, password, pmwithum);
if ( status != 0 ) { if ( status != 0 ) {
cout << endl << " MariaDB ColumnStore Install Failed" << endl << endl; cout << endl << " MariaDB ColumnStore Install Failed" << endl << endl;

View File

@ -10328,18 +10328,6 @@ int ProcessManager::setMySQLReplication(oam::DeviceNetworkList devicenetworklist
*/ */
log.writeLog(__LINE__, "Setup MySQL Replication", LOG_TYPE_DEBUG); log.writeLog(__LINE__, "Setup MySQL Replication", LOG_TYPE_DEBUG);
// mysql port number
string MySQLPort;
try {
oam.getSystemConfig("MySQLPort", MySQLPort);
}
catch(...) {
MySQLPort = "3306";
}
if ( MySQLPort.empty() )
MySQLPort = "3306";
//get master info //get master info
if ( masterModule == oam::UnassignedName) if ( masterModule == oam::UnassignedName)
{ {
@ -10390,6 +10378,13 @@ int ProcessManager::setMySQLReplication(oam::DeviceNetworkList devicenetworklist
if ( remoteModuleName == masterModule ) if ( remoteModuleName == masterModule )
continue; continue;
// don't do PMs unless PMwithUM flag is set
if ( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM ) {
string moduleType = remoteModuleName.substr(0,MAX_MODULE_TYPE_SIZE);
if ( moduleType == "pm" && PMwithUM == "n" )
continue;
}
ByteStream msg; ByteStream msg;
ByteStream::byte requestID = oam::MASTERDIST; ByteStream::byte requestID = oam::MASTERDIST;
msg << requestID; msg << requestID;
@ -10485,7 +10480,6 @@ int ProcessManager::setMySQLReplication(oam::DeviceNetworkList devicenetworklist
msg1 << masterLogFile; msg1 << masterLogFile;
msg1 << masterLogPos; msg1 << masterLogPos;
msg1 << MySQLPort;
} }
returnStatus = sendMsgProcMon( remoteModuleName, msg1, requestID, 60 ); returnStatus = sendMsgProcMon( remoteModuleName, msg1, requestID, 60 );
@ -10534,7 +10528,6 @@ int ProcessManager::setMySQLReplication(oam::DeviceNetworkList devicenetworklist
msg1 << masterLogFile; msg1 << masterLogFile;
msg1 << masterLogPos; msg1 << masterLogPos;
msg1 << MySQLPort;
} }
returnStatus = sendMsgProcMon( remoteModuleName, msg1, requestID, 60 ); returnStatus = sendMsgProcMon( remoteModuleName, msg1, requestID, 60 );

View File

@ -1582,7 +1582,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
} }
case RUNUPGRADE: /* case RUNUPGRADE:
{ {
log.writeLog(__LINE__, "MSG RECEIVED: Run upgrade script "); log.writeLog(__LINE__, "MSG RECEIVED: Run upgrade script ");
@ -1601,7 +1601,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
break; break;
} }
*/
case PROCUNMOUNT: case PROCUNMOUNT:
{ {
string dbrootID; string dbrootID;
@ -1862,8 +1862,6 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
msg >> masterLogFile; msg >> masterLogFile;
string masterLogPos; string masterLogPos;
msg >> masterLogPos; msg >> masterLogPos;
string port;
msg >> port;
if ( ( (PMwithUM == "n") && (config.moduleType() == "pm") ) && if ( ( (PMwithUM == "n") && (config.moduleType() == "pm") ) &&
( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM) ) ( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM) )
@ -1892,7 +1890,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
} }
// run Slave Rep script // run Slave Rep script
ret = runSlaveRep(masterLogFile, masterLogPos, port); ret = runSlaveRep(masterLogFile, masterLogPos);
ackMsg << (ByteStream::byte) ACK; ackMsg << (ByteStream::byte) ACK;
ackMsg << (ByteStream::byte) SLAVEREP; ackMsg << (ByteStream::byte) SLAVEREP;
@ -4677,7 +4675,7 @@ void ProcessMonitor::checkProcessFailover( std::string processName)
* purpose: run upgrade script * purpose: run upgrade script
* *
******************************************************************************************/ ******************************************************************************************/
int ProcessMonitor::runUpgrade(std::string mysqlpw) /*int ProcessMonitor::runUpgrade(std::string mysqlpw)
{ {
Oam oam; Oam oam;
@ -4711,7 +4709,7 @@ int ProcessMonitor::runUpgrade(std::string mysqlpw)
} }
return oam::API_FAILURE; return oam::API_FAILURE;
} }
*/
/****************************************************************************************** /******************************************************************************************
* @brief changeMyCnf * @brief changeMyCnf
@ -4734,204 +4732,103 @@ int ProcessMonitor::changeMyCnf(std::string type)
string dbDir = startup::StartUp::installDir() + "/mysql/db"; string dbDir = startup::StartUp::installDir() + "/mysql/db";
/* if ( type == "master" ) //get server-id based on ExeMgrx setup
string serverID = "0";
string localModuleName = config.moduleName();
for ( int id = 1 ; ; id++ )
{ {
// set master replication entries string Section = "ExeMgr" + oam.itoa(id);
vector <string> lines;
char line[200]; string moduleName;
string buf;
while (file.getline(line, 200)) try {
{ Config* sysConfig = Config::makeConfig();
buf = line; moduleName = sysConfig->getConfig(Section, "Module");
string::size_type pos = buf.find("server-id =",0);
if ( pos != string::npos ) { if ( moduleName == localModuleName )
buf = "server-id = 1"; {
serverID = oam.itoa(id);
break;
} }
// pos = buf.find("# binlog_format=ROW",0);
// if ( pos != string::npos ) {
// buf = "binlog_format=ROW";
// }
pos = buf.find("infinidb_local_query=1",0);
if ( pos != string::npos && pos == 0) {
buf = "# infinidb_local_query=1";
}
//output to temp file
lines.push_back(buf);
} }
catch (...) {}
file.close();
unlink (mycnfFile.c_str());
ofstream newFile (mycnfFile.c_str());
//create new file
int fd = open(mycnfFile.c_str(), O_RDWR|O_CREAT, 0664);
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
newFile.close();
close(fd);
} }
if ( type == "slave" ) if ( serverID == "0" )
{ {
*/ //get slave id based on ExeMgrx setup log.writeLog(__LINE__, "changeMyCnf: ExeMgr for local module doesn't exist", LOG_TYPE_ERROR);
string slaveID = "0"; return oam::API_FAILURE;
string localModuleName = config.moduleName(); }
for ( int id = 1 ; ; id++ )
// set server-id and other options in my.cnf
vector <string> lines;
char line[200];
string buf;
while (file.getline(line, 200))
{
buf = line;
string::size_type pos = buf.find("server-id",0);
if ( pos != string::npos ) {
buf = "server-id = " + serverID;
string command = "SET GLOBAL server_id=" + serverID + ";";
int ret = runMariaDBCommandLine(command);
if (ret != 0)
{
log.writeLog(__LINE__, "changeMyCnf: runMariaDBCommandLine Error", LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
}
// set local query flag if on pm
if ( (PMwithUM == "y") && config.moduleType() == "pm" )
{ {
string Section = "ExeMgr" + oam.itoa(id); pos = buf.find("infinidb_local_query",0);
if ( pos != string::npos ) {
buf = "infinidb_local_query=1";
string command = "SET GLOBAL " + buf + ";";
string moduleName; int ret = runMariaDBCommandLine(command);
if (ret != 0)
try {
Config* sysConfig = Config::makeConfig();
moduleName = sysConfig->getConfig(Section, "Module");
if ( moduleName == localModuleName )
{ {
slaveID = oam.itoa(id); log.writeLog(__LINE__, "changeMyCnf: runMariaDBCommandLine Error", LOG_TYPE_ERROR);
break; return oam::API_FAILURE;
} }
} }
catch (...) {}
} }
else
if ( slaveID == "0" ) { // disable, if needed
{ pos = buf.find("infinidb_local_query",0);
log.writeLog(__LINE__, "changeMyCnf: ExeMgr for local module doesn't exist", LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
// get local host name
/* string HOSTNAME = "localhost";
try
{
ModuleConfig moduleconfig;
oam.getSystemConfig(config.moduleName(), moduleconfig);
HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin();
HOSTNAME = (*pt1).HostName;
}
catch(...)
{}
char* p= getenv("HOSTNAME");
if (p && *p)
HOSTNAME = p;
*/
// set slave replication entries
vector <string> lines;
char line[200];
string buf;
while (file.getline(line, 200))
{
buf = line;
string::size_type pos = buf.find("server-id",0);
if ( pos != string::npos ) { if ( pos != string::npos ) {
buf = "server-id = " + slaveID; buf = "infinidb_local_query=0";
}
// set local query flag if on pm string command = "SET GLOBAL " + buf + ";";
if ( (PMwithUM == "y") && config.moduleType() == "pm" ) int ret = runMariaDBCommandLine(command);
{ if (ret != 0)
pos = buf.find("# infinidb_local_query=1",0); {
if ( pos != string::npos ) { log.writeLog(__LINE__, "changeMyCnf: runMariaDBCommandLine Error", LOG_TYPE_ERROR);
buf = "infinidb_local_query=1"; return oam::API_FAILURE;
} }
} }
else
{ // disable, if needed
pos = buf.find("infinidb_local_query=1",0);
if ( pos != string::npos ) {
buf = "# infinidb_local_query=1";
}
}
// pos = buf.find("binlog_format=ROW",0);
// if ( pos != string::npos && pos == 0 ) {
// buf = "# binlog_format=ROW";
// }
//output to temp file
lines.push_back(buf);
} }
file.close();
unlink (mycnfFile.c_str());
ofstream newFile (mycnfFile.c_str());
//create new file //output to temp file
int fd = open(mycnfFile.c_str(), O_RDWR|O_CREAT, 0664); lines.push_back(buf);
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
newFile.close();
close(fd);
// }
/* if ( type == "disable" )
{
// set master replication entries
vector <string> lines;
char line[200];
string buf;
while (file.getline(line, 200))
{
buf = line;
string::size_type pos = buf.find("server-id",0);
if ( pos != string::npos ) {
string::size_type pos1 = buf.find("1",pos);
if ( pos1 == string::npos ) {
buf = "# server-id = 1";
}
}
pos = buf.find("log-bin=mysql-bin",0);
if ( pos != string::npos ) {
buf = "# log-bin=mysql-bin";
}
pos = buf.find("binlog_format=ROW",0);
if ( pos != string::npos && pos == 0 ) {
buf = "# binlog_format=ROW";
}
pos = buf.find("infinidb_local_query=1",0);
if ( pos != string::npos && pos == 0) {
buf = "# infinidb_local_query=1";
}
pos = buf.find("# relay-log",0);
if ( pos != string::npos ) {
buf = buf;
}
else
{
pos = buf.find("relay-log",0);
if ( pos != string::npos ) {
buf = "# " + buf;
}
}
//output to temp file
lines.push_back(buf);
}
file.close();
unlink (mycnfFile.c_str());
ofstream newFile (mycnfFile.c_str());
//create new file
int fd = open(mycnfFile.c_str(), O_RDWR|O_CREAT, 0664);
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
newFile.close();
close(fd);
} }
*/
file.close();
unlink (mycnfFile.c_str());
ofstream newFile (mycnfFile.c_str());
//create new file
int fd = open(mycnfFile.c_str(), O_RDWR|O_CREAT, 0664);
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
newFile.close();
close(fd);
// set owner and permission // set owner and permission
string cmd = "chmod 664 " + mycnfFile + " >/dev/null 2>&1"; string cmd = "chmod 664 " + mycnfFile + " >/dev/null 2>&1";
if ( !rootUser) if ( !rootUser)
@ -4946,18 +4843,72 @@ int ProcessMonitor::changeMyCnf(std::string type)
system(cmd.c_str()); system(cmd.c_str());
// restart mysql // restart mysql
try { /* try {
oam.actionMysqlCalpont(MYSQL_RESTART); oam.actionMysqlCalpont(MYSQL_RESTART);
sleep(5); // give after mysql restart sleep(5); // give after mysql restart
} }
catch(...) catch(...)
{} {}
*/
log.writeLog(__LINE__, "changeMyCnf function successfully completed", LOG_TYPE_DEBUG); log.writeLog(__LINE__, "changeMyCnf function successfully completed", LOG_TYPE_DEBUG);
return oam::API_SUCCESS; return oam::API_SUCCESS;
} }
/******************************************************************************************
* @brief runMariaDBCommandLine
*
* purpose: run MariaDB Command Line script
*
******************************************************************************************/
int ProcessMonitor::runMariaDBCommandLine(std::string command)
{
Oam oam;
log.writeLog(__LINE__, "runMariaDBCommandLine function called: cmd = " + command, LOG_TYPE_DEBUG);
// mysql port number
string MySQLPort;
try {
oam.getSystemConfig("MySQLPort", MySQLPort);
}
catch(...) {
MySQLPort = "3306";
}
if ( MySQLPort.empty() )
MySQLPort = "3306";
string cmd = startup::StartUp::installDir() + "/bin/mariadb-command-line.sh --installdir=" + startup::StartUp::installDir() + " --command='" + command + "' --port=" + MySQLPort + " > /tmp/mariadb-command-line.sh.log 2>&1";
log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG);
system(cmd.c_str());
string logFile = "/tmp/mariadb-command-line.sh.log";
if (oam.checkLogStatus(logFile, "ERROR 1045") ) {
log.writeLog(__LINE__, "mariadb-command-line.sh: MySQL Password Error, check .my.cnf", LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
else
{
if (oam.checkLogStatus(logFile, "OK"))
{
log.writeLog(__LINE__, "mariadb-command-line.sh: Successful return", LOG_TYPE_DEBUG);
return oam::API_SUCCESS;
}
else
{
log.writeLog(__LINE__, "mariadb-command-line.sh: Error return, check log /tmp/mariadb-command-line.sh.log", LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
}
return oam::API_FAILURE;
}
/****************************************************************************************** /******************************************************************************************
* @brief runMasterRep * @brief runMasterRep
* *
@ -4984,6 +4935,18 @@ int ProcessMonitor::runMasterRep(std::string& masterLogFile, std::string& master
// log.writeLog(__LINE__, "EXCEPTION ERROR on getSystemConfig: Caught unknown exception!", LOG_TYPE_ERROR); // log.writeLog(__LINE__, "EXCEPTION ERROR on getSystemConfig: Caught unknown exception!", LOG_TYPE_ERROR);
} }
// mysql port number
string MySQLPort;
try {
oam.getSystemConfig("MySQLPort", MySQLPort);
}
catch(...) {
MySQLPort = "3306";
}
if ( MySQLPort.empty() )
MySQLPort = "3306";
// create user for each module by ip address // create user for each module by ip address
for ( unsigned int i = 0 ; i < systemModuleTypeConfig.moduletypeconfig.size(); i++) for ( unsigned int i = 0 ; i < systemModuleTypeConfig.moduletypeconfig.size(); i++)
{ {
@ -5000,46 +4963,41 @@ int ProcessMonitor::runMasterRep(std::string& masterLogFile, std::string& master
string moduleType = systemModuleTypeConfig.moduletypeconfig[i].ModuleType; string moduleType = systemModuleTypeConfig.moduletypeconfig[i].ModuleType;
if ( ( (PMwithUM == "n") && (config.moduleType() == "pm") ) && if ( ( (PMwithUM == "n") && (moduleType == "pm") ) &&
( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM) ) ( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM) )
continue; continue;
HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); HostConfigList::iterator pt1 = (*pt).hostConfigList.begin();
while(true) // need in case there is a password retry for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++ )
{ {
for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++ ) string ipAddr = (*pt1).IPAddr;
{
string ipAddr = (*pt1).IPAddr; string logFile = "/tmp/master-rep-columnstore-" + moduleName + ".log";
string cmd = startup::StartUp::installDir() + "/bin/master-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " --hostIP=" + ipAddr + " --port=" + MySQLPort + " > " + logFile + " 2>&1";
string logFile = "/tmp/master-rep-columnstore-" + moduleName + ".log"; log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG);
string cmd = startup::StartUp::installDir() + "/bin/master-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " --hostIP=" + ipAddr + " > " + logFile + " 2>&1";
log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG); system(cmd.c_str());
system(cmd.c_str()); if (oam.checkLogStatus(logFile, "ERROR 1045") ) {
if ( passwordError ) {
if (oam.checkLogStatus(logFile, "ERROR 1045") ) { log.writeLog(__LINE__, "master-rep-columnstore.sh: MySQL Password Error", LOG_TYPE_ERROR);
if ( passwordError ) { return oam::API_FAILURE;
log.writeLog(__LINE__, "master-rep-columnstore.sh: MySQL Password Error", LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
log.writeLog(__LINE__, "master-rep-columnstore.sh: Missing Password error, go check for a password and retry", LOG_TYPE_DEBUG);
passwordError = true;
break;
} }
else
log.writeLog(__LINE__, "master-rep-columnstore.sh: Missing Password error, go check for a password and retry", LOG_TYPE_DEBUG);
passwordError = true;
break;
}
else
{
if (oam.checkLogStatus(logFile, "OK"))
log.writeLog(__LINE__, "master-rep-columnstore.sh: Successful return for node " + moduleName, LOG_TYPE_DEBUG);
else
{ {
if (oam.checkLogStatus(logFile, "OK")) log.writeLog(__LINE__, "master-rep-columnstore.sh: Error return, check log " + logFile, LOG_TYPE_ERROR);
log.writeLog(__LINE__, "master-rep-columnstore.sh: Successful return for node " + moduleName, LOG_TYPE_DEBUG); return oam::API_FAILURE;
else
{
log.writeLog(__LINE__, "master-rep-columnstore.sh: Error return, check log " + logFile, LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
} }
} }
break;
} }
} }
} }
@ -5106,7 +5064,7 @@ int ProcessMonitor::runMasterRep(std::string& masterLogFile, std::string& master
* purpose: run Slave Replication script * purpose: run Slave Replication script
* *
******************************************************************************************/ ******************************************************************************************/
int ProcessMonitor::runSlaveRep(std::string& masterLogFile, std::string& masterLogPos, std::string& port) int ProcessMonitor::runSlaveRep(std::string& masterLogFile, std::string& masterLogPos)
{ {
Oam oam; Oam oam;
@ -5127,10 +5085,22 @@ int ProcessMonitor::runSlaveRep(std::string& masterLogFile, std::string& masterL
catch(...) catch(...)
{} {}
// mysql port number
string MySQLPort;
try {
oam.getSystemConfig("MySQLPort", MySQLPort);
}
catch(...) {
MySQLPort = "3306";
}
if ( MySQLPort.empty() )
MySQLPort = "3306";
bool passwordError = false; bool passwordError = false;
while(true) while(true)
{ {
string cmd = startup::StartUp::installDir() + "/bin/slave-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " --masteripaddr=" + masterIPAddress + " --masterlogfile=" + masterLogFile + " --masterlogpos=" + masterLogPos + + " --port=" + port + " > /tmp/slave-rep-columnstore.log 2>&1"; string cmd = startup::StartUp::installDir() + "/bin/slave-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " --masteripaddr=" + masterIPAddress + " --masterlogfile=" + masterLogFile + " --masterlogpos=" + masterLogPos + " --port=" + MySQLPort + " > /tmp/slave-rep-columnstore.log 2>&1";
log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG); log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG);
@ -5177,6 +5147,18 @@ int ProcessMonitor::runDisableRep()
log.writeLog(__LINE__, "runDisableRep function called", LOG_TYPE_DEBUG); log.writeLog(__LINE__, "runDisableRep function called", LOG_TYPE_DEBUG);
// mysql port number
string MySQLPort;
try {
oam.getSystemConfig("MySQLPort", MySQLPort);
}
catch(...) {
MySQLPort = "3306";
}
if ( MySQLPort.empty() )
MySQLPort = "3306";
string cmd = startup::StartUp::installDir() + "/bin/disable-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " > /tmp/disable-rep-columnstore.log 2>&1"; string cmd = startup::StartUp::installDir() + "/bin/disable-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " > /tmp/disable-rep-columnstore.log 2>&1";
log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG); log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG);
@ -5227,6 +5209,7 @@ int ProcessMonitor::runMasterDist(std::string& password, std::string& slaveModul
// log.writeLog(__LINE__, "EXCEPTION ERROR on getSystemConfig: Caught unknown exception!", LOG_TYPE_ERROR); // log.writeLog(__LINE__, "EXCEPTION ERROR on getSystemConfig: Caught unknown exception!", LOG_TYPE_ERROR);
} }
int slave = 0;
if ( slaveModule == "all" ) if ( slaveModule == "all" )
{ {
// Distrubuted MySQL Front-end DB to Slave Modules // Distrubuted MySQL Front-end DB to Slave Modules
@ -5238,7 +5221,7 @@ int ProcessMonitor::runMasterDist(std::string& password, std::string& slaveModul
string moduleType = systemModuleTypeConfig.moduletypeconfig[i].ModuleType; string moduleType = systemModuleTypeConfig.moduletypeconfig[i].ModuleType;
if ( ( (PMwithUM == "n") && (config.moduleType() == "pm") ) && if ( ( (PMwithUM == "n") && (moduleType == "pm") ) &&
( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM) ) ( config.ServerInstallType() != oam::INSTALL_COMBINE_DM_UM_PM) )
continue; continue;
@ -5251,6 +5234,8 @@ int ProcessMonitor::runMasterDist(std::string& password, std::string& slaveModul
if ( moduleName == config.moduleName() ) if ( moduleName == config.moduleName() )
continue; continue;
slave++;
HostConfigList::iterator pt1 = (*pt).hostConfigList.begin(); HostConfigList::iterator pt1 = (*pt).hostConfigList.begin();
for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++ ) for ( ; pt1 != (*pt).hostConfigList.end() ; pt1++ )
{ {
@ -5263,7 +5248,10 @@ int ProcessMonitor::runMasterDist(std::string& password, std::string& slaveModul
string logFile = "/tmp/master-dist_" + moduleName + ".log"; string logFile = "/tmp/master-dist_" + moduleName + ".log";
if (!oam.checkLogStatus(logFile, "FAILED")) if (!oam.checkLogStatus(logFile, "FAILED"))
{
log.writeLog(__LINE__, "runMasterDist: Success rsync to module: " + moduleName, LOG_TYPE_DEBUG); log.writeLog(__LINE__, "runMasterDist: Success rsync to module: " + moduleName, LOG_TYPE_DEBUG);
break;
}
else else
{ {
log.writeLog(__LINE__, "runMasterDist: Failure rsync to module: " + moduleName, LOG_TYPE_ERROR); log.writeLog(__LINE__, "runMasterDist: Failure rsync to module: " + moduleName, LOG_TYPE_ERROR);
@ -5275,24 +5263,37 @@ int ProcessMonitor::runMasterDist(std::string& password, std::string& slaveModul
} }
else else
{ {
// get slave IP address // don't do PMs unless PMwithUM flag is set
ModuleConfig moduleconfig;
oam.getSystemConfig(slaveModule, moduleconfig); string moduleType = slaveModule.substr(0,MAX_MODULE_TYPE_SIZE);
HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin();
string ipAddr = (*pt1).IPAddr;
string cmd = startup::StartUp::installDir() + "/bin/rsync.sh " + ipAddr + " " + password + " " + startup::StartUp::installDir() + " 1 > /tmp/master-dist_" + slaveModule + ".log"; if ( ( (PMwithUM == "y") && (moduleType == "pm") ) &&
system(cmd.c_str()); ( config.ServerInstallType() == oam::INSTALL_COMBINE_DM_UM_PM) )
string logFile = "/tmp/master-dist_" + slaveModule + ".log";
if (!oam.checkLogStatus(logFile, "FAILED"))
log.writeLog(__LINE__, "runMasterDist: Success rsync to module: " + slaveModule, LOG_TYPE_DEBUG);
else
{ {
log.writeLog(__LINE__, "runMasterDist: Failure rsync to module: " + slaveModule, LOG_TYPE_ERROR); slave++;
return oam::API_FAILURE;
// get slave IP address
ModuleConfig moduleconfig;
oam.getSystemConfig(slaveModule, moduleconfig);
HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin();
string ipAddr = (*pt1).IPAddr;
string cmd = startup::StartUp::installDir() + "/bin/rsync.sh " + ipAddr + " " + password + " " + startup::StartUp::installDir() + " 1 > /tmp/master-dist_" + slaveModule + ".log";
system(cmd.c_str());
string logFile = "/tmp/master-dist_" + slaveModule + ".log";
if (!oam.checkLogStatus(logFile, "FAILED"))
log.writeLog(__LINE__, "runMasterDist: Success rsync to module: " + slaveModule, LOG_TYPE_DEBUG);
else
{
log.writeLog(__LINE__, "runMasterDist: Failure rsync to module: " + slaveModule, LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
} }
} }
if (slave == 0 )
log.writeLog(__LINE__, "runMasterDist: No configured slave nodes", LOG_TYPE_DEBUG);
return oam::API_SUCCESS; return oam::API_SUCCESS;
} }

View File

@ -492,13 +492,19 @@ public:
/** /**
*@brief run upgrade script *@brief run upgrade script
*/ */
int runUpgrade(std::string mysqlpw); // int runUpgrade(std::string mysqlpw);
/** /**
*@brief change my.cnf *@brief change my.cnf
*/ */
int changeMyCnf(std::string type); int changeMyCnf(std::string type);
/**
*@brief run MariaDB Command Line script
*/
int runMariaDBCommandLine(std::string command);
/** /**
*@brief run Master Replication script *@brief run Master Replication script
*/ */
@ -512,7 +518,7 @@ public:
/** /**
*@brief run Slave Replication script *@brief run Slave Replication script
*/ */
int runSlaveRep(std::string& masterLogFile, std::string& masterLogPos, std::string& port); int runSlaveRep(std::string& masterLogFile, std::string& masterLogPos);
/** /**
*@brief run Disable Replication script *@brief run Disable Replication script