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

added option to create ebs in postconfigure

This commit is contained in:
david hill
2016-04-14 13:56:54 -05:00
parent fdcd05f8e4
commit bfa03e99eb
4 changed files with 240 additions and 105 deletions

View File

@@ -5922,6 +5922,69 @@ namespace oam
return 0; return 0;
} }
/***************************************************************************
*
* Function: addUMdisk
*
* Purpose: add UM disk
*
****************************************************************************/
void Oam::addUMdisk(const int moduleID, std::string& volumeName, std::string& device, string EBSsize)
{
string UMVolumeSize = "10";
try{
getSystemConfig("UMVolumeSize", UMVolumeSize);
}
catch(...) {}
writeLog("addUMdisk - Create new Volume for um" + itoa(moduleID), LOG_TYPE_DEBUG);
volumeName = createEC2Volume(UMVolumeSize);
if ( volumeName == "failed" ) {
writeLog("addModule: create volume failed", LOG_TYPE_CRITICAL);
exceptionControl("addUMdisk", API_FAILURE);
}
//attach and format volumes
device = "/dev/sdf" + itoa(moduleID);
string localInstance = getEC2LocalInstance();
//attach volumes to local instance
writeLog("addUMdisk - Attach new Volume to local instance: " + volumeName, LOG_TYPE_DEBUG);
if (!attachEC2Volume(volumeName, device, localInstance)) {
writeLog("addUMdisk: volume failed to attach to local instance", LOG_TYPE_CRITICAL);
exceptionControl("addUMdisk", API_FAILURE);
}
//format attached volume
writeLog("addUMdisk - Format new Volume for: " + volumeName, LOG_TYPE_DEBUG);
string cmd = "mkfs.ext2 -F " + device + " > /dev/null 2>&1";
system(cmd.c_str());
//detach volume
writeLog("addUMdisk - detach new Volume from local instance: " + volumeName, LOG_TYPE_DEBUG);
if (!detachEC2Volume(volumeName)) {
exceptionControl("addUMdisk", API_FAILURE);
}
// add instance tag
string AmazonAutoTagging;
string systemName;
try {
getSystemConfig("AmazonAutoTagging", AmazonAutoTagging);
getSystemConfig("SystemName", systemName);
}
catch(...) {}
if ( AmazonAutoTagging == "y" )
{
string tagValue = systemName + "-um" + itoa(moduleID);
createEC2tag( volumeName, "Name", tagValue );
}
}
/*************************************************************************** /***************************************************************************
* *
* Function: addDbroot * Function: addDbroot
@@ -5930,7 +5993,7 @@ namespace oam
* *
****************************************************************************/ ****************************************************************************/
void Oam::addDbroot(const int dbrootNumber, DBRootConfigList& dbrootlist, string EBSsize) void Oam::addDbroot(const int dbrootNumber, DBRootConfigList& dbrootlist, string EBSsize)
{ {
int SystemDBRootCount = 0; int SystemDBRootCount = 0;
string cloud; string cloud;
@@ -5999,33 +6062,36 @@ namespace oam
dbrootConfigList.push_back(*pt1); dbrootConfigList.push_back(*pt1);
} }
int newID = 1; if ( dbrootlist.empty() )
for ( int count = 0 ; count < dbrootNumber ; count++ )
{ {
//check for match int newID = 1;
while (true) for ( int count = 0 ; count < dbrootNumber ; count++ )
{ {
bool found = false; //check for match
DBRootConfigList::iterator pt = dbrootConfigList.begin(); while (true)
for( ; pt != dbrootConfigList.end() ; pt++)
{ {
if ( newID == *pt ) { bool found = false;
DBRootConfigList::iterator pt = dbrootConfigList.begin();
for( ; pt != dbrootConfigList.end() ; pt++)
{
if ( newID == *pt ) {
newID++;
found = true;
break;
}
}
if (!found)
{
dbrootlist.push_back(newID);
newID++; newID++;
found = true;
break; break;
} }
} }
if (!found)
{
dbrootlist.push_back(newID);
newID++;
break;
}
} }
} }
if ( dbrootlist.size() == 0 ) if ( dbrootlist.empty() )
{ {
cout << "ERROR: Failed add, No DBRoot IDs available" << endl; cout << "ERROR: Failed add, No DBRoot IDs available" << endl;
exceptionControl("addDbroot", API_INVALID_PARAMETER); exceptionControl("addDbroot", API_INVALID_PARAMETER);

View File

@@ -2246,6 +2246,11 @@ namespace oam
*/ */
EXPORT void addDbroot(const int dbrootNumber, DBRootConfigList& dbrootlist, std::string EBSsize = oam::UnassignedName); EXPORT void addDbroot(const int dbrootNumber, DBRootConfigList& dbrootlist, std::string EBSsize = oam::UnassignedName);
/**
*@brief add UM Disk
*/
EXPORT void addUMdisk(const int moduleID, std::string& volumeName, std::string& device, std::string EBSsize = oam::UnassignedName);
/** /**
*@brief distribute Fstab Updates *@brief distribute Fstab Updates
*/ */

View File

@@ -129,6 +129,9 @@ string DBRootStorageLoc;
string DBRootStorageType; string DBRootStorageType;
string UMStorageType; string UMStorageType;
string PMVolumeSize = oam::UnassignedName;
string UMVolumeSize = oam::UnassignedName;
int DBRootCount; int DBRootCount;
string deviceName; string deviceName;
@@ -2123,33 +2126,62 @@ int main(int argc, char *argv[])
if ( moduleType == "um" && moduleDisableState == oam::ENABLEDSTATE) { if ( moduleType == "um" && moduleDisableState == oam::ENABLEDSTATE) {
//get EC2 volume name and info //get EC2 volume name and info
if ( UMStorageType == "external" && cloud == "amazon" && if ( UMStorageType == "external" && cloud == "amazon" &&
IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM ) { IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM ) {
string create = "y";
while(true)
{
pcommand = callReadline("Do you need the volume created [y,n] (y) > ");
if (pcommand)
{
if (strlen(pcommand) > 0) create = pcommand;
callFree(pcommand);
}
if ( create == "y" || create == "n" )
break;
else
cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl;
create = "y";
if ( noPrompting )
exit(1);
}
string volumeNameID = "UMVolumeName" + oam.itoa(moduleID); string volumeNameID = "UMVolumeName" + oam.itoa(moduleID);
string volumeName = oam::UnassignedName; string volumeName = oam::UnassignedName;
string deviceNameID = "UMVolumeDeviceName" + oam.itoa(moduleID); string deviceNameID = "UMVolumeDeviceName" + oam.itoa(moduleID);
string deviceName = oam::UnassignedName; string deviceName = oam::UnassignedName;
try {
volumeName = sysConfig->getConfig(InstallSection, volumeNameID);
deviceName = sysConfig->getConfig(InstallSection, deviceNameID);
}
catch(...)
{}
prompt = "Enter Volume ID assigned to module '" + newModuleName + "' (" + volumeName + ") > "; if ( create == "n" ) {
pcommand = callReadline(prompt.c_str()); // prompt for volume ID
if (pcommand) try {
{ volumeName = sysConfig->getConfig(InstallSection, volumeNameID);
if (strlen(pcommand) > 0) volumeName = pcommand; }
callFree(pcommand); catch(...)
{}
prompt = "Enter Volume ID assigned to module '" + newModuleName + "' (" + volumeName + ") > ";
pcommand = callReadline(prompt.c_str());
if (pcommand)
{
if (strlen(pcommand) > 0) volumeName = pcommand;
callFree(pcommand);
}
//get device name based on dbroot ID
deviceName = "/dev/sdf" + oam.itoa(moduleID);
} }
else
prompt = "Enter Device Name (/dev/sdxx) '" + newModuleName + "' (" + deviceName + ") > ";
pcommand = callReadline(prompt.c_str());
if (pcommand)
{ {
if (strlen(pcommand) > 0) deviceName = pcommand; //create new UM volume
callFree(pcommand); try{
oam.addUMdisk(moduleID, volumeName, deviceName, UMVolumeSize);
}
catch(...) {
cout << "ERROR: volume create failed for " + newModuleName << endl;
return false;
}
} }
//write volume and device name //write volume and device name
@@ -2405,36 +2437,73 @@ int main(int argc, char *argv[])
//get EC2 volume name and info //get EC2 volume name and info
if ( DBRootStorageType == "external" && cloud == "amazon") { if ( DBRootStorageType == "external" && cloud == "amazon") {
cout << endl; cout << endl;
string create = "y";
while(true)
{
pcommand = callReadline("Do you need the volume created [y,n] (y) > ");
if (pcommand)
{
if (strlen(pcommand) > 0) create = pcommand;
callFree(pcommand);
}
if ( create == "y" || create == "n" )
break;
else
cout << "Invalid Entry, please enter 'y' for yes or 'n' for no" << endl;
create = "y";
if ( noPrompting )
exit(1);
}
string volumeNameID = "PMVolumeName" + *it; string volumeNameID = "PMVolumeName" + *it;
string volumeName = oam::UnassignedName; string volumeName = oam::UnassignedName;
try {
volumeName = sysConfig->getConfig(InstallSection, volumeNameID);
}
catch(...)
{}
prompt = "Enter Volume ID for '" + DBrootID + "' (" + volumeName + ") > ";
pcommand = callReadline(prompt.c_str());
if (pcommand)
{
if (strlen(pcommand) > 0) volumeName = pcommand;
callFree(pcommand);
}
string deviceNameID = "PMVolumeDeviceName" + *it; string deviceNameID = "PMVolumeDeviceName" + *it;
string deviceName = oam::UnassignedName; string deviceName = oam::UnassignedName;
try { try {
volumeName = sysConfig->getConfig(InstallSection, volumeNameID);
deviceName = sysConfig->getConfig(InstallSection, deviceNameID); deviceName = sysConfig->getConfig(InstallSection, deviceNameID);
} }
catch(...) catch(...)
{} {}
prompt = "Enter Device Name (/dev/sdxx) for volume '" + volumeName + "' (" + deviceName + ") > ";
pcommand = callReadline(prompt.c_str()); if ( create == "n" ) {
if (pcommand) prompt = "Enter Volume ID for '" + DBrootID + "' (" + volumeName + ") > ";
pcommand = callReadline(prompt.c_str());
if (pcommand)
{
if (strlen(pcommand) > 0) volumeName = pcommand;
callFree(pcommand);
}
}
else
{ {
if (strlen(pcommand) > 0) deviceName = pcommand; // create amazon ebs dbroot
callFree(pcommand); try
{
DBRootConfigList dbrootlist;
dbrootlist.push_back(atoi(DBrootID.c_str()));
oam.addDbroot(1, dbrootlist, PMVolumeSize);
sleep(2);
try {
volumeName = sysConfig->getConfig(InstallSection, volumeNameID);
deviceName = sysConfig->getConfig(InstallSection, deviceNameID);
}
catch(...)
{}
}
catch (exception& e)
{
cout << endl << "**** addDbroot Failed: " << e.what() << endl;
break;
}
} }
//write volume and device name //write volume and device name
@@ -4240,8 +4309,27 @@ bool storageSetup(string cloud)
if ( storageType == "1" ) if ( storageType == "1" )
UMStorageType = "internal"; UMStorageType = "internal";
else else
{
UMStorageType = "external"; UMStorageType = "external";
cout << endl;
oam.getSystemConfig("UMVolumeSize", UMVolumeSize);
string prompt = "Enter EBS Volume storage size in GB: (" + UMVolumeSize + "): ";
PMVolumeSize = callReadline(prompt);
//set DBRootStorageType
try {
sysConfig->setConfig(InstallSection, "UMVolumeSize", UMVolumeSize);
}
catch(...)
{
cout << "ERROR: Problem setting UMVolumeSize in the InfiniDB System Configuration file" << endl;
return false;
}
}
try { try {
sysConfig->setConfig(InstallSection, "UMStorageType", UMStorageType); sysConfig->setConfig(InstallSection, "UMStorageType", UMStorageType);
} }
@@ -4442,6 +4530,26 @@ bool storageSetup(string cloud)
} }
} }
// if external and amazon, prompt for storage size
if ( storageType == "2" && cloud == "amazon")
{
cout << endl;
oam.getSystemConfig("PMVolumeSize", PMVolumeSize);
string prompt = "Enter EBS Volume storage size in GB: (" + PMVolumeSize + "): ";
PMVolumeSize = callReadline(prompt);
//set DBRootStorageType
try {
sysConfig->setConfig(InstallSection, "PMVolumeSize", PMVolumeSize);
}
catch(...)
{
cout << "ERROR: Problem setting PMVolumeSize in the InfiniDB System Configuration file" << endl;
return false;
}
}
// if gluster // if gluster
if ( storageType == "3" ) if ( storageType == "3" )
{ {

View File

@@ -4656,42 +4656,13 @@ int ProcessManager::addModule(oam::DeviceNetworkList devicenetworklist, std::str
if ( volumeName.empty() || volumeName == oam::UnassignedName ) { if ( volumeName.empty() || volumeName == oam::UnassignedName ) {
// need to create a new one // need to create a new one
string UMVolumeSize = "10"; string device;
try{ try{
oam.getSystemConfig("UMVolumeSize", UMVolumeSize);
oam.addUMdisk(moduleID, volumeName, device);
} }
catch(...) {} catch(...) {
log.writeLog(__LINE__, "addModule: volume create failed for um: " + moduleName, LOG_TYPE_CRITICAL);
log.writeLog(__LINE__, "addModule - Create new Volume for: " + (*listPT).DeviceName, LOG_TYPE_DEBUG);
string volumeName = oam.createEC2Volume(UMVolumeSize);
if ( volumeName == "failed" ) {
log.writeLog(__LINE__, "addModule: create volume failed", LOG_TYPE_CRITICAL);
pthread_mutex_unlock(&THREAD_LOCK);
return API_FAILURE;
}
//attach and format volumes
string device = "/dev/sdf" + oam.itoa(moduleID);
string localInstance = oam.getEC2LocalInstance();
//attach volumes to local instance
log.writeLog(__LINE__, "addModule - Attach new Volume to local instance: " + volumeName, LOG_TYPE_DEBUG);
if (!oam.attachEC2Volume(volumeName, device, localInstance)) {
log.writeLog(__LINE__, "addModule: volume failed to attach to local instance", LOG_TYPE_CRITICAL);
pthread_mutex_unlock(&THREAD_LOCK);
return API_FAILURE;
}
//format attached volume
log.writeLog(__LINE__, "addModule - Format new Volume for: " + volumeName, LOG_TYPE_DEBUG);
string cmd = "mkfs.ext2 -F " + device + " > /dev/null 2>&1";
system(cmd.c_str());
//detach volume
log.writeLog(__LINE__, "addModule - detach new Volume from local instance: " + volumeName, LOG_TYPE_DEBUG);
if (!oam.detachEC2Volume(volumeName)) {
log.writeLog(__LINE__, "addModule: volume failed to deattach to local instance", LOG_TYPE_CRITICAL);
pthread_mutex_unlock(&THREAD_LOCK); pthread_mutex_unlock(&THREAD_LOCK);
} }
@@ -4713,21 +4684,6 @@ int ProcessManager::addModule(oam::DeviceNetworkList devicenetworklist, std::str
catch(...) catch(...)
{} {}
// add instance tag
string systemName;
{
try{
oam.getSystemConfig("SystemName", systemName);
}
catch(...) {}
}
if ( AmazonAutoTagging == "y" )
{
string tagValue = systemName + "-" + moduleName;
oam.createEC2tag( volumeName, "Name", tagValue );
}
log.writeLog(__LINE__, "addModule - create/attach new volume: " + volumeName + "/" + device, LOG_TYPE_DEBUG); log.writeLog(__LINE__, "addModule - create/attach new volume: " + volumeName + "/" + device, LOG_TYPE_DEBUG);
} }