溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

radosgw單機多怎么實現(xiàn)

發(fā)布時間:2021-12-30 16:29:08 來源:億速云 閱讀:119 作者:iii 欄目:云計算

本篇內(nèi)容主要講解“radosgw單機多怎么實現(xiàn)”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“radosgw單機多怎么實現(xiàn)”吧!

/etc/init.d/radosgw

#! /bin/sh
### BEGIN INIT INFO
# Provides:          radosgw
# Required-Start:    $remote_fs $named $network $time
# Required-Stop:     $remote_fs $named $network $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: radosgw RESTful rados gateway
# Description: radosgw RESTful rados gateway
### END INIT INFO

PATH=/sbin:/bin:/usr/bin

if [ -x /sbin/start-stop-daemon ]; then
    DEBIAN=1
    . /lib/lsb/init-functions
else
    . /etc/rc.d/init.d/functions
    DEBIAN=0

    # detect systemd, also check whether the systemd-run binary exists
    SYSTEMD_RUN=$(which systemd-run 2>/dev/null)
    grep -qs systemd /proc/1/comm || SYSTEMD_RUN=""
fi

daemon_is_running() {
    daemon=$1
    if pidof $daemon >/dev/null; then
        echo "$daemon is running."
        exit 0
    else
        echo "$daemon is not running."
        exit 1
    fi
}

VERBOSE=0
for opt in $*; do
    if [ "$opt" = "-v" ] || [ "$opt" = "--verbose" ]; then
       VERBOSE=1
    fi
done

# prefix for radosgw instances in ceph.conf
PREFIX='client.radosgw.'

# user to run radosgw as (if not specified in ceph.conf)
DEFAULT_USER='root'

RADOSGW=`which radosgw`
if [ ! -x "$RADOSGW" ]; then
    [ $VERBOSE -eq 1 ] && echo "$RADOSGW could not start, it is not executable."
    exit 1
fi

# list daemons, old-style and new-style
# NOTE: no support for cluster names that aren't "ceph"
dlist=`ceph-conf --list-sections $PREFIX`
if [ -d "/var/lib/ceph/radosgw" ]; then
    for d in `ls /var/lib/ceph/radosgw | grep ^ceph-`; do
	if [ -e "/var/lib/ceph/radosgw/$d/sysvinit" ]; then
	    id=`echo $d | cut -c 6-`
	    dlist="client.$id $dlist"
	fi
    done
fi

case "$1" in
    start)
        for name in $dlist
        do
            auto_start=`ceph-conf -n $name 'auto start'`
            if [ "$auto_start" = "no" ] || [ "$auto_start" = "false" ] || [ "$auto_start" = "0" ]; then
                continue
            fi

	    shortname=`echo $name | cut -c 8-`
	    if [ ! -e "/var/lib/ceph/radosgw/ceph-$shortname/sysvinit" ]; then
                # mapped to this host?
		host=`ceph-conf -n $name host`
		hostname=`hostname -s`
		if [ "$host" != "$hostname" ]; then
                    [ $VERBOSE -eq 1 ] && echo "hostname $hostname could not be found in ceph.conf:[$name], not starting."
                    continue
		fi
	    fi

            user=`ceph-conf -n $name user`
            if [ -z "$user" ]; then
                user="$DEFAULT_USER"
            fi

            log_file=`$RADOSGW -n $name --show-config-value log_file`
            if [ -n "$log_file" ]; then
                if [ ! -e "$log_file" ]; then
                    touch "$log_file"
                fi
                chown $user $log_file
            fi

            echo "Starting $name..."
	    if [ $DEBIAN -eq 1 ]; then
		start-stop-daemon --start -u $user -x $RADOSGW -p /var/run/ceph/client-$name.pid -- -n $name
	    elif [ -n "$SYSTEMD_RUN" ]; then
                $SYSTEMD_RUN -r su "$user" -c "ulimit -n 32768; $RADOSGW -n $name"
            else
		ulimit -n 32768
                daemon --user="$user" "$RADOSGW -n $name"
            fi
        done
        ;;
    reload)
        echo "Reloading $name..."
	if [ $DEBIAN -eq 1 ]; then
            start-stop-daemon --stop --signal HUP -x $RADOSGW --oknodo
	else
            killproc $RADOSGW -SIGHUP
	fi
	;;
    restart|force-reload)
        $0 stop
        $0 start
        ;;
    stop)
        timeout=0
        for name in $dlist
        do
          t=`$RADOSGW -n $name --show-config-value rgw_exit_timeout_secs`
          if [ $t -gt $timeout ]; then timeout=$t; fi
        done

	if [ $DEBIAN -eq 1 ]; then
            if [ $timeout -gt 0 ]; then TIMEOUT="-R $timeout"; fi
            start-stop-daemon --stop -x $RADOSGW -t
            start-stop-daemon --stop -x $RADOSGW --oknodo $TIMEOUT
	else
	    killproc $RADOSGW
	    while pidof $RADOSGW >/dev/null && [ $timeout -gt 0 ] ; do
		sleep 1
		timeout=$(($timeout - 1))
            done
	fi
        ;;
    status)
        daemon_is_running $RADOSGW
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|force-reload|reload|status} [-v|--verbose]" >&2
        exit 3
        ;;
esac

默認的啟動腳本是以hostname為判斷變量,我這里跳過了這個步驟。

使用流程

  1. 新建ceph auth新建radosgw用戶

  2. 添加用戶keyring

  3. 在ceph.conf里面添加radosgw服務(wù)配置信息

  4. 使用腳本啟動服務(wù)

到此,相信大家對“radosgw單機多怎么實現(xiàn)”有了更深的了解,不妨來實際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI