diff options
| -rwxr-xr-x | ctdb/config/ctdb.init | 1 | ||||
| -rw-r--r-- | ctdb/config/ctdb.sysconfig | 8 | ||||
| -rw-r--r-- | ctdb/include/ctdb_private.h | 1 | ||||
| -rw-r--r-- | ctdb/server/ctdb_takeover.c | 8 | ||||
| -rw-r--r-- | ctdb/server/ctdbd.c | 26 |
5 files changed, 44 insertions, 0 deletions
diff --git a/ctdb/config/ctdb.init b/ctdb/config/ctdb.init index 503c267407..724c1a8d13 100755 --- a/ctdb/config/ctdb.init +++ b/ctdb/config/ctdb.init @@ -57,6 +57,7 @@ CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK" [ -z "$CTDB_SOCKET" ] || CTDB_OPTIONS="$CTDB_OPTIONS --socket=$CTDB_SOCKET" [ -z "$CTDB_PUBLIC_ADDRESSES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-addresses=$CTDB_PUBLIC_ADDRESSES" [ -z "$CTDB_PUBLIC_INTERFACE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-interface=$CTDB_PUBLIC_INTERFACE" +[ -z "$CTDB_SINGLE_PUBLIC_IP" ] || CTDB_OPTIONS="$CTDB_OPTIONS --single-public-ip=$CTDB_SINGLE_PUBLIC_IP" [ -z "$CTDB_DBDIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir=$CTDB_DBDIR" [ -z "$CTDB_DBDIR_PERSISTENT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir-persistent=$CTDB_DBDIR_PERSISTENT" [ -z "$CTDB_EVENT_SCRIPT_DIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script-dir $CTDB_EVENT_SCRIPT_DIR" diff --git a/ctdb/config/ctdb.sysconfig b/ctdb/config/ctdb.sysconfig index c4b192bec5..d290321b99 100644 --- a/ctdb/config/ctdb.sysconfig +++ b/ctdb/config/ctdb.sysconfig @@ -21,6 +21,14 @@ # # CTDB_PUBLIC_ADDRESSES=/etc/ctdb/public_addresses +# Should ctdb implement a single public ip address across the entire cluster +# and multiplex incoming connections across the connected nodes +# When using a single public ip you must also specify the public interface! +# This makes all incoming traffic go through a single ctdb node which +# will then forward the packets out acros the other nodes. This will +# impact performance. +# CTDB_SINGLE_PUBLIC_IP=10.1.1.1 + # should ctdb manage starting/stopping the Samba service for you? # default is to not manage Samba # CTDB_MANAGES_SAMBA=yes diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 983871006a..5a82988a0b 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -343,6 +343,7 @@ struct ctdb_context { uint16_t idr_cnt; struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */ struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */ + struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */ char *err_msg; const struct ctdb_methods *methods; /* transport methods */ const struct ctdb_upcalls *upcalls; /* transport upcalls */ diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index c30e6c57bc..9986714a17 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -1357,6 +1357,14 @@ static int ctdb_killtcp_add_connection(struct ctdb_context *ctdb, vnn = find_public_ip_vnn(ctdb, *src); } if (vnn == NULL) { + /* if it is not a public ip it could be our 'single ip' */ + if (ctdb->single_ip_vnn) { + if (ctdb_same_ip(&ctdb->single_ip_vnn->public_address, dst)) { + vnn = ctdb->single_ip_vnn; + } + } + } + if (vnn == NULL) { DEBUG(0,(__location__ " Could not killtcp, not a public address\n")); return -1; } diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index 6ba76ffc95..55b87418f9 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -48,6 +48,7 @@ static struct { const char *db_dir; const char *db_dir_persistent; const char *public_interface; + const char *single_public_ip; int no_setsched; } options = { .nlist = ETCDIR "/ctdb/nodes", @@ -104,6 +105,7 @@ int main(int argc, const char *argv[]) { "interactive", 'i', POPT_ARG_NONE, &interactive, 0, "don't fork", NULL }, { "public-addresses", 0, POPT_ARG_STRING, &options.public_address_list, 0, "public address list file", "filename" }, { "public-interface", 0, POPT_ARG_STRING, &options.public_interface, 0, "public interface", "interface"}, + { "single-public-ip", 0, POPT_ARG_STRING, &options.single_public_ip, 0, "single public ip", "ip-address"}, { "event-script-dir", 0, POPT_ARG_STRING, &options.event_script_dir, 0, "event script directory", "dirname" }, { "logfile", 0, POPT_ARG_STRING, &options.logfile, 0, "log file location", "filename" }, { "nlist", 0, POPT_ARG_STRING, &options.nlist, 0, "node list file", "filename" }, @@ -215,6 +217,30 @@ int main(int argc, const char *argv[]) CTDB_NO_MEMORY(ctdb, ctdb->default_public_interface); } + if (options.single_public_ip) { + struct ctdb_vnn *svnn; + + if (options.public_interface == NULL) { + DEBUG(0,("--single_public_ip used but --public_interface is not specified. You must specify the public interface when using single public ip. Exiting\n")); + exit(10); + } + + svnn = talloc_zero(ctdb, struct ctdb_vnn); + CTDB_NO_MEMORY(ctdb, svnn); + + ctdb->single_ip_vnn = svnn; + svnn->iface = talloc_strdup(svnn, options.public_interface); + CTDB_NO_MEMORY(ctdb, svnn->iface); + + if (inet_aton(options.single_public_ip, + &svnn->public_address.sin_addr) == 0) { + DEBUG(0,("Invalid --single-public-ip argument : %s . This is not a valid ip address. Exiting.\n", options.single_public_ip)); + exit(10); + } + svnn->public_address.sin_family = AF_INET; + svnn->public_address.sin_port = 0; + } + if (options.public_address_list) { ret = ctdb_set_public_addresses(ctdb, options.public_address_list); if (ret == -1) { |
