setup-object-storage.sh 12.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/bin/sh

##
## Setup a OpenStack object storage node.
##

set -x

# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

# Grab our libs
. "`dirname $0`/setup-lib.sh"

if [ "$HOSTNAME" != "$OBJECTHOST" ]; then
    exit 0;
fi

if [ -f $OURDIR/setup-object-host-done ]; then
    exit 0
fi

26 27 28 29 30
#
# Ensure extra space, *before* we source LOCALSETTINGS.
#
$DIRNAME/setup-extra-space.sh

31 32
logtstart "object-storage"

33 34 35
if [ -f $SETTINGS ]; then
    . $SETTINGS
fi
36 37 38
if [ -f $LOCALSETTINGS ]; then
    . $LOCALSETTINGS
fi
39

40
maybe_install_packages xfsprogs rsync
41

42
#
43
# Handle the case where we have no LVM.
44
#
45
LDEVS=""
46
if [ $LVM -eq 0 ] ; then
47
    dd if=/dev/zero of=${STORAGEDIR}/swiftv1 bs=32768 count=131072
48
    LDEV=`losetup -f`
49
    losetup $LDEV ${STORAGEDIR}/swiftv1
50
    LDEVS="${LDEV}"
51
    dd if=/dev/zero of=${STORAGEDIR}/swiftv1-2 bs=32768 count=131072
52
    LDEV=`losetup -f`
53
    losetup $LDEV ${STORAGEDIR}/swiftv1-2
54
    LDEVS="${LDEVS} ${LDEV}"
55
else
56
    lvcreate -n swiftv1 -L ${SWIFT_LV_SIZE}G $VGNAME
57
    LDEV=/dev/${VGNAME}/swiftv1
58
    LDEVS="${LDEV}"
59
    lvcreate -n swiftv1-2 -L ${SWIFT_LV_SIZE}G $VGNAME
60 61
    LDEV=/dev/${VGNAME}/swiftv1-2
    LDEVS="${LDEVS} ${LDEV}"
62
fi
63

64
mkdir -p ${STORAGEDIR}/mnt/swift
65 66 67 68
for ldev in $LDEVS ; do
    base=`basename $ldev`
    mkfs.xfs $ldev
    cat <<EOF >> /etc/fstab
69
$ldev ${STORAGEDIR}/mnt/swift/$base xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
70
EOF
71 72
    mkdir -p ${STORAGEDIR}/mnt/swift/$base
    mount ${STORAGEDIR}/mnt/swift/$base
73
done
74 75 76 77 78 79

cat <<EOF >> /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
80
address = $MGMTIP
81 82 83

[account]
max connections = 8
84
path = ${STORAGEDIR}/mnt/swift
85 86 87 88 89
read only = false
lock file = /var/lock/account.lock

[container]
max connections = 8
90
path = ${STORAGEDIR}/mnt/swift
91 92 93 94 95
read only = false
lock file = /var/lock/container.lock

[object]
max connections = 8
96
path = ${STORAGEDIR}/mnt/swift
97 98 99 100 101 102 103 104
read only = false
lock file = /var/lock/object.lock
EOF

cat <<EOF >> /etc/default/rsync
RSYNC_ENABLE=true
EOF

105 106 107
service_enable rsync
service_restart rsync
service_start rsync
108

109 110
mkdir -p /var/log/swift
chown -R syslog.adm /var/log/swift
111

112
maybe_install_packages swift swift-account swift-container swift-object
113

David Johnson's avatar
David Johnson committed
114
wget -O /etc/swift/account-server.conf \
115
    "https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/${OSCODENAME}"
116 117 118 119 120
if [ ! $? -eq 0 ]; then
    # Try the EOL version...
    wget -O /etc/swift/account-server.conf \
	"https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=${OSCODENAME}-eol"
fi
121

David Johnson's avatar
David Johnson committed
122
wget -O /etc/swift/container-server.conf \
123
    "https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/${OSCODENAME}"
124 125 126 127 128
if [ ! $? -eq 0 ]; then
    # Try the EOL version...
    wget -O /etc/swift/container-server.conf \
	"https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=${OSCODENAME}-eol"
fi
129

David Johnson's avatar
David Johnson committed
130
wget -O /etc/swift/object-server.conf \
131
    "https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/${OSCODENAME}"
132 133 134 135 136
if [ ! $? -eq 0 ]; then
    # Try the EOL version...
    wget -O /etc/swift/object-server.conf \
	"https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=${OSCODENAME}-eol"
fi
137

138
if [ $OSVERSION -ge $OSKILO ]; then
139 140
    wget -O /etc/swift/container-reconciler.conf \
	"https://git.openstack.org/cgit/openstack/swift/plain/etc/container-reconciler.conf-sample?h=stable/${OSCODENAME}"
141 142 143 144 145
    if [ ! $? -eq 0 ]; then
        # Try the EOL version...
	wget -O /etc/swift/container-reconciler.conf \
	    "https://git.openstack.org/cgit/openstack/swift/plain/etc/container-reconciler.conf-sample?h=${OSCODENAME}-eol"
    fi
