]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: new default mon port; try to bind to port in known range
authorSage Weil <sage@newdream.net>
Mon, 8 Dec 2008 19:44:21 +0000 (11:44 -0800)
committerSage Weil <sage@newdream.net>
Mon, 8 Dec 2008 19:46:36 +0000 (11:46 -0800)
New monitor port in unused region (according to nmap-services).

Try to bind to a port in a known range, so that tools can easily
identify the protocol in use.

Remove some old .sh cruft.

src/dstart.sh
src/include/ceph_fs.h
src/mkcephfs.sh
src/mkfs.sh [deleted file]
src/msg/SimpleMessenger.cc
src/startnew.sh [deleted file]
src/vstart.sh

index 7d89893ea1c1891d28fe6e5a66e98db44cb27ed9..5e2f4beca7fa08750ef17ce432df328082f0bd97 100755 (executable)
@@ -65,7 +65,7 @@ if [ $new -eq 1 ]; then
     fi
     
     # build a fresh fs monmap, mon fs
-    ./monmaptool --create --clobber --add $IP:12345 --print .ceph_monmap
+    ./monmaptool --create --clobber --add $IP:6789 --print .ceph_monmap
     ./mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap
 fi
 
index 004f1adb357a1b68a4e616619393f521c07abcc1..4eba54853c978a5f3361876593c935717451322a 100644 (file)
@@ -9,7 +9,16 @@
 #define _FS_CEPH_CEPH_FS_H
 
 
-#define CEPH_MON_PORT 12345
+#define CEPH_MON_PORT    6789  /* default monitor port */
+
+/*
+ * client-side processes will try to bind to ports in this
+ * range, simply for the benefit of tools like nmap or wireshark
+ * that would like to identify the protocol.
+ */
+#define CEPH_PORT_FIRST  6789
+#define CEPH_PORT_START  6800  /* non-monitors start here */
+#define CEPH_PORT_LAST   6900
 
 /*
  * Max file size is a policy choice; in reality we are limited
index 7f952ccb68ad69a7f905bc749412ef879b087f55..748979ed30222592e0e04441ac66e770f4c1a51e 100755 (executable)
@@ -17,7 +17,7 @@ then
 fi
 
 # build a fresh fs monmap, mon fs
-$CEPH_BIN/monmaptool --create --clobber --add $IP:12345 --print .ceph_monmap
+$CEPH_BIN/monmaptool --create --clobber --add $IP:6789 --print .ceph_monmap
 $CEPH_BIN/mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap
 
 # shared args
diff --git a/src/mkfs.sh b/src/mkfs.sh
deleted file mode 100755 (executable)
index 056742b..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-# figure machine's ip
-HOSTNAME=`hostname`
-IP=`host $HOSTNAME | cut -d ' ' -f 4`
-[ "$CEPH_BIN" == "" ] && CEPH_BIN=.
-
-echo hostname $HOSTNAME
-echo "ip $IP"
-if [ `echo $IP | grep '^127\\.'` ]
-then
-       echo
-       echo "WARNING: hostname resolves to loopback; remote hosts will not be able to"
-       echo "  connect.  either adjust /etc/hosts, or edit this script to use your"
-       echo "  machine's real IP."
-       echo
-fi
-
-# build a fresh fs monmap, mon fs
-$CEPH_BIN/monmaptool --create --clobber --add $IP:12345 --print .ceph_monmap
-$CEPH_BIN/mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap
-
-# shared args
-ARGS="-d --debug_ms 1"
-
-# start monitor
-$CEPH_BIN/cmon $ARGS mondata/mon0 --debug_mon 20 --debug_ms 1
-
-# build and inject an initial osd map
-$CEPH_BIN/osdmaptool --clobber --createsimple .ceph_monmap 4 --print .ceph_osdmap
-$CEPH_BIN/cmonctl osd setmap -i .ceph_osdmap
-
-# initialize osd stores
-for osd in 0 1 2 3
-do
- $CEPH_BIN/cosd --mkfs_for_osd $osd dev/osd$osd  # initialize empty object store
-done
-
-# stop monitor
-killall cmon
-#$CEPH_BIN/cmonctl stop
-
-echo "mkfs done."
-
index 97f9b5a27f4762beed79108a8358e25c59ee0765..33bbac79cd5cf9453bb371616adfe08a31c5d7d7 100644 (file)
@@ -121,11 +121,29 @@ int Rank::Accepter::bind(int64_t force_nonce)
   ::setsockopt(listen_sd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
   
   /* bind to port */
