diff options
-rw-r--r-- | ctdb/Makefile.in | 5 | ||||
-rw-r--r-- | ctdb/common/cmdline.c | 6 | ||||
-rwxr-xr-x | ctdb/config/statd-callout | 19 | ||||
-rw-r--r-- | ctdb/lib/util/debug.c | 4 | ||||
-rw-r--r-- | ctdb/packaging/RPM/ctdb.spec | 1 | ||||
-rw-r--r-- | ctdb/tools/ctdb.c | 115 | ||||
-rw-r--r-- | ctdb/utils/scsi_io/scsi_io.c (renamed from ctdb/scsi/scsi_io.c) | 0 | ||||
-rw-r--r-- | ctdb/web/nfs.html | 7 |
8 files changed, 96 insertions, 61 deletions
diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in index f1b08f14e9..9622180ce7 100644 --- a/ctdb/Makefile.in +++ b/ctdb/Makefile.in @@ -77,9 +77,9 @@ bin/ctdbd: $(CTDB_SERVER_OBJ) @echo Linking $@ @$(CC) $(CFLAGS) -o $@ $(CTDB_SERVER_OBJ) $(LIB_FLAGS) -bin/scsi_io: $(CTDB_CLIENT_OBJ) scsi/scsi_io.o +bin/scsi_io: $(CTDB_CLIENT_OBJ) utils/scsi_io/scsi_io.o @echo Linking $@ - @$(CC) $(CFLAGS) -o $@ scsi/scsi_io.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) + @$(CC) $(CFLAGS) -o $@ utils/scsi_io/scsi_io.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) bin/ctdb: $(CTDB_CLIENT_OBJ) tools/ctdb.o @echo Linking $@ @@ -145,6 +145,7 @@ install: all mkdir -p $(DESTDIR)$(etcdir)/ctdb/events.d ${INSTALLCMD} -m 755 bin/ctdb $(DESTDIR)$(bindir) ${INSTALLCMD} -m 755 bin/ctdbd $(DESTDIR)$(sbindir) + ${INSTALLCMD} -m 755 bin/smnotify $(DESTDIR)$(bindir) ${INSTALLCMD} -m 644 include/ctdb.h $(DESTDIR)$(includedir) ${INSTALLCMD} -m 644 include/ctdb_private.h $(DESTDIR)$(includedir) # for samba3 ${INSTALLCMD} -m 755 config/events $(DESTDIR)$(etcdir)/ctdb diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c index f8fca5e4a0..df01110e8a 100644 --- a/ctdb/common/cmdline.c +++ b/ctdb/common/cmdline.c @@ -102,20 +102,20 @@ struct ctdb_context *ctdb_cmdline_client(struct event_context *ev) /* initialise ctdb */ ctdb = ctdb_init(ev); if (ctdb == NULL) { - printf("Failed to init ctdb\n"); + fprintf(stderr, "Failed to init ctdb\n"); exit(1); } /* tell ctdb the socket address */ ret = ctdb_set_socketname(ctdb, ctdb_cmdline.socketname); if (ret == -1) { - printf("ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb)); + fprintf(stderr, "ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb)); exit(1); } ret = ctdb_socket_connect(ctdb); if (ret != 0) { - DEBUG(0,(__location__ " Failed to connect to daemon\n")); + fprintf(stderr, __location__ " Failed to connect to daemon\n"); talloc_free(ctdb); return NULL; } diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index 3f645ec732..0c61c4a27e 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -27,19 +27,22 @@ case "$1" in done ;; notify) - # restart the local lock manager and statd - /etc/init.d/nfslock stop > /dev/null 2>&1 - /etc/init.d/nfslock start > /dev/null 2>&1 # send out notifications to any additional ips we now serve for f in `/bin/ls /etc/ctdb/state/statd/ip/*`; do ip=`/bin/basename $f` - [ -d $STATD_SHARED_DIRECTORY/$ip ] && { - # we must copy to a different directory since rpc.statd gets - # "upset" if sm-notify touches the files. + [ -d $STATD_SHARED_DIRECTORY/$ip ] && [ -x /usr/bin/smnotify ] && { /bin/rm -rf /tmp/statd/$ip /bin/mkdir -p /tmp/statd/$ip - /bin/cp -apr $STATD_SHARED_DIRECTORY/$ip/* /tmp/statd/$ip - [ -x /usr/sbin/sm-notify ] && /usr/sbin/sm-notify -P /tmp/statd/$ip -v $ip -n + /bin/cp $STATD_SHARED_DIRECTORY/$ip/sm/* /tmp/statd/$ip + for g in `/bin/ls /tmp/statd/$ip/*`; do + client=`/bin/basename $g` + # send the notifications twice so we force the other + # end to recognice a state change has occured and that + # it MUST reclaim the locks. + # + /usr/bin/smnotify --client=$client --ip=$ip --server=$ip --stateval=4 + /usr/bin/smnotify --client=$client --ip=$ip --server=$ip --stateval=5 + done } done ;; diff --git a/ctdb/lib/util/debug.c b/ctdb/lib/util/debug.c index 1d709248be..78d465d52b 100644 --- a/ctdb/lib/util/debug.c +++ b/ctdb/lib/util/debug.c @@ -39,7 +39,7 @@ void do_debug(const char *format, ...) strftime(tbuf,sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm); - printf("%s.%06u [%5u]: %s", tbuf, (unsigned)t.tv_usec, (unsigned)getpid(), s); - fflush(stdout); + fprintf(stderr, "%s.%06u [%5u]: %s", tbuf, (unsigned)t.tv_usec, (unsigned)getpid(), s); + fflush(stderr); free(s); } diff --git a/ctdb/packaging/RPM/ctdb.spec b/ctdb/packaging/RPM/ctdb.spec index c9330e81e8..68cad76da1 100644 --- a/ctdb/packaging/RPM/ctdb.spec +++ b/ctdb/packaging/RPM/ctdb.spec @@ -102,6 +102,7 @@ fi %{_sysconfdir}/ctdb/statd-callout %{_sbindir}/ctdbd %{_bindir}/ctdb +%{_bindir}/smnotify %{_bindir}/onnode.ssh %{_bindir}/onnode.rsh %{_bindir}/onnode diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 7b44dc62cd..c864fdefdb 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -48,7 +48,7 @@ static int control_process_exists(struct ctdb_context *ctdb, int argc, const cha } if (sscanf(argv[0], "%u:%u", &vnn, &pid) != 2) { - printf("Badly formed vnn:pid\n"); + fprintf(stderr, "Badly formed vnn:pid\n"); return -1; } @@ -151,7 +151,7 @@ static int control_statistics_all(struct ctdb_context *ctdb) offsetof(struct ctdb_statistics, __last_counter) / sizeof(uint32_t); ret = ctdb_ctrl_statistics(ctdb, nodes[i], &s1); if (ret != 0) { - printf("Unable to get statistics from node %u\n", nodes[i]); + fprintf(stderr, "Unable to get statistics from node %u\n", nodes[i]); return ret; } for (j=0;j<num_ints;j++) { @@ -184,7 +184,7 @@ static int control_statistics(struct ctdb_context *ctdb, int argc, const char ** ret = ctdb_ctrl_statistics(ctdb, options.vnn, &statistics); if (ret != 0) { - printf("Unable to get statistics from node %u\n", options.vnn); + fprintf(stderr, "Unable to get statistics from node %u\n", options.vnn); return ret; } show_statistics(&statistics); @@ -201,7 +201,7 @@ static int control_statistics_reset(struct ctdb_context *ctdb, int argc, const c ret = ctdb_statistics_reset(ctdb, options.vnn); if (ret != 0) { - printf("Unable to reset statistics on node %u\n", options.vnn); + fprintf(stderr, "Unable to reset statistics on node %u\n", options.vnn); return ret; } return 0; @@ -217,13 +217,16 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv struct ctdb_vnn_map *vnnmap=NULL; struct ctdb_node_map *nodemap=NULL; uint32_t recmode, recmaster; - uint32_t myvnn; + int myvnn; myvnn = ctdb_ctrl_getvnn(ctdb, TIMELIMIT(), options.vnn); + if (myvnn == -1) { + return -1; + } ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), options.vnn, ctdb, &nodemap); if (ret != 0) { - printf("Unable to get nodemap from node %u\n", options.vnn); + fprintf(stderr, "Unable to get nodemap from node %u\n", options.vnn); return ret; } @@ -276,7 +279,7 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_getvnnmap(ctdb, TIMELIMIT(), options.vnn, ctdb, &vnnmap); if (ret != 0) { - printf("Unable to get vnnmap from node %u\n", options.vnn); + fprintf(stderr, "Unable to get vnnmap from node %u\n", options.vnn); return ret; } printf("Generation:%d\n",vnnmap->generation); @@ -287,14 +290,14 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_getrecmode(ctdb, TIMELIMIT(), options.vnn, &recmode); if (ret != 0) { - printf("Unable to get recmode from node %u\n", options.vnn); + fprintf(stderr, "Unable to get recmode from node %u\n", options.vnn); return ret; } printf("Recovery mode:%s (%d)\n",recmode==CTDB_RECOVERY_NORMAL?"NORMAL":"RECOVERY",recmode); ret = ctdb_ctrl_getrecmaster(ctdb, TIMELIMIT(), options.vnn, &recmaster); if (ret != 0) { - printf("Unable to get recmaster from node %u\n", options.vnn); + fprintf(stderr, "Unable to get recmaster from node %u\n", options.vnn); return ret; } printf("Recovery master:%d\n",recmaster); @@ -319,7 +322,7 @@ static int control_get_tickles(struct ctdb_context *ctdb, int argc, const char * ret = ctdb_ctrl_get_tcp_tickles(ctdb, TIMELIMIT(), options.vnn, ctdb, vnn, &list); if (ret == -1) { - printf("Unable to list tickles\n"); + fprintf(stderr, "Unable to list tickles\n"); return -1; } @@ -348,18 +351,18 @@ static int kill_tcp(struct ctdb_context *ctdb, int argc, const char **argv) } if (!parse_ip_port(argv[0], &killtcp.src)) { - printf("Bad IP:port '%s'\n", argv[0]); + fprintf(stderr, "Bad IP:port '%s'\n", argv[0]); return -1; } if (!parse_ip_port(argv[1], &killtcp.dst)) { - printf("Bad IP:port '%s'\n", argv[1]); + fprintf(stderr, "Bad IP:port '%s'\n", argv[1]); return -1; } ret = ctdb_ctrl_killtcp(ctdb, TIMELIMIT(), options.vnn, &killtcp); if (ret != 0) { - printf("Unable to killtcp from node %u\n", options.vnn); + fprintf(stderr, "Unable to killtcp from node %u\n", options.vnn); return ret; } @@ -379,18 +382,18 @@ static int tickle_tcp(struct ctdb_context *ctdb, int argc, const char **argv) } if (!parse_ip_port(argv[0], &src)) { - printf("Bad IP:port '%s'\n", argv[0]); + fprintf(stderr, "Bad IP:port '%s'\n", argv[0]); return -1; } if (!parse_ip_port(argv[1], &dst)) { - printf("Bad IP:port '%s'\n", argv[1]); + fprintf(stderr, "Bad IP:port '%s'\n", argv[1]); return -1; } s = ctdb_sys_open_sending_socket(); if (s == -1) { - printf("Failed to open socket for sending tickle\n"); + fprintf(stderr, "Failed to open socket for sending tickle\n"); return 0; } @@ -399,7 +402,7 @@ static int tickle_tcp(struct ctdb_context *ctdb, int argc, const char **argv) if (ret==0) { return 0; } - printf("Error while sending tickle ack\n"); + fprintf(stderr, "Error while sending tickle ack\n"); return -1; } @@ -411,13 +414,16 @@ static int control_ip(struct ctdb_context *ctdb, int argc, const char **argv) { int i, ret; struct ctdb_all_public_ips *ips; - uint32_t myvnn; + int myvnn; myvnn = ctdb_ctrl_getvnn(ctdb, TIMELIMIT(), options.vnn); + if (myvnn == -1) { + return -1; + } ret = ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), options.vnn, ctdb, &ips); if (ret != 0) { - printf("Unable to get public ips from node %u\n", options.vnn); + fprintf(stderr, "Unable to get public ips from node %u\n", options.vnn); return ret; } @@ -443,6 +449,31 @@ static int control_ip(struct ctdb_context *ctdb, int argc, const char **argv) } /* + display public ip address of this node + */ +static int control_publicip(struct ctdb_context *ctdb, int argc, const char **argv) +{ + int ret; + struct ctdb_all_public_ips *ips; + int myvnn; + + myvnn = ctdb_ctrl_getvnn(ctdb, TIMELIMIT(), options.vnn); + if (myvnn == -1) { + return -1; + } + + ret = ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), options.vnn, ctdb, &ips); + if (ret != 0) { + fprintf(stderr, "Unable to get public ips from node %u\n", options.vnn); + return ret; + } + + printf("%-16s\n", inet_ntoa(ips->ips[myvnn].sin.sin_addr)); + + return 0; +} + +/* display pid of a ctdb daemon */ static int control_getpid(struct ctdb_context *ctdb, int argc, const char **argv) @@ -452,7 +483,7 @@ static int control_getpid(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_getpid(ctdb, TIMELIMIT(), options.vnn, &pid); if (ret != 0) { - printf("Unable to get daemon pid from node %u\n", options.vnn); + fprintf(stderr, "Unable to get daemon pid from node %u\n", options.vnn); return ret; } printf("Pid:%d\n", pid); @@ -469,7 +500,7 @@ static int control_disable(struct ctdb_context *ctdb, int argc, const char **arg ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.vnn, NODE_FLAGS_PERMANENTLY_DISABLED, 0); if (ret != 0) { - printf("Unable to disable node %u\n", options.vnn); + fprintf(stderr, "Unable to disable node %u\n", options.vnn); return ret; } @@ -485,7 +516,7 @@ static int control_enable(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.vnn, 0, NODE_FLAGS_PERMANENTLY_DISABLED); if (ret != 0) { - printf("Unable to enable node %u\n", options.vnn); + fprintf(stderr, "Unable to enable node %u\n", options.vnn); return ret; } @@ -568,7 +599,7 @@ static int control_shutdown(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_shutdown(ctdb, TIMELIMIT(), options.vnn); if (ret != 0) { - printf("Unable to shutdown node %u\n", options.vnn); + fprintf(stderr, "Unable to shutdown node %u\n", options.vnn); return ret; } @@ -584,13 +615,13 @@ static int control_recover(struct ctdb_context *ctdb, int argc, const char **arg ret = ctdb_ctrl_freeze(ctdb, TIMELIMIT(), options.vnn); if (ret != 0) { - printf("Unable to freeze node\n"); + fprintf(stderr, "Unable to freeze node\n"); return ret; } ret = ctdb_ctrl_setrecmode(ctdb, TIMELIMIT(), options.vnn, CTDB_RECOVERY_ACTIVE); if (ret != 0) { - printf("Unable to set recovery mode\n"); + fprintf(stderr, "Unable to set recovery mode\n"); return ret; } @@ -608,7 +639,7 @@ static int control_getmonmode(struct ctdb_context *ctdb, int argc, const char ** ret = ctdb_ctrl_getmonmode(ctdb, TIMELIMIT(), options.vnn, &monmode); if (ret != 0) { - printf("Unable to get monmode from node %u\n", options.vnn); + fprintf(stderr, "Unable to get monmode from node %u\n", options.vnn); return ret; } printf("Monitoring mode:%s (%d)\n",monmode==CTDB_MONITORING_ACTIVE?"ACTIVE":"DISABLED",monmode); @@ -632,7 +663,7 @@ static int control_setmonmode(struct ctdb_context *ctdb, int argc, const char ** ret = ctdb_ctrl_setmonmode(ctdb, TIMELIMIT(), options.vnn, monmode); if (ret != 0) { - printf("Unable to set monmode on node %u\n", options.vnn); + fprintf(stderr, "Unable to set monmode on node %u\n", options.vnn); return ret; } @@ -663,7 +694,7 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv) /* traverse and dump the cluster tdb */ ret = ctdb_dump_db(ctdb_db, stdout); if (ret == -1) { - printf("Unable to dump database\n"); + fprintf(stderr, "Unable to dump database\n"); return -1; } talloc_free(ctdb_db); @@ -683,7 +714,7 @@ static int control_getdbmap(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_getdbmap(ctdb, TIMELIMIT(), options.vnn, ctdb, &dbmap); if (ret != 0) { - printf("Unable to get dbids from node %u\n", options.vnn); + fprintf(stderr, "Unable to get dbids from node %u\n", options.vnn); return ret; } @@ -734,7 +765,7 @@ static int control_getvar(struct ctdb_context *ctdb, int argc, const char **argv name = argv[0]; ret = ctdb_ctrl_get_tunable(ctdb, TIMELIMIT(), options.vnn, name, &value); if (ret == -1) { - printf("Unable to get tunable variable '%s'\n", name); + fprintf(stderr, "Unable to get tunable variable '%s'\n", name); return -1; } @@ -760,7 +791,7 @@ static int control_setvar(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_set_tunable(ctdb, TIMELIMIT(), options.vnn, name, value); if (ret == -1) { - printf("Unable to set tunable variable '%s'\n", name); + fprintf(stderr, "Unable to set tunable variable '%s'\n", name); return -1; } return 0; @@ -777,7 +808,7 @@ static int control_listvars(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_list_tunables(ctdb, TIMELIMIT(), options.vnn, ctdb, &list, &count); if (ret == -1) { - printf("Unable to list tunable variables\n"); + fprintf(stderr, "Unable to list tunable variables\n"); return -1; } @@ -800,7 +831,7 @@ static int control_getdebug(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_get_debuglevel(ctdb, options.vnn, &level); if (ret != 0) { - printf("Unable to get debuglevel response from node %u\n", + fprintf(stderr, "Unable to get debuglevel response from node %u\n", options.vnn); } else { printf("Node %u is at debug level %u\n", options.vnn, level); @@ -825,7 +856,7 @@ static int control_setdebug(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_set_debuglevel(ctdb, options.vnn, level); if (ret != 0) { - printf("Unable to set debug level on node %u\n", options.vnn); + fprintf(stderr, "Unable to set debug level on node %u\n", options.vnn); } return 0; } @@ -840,7 +871,7 @@ static int control_freeze(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_freeze(ctdb, TIMELIMIT(), options.vnn); if (ret != 0) { - printf("Unable to freeze node %u\n", options.vnn); + fprintf(stderr, "Unable to freeze node %u\n", options.vnn); } return 0; } @@ -854,7 +885,7 @@ static int control_thaw(struct ctdb_context *ctdb, int argc, const char **argv) ret = ctdb_ctrl_thaw(ctdb, TIMELIMIT(), options.vnn); if (ret != 0) { - printf("Unable to thaw node %u\n", options.vnn); + fprintf(stderr, "Unable to thaw node %u\n", options.vnn); } return 0; } @@ -907,6 +938,7 @@ static const struct { { "statistics", control_statistics, false, "show statistics" }, { "statisticsreset", control_statistics_reset, true, "reset statistics"}, { "ip", control_ip, true, "show which public ip's that ctdb manages" }, + { "publicip", control_publicip, false, "show the default public ip address for this node" }, { "process-exists", control_process_exists, true, "check if a process exists on a node", "<pid>"}, { "getdbmap", control_getdbmap, true, "show the database map" }, { "catdb", control_catdb, true, "dump a database" , "<dbname>"}, @@ -1018,7 +1050,7 @@ int main(int argc, const char *argv[]) /* initialise ctdb */ ctdb = ctdb_cmdline_client(ev); if (ctdb == NULL) { - printf("Failed to init ctdb\n"); + fprintf(stderr, "Failed to init ctdb\n"); exit(1); } @@ -1027,7 +1059,12 @@ int main(int argc, const char *argv[]) int j; if (options.vnn == CTDB_CURRENT_NODE) { - options.vnn = ctdb_ctrl_getvnn(ctdb, TIMELIMIT(), options.vnn); + int vnn; + vnn = ctdb_ctrl_getvnn(ctdb, TIMELIMIT(), options.vnn); + if (vnn == -1) { + return -1; + } + options.vnn = vnn; } if (ctdb_commands[i].auto_all && @@ -1052,7 +1089,7 @@ int main(int argc, const char *argv[]) } if (i == ARRAY_SIZE(ctdb_commands)) { - printf("Unknown control '%s'\n", control); + fprintf(stderr, "Unknown control '%s'\n", control); exit(1); } diff --git a/ctdb/scsi/scsi_io.c b/ctdb/utils/scsi_io/scsi_io.c index a177d726dc..a177d726dc 100644 --- a/ctdb/scsi/scsi_io.c +++ b/ctdb/utils/scsi_io/scsi_io.c diff --git a/ctdb/web/nfs.html b/ctdb/web/nfs.html index 6bec33bc64..b10171acac 100644 --- a/ctdb/web/nfs.html +++ b/ctdb/web/nfs.html @@ -14,13 +14,6 @@ NFS for CTDB clustering</a> at samba.org for additional information. Configure CTDB as above and set it up to use public ipaddresses.<br> Verify that the CTDB cluster works. -<h2>sm-notify</h2> - -Make sure you have the sm-notify tool installed in /usr/sbin.<br> -You should find that tool in the nfs-util package for your operating system.<br><br> -This tool is required so that CTDB will be able to successfully trigger lock recovery after an ip address failover/failback.<br><br> -This tool must be installed as /usr/sbin/sm-notify on all nodes in the cluster. - <h2>/etc/exports</h2> Export the same directory from all nodes.<br> |