146 147
    wget -O /etc/swift/object-expirer.conf \
	"https://git.openstack.org/cgit/openstack/swift/plain/etc/object-expirer.conf-sample?h=stable/${OSCODENAME}"
148 149 150 151 152
    if [ ! $? -eq 0 ]; then
        # Try the EOL version...
	wget -O /etc/swift/object-expirer.conf \
	    "https://git.openstack.org/cgit/openstack/swift/plain/etc/object-expirer.conf-sample?h=${OSCODENAME}-eol"
    fi
153
fi
154

155 156 157 158
crudini --set /etc/swift/account-server.conf DEFAULT bind_ip $MGMTIP
crudini --set /etc/swift/account-server.conf DEFAULT bind_port 6002
crudini --set /etc/swift/account-server.conf DEFAULT user swift
crudini --set /etc/swift/account-server.conf DEFAULT swift_dir /etc/swift
159
crudini --set /etc/swift/account-server.conf DEFAULT devices ${STORAGEDIR}/mnt/swift
160 161 162
if [ $OSVERSION -ge $OSLIBERTY ]; then
    crudini --set /etc/swift/account-server.conf DEFAULT mount_check true
fi
163

164 165 166 167 168 169
crudini --set /etc/swift/account-server.conf pipeline:main \
    pipeline 'healthcheck recon account-server'
crudini --set /etc/swift/account-server.conf filter:recon \
    use 'egg:swift#recon'
crudini --set /etc/swift/account-server.conf filter:recon \
    recon_cache_path /var/cache/swift
170

171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
crudini --set /etc/swift/account-server.conf DEFAULT log_facility LOG_LOCAL1
crudini --set /etc/swift/account-server.conf DEFAULT log_level INFO
crudini --set /etc/swift/account-server.conf DEFAULT log_name swift-account
crudini --set /etc/swift/account-server.conf app:account-server log_facility LOG_LOCAL1
crudini --set /etc/swift/account-server.conf app:account-server log_level INFO
crudini --set /etc/swift/account-server.conf app:account-server log_name swift-account
crudini --set /etc/swift/account-server.conf account-replicator log_facility LOG_LOCAL1
crudini --set /etc/swift/account-server.conf account-replicator log_level INFO
crudini --set /etc/swift/account-server.conf account-replicator log_name swift-account-replicator
crudini --set /etc/swift/account-server.conf account-auditor log_facility LOG_LOCAL1
crudini --set /etc/swift/account-server.conf account-auditor log_level INFO
crudini --set /etc/swift/account-server.conf account-auditor log_name swift-account-auditor
crudini --set /etc/swift/account-server.conf account-reaper log_facility LOG_LOCAL1
crudini --set /etc/swift/account-server.conf account-reaper log_level INFO
crudini --set /etc/swift/account-server.conf account-reaper log_name swift-account-reaper

echo 'if $programname == "swift-account" then { action(type="omfile" file="/var/log/swift/swift-account.log") }' >> /etc/rsyslog.d/99-swift.conf

189 190 191 192
crudini --set /etc/swift/container-server.conf DEFAULT bind_ip $MGMTIP
crudini --set /etc/swift/container-server.conf DEFAULT bind_port 6001
crudini --set /etc/swift/container-server.conf DEFAULT user swift
crudini --set /etc/swift/container-server.conf DEFAULT swift_dir /etc/swift
193
crudini --set /etc/swift/container-server.conf DEFAULT devices ${STORAGEDIR}/mnt/swift
194 195 196
if [ $OSVERSION -ge $OSLIBERTY ]; then
    crudini --set /etc/swift/container-server.conf DEFAULT mount_check true
fi
197

198 199 200 201 202 203
crudini --set /etc/swift/container-server.conf pipeline:main \
    pipeline 'healthcheck recon container-server'
crudini --set /etc/swift/container-server.conf filter:recon \
    use 'egg:swift#recon'
crudini --set /etc/swift/container-server.conf filter:recon \
    recon_cache_path /var/cache/swift
204

205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
crudini --set /etc/swift/container-server.conf DEFAULT log_facility LOG_LOCAL1
crudini --set /etc/swift/container-server.conf DEFAULT log_level INFO
crudini --set /etc/swift/container-server.conf DEFAULT log_name swift-container
crudini --set /etc/swift/container-server.conf app:container-server log_facility LOG_LOCAL1
crudini --set /etc/swift/container-server.conf app:container-server log_level INFO
crudini --set /etc/swift/container-server.conf app:container-server log_name swift-container
crudini --set /etc/swift/container-server.conf container-replicator log_facility LOG_LOCAL1
crudini --set /etc/swift/container-server.conf container-replicator log_level INFO
crudini --set /etc/swift/container-server.conf container-replicator log_name swift-container-replicator
crudini --set /etc/swift/container-server.conf container-updater log_facility LOG_LOCAL1
crudini --set /etc/swift/container-server.conf container-updater log_level INFO
crudini --set /etc/swift/container-server.conf container-updater log_name swift-container-updater
crudini --set /etc/swift/container-server.conf container-auditor log_facility LOG_LOCAL1
crudini --set /etc/swift/container-server.conf container-auditor log_level INFO
crudini --set /etc/swift/container-server.conf container-auditor log_name swift-container-auditor
crudini --set /etc/swift/container-server.conf container-sync log_facility LOG_LOCAL1
crudini --set /etc/swift/container-server.conf container-sync log_level INFO
crudini --set /etc/swift/container-server.conf container-sync log_name swift-container-sync

