]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
init: add systemd service files 2154/head
authorFederico Simoncelli <fsimonce@redhat.com>
Sun, 20 Jul 2014 02:08:43 +0000 (22:08 -0400)
committerFederico Simoncelli <fsimonce@redhat.com>
Tue, 22 Jul 2014 15:30:55 +0000 (11:30 -0400)
This patch adds systemd service files. It is possible to start and
enable multiple instances (per monid, osdid, mds name), e.g.

 # systemctl start ceph-mon@node01
 # systemctl enable ceph-mon@node01

 # systemctl start ceph-osd@0
 # systemctl enable ceph-osd@0

The ceph cluster can be set in the system config file:

 /etc/sysconfig/ceph

adding or editing the CLUSTER environment variable.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
ceph.spec.in
debian/ceph.install
src/Makefile.am
src/ceph-osd-prestart.sh [new file with mode: 0644]
src/upstart/ceph-osd.conf
systemd/ceph-mds@.service [new file with mode: 0644]
systemd/ceph-mon@.service [new file with mode: 0644]
systemd/ceph-osd@.service [new file with mode: 0644]

index 871b43e8d8ad1ca76d3788b560a26556f5c194ec..8e726ccaf9c24e8d6c7447268917fef13542f41b 100644 (file)
@@ -447,6 +447,7 @@ fi
 %endif
 %dir %{_libdir}/ceph
 %{_libdir}/ceph/ceph_common.sh
+%{_libexecdir}/ceph/ceph-osd-prestart.sh
 %dir %{_libdir}/rados-classes
 %{_libdir}/rados-classes/libcls_rbd.so*
 %{_libdir}/rados-classes/libcls_hello.so*
index f9e1159d33fa77a3cdf6da1be37fc9bd2b3063ee..200cd809829441f00a8747d929955f37dfe53d49 100644 (file)
@@ -18,6 +18,7 @@ usr/bin/osdmaptool
 usr/lib/ceph/ceph_common.sh
 usr/lib/ceph/erasure-code/*
 usr/lib/rados-classes/*
+usr/libexec/ceph/ceph-osd-prestart.sh
 usr/share/doc/ceph/sample.ceph.conf
 usr/share/doc/ceph/sample.fetch_config
 usr/share/man/man8/ceph-clsinfo.8
index 9bbe667ced019e26e4ab270f962007e969752692..b0f52b822de4feef8d53a6b2cf6dcdef1c4f1f32 100644 (file)
@@ -154,6 +154,7 @@ EXTRA_DIST += \
        $(srcdir)/vstart.sh \
        $(srcdir)/stop.sh \
        ceph-run \
+       $(srcdir)/ceph-osd-prestart.sh \
        $(srcdir)/ceph_common.sh \
        $(srcdir)/init-radosgw \
        $(srcdir)/init-radosgw.sysv \
@@ -222,6 +223,9 @@ doc_DATA = $(srcdir)/sample.ceph.conf sample.fetch_config
 shell_commondir = $(libdir)/ceph
 shell_common_SCRIPTS = ceph_common.sh
 
+ceph_libexecdir = $(libexecdir)/ceph
+ceph_libexec_SCRIPTS = ceph-osd-prestart.sh
+
 bash_completiondir = $(sysconfdir)/bash_completion.d
 bash_completion_DATA = $(srcdir)/bash_completion/ceph \
                $(srcdir)/bash_completion/rados \
diff --git a/src/ceph-osd-prestart.sh b/src/ceph-osd-prestart.sh
new file mode 100644 (file)
index 0000000..77153c9
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+eval set -- "$(getopt -o i: --long id:,cluster: -- $@)"
+
+while true ; do
+       case "$1" in
+               -i|--id) id=$2; shift 2 ;;
+               --cluster) cluster=$2; shift 2 ;;
+               --) shift ; break ;;
+       esac
+done
+
+if [ -z "$id"  ]; then
+    echo "Usage: $0 [OPTIONS]"
+    echo "--id/-i ID        set ID portion of my name"
+    echo "--cluster NAME    set cluster name (default: ceph)"
+    exit 1;
+fi
+
+update="$(ceph-conf --cluster=${cluster:-ceph} --name=osd.$id --lookup osd_crush_update_on_start || :)"
+
+if [ "${update:-1}" = "1" -o "${update:-1}" = "true" ]; then
+    # update location in crush
+    hook="$(ceph-conf --cluster=${cluster:-ceph} --name=osd.$id --lookup osd_crush_location_hook || :)"
+    if [ -z "$hook" ]; then
+        hook="/usr/bin/ceph-crush-location"
+    fi
+    location="$($hook --cluster ${cluster:-ceph} --id $id --type osd)"
+    weight="$(ceph-conf --cluster=${cluster:-ceph} --name=osd.$id --lookup osd_crush_initial_weight || :)"
+    defaultweight=`df -P -k /var/lib/ceph/osd/${cluster:-ceph}-$id/ | tail -1 | awk '{ d= $2/1073741824 ; r = sprintf("%.2f", d); print r }'`
+    ceph \
+        --cluster="${cluster:-ceph}" \
+        --name="osd.$id" \
+        --keyring="/var/lib/ceph/osd/${cluster:-ceph}-$id/keyring" \
+        osd crush create-or-move \
+        -- \
+        "$id" \
+        "${weight:-${defaultweight:-1}}" \
+        $location
+fi
+
+journal="/var/lib/ceph/osd/${cluster:-ceph}-$id/journal"
+if [ -L "$journal" -a ! -e "$journal" ]; then
+    udevadm settle --timeout=5 || :
+    if [ -L "$journal" -a ! -e "$journal" ]; then
+        echo "ceph-osd($UPSTART_INSTANCE): journal not present, not starting yet." 1>&2
+        stop
+        exit 0
+    fi
+fi
index 7175c2d93008cd51f8e49b4b8b9027336ce35318..81469f2b12510f9ff029bb78666ec9ca717a9863 100644 (file)
@@ -15,36 +15,7 @@ pre-start script
 
     install -d -m0755 /var/run/ceph
 
-    update="$(ceph-conf --cluster=${cluster:-ceph} --name=osd.$id --lookup osd_crush_update_on_start || :)"
-    if [ "${update:-1}" = "1" -o "${update:-1}" = "true" ]; then
-        # update location in crush
-       hook="$(ceph-conf --cluster=${cluster:-ceph} --name=osd.$id --lookup osd_crush_location_hook || :)"
-       if [ -z "$hook" ]; then
-           hook="/usr/bin/ceph-crush-location"
-       fi
-       location="$($hook --cluster ${cluster:-ceph} --id $id --type osd)"
-       weight="$(ceph-conf --cluster=${cluster:-ceph} --name=osd.$id --lookup osd_crush_initial_weight || :)"
-       defaultweight=`df -P -k /var/lib/ceph/osd/${cluster:-ceph}-$id/ | tail -1 | awk '{ d= $2/1073741824 ; r = sprintf("%.2f", d); print r }'`
-       ceph \
-            --cluster="${cluster:-ceph}" \
-            --name="osd.$id" \
-            --keyring="/var/lib/ceph/osd/${cluster:-ceph}-$id/keyring" \
-            osd crush create-or-move \
-           -- \
-            "$id" \
-           "${weight:-${defaultweight:-1}}" \
-           $location
-    fi
-
-    journal="/var/lib/ceph/osd/${cluster:-ceph}-$id/journal"
-    if [ -L "$journal" -a ! -e "$journal" ]; then
-        udevadm settle --timeout=5 || :
-       if [ -L "$journal" -a ! -e "$journal" ]; then
-            echo "ceph-osd($UPSTART_INSTANCE): journal not present, not starting yet." 1>&2
-           stop
-           exit 0
-       fi
-    fi
+    /usr/libexec/ceph/ceph-osd-prestart.sh --cluster="${cluster:-ceph}" -i "$id"
 end script
 
 instance ${cluster:-ceph}/$id
diff --git a/systemd/ceph-mds@.service b/systemd/ceph-mds@.service
new file mode 100644 (file)
index 0000000..08bab79
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=Ceph metadata server daemon
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/ceph
+Environment=CLUSTER=ceph
+ExecStart=/usr/bin/ceph-mds -f --cluster ${CLUSTER} --id %i
+
+[Install]
+WantedBy=multi-user.target
diff --git a/systemd/ceph-mon@.service b/systemd/ceph-mon@.service
new file mode 100644 (file)
index 0000000..8ba0843
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=Ceph cluster monitor daemon
+
+# According to:
+#   http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
+# these can be removed once ceph-mon will dynamically change network
+# configuration.
+After=network-online.target
+Wants=network-online.target
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/ceph
+Environment=CLUSTER=ceph
+ExecStart=/usr/bin/ceph-mon -f --cluster ${CLUSTER} --id %i
+
+[Install]
+WantedBy=multi-user.target
diff --git a/systemd/ceph-osd@.service b/systemd/ceph-osd@.service
new file mode 100644 (file)
index 0000000..1811d7e
--- /dev/null
@@ -0,0 +1,11 @@
+[Unit]
+Description=Ceph object storage daemon
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/ceph
+Environment=CLUSTER=ceph
+ExecStart=/usr/bin/ceph-osd -f --cluster ${CLUSTER} --id %i
+ExecStartPre=/usr/libexec/ceph/ceph-osd-prestart.sh --cluster ${CLUSTER} --id %i
+
+[Install]
+WantedBy=multi-user.target