./dstop.sh
fi
+if [ $new -eq 1 ]; then
+ # build and inject an initial osd map
+ ./osdmaptool --clobber --createsimple 32 --num_dom 4 .ceph_osdmap
+
+ # use custom crush map to separate data from metadata
+ ./crushtool -c cm.txt -o cm
+ ./osdmaptool --clobber --import-crush cm .ceph_osdmap
+
+# ./ceph osd setmap 2 -i .ceph_osdmap
+fi
# mkmonfs
if [ $new -eq 1 ]; then
# build a fresh fs monmap, mon fs
./monmaptool --create --clobber --add $IP:6789 --print .ceph_monmap
- ./mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap
+ ./mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap --osdmap .ceph_osdmap
fi
# monitor
./cmon -d mondata/mon0 $ARGS $CMON_ARGS
-if [ $new -eq 1 ]; then
- # build and inject an initial osd map
- ./osdmaptool --clobber --createsimple .ceph_monmap 32 --num_dom 4 .ceph_osdmap
-
- # use custom crush map to separate data from metadata
- ./crushtool -c cm.txt -o cm
- ./osdmaptool --clobber --import-crush cm .ceph_osdmap
-
- ./ceph osd setmap 2 -i .ceph_osdmap
-fi
-
-
# osds
savelog -l cosd
cp -p cosd.0 cosd
const char *fsdir = 0;
int whoami = -1;
const char *monmapfn = 0;
+ const char *osdmapfn = 0;
for (unsigned i = 0; i < args.size(); i++) {
if (strcmp(args[i], "--clobber") == 0)
clobber = true;
whoami = atoi(args[++i]);
else if (strcmp(args[i], "--monmap") == 0)
monmapfn = args[++i];
+ else if (strcmp(args[i], "--osdmap") == 0)
+ osdmapfn = args[++i];
else if (!fsdir)
fsdir = args[i];
else
}
// load monmap
- bufferlist monmapbl;
+ bufferlist monmapbl, osdmapbl;
int err = monmapbl.read_file(monmapfn);
if (err < 0)
exit(1);
MonMap monmap;
monmap.decode(monmapbl);
+ err = osdmapbl.read_file(osdmapfn);
+ if (err < 0)
+ exit(1);
+
// go
MonitorStore store(fsdir);
Monitor mon(whoami, &store, 0, &monmap);
- mon.mkfs();
+ mon.mkfs(osdmapbl);
cout << argv[0] << ": created monfs at " << fsdir
<< " for mon" << whoami
<< std::endl;
<< dendl;
}
-void ClientMonitor::create_initial()
+void ClientMonitor::create_initial(bufferlist& bl)
{
dout(10) << "create_initial -- creating initial map" << dendl;
}
// leader
ClientMap::Incremental pending_inc;
- void create_initial();
+ void create_initial(bufferlist& bl);
bool update_from_paxos();
void create_pending(); // prepare a new pending
void encode_pending(bufferlist &bl); // propose pending update to peers
}
-void LogMonitor::create_initial()
+void LogMonitor::create_initial(bufferlist& bl)
{
dout(10) << "create_initial -- creating initial map" << dendl;
LogEntry e;
bufferlist pending_inc;
version_t log_version;
- void create_initial();
+ void create_initial(bufferlist& bl);
bool update_from_paxos();
void create_pending(); // prepare a new pending
void encode_pending(bufferlist &bl); // propose pending update to peers
// service methods
-void MDSMonitor::create_initial()
+void MDSMonitor::create_initial(bufferlist& bl)
{
dout(10) << "create_initial" << dendl;
pending_mdsmap.max_mds = 1;
// service methods
- void create_initial();
+ void create_initial(bufferlist& bl);
bool update_from_paxos();
void create_pending();
void encode_pending(bufferlist &bl);
#include "PGMonitor.h"
#include "LogMonitor.h"
+#include "osd/OSDMap.h"
+
#include "config.h"
#define DOUT_SUBSYS mon
* this is the closest thing to a traditional 'mkfs' for ceph.
* initialize the monitor state machines to their initial values.
*/
-int Monitor::mkfs()
+int Monitor::mkfs(bufferlist& osdmapbl)
{
// create it
int err = store->mkfs();
for (vector<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); p++) {
PaxosService *svc = *p;
+ bufferlist bl;
dout(10) << "initializing " << svc->get_machine_name() << dendl;
svc->paxos->init();
svc->create_pending();
- svc->create_initial();
-
+ if (svc->paxos->machine_id == PAXOS_OSDMAP)
+ svc->create_initial(osdmapbl);
+ else
+ svc->create_initial(bl);
// commit to paxos
- bufferlist bl;
svc->encode_pending(bl);
store->put_bl_sn(bl, svc->get_machine_name(), 1);
store->put_int(1, svc->get_machine_name(), "last_committed");
#include "Elector.h"
#include "Paxos.h"
+#include "osd/OSDMap.h"
+
class MonitorStore;
void stop_cluster();
- int mkfs();
+ int mkfs(bufferlist& osdmapbl);
};
/************ MAPS ****************/
-void OSDMonitor::create_initial()
+void OSDMonitor::create_initial(bufferlist& bl)
{
- dout(10) << "create_initial for " << mon->monmap->fsid << " from g_conf" << dendl;
+ dout(0) << "create_initial for " << mon->monmap->fsid << dendl;
OSDMap newmap;
+ newmap.decode(bl);
newmap.epoch = 1;
newmap.set_fsid(mon->monmap->fsid);
newmap.ctime = g_clock.now();
- newmap.crush.create(); // empty crush map
// encode into pending incremental
newmap.encode(pending_inc.fullmap);
}
-
-
-
-
bool OSDMonitor::update_from_paxos()
{
assert(paxos->is_active());
// svc
public:
- void create_initial();
+ void create_initial(bufferlist& bl);
private:
bool update_from_paxos();
void create_pending(); // prepare a new pending
*/
}
-void PGMonitor::create_initial()
+void PGMonitor::create_initial(bufferlist& bl)
{
dout(10) << "create_initial -- creating initial map" << dendl;
}
private:
PGMap::Incremental pending_inc;
- void create_initial();
+ void create_initial(bufferlist& bl);
bool update_from_paxos();
void create_pending(); // prepare a new pending
void encode_pending(bufferlist &bl); // propose pending update to peers
void propose_pending(); // propose current pending as new paxos state
// you implement
- virtual void create_initial() = 0;
+ virtual void create_initial(bufferlist& bl) = 0;
virtual bool update_from_paxos() = 0; // assimilate latest state from paxos
virtual void create_pending() = 0; // [leader] create new pending structures
virtual void encode_pending(bufferlist& bl) = 0; // [leader] finish and encode pending for next paxos state
void usage(const char *me)
{
- cout << me << " usage: [--print] [--createsimple <monmapfile> <numosd> [--clobber] [--pgbits <bitsperosd>]] <mapfilename>" << std::endl;
+ cout << me << " usage: [--print] [--createsimple <numosd> [--clobber] [--pgbits <bitsperosd>]] <mapfilename>" << std::endl;
cout << me << " --export-crush <file> write osdmap's crush map to <file>" << std::endl;
cout << me << " --import-crush <file> replace osdmap's crush map with <file>" << std::endl;
exit(1);
const char *fn = 0;
bool print = false;
bool createsimple = false;
- const char *monmapfn = 0;
int num_osd = 0, num_dom = 0;
int pg_bits = g_conf.osd_pg_bits;
int lpg_bits = g_conf.osd_lpg_bits;
print = true;
else if (strcmp(args[i], "--createsimple") == 0) {
createsimple = true;
- monmapfn = args[++i];
num_osd = atoi(args[++i]);
} else if (strcmp(args[i], "--clobber") == 0)
clobber = true;
}
if (createsimple) {
- MonMap monmap;
- int r = monmap.read(monmapfn);
- if (r < 0) {
- cerr << me << ": can't read monmap from " << monmapfn << ": " << strerror(r) << std::endl;
- exit(1);
- }
if (num_osd < 1) {
cerr << me << ": osd count must be > 0" << std::endl;
exit(1);
}
- osdmap.build_simple(0, monmap.fsid, num_osd, num_dom, pg_bits, lpg_bits, 0);
+ ceph_fsid_t fsid;
+ memset(&fsid, 0, sizeof(ceph_fsid_t));
+ osdmap.build_simple(0, fsid, num_osd, num_dom, pg_bits, lpg_bits, 0);
modified = true;
}
[ "$CEPH_PORT" == "" ] && CEPH_PORT=6789
if [ $start_mon -eq 1 ]; then
+ if [ $new -eq 1 ]; then
+ # build and inject an initial osd map
+ $CEPH_BIN/osdmaptool --clobber --createsimple 4 .ceph_osdmap # --pgbits 2
+# $CEPH_BIN/ceph osd setmap 2 -i .ceph_osdmap
+ fi
+
if [ $new -eq 1 ]; then
if [ `echo $IP | grep '^127\\.'` ]
then
for f in `seq 0 $((CEPH_NUM_MON-1))`
do
- $CEPH_BIN/mkmonfs --clobber mondata/mon$f --mon $f --monmap .ceph_monmap
+ $CEPH_BIN/mkmonfs --clobber mondata/mon$f --mon $f --monmap .ceph_monmap --osdmap .ceph_osdmap
done
fi
done
sleep 1
fi
-
- if [ $new -eq 1 ]; then
- # build and inject an initial osd map
- $CEPH_BIN/osdmaptool --clobber --createsimple .ceph_monmap 4 .ceph_osdmap # --pgbits 2
- $CEPH_BIN/ceph osd setmap 2 -i .ceph_osdmap
- fi
fi
#osd