-  int rc = ::bind(listen_sd, (struct sockaddr *) &listen_addr, sizeof(listen_addr));
-  if (rc < 0) {
-    derr(0) << "accepter.bind unable to bind to " << g_my_addr.ipaddr
-           << ": " << strerror(errno) << dendl;
-    return -errno;
+  int rc;
+  if (listen_addr.sin_port) {
+    // specific port
+    rc = ::bind(listen_sd, (struct sockaddr *) &listen_addr, sizeof(listen_addr));
+    if (rc < 0) {
+      derr(0) << "accepter.bind unable to bind to " << g_my_addr.ipaddr
+             << ": " << strerror(errno) << dendl;
+      return -errno;
+    }
+  } else {
+    // try a range of ports
+    for (int port = CEPH_PORT_START; port <= CEPH_PORT_LAST; port++) {
+      listen_addr.sin_port = htons(port);
+      rc = ::bind(listen_sd, (struct sockaddr *) &listen_addr, sizeof(listen_addr));
+      if (rc == 0)
+       break;
+    }
+    if (rc < 0) {
+      derr(0) << "accepter.bind unable to bind to " << g_my_addr.ipaddr
+             << " on any port in range " << CEPH_PORT_START << "-" << CEPH_PORT_LAST
+             << ": " << strerror(errno) << dendl;
+      return -errno;
+    }
   }
 
   // what port did we get?
diff --git a/src/startnew.sh b/src/startnew.sh
deleted file mode 100755 (executable)
index b9238f4..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-
-# sudo if btrfs
-test -d dev/osd0 && SUDO="sudo"
-
-$SUDO ./stop.sh
-$SUDO rm core*
-
-test -d out || mkdir out
-$SUDO rm out/*
-
-# figure machine's ip
-HOSTNAME=`hostname`
-IP=`host $HOSTNAME | cut -d ' ' -f 4`
-[ "$CEPH_BIN" == "" ] && CEPH_BIN=.
-[ "$CEPH_PORT" == "" ] && CEPH_PORT=12345
-
-echo hostname $HOSTNAME
-echo "ip $IP"
-if [ `echo $IP | grep '^127\\.'` ]
-then
-       echo
-       echo "WARNING: hostname resolves to loopback; remote hosts will not be able to"
-       echo "  connect.  either adjust /etc/hosts, or edit this script to use your"
-       echo "  machine's real IP."
-       echo
-fi
-
-# build a fresh fs monmap, mon fs
-$CEPH_BIN/monmaptool --create --clobber --add $IP:$CEPH_PORT --print .ceph_monmap
-$CEPH_BIN/mkmonfs --clobber mondata/mon0 --mon 0 --monmap .ceph_monmap
-
-# shared args
-ARGS="-f"
-CMON_ARGS=""
-CMDS_ARGS=""
-COSD_ARGS=""
-
-# start monitor
-$CEPH_BIN/crun $CEPH_BIN/cmon $ARGS $CMON_ARGS mondata/mon0 --debug_mon 10 --debug_ms 1 &
-
-
-# build and inject an initial osd map
-$CEPH_BIN/osdmaptool --clobber --createsimple .ceph_monmap 4 .ceph_osdmap
-$CEPH_BIN/cmonctl osd setmap -i .ceph_osdmap
-
-for osd in 0 #1 2 3 
-do
- $SUDO $CEPH_BIN/cosd --mkfs_for_osd $osd dev/osd$osd  # initialize empty object store
- $CEPH_BIN/crun $SUDO $CEPH_BIN/cosd $ARGS $COSD_ARGS dev/osd$osd &
-done
-
-# mds
-$CEPH_BIN/crun $CEPH_BIN/cmds $ARGS $CMDS_ARGS & # --debug_ms 1 #--debug_mds 20 --debug_ms 20
-
-echo "started.  stop.sh to stop.  see out/* (e.g. 'tail -f out/????') for debug output."
-
index 976f2ba9099f6b07b77dc82f0dc77332fc45110a..3705f60597d0c9d0eeb2524923a9734cb540141c 100755 (executable)
@@ -60,7 +60,7 @@ test -d gmon && $SUDO rm -rf gmon/*
 HOSTNAME=`hostname`
 IP=`host $HOSTNAME | grep $HOSTNAME | cut -d ' ' -f 4`
 [ "$CEPH_BIN" == "" ] && CEPH_BIN=.
-[ "$CEPH_PORT" == "" ] && CEPH_PORT=12345
+[ "$CEPH_PORT" == "" ] && CEPH_PORT=6789
 echo hostname $HOSTNAME
 echo "ip $IP"