18 #include <ndb_global.h>
20 #include <kernel/NodeBitmask.hpp>
21 #include <portlib/ndb_daemon.h>
26 #include <EventLogger.hpp>
29 static int opt_daemon, opt_no_daemon, opt_foreground,
30 opt_initialstart, opt_verbose;
31 static const char* opt_nowait_nodes = 0;
32 static const char* opt_bind_address = 0;
33 static int opt_report_fd;
34 static int opt_initial;
35 static int opt_no_start;
36 static unsigned opt_allocated_nodeid;
40 static struct my_option my_long_options[] =
43 {
"initial", NDB_OPT_NOSHORT,
44 "Perform initial start of ndbd, including cleaning the file system. "
45 "Consult documentation before using this",
46 (uchar**) &opt_initial, (uchar**) &opt_initial, 0,
47 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
49 "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd",
50 (uchar**) &opt_no_start, (uchar**) &opt_no_start, 0,
51 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
52 {
"daemon",
'd',
"Start ndbd as daemon (default)",
53 (uchar**) &opt_daemon, (uchar**) &opt_daemon, 0,
54 GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
55 {
"nodaemon", NDB_OPT_NOSHORT,
56 "Do not start ndbd as daemon, provided for testing purposes",
57 (uchar**) &opt_no_daemon, (uchar**) &opt_no_daemon, 0,
58 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
59 {
"foreground", NDB_OPT_NOSHORT,
60 "Run real ndbd in foreground, provided for debugging purposes"
61 " (implies --nodaemon)",
62 (uchar**) &opt_foreground, (uchar**) &opt_foreground, 0,
63 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
64 {
"nowait-nodes", NDB_OPT_NOSHORT,
65 "Nodes that will not be waited for during start",
66 (uchar**) &opt_nowait_nodes, (uchar**) &opt_nowait_nodes, 0,
67 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
68 {
"initial-start", NDB_OPT_NOSHORT,
69 "Perform a partial initial start of the cluster. "
70 "Each node should be started with this option, as well as --nowait-nodes",
71 (uchar**) &opt_initialstart, (uchar**) &opt_initialstart, 0,
72 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
73 {
"bind-address", NDB_OPT_NOSHORT,
75 (uchar**) &opt_bind_address, (uchar**) &opt_bind_address, 0,
76 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
78 "Write more log messages",
79 (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0,
80 GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 },
82 "INTERNAL: fd where to write extra shutdown status",
83 (uchar**) &opt_report_fd, (uchar**) &opt_report_fd, 0,
84 GET_UINT, REQUIRED_ARG, 0, 0, ~0, 0, 0, 0 },
85 {
"allocated-nodeid", 256,
86 "INTERNAL: nodeid allocated by angel process",
87 (uchar**) &opt_allocated_nodeid, (uchar**) &opt_allocated_nodeid, 0,
88 GET_UINT, REQUIRED_ARG, 0, 0, ~0, 0, 0, 0 },
89 { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
92 const char *load_default_groups[]= {
"mysql_cluster",
"ndbd", 0 };
95 static void short_usage_sub(
void)
97 ndb_short_usage_sub(NULL);
98 ndb_service_print_options(
"ndbd");
103 ndb_usage(short_usage_sub, load_default_groups, my_long_options);
106 extern int g_ndb_init_need_monotonic;
108 #include "../common/util/parse_mask.hpp"
117 real_main(
int argc,
char** argv)
119 g_ndb_init_need_monotonic = 1;
135 ndb_opt_set_usage_funcs(short_usage_sub, usage);
136 load_defaults(
"my",load_default_groups,&argc,&argv);
139 opt_debug=
"d:t:O,/tmp/ndbd.trace";
143 const char* progname = argv[0];
145 for (
int i = 0;
i < argc;
i++)
147 if (ndb_is_load_default_arg_separator(argv[
i]))
149 original_args.push_back(argv[i]);
153 if ((ho_error=handle_options(&argc, &argv, my_long_options,
154 ndb_std_get_one_option)))
157 if (opt_no_daemon || opt_foreground) {
164 g_eventLogger->
enable(Logger::LL_DEBUG);
166 if (opt_nowait_nodes)
168 int res = parse_mask(opt_nowait_nodes, g_nowait_nodes);
169 if(res == -2 || (res > 0 && g_nowait_nodes.
get(0)))
171 g_eventLogger->
error(
"Invalid nodeid specified in nowait-nodes: %s",
177 g_eventLogger->
error(
"Unable to parse nowait-nodes argument: %s",
183 if (opt_foreground ||
184 opt_allocated_nodeid ||
187 ndbd_run(opt_foreground, opt_report_fd,
188 opt_ndb_connectstring, opt_ndb_nodeid, opt_bind_address,
189 opt_no_start, opt_initial, opt_initialstart,
190 opt_allocated_nodeid);
195 opt_ndb_connectstring,
206 main(
int argc,
char** argv)
208 return ndb_daemon_init(argc, argv, real_main, angel_stop,
209 "ndbd",
"MySQL Cluster Data Node Daemon");