Commit c42ce285 authored by unknown's avatar unknown

ndb cluster config fixes, se respective files


mysql-test/ndb/ndb_config_2_node.ini:
  added new config parameter datadir
ndb/include/mgmapi/mgmapi_config_parameters.h:
  added new config parameter datadir and backup data dir
ndb/include/mgmcommon/ConfigRetriever.hpp:
  changed verify config so that it can be used by mgmt srvr
ndb/include/mgmcommon/NdbConfig.h:
  added option to set path for ndb files
ndb/src/common/mgmcommon/ConfigInfo.cpp:
  changed token names for DB, MGM and API
  added config parametsers for datadir and backup data dir
ndb/src/common/mgmcommon/ConfigRetriever.cpp:
  changed verify config so that it can be used by mgmt srvr
ndb/src/common/mgmcommon/InitConfigFileParser.cpp:
  no need anymore to make uppercase
ndb/src/common/mgmcommon/NdbConfig.c:
  bugfix+
  added method to set datadir
ndb/src/kernel/Makefile.am:
  added debug libs to ndbd
ndb/src/kernel/vm/Configuration.cpp:
  added debug libs to ndbd
ndb/src/mgmsrv/MgmtSrvr.cpp:
  added verify config to mgmt srvr
ndb/src/mgmsrv/main.cpp:
  .
parent e387719d
...@@ -5,15 +5,16 @@ DataMemory= CHOOSE_DataMemory ...@@ -5,15 +5,16 @@ DataMemory= CHOOSE_DataMemory
IndexMemory= CHOOSE_IndexMemory IndexMemory= CHOOSE_IndexMemory
Diskless= CHOOSE_Diskless Diskless= CHOOSE_Diskless
TimeBetweenWatchDogCheck= 30000 TimeBetweenWatchDogCheck= 30000
FileSystemPath= CHOOSE_FILESYSTEM DataDir= CHOOSE_FILESYSTEM
[ndbd] [ndbd]
HostName: CHOOSE_HOSTNAME_1 HostName= CHOOSE_HOSTNAME_1
[ndbd] [ndbd]
HostName: CHOOSE_HOSTNAME_2 HostName= CHOOSE_HOSTNAME_2
[ndb_mgmd] [ndb_mgmd]
DataDir= CHOOSE_FILESYSTEM
PortNumber= CHOOSE_PORT_MGM PortNumber= CHOOSE_PORT_MGM
[mysqld] [mysqld]
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define CFG_NODE_BYTE_ORDER 4 #define CFG_NODE_BYTE_ORDER 4
#define CFG_NODE_HOST 5 #define CFG_NODE_HOST 5
#define CFG_NODE_SYSTEM 6 #define CFG_NODE_SYSTEM 6
#define CFG_NODE_DATADIR 7
/** /**
* DB config parameters * DB config parameters
...@@ -89,6 +90,8 @@ ...@@ -89,6 +90,8 @@
#define CFG_DB_LONG_SIGNAL_BUFFER 157 #define CFG_DB_LONG_SIGNAL_BUFFER 157
#define CFG_DB_BACKUP_DATA_PATH 158
#define CFG_NODE_ARBIT_RANK 200 #define CFG_NODE_ARBIT_RANK 200
#define CFG_NODE_ARBIT_DELAY 201 #define CFG_NODE_ARBIT_DELAY 201
......
...@@ -78,6 +78,11 @@ public: ...@@ -78,6 +78,11 @@ public:
* Get config from file * Get config from file
*/ */
struct ndb_mgm_configuration * getConfig(const char * file); struct ndb_mgm_configuration * getConfig(const char * file);
/**
* Verify config
*/
bool verifyConfig(const struct ndb_mgm_configuration *, Uint32 nodeid);
private: private:
BaseString errorString; BaseString errorString;
enum ErrorType { enum ErrorType {
...@@ -97,11 +102,6 @@ private: ...@@ -97,11 +102,6 @@ private:
Uint32 m_version; Uint32 m_version;
Uint32 m_node_type; Uint32 m_node_type;
NdbMgmHandle m_handle; NdbMgmHandle m_handle;
/**
* Verify config
*/
bool verifyConfig(const struct ndb_mgm_configuration *);
}; };
#endif #endif
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
extern "C" { extern "C" {
#endif #endif
void NdbConfig_SetPath(const char *path);
char* NdbConfig_NdbCfgName(int with_ndb_home); char* NdbConfig_NdbCfgName(int with_ndb_home);
char* NdbConfig_ErrorFileName(int node_id); char* NdbConfig_ErrorFileName(int node_id);
char* NdbConfig_ClusterLogFileName(int node_id); char* NdbConfig_ClusterLogFileName(int node_id);
......
This diff is collapsed.
...@@ -154,7 +154,7 @@ ConfigRetriever::getConfig() { ...@@ -154,7 +154,7 @@ ConfigRetriever::getConfig() {
if(p == 0) if(p == 0)
return 0; return 0;
if(!verifyConfig(p)){ if(!verifyConfig(p, _ownNodeId)){
free(p); free(p);
p= 0; p= 0;
} }
...@@ -239,7 +239,7 @@ ConfigRetriever::setConnectString(const char * connectString) { ...@@ -239,7 +239,7 @@ ConfigRetriever::setConnectString(const char * connectString) {
} }
bool bool
ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32 nodeid){
char buf[255]; char buf[255];
ndb_mgm_configuration_iterator * it; ndb_mgm_configuration_iterator * it;
...@@ -253,8 +253,8 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ ...@@ -253,8 +253,8 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){
} }
NdbAutoPtr<ndb_mgm_configuration_iterator> ptr(it); NdbAutoPtr<ndb_mgm_configuration_iterator> ptr(it);
if(ndb_mgm_find(it, CFG_NODE_ID, _ownNodeId) != 0){ if(ndb_mgm_find(it, CFG_NODE_ID, nodeid) != 0){
snprintf(buf, 255, "Unable to find node with id: %d", _ownNodeId); snprintf(buf, 255, "Unable to find node with id: %d", nodeid);
setError(CR_ERROR, buf); setError(CR_ERROR, buf);
return false; return false;
} }
...@@ -266,6 +266,11 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ ...@@ -266,6 +266,11 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){
return false; return false;
} }
const char * datadir;
if(!ndb_mgm_get_string_parameter(it, CFG_NODE_DATADIR, &datadir)){
NdbConfig_SetPath(datadir);
}
char localhost[MAXHOSTNAMELEN]; char localhost[MAXHOSTNAMELEN];
if(NdbHost_GetHostName(localhost) != 0){ if(NdbHost_GetHostName(localhost) != 0){
snprintf(buf, 255, "Unable to get own hostname"); snprintf(buf, 255, "Unable to get own hostname");
...@@ -332,8 +337,8 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ ...@@ -332,8 +337,8 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){
if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue; if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue;
if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue; if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue;
if(nodeId1 != _ownNodeId && nodeId2 != _ownNodeId) continue; if(nodeId1 != nodeid && nodeId2 != nodeid) continue;
remoteNodeId = (_ownNodeId == nodeId1 ? nodeId2 : nodeId1); remoteNodeId = (nodeid == nodeId1 ? nodeId2 : nodeId1);
const char * name; const char * name;
struct in_addr addr; struct in_addr addr;
...@@ -342,7 +347,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ ...@@ -342,7 +347,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){
if(Ndb_getInAddr(&addr, name) != 0){ if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, " tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d", "connection from node %d to node %d",
name, _ownNodeId, remoteNodeId); name, nodeid, remoteNodeId);
setError(CR_ERROR, tmp.c_str()); setError(CR_ERROR, tmp.c_str());
return false; return false;
} }
...@@ -352,7 +357,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){ ...@@ -352,7 +357,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf){
if(Ndb_getInAddr(&addr, name) != 0){ if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, " tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d", "connection from node %d to node %d",
name, _ownNodeId, remoteNodeId); name, nodeid, remoteNodeId);
setError(CR_ERROR, tmp.c_str()); setError(CR_ERROR, tmp.c_str());
return false; return false;
} }
......
...@@ -480,10 +480,6 @@ InitConfigFileParser::parseSectionHeader(const char* line) const { ...@@ -480,10 +480,6 @@ InitConfigFileParser::parseSectionHeader(const char* line) const {
tmp[0] = ' '; tmp[0] = ' ';
trim(tmp); trim(tmp);
// Convert section header to upper
for(int i= strlen(tmp)-1; i >= 0; i--)
tmp[i]= toupper(tmp[i]);
// Get the correct header name if an alias // Get the correct header name if an alias
{ {
const char *tmp_alias= m_info->getAlias(tmp); const char *tmp_alias= m_info->getAlias(tmp);
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include <NdbEnv.h> #include <NdbEnv.h>
#include <NdbMem.h> #include <NdbMem.h>
static char *datadir_path= 0;
static char* static char*
NdbConfig_AllocHomePath(int _len) NdbConfig_AllocHomePath(int _len)
{ {
...@@ -27,19 +29,27 @@ NdbConfig_AllocHomePath(int _len) ...@@ -27,19 +29,27 @@ NdbConfig_AllocHomePath(int _len)
int path_len= 0; int path_len= 0;
char *buf; char *buf;
if (path == 0)
path= datadir_path;
if (path) if (path)
path_len= strlen(path); path_len= strlen(path);
len+= path_len; len+= path_len;
buf= NdbMem_Allocate(len); buf= NdbMem_Allocate(len);
if (path_len > 0) if (path_len > 0)
snprintf(buf, len, "%s%c", path, DIR_SEPARATOR); snprintf(buf, len, "%s%s", path, DIR_SEPARATOR);
else else
buf[0]= 0; buf[0]= 0;
return buf; return buf;
} }
void
NdbConfig_SetPath(const char* path){
datadir_path= path;
}
char* char*
NdbConfig_NdbCfgName(int with_ndb_home){ NdbConfig_NdbCfgName(int with_ndb_home){
char *buf; char *buf;
......
...@@ -52,7 +52,10 @@ LDADD += \ ...@@ -52,7 +52,10 @@ LDADD += \
$(top_builddir)/ndb/src/common/mgmcommon/libmgmsrvcommon.la \ $(top_builddir)/ndb/src/common/mgmcommon/libmgmsrvcommon.la \
$(top_builddir)/ndb/src/mgmapi/libmgmapi.la \ $(top_builddir)/ndb/src/mgmapi/libmgmapi.la \
$(top_builddir)/ndb/src/common/portlib/libportlib.la \ $(top_builddir)/ndb/src/common/portlib/libportlib.la \
$(top_builddir)/ndb/src/common/util/libgeneral.la $(top_builddir)/ndb/src/common/util/libgeneral.la \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include <my_sys.h>
#include "Configuration.hpp" #include "Configuration.hpp"
#include <ErrorHandlingMacros.hpp> #include <ErrorHandlingMacros.hpp>
#include "GlobalData.hpp" #include "GlobalData.hpp"
...@@ -56,6 +59,9 @@ Configuration::init(int argc, const char** argv){ ...@@ -56,6 +59,9 @@ Configuration::init(int argc, const char** argv){
int _deamon = 0; int _deamon = 0;
int _help = 0; int _help = 0;
int _print_version = 0; int _print_version = 0;
#ifndef DBUG_OFF
const char *debug_option= 0;
#endif
/** /**
* Arguments to NDB process * Arguments to NDB process
...@@ -66,6 +72,10 @@ Configuration::init(int argc, const char** argv){ ...@@ -66,6 +72,10 @@ Configuration::init(int argc, const char** argv){
{ "nostart", 'n', arg_flag, &_no_start, { "nostart", 'n', arg_flag, &_no_start,
"Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", "" }, "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", "" },
{ "daemon", 'd', arg_flag, &_deamon, "Start ndbd as daemon", "" }, { "daemon", 'd', arg_flag, &_deamon, "Start ndbd as daemon", "" },
#ifndef DBUG_OFF
{ "debug", 0, arg_string, &debug_option,
"Specify debug options e.g. d:t:i:o,out.trace", "options" },
#endif
{ "initial", 'i', arg_flag, &_initial, { "initial", 'i', arg_flag, &_initial,
"Perform initial start of ndbd, including cleaning the file system. Consult documentation before using this", "" }, "Perform initial start of ndbd, including cleaning the file system. Consult documentation before using this", "" },
...@@ -84,15 +94,17 @@ Configuration::init(int argc, const char** argv){ ...@@ -84,15 +94,17 @@ Configuration::init(int argc, const char** argv){
return false; return false;
} }
#if 0 #ifndef DBUG_OFF
ndbout << "no_start=" <<_no_start<< endl; my_init();
ndbout << "initial=" <<_initial<< endl; if (debug_option)
ndbout << "deamon=" <<_deamon<< endl; DBUG_PUSH(debug_option);
ndbout << "connect_str="<<_connect_str<<endl;
arg_printusage(args, num_args, argv[0], desc);
return false;
#endif #endif
DBUG_PRINT("info", ("no_start=%d", _no_start));
DBUG_PRINT("info", ("initial=%d", _initial));
DBUG_PRINT("info", ("deamon=%d", _deamon));
DBUG_PRINT("info", ("connect_str=%s", _connect_str));
ndbSetOwnVersion(); ndbSetOwnVersion();
if (_print_version) { if (_print_version) {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "MgmtSrvr.hpp" #include "MgmtSrvr.hpp"
#include "MgmtErrorReporter.hpp" #include "MgmtErrorReporter.hpp"
#include <ConfigRetriever.hpp>
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbApiSignal.hpp> #include <NdbApiSignal.hpp>
...@@ -512,6 +513,8 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, ...@@ -512,6 +513,8 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
theConfCount(0), theConfCount(0),
m_allocated_resources(*this) { m_allocated_resources(*this) {
DBUG_ENTER("MgmtSrvr::MgmtSrvr");
_config = NULL; _config = NULL;
_isStatPortActive = false; _isStatPortActive = false;
_isClusterLogStatActive = false; _isClusterLogStatActive = false;
...@@ -543,37 +546,39 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, ...@@ -543,37 +546,39 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
for(Uint32 i = 0; i<MAX_NODES; i++) for(Uint32 i = 0; i<MAX_NODES; i++)
nodeTypes[i] = (enum ndb_mgm_node_type)-1; nodeTypes[i] = (enum ndb_mgm_node_type)-1;
ndb_mgm_configuration_iterator * iter = ndb_mgm_create_configuration_iterator {
(config->m_configValues, CFG_SECTION_NODE); ndb_mgm_configuration_iterator * iter = ndb_mgm_create_configuration_iterator
for(ndb_mgm_first(iter); ndb_mgm_valid(iter); ndb_mgm_next(iter)){ (config->m_configValues, CFG_SECTION_NODE);
unsigned type, id; for(ndb_mgm_first(iter); ndb_mgm_valid(iter); ndb_mgm_next(iter)){
if(ndb_mgm_get_int_parameter(iter, CFG_TYPE_OF_SECTION, &type) != 0) unsigned type, id;
continue; if(ndb_mgm_get_int_parameter(iter, CFG_TYPE_OF_SECTION, &type) != 0)
continue;
if(ndb_mgm_get_int_parameter(iter, CFG_NODE_ID, &id) != 0)
continue;
MGM_REQUIRE(id < MAX_NODES);
switch(type){ if(ndb_mgm_get_int_parameter(iter, CFG_NODE_ID, &id) != 0)
case NODE_TYPE_DB: continue;
nodeTypes[id] = NDB_MGM_NODE_TYPE_NDB;
break; MGM_REQUIRE(id < MAX_NODES);
case NODE_TYPE_API:
nodeTypes[id] = NDB_MGM_NODE_TYPE_API; switch(type){
break; case NODE_TYPE_DB:
case NODE_TYPE_MGM: nodeTypes[id] = NDB_MGM_NODE_TYPE_NDB;
nodeTypes[id] = NDB_MGM_NODE_TYPE_MGM; break;
break; case NODE_TYPE_API:
case NODE_TYPE_REP: nodeTypes[id] = NDB_MGM_NODE_TYPE_API;
nodeTypes[id] = NDB_MGM_NODE_TYPE_REP; break;
break; case NODE_TYPE_MGM:
case NODE_TYPE_EXT_REP: nodeTypes[id] = NDB_MGM_NODE_TYPE_MGM;
default: break;
break; case NODE_TYPE_REP:
nodeTypes[id] = NDB_MGM_NODE_TYPE_REP;
break;
case NODE_TYPE_EXT_REP:
default:
break;
}
} }
ndb_mgm_destroy_iterator(iter);
} }
ndb_mgm_destroy_iterator(iter);
m_statisticsListner = NULL; m_statisticsListner = NULL;
...@@ -589,6 +594,18 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, ...@@ -589,6 +594,18 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
exit(-1); exit(-1);
} }
_ownNodeId = tmp; _ownNodeId = tmp;
{
DBUG_PRINT("info", ("verifyConfig"));
ConfigRetriever cr(NDB_VERSION, NDB_MGM_NODE_TYPE_MGM);
if (!cr.verifyConfig(config->m_configValues, _ownNodeId)) {
ndbout << cr.getErrorString() << endl;
exit(-1);
}
}
DBUG_VOID_RETURN;
} }
......
...@@ -109,7 +109,7 @@ struct getargs args[] = { ...@@ -109,7 +109,7 @@ struct getargs args[] = {
"Specify cluster configuration file", "filename" }, "Specify cluster configuration file", "filename" },
#ifndef DBUG_OFF #ifndef DBUG_OFF
{ "debug", 0, arg_string, &debug_option, { "debug", 0, arg_string, &debug_option,
"Specify debug option e.d. d:t:i:o,out.trace", "options" }, "Specify debug options e.g. d:t:i:o,out.trace", "options" },
#endif #endif
{ "daemon", 'd', arg_flag, &glob.daemon, { "daemon", 'd', arg_flag, &glob.daemon,
"Run ndb_mgmd in daemon mode" }, "Run ndb_mgmd in daemon mode" },
...@@ -143,8 +143,8 @@ NDB_MAIN(mgmsrv){ ...@@ -143,8 +143,8 @@ NDB_MAIN(mgmsrv){
exit(1); exit(1);
} }
my_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
my_init();
if (debug_option) if (debug_option)
DBUG_PUSH(debug_option); DBUG_PUSH(debug_option);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment