From: Sage Weil Date: Fri, 5 Jul 2013 19:14:13 +0000 (-0700) Subject: mon: add --force-sync startup option X-Git-Tag: v0.67-rc1~126^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=45907dc1bafb9f254ca02b46145672c856c88304;p=ceph.git mon: add --force-sync startup option Signed-off-by: Sage Weil --- diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 7d8d5c4db295..b62443aa0354 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -107,6 +107,8 @@ void usage() cerr << " debug monitor level (e.g. 10)\n"; cerr << " --mkfs\n"; cerr << " build fresh monitor fs\n"; + cerr << " --force-sync\n"; + cerr << " force a sync from another mon by wiping local data (BE CAREFUL)\n"; generic_server_usage(); } @@ -116,6 +118,8 @@ int main(int argc, const char **argv) bool mkfs = false; bool compact = false; + bool force_sync = false; + bool yes_really = false; std::string osdmapfn, inject_monmap, extract_monmap; vector args; @@ -136,6 +140,10 @@ int main(int argc, const char **argv) mkfs = true; } else if (ceph_argparse_flag(args, i, "--compact", (char*)NULL)) { compact = true; + } else if (ceph_argparse_flag(args, i, "--force-sync", (char*)NULL)) { + force_sync = true; + } else if (ceph_argparse_flag(args, i, "--yes-i-really-mean-it", (char*)NULL)) { + yes_really = true; } else if (ceph_argparse_witharg(args, i, &val, "--osdmap", (char*)NULL)) { osdmapfn = val; } else if (ceph_argparse_witharg(args, i, &val, "--inject_monmap", (char*)NULL)) { @@ -151,6 +159,12 @@ int main(int argc, const char **argv) usage(); } + if (force_sync && !yes_really) { + cerr << "are you SURE you want to force a sync? this will erase local data and may\n" + << "break your mon cluster. pass --yes-i-really-mean-it if you do." << std::endl; + exit(1); + } + if (g_conf->mon_data.empty()) { cerr << "must specify '--mon-data=foo' data path" << std::endl; usage(); @@ -406,7 +420,6 @@ int main(int argc, const char **argv) } } - // this is what i will bind to entity_addr_t ipaddr; @@ -510,6 +523,11 @@ int main(int argc, const char **argv) mon = new Monitor(g_ceph_context, g_conf->name.get_id(), store, messenger, &monmap); + if (force_sync) { + derr << "flagging a forced sync ..." << dendl; + mon->sync_force(cerr); + } + err = mon->preinit(); if (err < 0) prefork.exit(1); diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 56d634276a8b..12b98f70b0cf 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -308,11 +308,13 @@ private: */ void sync_start(entity_inst_t &entity, bool full); +public: /** * force a sync on next mon restart */ void sync_force(ostream& ss); +private: /** * reset the sync timeout *