You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-3915 Remove some configuration from postConfigure. Default Columnstore.xml to a standard single server config.
This commit is contained in:
@ -319,39 +319,6 @@ int main(int argc, char* argv[])
|
||||
|
||||
string postConfigureLog = "/var/log/columnstore-postconfigure-" + currentDate;
|
||||
|
||||
if (oam.checkSystemRunning())
|
||||
{
|
||||
cout << "MariaDB ColumnStore is running, can't run postConfigure while MariaDB ColumnStore is running. Exiting.." << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
char buf[512];
|
||||
*(int64_t*)buf = 0;
|
||||
FILE* cmd_pipe = popen("pidof -s mysqld", "r");
|
||||
if (cmd_pipe)
|
||||
{
|
||||
fgets(buf, 512, cmd_pipe);
|
||||
pid_t pid = strtoul(buf, NULL, 10);
|
||||
pclose(cmd_pipe);
|
||||
if (pid)
|
||||
{
|
||||
cout << "MariaDB Server is currently running on PID " << pid << ". Cannot run postConfigure whilst this is running. Exiting.." << endl;
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "The utility 'pidof' is not installed. Can't check for MariaDB server already running Exiting..." << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
//check Config saved files
|
||||
if ( !checkSaveConfigFile())
|
||||
{
|
||||
cout << "ERROR: Configuration File not setup" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//determine package type
|
||||
string EEPackageType;
|
||||
|
||||
@ -390,74 +357,11 @@ int main(int argc, char* argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//check mysql port changes
|
||||
string MySQLPort;
|
||||
|
||||
try
|
||||
{
|
||||
MySQLPort = sysConfig->getConfig(InstallSection, "MySQLPort");
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
|
||||
if ( mysqlPort == oam::UnassignedName )
|
||||
{
|
||||
if ( MySQLPort.empty() || MySQLPort == "" )
|
||||
{
|
||||
mysqlPort = "3306";
|
||||
|
||||
try
|
||||
{
|
||||
sysConfig->setConfig(InstallSection, "MySQLPort", "3306");
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
}
|
||||
else
|
||||
mysqlPort = MySQLPort;
|
||||
}
|
||||
else
|
||||
{
|
||||
// mysql port was providing on command line
|
||||
try
|
||||
{
|
||||
sysConfig->setConfig(InstallSection, "MySQLPort", mysqlPort);
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
}
|
||||
|
||||
// perform single server install
|
||||
cout << endl << "Performing the Single Server Install." << endl << endl;
|
||||
|
||||
//setup to Columnstore.xml file for single server
|
||||
singleServerConfigSetup(sysConfig);
|
||||
|
||||
//module ProcessConfig.xml to setup all apps on the pm
|
||||
if ( !updateProcessConfig() )
|
||||
cout << "Update ProcessConfig.xml error" << endl;
|
||||
|
||||
try
|
||||
{
|
||||
sysConfig->setConfig(InstallSection, "SingleServerInstall", "y");
|
||||
sysConfig->setConfig(InstallSection, "ServerTypeInstall", "2");
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "ERROR: Problem setting SingleServerInstall from the MariaDB ColumnStore System Configuration file" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( !writeConfig(sysConfig) )
|
||||
{
|
||||
cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
setSystemName();
|
||||
cout << endl;
|
||||
|
||||
system(cmd.c_str());
|
||||
//singleServerConfigSetup(sysConfig);
|
||||
|
||||
// setup storage
|
||||
if (!storageSetup(false))
|
||||
@ -470,24 +374,6 @@ int main(int argc, char* argv[])
|
||||
if ( !updateBash() )
|
||||
cout << "updateBash error" << endl;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
//check if dbrm data resides in older directory path and inform user if it does
|
||||
dbrmDirCheck();
|
||||
|
||||
@ -513,165 +399,6 @@ int main(int argc, char* argv[])
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for reuse of RPM saved Columnstore.xml
|
||||
*/
|
||||
bool checkSaveConfigFile()
|
||||
{
|
||||
string rpmFileName = std::string(MCSSYSCONFDIR) + "/columnstore/Columnstore.xml";
|
||||
string newFileName = std::string(MCSSYSCONFDIR) + "/columnstore/Columnstore.xml.new";
|
||||
|
||||
string extentMapCheckOnly = " ";
|
||||
|
||||
//check if Columnstore.xml.rpmsave exist
|
||||
ifstream File (oldFileName.c_str());
|
||||
|
||||
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();
|
||||
|
||||
// If 'oldFileName' isn't configured, exit
|
||||
Config* oldSysConfig = Config::makeConfig(oldFileName);
|
||||
|
||||
string oldpm1 = oldSysConfig->getConfig("SystemModuleConfig", "ModuleIPAddr1-1-3");
|
||||
|
||||
if ( oldpm1 == "0.0.0.0")
|
||||
{
|
||||
if ( noPrompting )
|
||||
{
|
||||
cout << endl << "Old Config File not Configured, PM1 IP Address entry is '0.0.0.0', '" + oldFileName + "', exiting" << endl;
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
// get single-server system install type
|
||||
string temp;
|
||||
|
||||
try
|
||||
{
|
||||
temp = oldSysConfig->getConfig(InstallSection, "SingleServerInstall");
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
|
||||
if ( !temp.empty() )
|
||||
singleServerInstall = temp;
|
||||
|
||||
if ( singleServerInstall == "y" )
|
||||
singleServerInstall = "1";
|
||||
else
|
||||
singleServerInstall = "2";
|
||||
|
||||
// clear this entry out to validate updates being made
|
||||
Config* sysConfig = Config::makeConfig();
|
||||
sysConfig->setConfig("ExeMgr1", "IPAddr", "0.0.0.0");
|
||||
|
||||
for ( int retry = 0 ; retry < 5 ; retry++ )
|
||||
{
|
||||
string cmd = "mv -f " + rpmFileName + " " + newFileName;
|
||||
int rtnCode = system(cmd.c_str());
|
||||
|
||||
if (WEXITSTATUS(rtnCode) != 0)
|
||||
{
|
||||
cout << "Error moving installed version of Columnstore.xml" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd = "cp " + oldFileName + " " + rpmFileName;
|
||||
rtnCode = system(cmd.c_str());
|
||||
|
||||
if (WEXITSTATUS(rtnCode) != 0)
|
||||
{
|
||||
cout << "Error moving pkgsave file" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd = "cd " + std::string(MCSSYSCONFDIR) + "/columnstore;autoConfigure " + extentMapCheckOnly;
|
||||
rtnCode = system(cmd.c_str());
|
||||
|
||||
if (WEXITSTATUS(rtnCode) != 0)
|
||||
{
|
||||
cout << "Error running autoConfigure" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd = "mv -f " + newFileName + " " + rpmFileName;
|
||||
rtnCode = system(cmd.c_str());
|
||||
|
||||
if (WEXITSTATUS(rtnCode) != 0)
|
||||
{
|
||||
cout << "Error moving pkgsave file" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
//check to see if updates were made
|
||||
if ( sysConfig->getConfig("ExeMgr1", "IPAddr") != "0.0.0.0")
|
||||
{
|
||||
//Columnstore.xml is ready to go, get feature options
|
||||
|
||||
if ( MySQLRep == "n" )
|
||||
{
|
||||
try
|
||||
{
|
||||
MySQLRep = sysConfig->getConfig(InstallSection, "MySQLRep");
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
|
||||
if ( MySQLRep == "y" )
|
||||
mysqlRep = true;
|
||||
}
|
||||
|
||||
if ( PMwithUM == "n" )
|
||||
{
|
||||
//get local query / PMwithUM feature flag
|
||||
try
|
||||
{
|
||||
PMwithUM = sysConfig->getConfig(InstallSection, "PMwithUM");
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
|
||||
if ( PMwithUM == "y" )
|
||||
{
|
||||
pmwithum = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
if ( reuseConfig == "n" )
|
||||
return true;
|
||||
|
||||
cout << "ERROR: Failed to copy data to Columnstore.xml" << endl;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup OS Files by appending the Calpont versions
|
||||
*/
|
||||
@ -730,84 +457,6 @@ bool setOSFiles(string parentOAMModuleName, int serverTypeInstall)
|
||||
return allfound;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update ProcessConfig.xml file for a single server configuration
|
||||
* Change the 'um' to 'pm'
|
||||
*/
|
||||
bool updateProcessConfig()
|
||||
{
|
||||
vector <string> oldModule;
|
||||
string newModule = ">pm";
|
||||
oldModule.push_back(">um");
|
||||
|
||||
string fileName = std::string(MCSSYSCONFDIR) + "/columnstore/ProcessConfig.xml";
|
||||
|
||||
//Save a copy of the original version
|
||||
string cmd = "/bin/cp -f " + fileName + " " + fileName + ".columnstoreSave > /dev/null 2>&1";
|
||||
system(cmd.c_str());
|
||||
|
||||
ifstream oldFile (fileName.c_str());
|
||||
|
||||
if (!oldFile) return true;
|
||||
|
||||
vector <string> lines;
|
||||
char line[200];
|
||||
string buf;
|
||||
string newLine;
|
||||
string newLine1;
|
||||
|
||||
while (oldFile.getline(line, 200))
|
||||
{
|
||||
buf = line;
|
||||
newLine = line;
|
||||
|
||||
std::vector<std::string>::iterator pt1 = oldModule.begin();
|
||||
|
||||
for ( ; pt1 != oldModule.end() ; pt1++)
|
||||
{
|
||||
int start = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
string::size_type pos = buf.find(*pt1, start);
|
||||
|
||||
if (pos != string::npos)
|
||||
{
|
||||
newLine = buf.substr(0, pos);
|
||||
newLine.append(newModule);
|
||||
|
||||
newLine1 = buf.substr(pos + 3, 200);
|
||||
newLine.append(newLine1);
|
||||
start = pos + 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = newLine;
|
||||
start = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//output to temp file
|
||||
lines.push_back(buf);
|
||||
}
|
||||
|
||||
oldFile.close();
|
||||
unlink (fileName.c_str());
|
||||
ofstream newFile (fileName.c_str());
|
||||
|
||||
//create new file
|
||||
int fd = open(fileName.c_str(), O_RDWR | O_CREAT, 0664);
|
||||
|
||||
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
|
||||
newFile.close();
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Uncomment entry in Columnstore.xml
|
||||
*/
|
||||
@ -1526,45 +1175,6 @@ bool storageSetup(bool amazonInstall)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void setSystemName()
|
||||
{
|
||||
Oam oam;
|
||||
|
||||
//setup System Name
|
||||
|
||||
if ( systemName.empty() )
|
||||
{
|
||||
try {
|
||||
systemName = sysConfig->getConfig(SystemSection, "SystemName");
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
systemName = oam::UnassignedName;
|
||||
}
|
||||
}
|
||||
|
||||
if ( systemName.empty() )
|
||||
systemName = "columnstore-1";
|
||||
|
||||
try
|
||||
{
|
||||
sysConfig->setConfig(SystemSection, "SystemName", systemName);
|
||||
oam.changeMyCnf( "server_audit_syslog_info", systemName );
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "ERROR: Problem setting SystemName 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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy fstab file
|
||||
*/
|
||||
@ -1748,162 +1358,6 @@ bool attachVolume(string instanceName, string volumeName, string deviceName, str
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool singleServerDBrootSetup()
|
||||
{
|
||||
Oam oam;
|
||||
|
||||
cout << endl;
|
||||
|
||||
//get number of dbroots
|
||||
string moduledbrootcount = "ModuleDBRootCount1-3";
|
||||
unsigned int count;
|
||||
|
||||
try
|
||||
{
|
||||
count = atoi(sysConfig->getConfig(ModuleSection, moduledbrootcount).c_str());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "ERROR: Problem setting DBRoot count in the MariaDB ColumnStore System Configuration file" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
string dbrootList;
|
||||
|
||||
for ( unsigned int id = 1 ; id < count + 1 ; )
|
||||
{
|
||||
string moduledbrootid = "ModuleDBRootID1-" + oam.itoa(id) + "-3";
|
||||
|
||||
try
|
||||
{
|
||||
string dbrootid = sysConfig->getConfig(ModuleSection, moduledbrootid);
|
||||
|
||||
if ( dbrootid != oam::UnassignedName)
|
||||
{
|
||||
sysConfig->setConfig(ModuleSection, moduledbrootid, oam::UnassignedName);
|
||||
|
||||
dbrootList = dbrootList + dbrootid;
|
||||
id ++;
|
||||
|
||||
if ( id < count + 1 )
|
||||
dbrootList = dbrootList + ",";
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "ERROR: Problem setting DBRoot ID in the MariaDB ColumnStore System Configuration file" << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
vector <string> dbroots;
|
||||
string tempdbrootList;
|
||||
|
||||
while (true)
|
||||
{
|
||||
dbroots.clear();
|
||||
tempdbrootList = dbrootList;
|
||||
|
||||
if ( tempdbrootList.empty())
|
||||
continue;
|
||||
|
||||
//check for range
|
||||
int firstID;
|
||||
int lastID;
|
||||
string::size_type pos = tempdbrootList.find("-", 0);
|
||||
|
||||
if (pos != string::npos)
|
||||
{
|
||||
firstID = atoi(tempdbrootList.substr(0, pos).c_str());
|
||||
lastID = atoi(tempdbrootList.substr(pos + 1, 200).c_str());
|
||||
|
||||
if ( firstID >= lastID )
|
||||
{
|
||||
cout << "Invalid Entry, please re-enter" << endl;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int id = firstID ; id < lastID + 1 ; id++ )
|
||||
{
|
||||
dbroots.push_back(oam.itoa(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::char_separator<char> sep(",");
|
||||
boost::tokenizer< boost::char_separator<char> > tokens(tempdbrootList, sep);
|
||||
|
||||
for ( boost::tokenizer< boost::char_separator<char> >::iterator it = tokens.begin();
|
||||
it != tokens.end();
|
||||
++it)
|
||||
{
|
||||
dbroots.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
int id = 1;
|
||||
std::vector<std::string>::iterator it = dbroots.begin();
|
||||
|
||||
for (; it != dbroots.end() ; it++, ++id)
|
||||
{
|
||||
//store DBRoot ID
|
||||
string moduledbrootid = "ModuleDBRootID1-" + oam.itoa(id) + "-3";
|
||||
|
||||
try
|
||||
{
|
||||
sysConfig->setConfig(ModuleSection, moduledbrootid, *it);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "ERROR: Problem setting DBRoot ID in the MariaDB ColumnStore System Configuration file" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
string DBrootID = "DBRoot" + *it;
|
||||
string pathID = "/var/lib/columnstore/data" + *it;
|
||||
|
||||
try
|
||||
{
|
||||
sysConfig->setConfig(SystemSection, DBrootID, pathID);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "ERROR: Problem setting DBRoot in the MariaDB ColumnStore System Configuration file" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//store number of dbroots
|
||||
moduledbrootcount = "ModuleDBRootCount1-3";
|
||||
|
||||
try
|
||||
{
|
||||
sysConfig->setConfig(ModuleSection, moduledbrootcount, oam.itoa(dbroots.size()));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "ERROR: Problem setting DBRoot count in the MariaDB ColumnStore System Configuration file" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//total dbroots on the system
|
||||
DBRootCount = DBRootCount + dbroots.size();
|
||||
|
||||
if ( !writeConfig(sysConfig) )
|
||||
{
|
||||
cout << "ERROR: Failed trying to update MariaDB ColumnStore System Configuration file" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pthread_mutex_t THREAD_LOCK;
|
||||
|
||||
void remoteInstallThread(void* arg)
|
||||
|
Reference in New Issue
Block a user