--cap mon 'allow *'
ceph-authtool /path/to/admin.keyring -n client.admin \
--cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *'
- ceph-monstore-tool $ms rebuild -- --keyring /path/to/admin.keyring
+ # if your monitors' ids are not single characters like 'a', 'b', 'c', please
+ # specify them in the command line by passing them as arguments of the "--mon-ids"
+ # option. if you are not sure, please check your ceph.conf to see if there is any
+ # sections named like '[mon.foo]'. don't pass the "--mon-ids" option, if you are
+ # using DNS SRV for looking up monitors.
+ ceph-monstore-tool $ms rebuild -- --keyring /path/to/admin.keyring --mon-ids alpha beta gamma
# make a backup of the corrupted store.db just in case! repeat for
# all monitors.
return 0;
}
-static int update_mkfs(MonitorDBStore& st, const string& monmap_path)
+static int update_mkfs(MonitorDBStore& st,
+ const string& monmap_path,
+ const vector<string>& mon_ids)
{
MonMap monmap;
if (!monmap_path.empty()) {
cerr << "no initial monitors" << std::endl;
return -EINVAL;
}
+ vector<string> new_names;
+ if (!mon_ids.empty()) {
+ if (mon_ids.size() != monmap.size()) {
+ cerr << "Please pass the same number of <mon-ids> to name the hosts "
+ << "listed in 'mon_host'. "
+ << mon_ids.size() << " mon-id(s) specified, "
+ << "while you have " << monmap.size() << " mon hosts." << std::endl;
+ return -EINVAL;
+ }
+ new_names = mon_ids;
+ } else {
+ for (unsigned rank = 0; rank < monmap.size(); rank++) {
+ string new_name{"a"};
+ new_name[0] += rank;
+ new_names.push_back(std::move(new_name));
+ }
+ }
+ for (unsigned rank = 0; rank < monmap.size(); rank++) {
+ auto name = monmap.get_name(rank);
+ if (name.compare(0, 7, "noname-") == 0) {
+ monmap.rename(name, new_names[rank]);
+ }
+ }
}
monmap.print(cout);
bufferlist bl;
po::options_description op_desc("Allowed 'rebuild' options");
string keyring_path;
string monmap_path;
+ vector<string> mon_ids;
op_desc.add_options()
("keyring", po::value<string>(&keyring_path),
"path to the client.admin key")
("monmap", po::value<string>(&monmap_path),
- "path to the initial monmap");
+ "path to the initial monmap")
+ ("mon-ids", po::value<vector<string>>(&mon_ids)->multitoken(),
+ "mon ids, use 'a', 'b', ... if not specified");
+ po::positional_options_description pos_desc;
+ pos_desc.add("mon-ids", -1);
po::variables_map op_vm;
- int r = parse_cmd_args(&op_desc, nullptr, nullptr, subcmds, &op_vm);
+ int r = parse_cmd_args(&op_desc, nullptr, &pos_desc, subcmds, &op_vm);
if (r) {
return -r;
}
if ((r = update_paxos(st))) {
return r;
}
- if ((r = update_mkfs(st, monmap_path))) {
+ if ((r = update_mkfs(st, monmap_path, mon_ids))) {
return r;
}
if ((r = update_monitor(st))) {