| **ceph-bluestore-tool** *command*
[ --dev *device* ... ]
+ [ -i *osd_id* ]
[ --path *osd path* ]
[ --out-dir *dir* ]
[ --log-file | -l *filename* ]
Add *device* to the list of devices to consider
+.. option:: -i *osd_id*
+
+ Operate as OSD *osd_id*. Connect to monitor for OSD specific options.
+ If monitor is unavailable, add --no-mon-config to read from ceph.conf instead.
+
.. option:: --devs-source *device*
Add *device* to the list of devices to consider as sources for migrate operation
.. option:: --path *osd path*
- Specify an osd path. In most cases, the device list is inferred from the symlinks present in *osd path*. This is usually simpler than explicitly specifying the device(s) with --dev.
+ Specify an osd path. In most cases, the device list is inferred from the symlinks present in *osd path*. This is usually simpler than explicitly specifying the device(s) with --dev. Not necessary if -i *osd_id* is provided.
.. option:: --out-dir *dir*
<iterator_refresh_bytes>/<iterator_refresh_keys>/<batch_commit_bytes>/<batch_commit_keys>
Default: 10000000/10000/1000000/1000
+Additional ceph.conf options
+============================
+
+Any configuration option that is accepted by OSD can be also passed to **ceph-bluestore-tool**.
+Useful to provide necessary configuration options when access to monitor/ceph.conf is impossible and -i option cannot be used.
+
Device labels
=============
int main(int argc, char **argv)
{
string out_dir;
+ string osd_instance;
vector<string> devs;
vector<string> devs_source;
string dev_target;
po::options_description po_options("Options");
po_options.add_options()
("help,h", "produce help message")
+ (",i", po::value<string>(&osd_instance), "OSD instance. Requires access to monitor/ceph.conf")
("path", po::value<string>(&path), "bluestore path")
("out-dir", po::value<string>(&out_dir), "output directory")
("input-file", po::value<string>(&input_file), "import file")
;
po::options_description po_all("All options");
po_all.add(po_options).add(po_positional);
- po::positional_options_description pd;
- pd.add("command", 1);
vector<string> ceph_option_strings;
po::variables_map vm;
try {
po::parsed_options parsed =
- po::command_line_parser(argc, argv).options(po_all).allow_unregistered().positional(pd).run();
+ po::command_line_parser(argc, argv).options(po_all).allow_unregistered().run();
po::store( parsed, vm);
po::notify(vm);
ceph_option_strings = po::collect_unrecognized(parsed.options,
usage(po_all);
exit(EXIT_SUCCESS);
}
+
+ vector<const char*> args;
+ if (log_file.size()) {
+ args.push_back("--log-file");
+ args.push_back(log_file.c_str());
+ static char ll[10];
+ snprintf(ll, sizeof(ll), "%d", log_level);
+ args.push_back("--debug-bluestore");
+ args.push_back(ll);
+ args.push_back("--debug-bluefs");
+ args.push_back(ll);
+ args.push_back("--debug-rocksdb");
+ args.push_back(ll);
+ } else {
+ // do not write to default-named log "osd.x.log" if --log-file is not provided
+ if (!osd_instance.empty()) {
+ args.push_back("--no-log-to-file");
+ }
+ }
+
+ if (!osd_instance.empty()) {
+ args.push_back("-i");
+ args.push_back(osd_instance.c_str());
+ }
+ args.push_back("--no-log-to-stderr");
+ args.push_back("--err-to-stderr");
+
+ for (auto& i : ceph_option_strings) {
+ args.push_back(i.c_str());
+ }
+ auto cct = global_init(NULL, args, osd_instance.empty() ? CEPH_ENTITY_TYPE_CLIENT : CEPH_ENTITY_TYPE_OSD,
+ CODE_ENVIRONMENT_UTILITY,
+ osd_instance.empty() ? CINIT_FLAG_NO_DEFAULT_CONFIG_FILE : 0);
+
+ common_init_finish(cct.get());
+ if (action.empty()) {
+ // if action ("command") is not yet defined try to use first param as action
+ if (args.size() > 0) {
+ if (args.size() == 1) {
+ // treat first unparsed value as action
+ action = args[0];
+ } else {
+ std::cerr << "Unknown options: " << args << std::endl;
+ exit(EXIT_FAILURE);
+ }
+ }
+ } else {
+ if (args.size() != 0) {
+ std::cerr << "Unknown options: " << args << std::endl;
+ exit(EXIT_FAILURE);
+ }
+ }
+
if (action.empty()) {
cerr << "must specify an action; --help for help" << std::endl;
exit(EXIT_FAILURE);
}
+ if (!osd_instance.empty()) {
+ // when "-i" is provided "osd data" can be used as path
+ if (path.size() == 0) {
+ path = cct->_conf.get_val<std::string>("osd_data");
+ }
+ }
+
if (action == "fsck" || action == "repair" || action == "quick-fix") {
if (path.empty()) {
cerr << "must specify bluestore path" << std::endl;
exit(EXIT_FAILURE);
}
}
- vector<const char*> args;
- if (log_file.size()) {
- args.push_back("--log-file");
- args.push_back(log_file.c_str());
- static char ll[10];
- snprintf(ll, sizeof(ll), "%d", log_level);
- args.push_back("--debug-bluestore");
- args.push_back(ll);
- args.push_back("--debug-bluefs");
- args.push_back(ll);
- args.push_back("--debug-rocksdb");
- args.push_back(ll);
- }
- args.push_back("--no-log-to-stderr");
- args.push_back("--err-to-stderr");
-
- for (auto& i : ceph_option_strings) {
- args.push_back(i.c_str());
- }
- auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
- CODE_ENVIRONMENT_UTILITY,
- CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
-
- common_init_finish(cct.get());
if (action == "fsck" ||
action == "repair" ||