mirror of
https://github.com/ceph/ceph
synced 2025-03-04 23:40:07 +00:00
Merge pull request #11276 from tchaikov/wip-17400
tools/ceph_monstore_tool: update pgmap_meta also when rebuilding store.db Tested-by: Huawen Ren <ren.huanwen@zte.com.cn> Reviewed-by: Greg Farnum <gfarnum@redhat.com>
This commit is contained in:
commit
754ad16eae
@ -430,8 +430,13 @@ information stored in OSDs.::
|
||||
rsync -avz user@host:$ms $ms
|
||||
done
|
||||
# rebuild the monitor store from the collected map, if the cluster does not
|
||||
# use cephx authentication, there is no need to pass the "--keyring" option.
|
||||
# i.e. use "ceph-monstore-tool /tmp/mon-store rebuild" instead
|
||||
# use cephx authentication, we can skip the following steps to update the
|
||||
# keyring with the caps, and there is no need to pass the "--keyring" option.
|
||||
# i.e. just use "ceph-monstore-tool /tmp/mon-store rebuild" instead
|
||||
ceph-authtool /path/to/admin.keyring -n mon. \
|
||||
--cap mon allow 'allow *'
|
||||
ceph-authtool /path/to/admin.keyring -n client.admin \
|
||||
--cap mon allow 'allow *' --cap osd 'allow *' --cap mds 'allow *'
|
||||
ceph-monstore-tool /tmp/mon-store rebuild -- --keyring /path/to/admin.keyring
|
||||
# backup corrupted store.db just in case
|
||||
mv /var/lib/ceph/mon/mon.0/store.db /var/lib/ceph/mon/mon.0/store.db.corrupted
|
||||
|
@ -532,6 +532,10 @@ static int update_auth(MonitorDBStore& st, const string& keyring_path)
|
||||
KeyServerData::Incremental auth_inc;
|
||||
auth_inc.name = k.first;
|
||||
auth_inc.auth = k.second;
|
||||
if (auth_inc.auth.caps.empty()) {
|
||||
cerr << "no caps granted to: " << auth_inc.name << std::endl;
|
||||
return -EINVAL;
|
||||
}
|
||||
auth_inc.op = KeyServerData::AUTH_INC_ADD;
|
||||
|
||||
AuthMonitor::Incremental inc;
|
||||
@ -593,7 +597,8 @@ static int update_paxos(MonitorDBStore& st)
|
||||
bufferlist pending_proposal;
|
||||
{
|
||||
MonitorDBStore::Transaction t;
|
||||
vector<string> prefixes = {"auth", "osdmap", "pgmap", "pgmap_pg"};
|
||||
vector<string> prefixes = {"auth", "osdmap",
|
||||
"pgmap", "pgmap_pg", "pgmap_meta"};
|
||||
for (const auto& prefix : prefixes) {
|
||||
for (auto i = st.get_iterator(prefix); i->valid(); i->next()) {
|
||||
auto key = i->raw_key();
|
||||
@ -615,6 +620,52 @@ static int update_paxos(MonitorDBStore& st)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// rebuild
|
||||
// - pgmap_meta/version
|
||||
// - pgmap_meta/last_osdmap_epoch
|
||||
// - pgmap_meta/last_pg_scan
|
||||
// - pgmap_meta/full_ratio
|
||||
// - pgmap_meta/nearfull_ratio
|
||||
// - pgmap_meta/stamp
|
||||
static int update_pgmap_meta(MonitorDBStore& st)
|
||||
{
|
||||
const string prefix("pgmap_meta");
|
||||
auto t = make_shared<MonitorDBStore::Transaction>();
|
||||
// stolen from PGMonitor::create_pending()
|
||||
// the first pgmap_meta
|
||||
t->put(prefix, "version", 1);
|
||||
{
|
||||
auto stamp = ceph_clock_now(g_ceph_context);
|
||||
bufferlist bl;
|
||||
::encode(stamp, bl);
|
||||
t->put(prefix, "stamp", bl);
|
||||
}
|
||||
{
|
||||
auto last_osdmap_epoch = st.get("osdmap", "last_committed");
|
||||
t->put(prefix, "last_osdmap_epoch", last_osdmap_epoch);
|
||||
}
|
||||
// be conservative, so PGMonitor will scan the all pools for pg changes
|
||||
t->put(prefix, "last_pg_scan", 1);
|
||||
{
|
||||
auto full_ratio = g_ceph_context->_conf->mon_osd_full_ratio;
|
||||
if (full_ratio > 1.0)
|
||||
full_ratio /= 100.0;
|
||||
bufferlist bl;
|
||||
::encode(full_ratio, bl);
|
||||
t->put(prefix, "full_ratio", bl);
|
||||
}
|
||||
{
|
||||
auto nearfull_ratio = g_ceph_context->_conf->mon_osd_nearfull_ratio;
|
||||
if (nearfull_ratio > 1.0)
|
||||
nearfull_ratio /= 100.0;
|
||||
bufferlist bl;
|
||||
::encode(nearfull_ratio, bl);
|
||||
t->put(prefix, "nearfull_ratio", bl);
|
||||
}
|
||||
st.apply_transaction(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rebuild_monstore(const char* progname,
|
||||
vector<string>& subcmds,
|
||||
MonitorDBStore& st)
|
||||
@ -635,6 +686,9 @@ int rebuild_monstore(const char* progname,
|
||||
}
|
||||
if (!keyring_path.empty())
|
||||
update_auth(st, keyring_path);
|
||||
if ((r = update_pgmap_meta(st))) {
|
||||
return r;
|
||||
}
|
||||
if ((r = update_paxos(st))) {
|
||||
return r;
|
||||
}
|
||||
|
@ -331,52 +331,6 @@ int update_osdmap(ObjectStore& fs, OSDSuperblock& sb, MonitorDBStore& ms)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// rebuild
|
||||
// - pgmap_meta/version
|
||||
// - pgmap_meta/last_osdmap_epoch
|
||||
// - pgmap_meta/last_pg_scan
|
||||
// - pgmap_meta/full_ratio
|
||||
// - pgmap_meta/nearfull_ratio
|
||||
// - pgmap_meta/stamp
|
||||
int update_pgmap_meta(MonitorDBStore& st)
|
||||
{
|
||||
const string prefix("pgmap_meta");
|
||||
auto t = make_shared<MonitorDBStore::Transaction>();
|
||||
// stolen from PGMonitor::create_pending()
|
||||
// the first pgmap_meta
|
||||
t->put(prefix, "version", 1);
|
||||
{
|
||||
auto stamp = ceph_clock_now(g_ceph_context);
|
||||
bufferlist bl;
|
||||
::encode(stamp, bl);
|
||||
t->put(prefix, "stamp", bl);
|
||||
}
|
||||
{
|
||||
auto last_osdmap_epoch = st.get("osdmap", "last_committed");
|
||||
t->put(prefix, "last_osdmap_epoch", last_osdmap_epoch);
|
||||
}
|
||||
// be conservative, so PGMonitor will scan the all pools for pg changes
|
||||
t->put(prefix, "last_pg_scan", 1);
|
||||
{
|
||||
auto full_ratio = g_ceph_context->_conf->mon_osd_full_ratio;
|
||||
if (full_ratio > 1.0)
|
||||
full_ratio /= 100.0;
|
||||
bufferlist bl;
|
||||
::encode(full_ratio, bl);
|
||||
t->put(prefix, "full_ratio", bl);
|
||||
}
|
||||
{
|
||||
auto nearfull_ratio = g_ceph_context->_conf->mon_osd_nearfull_ratio;
|
||||
if (nearfull_ratio > 1.0)
|
||||
nearfull_ratio /= 100.0;
|
||||
bufferlist bl;
|
||||
::encode(nearfull_ratio, bl);
|
||||
t->put(prefix, "nearfull_ratio", bl);
|
||||
}
|
||||
st.apply_transaction(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// rebuild
|
||||
// - pgmap_pg/${pgid}
|
||||
int update_pgmap_pg(ObjectStore& fs, MonitorDBStore& ms)
|
||||
|
Loading…
Reference in New Issue
Block a user