echo 'if $programname == "swift-container" then { action(type="omfile" file="/var/log/swift/swift-container.log") }' >> /etc/rsyslog.d/99-swift.conf

226 227 228 229
crudini --set /etc/swift/object-server.conf DEFAULT bind_ip $MGMTIP
crudini --set /etc/swift/object-server.conf DEFAULT bind_port 6000
crudini --set /etc/swift/object-server.conf DEFAULT user swift
crudini --set /etc/swift/object-server.conf DEFAULT swift_dir /etc/swift
230
crudini --set /etc/swift/object-server.conf DEFAULT devices ${STORAGEDIR}/mnt/swift
231 232 233
if [ $OSVERSION -ge $OSLIBERTY ]; then
    crudini --set /etc/swift/object-server.conf DEFAULT mount_check true
fi
234

235 236 237 238 239 240 241 242 243
crudini --set /etc/swift/object-server.conf pipeline:main \
    pipeline 'healthcheck recon object-server'
crudini --set /etc/swift/object-server.conf filter:recon \
    use 'egg:swift#recon'
crudini --set /etc/swift/object-server.conf filter:recon \
    recon_cache_path /var/cache/swift
if [ $OSVERSION -ge $OSKILO ]; then
    crudini --set /etc/swift/object-server.conf filter:recon \
	recon_lock_path /var/lock
David Johnson's avatar
David Johnson committed
244
fi
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

crudini --set /etc/swift/object-server.conf DEFAULT log_facility LOG_LOCAL1
crudini --set /etc/swift/object-server.conf DEFAULT log_level INFO
crudini --set /etc/swift/object-server.conf DEFAULT log_name swift-object
crudini --set /etc/swift/object-server.conf app:object-server log_facility LOG_LOCAL1
crudini --set /etc/swift/object-server.conf app:object-server log_level INFO
crudini --set /etc/swift/object-server.conf app:object-server log_name swift-object
crudini --set /etc/swift/object-server.conf object-replicator log_facility LOG_LOCAL1
crudini --set /etc/swift/object-server.conf object-replicator log_level INFO
crudini --set /etc/swift/object-server.conf object-replicator log_name swift-object-replicator
crudini --set /etc/swift/object-server.conf object-reconstructor log_facility LOG_LOCAL1
crudini --set /etc/swift/object-server.conf object-reconstructor log_level INFO
crudini --set /etc/swift/object-server.conf object-reconstructor log_name swift-object-reconstructor
crudini --set /etc/swift/object-server.conf object-updater log_facility LOG_LOCAL1
crudini --set /etc/swift/object-server.conf object-updater log_level INFO
crudini --set /etc/swift/object-server.conf object-updater log_name swift-object-updater
crudini --set /etc/swift/object-server.conf object-auditor log_facility LOG_LOCAL1
crudini --set /etc/swift/object-server.conf object-auditor log_level INFO
crudini --set /etc/swift/object-server.conf object-auditor log_name swift-object-auditor

echo 'if $programname == "swift-object" then { action(type="omfile" file="/var/log/swift/swift-object.log") }' >> /etc/rsyslog.d/99-swift.conf
266

267
chown -R swift:swift ${STORAGEDIR}/mnt/swift
268 269 270 271

mkdir -p /var/cache/swift
chown -R swift:swift /var/cache/swift

272 273 274 275
if [ ${HAVE_SYSTEMD} -eq 0 ]; then
    swift-init all start
    service rsyslog restart
else
276 277
    service_restart rsyslog
    service_restart swift-account
278 279
    service_enable swift-proxy
    service_restart swift-proxy
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
    service_enable swift-account
    service_restart swift-account-auditor
    service_enable swift-account-auditor
    service_restart swift-account-reaper
    service_enable swift-account-reaper
    service_restart swift-account-replicator
    service_enable swift-account-replicator
    service_restart swift-container
    service_enable swift-container
    service_restart swift-container-auditor
    service_enable swift-container-auditor
    service_restart swift-container-replicator
    service_enable swift-container-replicator
    service_restart swift-container-sync
    service_enable swift-container-sync
    service_restart swift-container-updater
    service_enable swift-container-updater
    service_restart swift-object
    service_enable swift-object
    service_restart swift-object-auditor
    service_enable swift-object-auditor
    service_restart swift-object-replicator
    service_enable swift-object-replicator
    service_restart swift-object-updater
    service_enable swift-object-updater
305
fi
306 307 308

touch $OURDIR/setup-object-host-done

309 310
logtend "object-storage"

311
exit 0