1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-2129 - added a new postConfigure flag -xr to reverse dns lookup given hostnames and use that value instead of the original hostname value

This commit is contained in:
sneJ-
2019-02-01 15:00:26 +01:00
parent 13398fa530
commit dd05b3af13

View File

@ -55,7 +55,6 @@
#include <arpa/inet.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <stdio.h>
#include <string.h> /* for strncpy */
#include <sys/types.h>
@ -111,8 +110,6 @@ typedef std::vector<ModuleIP> ModuleIpList;
void offLineAppCheck();
bool setOSFiles(string parentOAMModuleName, int serverTypeInstall);
bool checkSaveConfigFile();
string getModuleName();
bool setModuleName(string moduleName);
bool updateBash();
bool makeModuleFile(string moduleName, string parentOAMModuleName);
bool updateProcessConfig();
@ -126,6 +123,7 @@ bool singleServerDBrootSetup();
bool copyFstab(string moduleName);
bool attachVolume(string instanceName, string volumeName, string deviceName, string dbrootPath);
void singleServerConfigSetup(Config* sysConfig);
std::string resolveHostNameToReverseDNSName(std::string hostname);
void remoteInstallThread(void*);
@ -193,6 +191,7 @@ bool single_server_quick_install = false;
bool multi_server_quick_install = false;
bool amazon_quick_install = false;
bool doNotResolveHostNames = false;
bool resolveHostNamesToReverseDNSNames = false;
string DataFileEnvFile;
@ -316,7 +315,7 @@ int main(int argc, char* argv[])
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][-qs][-qm][-qa][-port][-i][-n][-d][-sn][-pm-ip-addrs][-um-ip-addrs][-pm-count][-um-count][-numBlocksPct][-totalUmMemory]" << 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][-x][-xr][-numBlocksPct][-totalUmMemory]" << 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;
@ -332,6 +331,7 @@ int main(int argc, char* argv[])
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;
cout << " -x Do not resolve IP Addresses from host names" << endl;
cout << " -xr Resolve host names into their reverse DNS host names. Only applied in combination with -x" << endl;
cout << " -numBlocksPct amount of physical memory to utilize for disk block caching" << endl;
cout << " (percentages of the total memory need to be stated without suffix, explcit values with suffixes M or G)" << endl;
cout << " -totalUmMemory amount of physical memory to utilize for joins, intermediate results and set operations on the UM" << endl;
@ -341,6 +341,10 @@ int main(int argc, char* argv[])
else if (string("-x") == argv[i])
{
doNotResolveHostNames = true;
}
else if (string("-xr") == argv[i])
{
resolveHostNamesToReverseDNSNames = true;
}
else if( string("-qs") == argv[i] )
{
@ -517,7 +521,7 @@ int main(int argc, char* argv[])
else
{
cout << " ERROR: Invalid Argument = " << argv[i] << 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][-numBlocksPct][-totalUmMemory]" << 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][-x][-xr][-numBlocksPct][-totalUmMemory]" << endl;
exit (1);
}
}
@ -2566,7 +2570,12 @@ int main(int argc, char* argv[])
//get IP Address
string IPAddress;
if (doNotResolveHostNames)
if (resolveHostNamesToReverseDNSNames) {
IPAddress = resolveHostNameToReverseDNSName(newModuleHostName);
}
else {
IPAddress = newModuleHostName;
}
else
IPAddress = oam.getIPAddress( newModuleHostName);
@ -6550,7 +6559,12 @@ bool glusterSetup(string password, bool doNotResolveHostNames)
//get IP Address
string IPAddress;
if (doNotResolveHostNames)
if (resolveHostNamesToReverseDNSNames) {
IPAddress = resolveHostNameToReverseDNSName(moduleHostName);
}
else {
IPAddress = moduleHostName;
}
else
IPAddress = oam.getIPAddress( moduleHostName);
@ -7111,6 +7125,25 @@ void singleServerConfigSetup(Config* sysConfig)
return;
}
/**
Resolves the given hostname into its reverse DNS name.
@param hostname the hostname to resolve.
@return the reverse dns name of given hostname or an empty string in case the hostname could not be resolved.
*/
std::string resolveHostNameToReverseDNSName(std::string hostname) {
struct hostent *hp = gethostbyname(hostname.c_str());
if (hp == NULL) {
std::cout << "Error: Couldn't resolve hostname " << hostname << " to ip address" << std::endl;
return "";
}
struct hostent *rl = gethostbyaddr(hp->h_addr_list[0], sizeof hp->h_addr_list[0], AF_INET);
if (rl == NULL) {
std::cout << "Error: Couldn't resolve ip address of hostname " << hostname << " back to a hostname" << std::endl;
return "";
}
hostname = rl->h_name;
return hostname;
}
// vim:ts=4 sw=4: