Commit 5cccb453 authored by unknown's avatar unknown

-d default on ndb_mgmd and ndbd

-i depricated on ndbd
fixed bug in shutdown command in ndb_mgm


ndb/src/mgmsrv/main.cpp:
  added config.ini as default configuration file
  -d default on ndb_mgmd and ndbd
  -i depricated on ndbd
  fixed bug in shutdown command in ndb_mgm
parent 862d056d
...@@ -54,7 +54,7 @@ while test $# -gt 0; do ...@@ -54,7 +54,7 @@ while test $# -gt 0; do
stop_ndb=1 stop_ndb=1
;; ;;
--initial) --initial)
flags_ndb="$flags_ndb -i" flags_ndb="$flags_ndb --initial"
initial_ndb=1 initial_ndb=1
;; ;;
--debug*) --debug*)
...@@ -143,7 +143,7 @@ fi ...@@ -143,7 +143,7 @@ fi
rm -f "$cfgfile" 2>&1 | cat > /dev/null rm -f "$cfgfile" 2>&1 | cat > /dev/null
rm -f "$fs_ndb/$cfgfile" 2>&1 | cat > /dev/null rm -f "$fs_ndb/$cfgfile" 2>&1 | cat > /dev/null
if ( cd "$fs_ndb" ; $exec_mgmtsrvr -d -c config.ini ) ; then :; else if ( cd "$fs_ndb" ; $exec_mgmtsrvr -c config.ini ) ; then :; else
echo "Unable to start $exec_mgmtsrvr from `pwd`" echo "Unable to start $exec_mgmtsrvr from `pwd`"
exit 1 exit 1
fi fi
...@@ -153,14 +153,14 @@ cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" ...@@ -153,14 +153,14 @@ cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
# Start database node # Start database node
echo "Starting ndbd" echo "Starting ndbd"
( cd "$fs_ndb" ; $exec_ndb -d $flags_ndb & ) ( cd "$fs_ndb" ; $exec_ndb $flags_ndb & )
cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
# Start database node # Start database node
echo "Starting ndbd" echo "Starting ndbd"
( cd "$fs_ndb" ; $exec_ndb -d $flags_ndb & ) ( cd "$fs_ndb" ; $exec_ndb $flags_ndb & )
cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile" cat `find "$fs_ndb" -name 'ndb_*.pid'` > "$fs_ndb/$pidfile"
......
...@@ -56,7 +56,8 @@ Configuration::init(int argc, const char** argv){ ...@@ -56,7 +56,8 @@ Configuration::init(int argc, const char** argv){
int _no_start = 0; int _no_start = 0;
int _initial = 0; int _initial = 0;
const char* _connect_str = NULL; const char* _connect_str = NULL;
int _deamon = 0; int _daemon = 1;
int _no_daemon = 0;
int _help = 0; int _help = 0;
int _print_version = 0; int _print_version = 0;
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -71,12 +72,13 @@ Configuration::init(int argc, const char** argv){ ...@@ -71,12 +72,13 @@ Configuration::init(int argc, const char** argv){
{ "version", 'v', arg_flag, &_print_version, "Print ndbd version", "" }, { "version", 'v', arg_flag, &_print_version, "Print ndbd version", "" },
{ "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, &_daemon, "Start ndbd as daemon (default)", "" },
{ "nodaemon", 0, arg_flag, &_no_daemon, "Do not start ndbd as daemon, provided for testing purposes", "" },
#ifndef DBUG_OFF #ifndef DBUG_OFF
{ "debug", 0, arg_string, &debug_option, { "debug", 0, arg_string, &debug_option,
"Specify debug options e.g. d:t:i:o,out.trace", "options" }, "Specify debug options e.g. d:t:i:o,out.trace", "options" },
#endif #endif
{ "initial", 'i', arg_flag, &_initial, { "initial", 0, 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", "" },
{ "connect-string", 'c', arg_string, &_connect_str, { "connect-string", 'c', arg_string, &_connect_str,
...@@ -91,18 +93,27 @@ Configuration::init(int argc, const char** argv){ ...@@ -91,18 +93,27 @@ Configuration::init(int argc, const char** argv){
if(getarg(args, num_args, argc, argv, &optind) || _help) { if(getarg(args, num_args, argc, argv, &optind) || _help) {
arg_printusage(args, num_args, argv[0], desc); arg_printusage(args, num_args, argv[0], desc);
for (int i = 0; i < argc; i++) {
if (strcmp("-i",argv[i]) == 0) {
printf("flag depricated %s, use %s\n", "-i", "--initial");
}
}
return false; return false;
} }
if (_no_daemon) {
_daemon= 0;
}
// check for depricated flag '-i'
#ifndef DBUG_OFF
my_init(); my_init();
#ifndef DBUG_OFF
if (debug_option) if (debug_option)
DBUG_PUSH(debug_option); DBUG_PUSH(debug_option);
#endif #endif
DBUG_PRINT("info", ("no_start=%d", _no_start)); DBUG_PRINT("info", ("no_start=%d", _no_start));
DBUG_PRINT("info", ("initial=%d", _initial)); DBUG_PRINT("info", ("initial=%d", _initial));
DBUG_PRINT("info", ("deamon=%d", _deamon)); DBUG_PRINT("info", ("daemon=%d", _daemon));
DBUG_PRINT("info", ("connect_str=%s", _connect_str)); DBUG_PRINT("info", ("connect_str=%s", _connect_str));
ndbSetOwnVersion(); ndbSetOwnVersion();
...@@ -126,8 +137,8 @@ Configuration::init(int argc, const char** argv){ ...@@ -126,8 +137,8 @@ Configuration::init(int argc, const char** argv){
if (_connect_str) if (_connect_str)
_connectString = strdup(_connect_str); _connectString = strdup(_connect_str);
// Check deamon flag // Check daemon flag
if (_deamon) if (_daemon)
_daemonMode = true; _daemonMode = true;
// Save programname // Save programname
...@@ -202,7 +213,7 @@ Configuration::fetch_configuration(){ ...@@ -202,7 +213,7 @@ Configuration::fetch_configuration(){
if((globalData.ownId = cr.allocNodeId()) == 0){ if((globalData.ownId = cr.allocNodeId()) == 0){
for(Uint32 i = 0; i<3; i++){ for(Uint32 i = 0; i<3; i++){
NdbSleep_SecSleep(3); NdbSleep_SecSleep(3);
if(globalData.ownId = cr.allocNodeId()) if((globalData.ownId = cr.allocNodeId()) != 0)
break; break;
} }
} }
......
...@@ -655,13 +655,13 @@ CommandInterpreter::executeShutdown(char* parameters) ...@@ -655,13 +655,13 @@ CommandInterpreter::executeShutdown(char* parameters)
int result = 0; int result = 0;
result = ndb_mgm_stop(m_mgmsrv, 0, 0); result = ndb_mgm_stop(m_mgmsrv, 0, 0);
if (result <= 0) { if (result < 0) {
ndbout << "Shutdown failed." << endl; ndbout << "Shutdown failed." << endl;
printError(); printError();
return; return;
} }
ndbout << "NDB Cluster storage node(s) have shutdown." << endl; ndbout << result << " NDB Cluster storage node(s) have shutdown." << endl;
int mgm_id= 0; int mgm_id= 0;
for(int i=0; i < state->no_of_nodes; i++) { for(int i=0; i < state->no_of_nodes; i++) {
...@@ -989,7 +989,7 @@ CommandInterpreter::executeStop(int processId, const char *, bool all) ...@@ -989,7 +989,7 @@ CommandInterpreter::executeStop(int processId, const char *, bool all)
} else { } else {
result = ndb_mgm_stop(m_mgmsrv, 1, &processId); result = ndb_mgm_stop(m_mgmsrv, 1, &processId);
} }
if (result <= 0) { if (result < 0) {
ndbout << "Shutdown failed." << endl; ndbout << "Shutdown failed." << endl;
printError(); printError();
} else } else
......
...@@ -61,6 +61,7 @@ struct MgmGlobals { ...@@ -61,6 +61,7 @@ struct MgmGlobals {
/** Command line arguments */ /** Command line arguments */
int daemon; // NOT bool, bool need not be int int daemon; // NOT bool, bool need not be int
int non_interactive; int non_interactive;
int interactive;
const char * config_filename; const char * config_filename;
const char * local_config_filename; const char * local_config_filename;
...@@ -112,10 +113,12 @@ struct getargs args[] = { ...@@ -112,10 +113,12 @@ struct getargs args[] = {
"Specify debug options e.g. 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 (default)" },
{ NULL, 'l', arg_string, &glob.local_config_filename, { NULL, 'l', arg_string, &glob.local_config_filename,
"Specify configuration file connect string (will default use Ndb.cfg if available)", "Specify configuration file connect string (will default use Ndb.cfg if available)",
"filename" }, "filename" },
{ "interactive", 0, arg_flag, &glob.interactive,
"Run interactive. Not supported but provided for testing purposes", "" },
{ "nodaemon", 'n', arg_flag, &glob.non_interactive, { "nodaemon", 'n', arg_flag, &glob.non_interactive,
"Don't run as daemon, but don't read from stdin", "non-interactive" } "Don't run as daemon, but don't read from stdin", "non-interactive" }
}; };
...@@ -143,6 +146,11 @@ NDB_MAIN(mgmsrv){ ...@@ -143,6 +146,11 @@ NDB_MAIN(mgmsrv){
exit(1); exit(1);
} }
if (glob.interactive ||
glob.non_interactive) {
glob.daemon= 0;
}
#ifndef DBUG_OFF #ifndef DBUG_OFF
my_init(); my_init();
if (debug_option) if (debug_option)
...@@ -155,8 +163,7 @@ NDB_MAIN(mgmsrv){ ...@@ -155,8 +163,7 @@ NDB_MAIN(mgmsrv){
} }
if(glob.config_filename == NULL) { if(glob.config_filename == NULL) {
fprintf(stderr, "No configuration file specified\n"); glob.config_filename= "config.ini";
exit(1);
} }
glob.socketServer = new SocketServer(); glob.socketServer = new SocketServer();
...@@ -178,6 +185,8 @@ NDB_MAIN(mgmsrv){ ...@@ -178,6 +185,8 @@ NDB_MAIN(mgmsrv){
"" : glob.local_config_filename), "" : glob.local_config_filename),
glob.cluster_config); glob.cluster_config);
chdir(NdbConfig_get_path(0));
glob.cluster_config = 0; glob.cluster_config = 0;
glob.localNodeId= glob.mgmObject->getOwnNodeId(); glob.localNodeId= glob.mgmObject->getOwnNodeId();
...@@ -269,7 +278,7 @@ NDB_MAIN(mgmsrv){ ...@@ -269,7 +278,7 @@ NDB_MAIN(mgmsrv){
glob.socketServer->startServer(); glob.socketServer->startServer();
#if ! defined NDB_OSE && ! defined NDB_SOFTOSE #if ! defined NDB_OSE && ! defined NDB_SOFTOSE
if(!glob.daemon && !glob.non_interactive){ if(glob.interactive) {
CommandInterpreter com(* glob.mgmObject); CommandInterpreter com(* glob.mgmObject);
while(com.readAndExecute()); while(com.readAndExecute());
} else } else
...@@ -296,8 +305,9 @@ MgmGlobals::MgmGlobals(){ ...@@ -296,8 +305,9 @@ MgmGlobals::MgmGlobals(){
local_config_filename = NULL; local_config_filename = NULL;
interface_name = 0; interface_name = 0;
cluster_config = 0; cluster_config = 0;
daemon = false; daemon = 1;
non_interactive = 0; non_interactive = 0;
interactive = 0;
socketServer = 0; socketServer = 0;
mgmObject = 0; mgmObject = 0;
} }
......
...@@ -465,7 +465,7 @@ setup_config(atrt_config& config){ ...@@ -465,7 +465,7 @@ setup_config(atrt_config& config){
proc.m_type = atrt_process::NDB_DB; proc.m_type = atrt_process::NDB_DB;
proc.m_proc.m_name.assfmt("%d-%s", index, "ndbd"); proc.m_proc.m_name.assfmt("%d-%s", index, "ndbd");
proc.m_proc.m_path.assign(dir).append("/libexec/ndbd"); proc.m_proc.m_path.assign(dir).append("/libexec/ndbd");
proc.m_proc.m_args = "-i -n"; proc.m_proc.m_args = "--initial --nodaemon -n";
proc.m_proc.m_cwd.appfmt("%d.ndbd", index); proc.m_proc.m_cwd.appfmt("%d.ndbd", index);
} else if(split1[0] == "mysqld"){ } else if(split1[0] == "mysqld"){
proc.m_type = atrt_process::MYSQL_SERVER; proc.m_type = atrt_process::MYSQL_SERVER;
......
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