-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup-object-storage.sh
executable file
·311 lines (269 loc) · 12.5 KB
/
setup-object-storage.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
305
306
307
308
309
310
311
#!/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
#
# Ensure extra space, *before* we source LOCALSETTINGS.
#
$DIRNAME/setup-extra-space.sh
logtstart "object-storage"
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
if [ -f $LOCALSETTINGS ]; then
. $LOCALSETTINGS
fi
maybe_install_packages xfsprogs rsync
#
# Handle the case where we have no LVM.
#
LDEVS=""
if [ $LVM -eq 0 ] ; then
dd if=/dev/zero of=${STORAGEDIR}/swiftv1 bs=32768 count=131072
LDEV=`losetup -f`
losetup $LDEV ${STORAGEDIR}/swiftv1
LDEVS="${LDEV}"
dd if=/dev/zero of=${STORAGEDIR}/swiftv1-2 bs=32768 count=131072
LDEV=`losetup -f`
losetup $LDEV ${STORAGEDIR}/swiftv1-2
LDEVS="${LDEVS} ${LDEV}"
else
lvcreate -n swiftv1 -L ${SWIFT_LV_SIZE}G $VGNAME
LDEV=/dev/${VGNAME}/swiftv1
LDEVS="${LDEV}"
lvcreate -n swiftv1-2 -L ${SWIFT_LV_SIZE}G $VGNAME
LDEV=/dev/${VGNAME}/swiftv1-2
LDEVS="${LDEVS} ${LDEV}"
fi
mkdir -p ${STORAGEDIR}/mnt/swift
for ldev in $LDEVS ; do
base=`basename $ldev`
mkfs.xfs $ldev
cat <<EOF >> /etc/fstab
$ldev ${STORAGEDIR}/mnt/swift/$base xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
EOF
mkdir -p ${STORAGEDIR}/mnt/swift/$base
mount ${STORAGEDIR}/mnt/swift/$base
done
cat <<EOF >> /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = $MGMTIP
[account]
max connections = 8
path = ${STORAGEDIR}/mnt/swift
read only = false
lock file = /var/lock/account.lock
[container]
max connections = 8
path = ${STORAGEDIR}/mnt/swift
read only = false
lock file = /var/lock/container.lock
[object]
max connections = 8
path = ${STORAGEDIR}/mnt/swift
read only = false
lock file = /var/lock/object.lock
EOF
cat <<EOF >> /etc/default/rsync
RSYNC_ENABLE=true
EOF
service_enable rsync
service_restart rsync
service_start rsync
mkdir -p /var/log/swift
chown -R syslog.adm /var/log/swift
maybe_install_packages swift swift-account swift-container swift-object
wget -O /etc/swift/account-server.conf \
"https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/${OSCODENAME}"
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
wget -O /etc/swift/container-server.conf \
"https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/${OSCODENAME}"
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
wget -O /etc/swift/object-server.conf \
"https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/${OSCODENAME}"
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
if [ $OSVERSION -ge $OSKILO ]; then
wget -O /etc/swift/container-reconciler.conf \
"https://git.openstack.org/cgit/openstack/swift/plain/etc/container-reconciler.conf-sample?h=stable/${OSCODENAME}"
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
wget -O /etc/swift/object-expirer.conf \
"https://git.openstack.org/cgit/openstack/swift/plain/etc/object-expirer.conf-sample?h=stable/${OSCODENAME}"
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
fi
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
crudini --set /etc/swift/account-server.conf DEFAULT devices ${STORAGEDIR}/mnt/swift
if [ $OSVERSION -ge $OSLIBERTY ]; then
crudini --set /etc/swift/account-server.conf DEFAULT mount_check true
fi
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
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
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
crudini --set /etc/swift/container-server.conf DEFAULT devices ${STORAGEDIR}/mnt/swift
if [ $OSVERSION -ge $OSLIBERTY ]; then
crudini --set /etc/swift/container-server.conf DEFAULT mount_check true
fi
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
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
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
crudini --set /etc/swift/object-server.conf DEFAULT devices ${STORAGEDIR}/mnt/swift
if [ $OSVERSION -ge $OSLIBERTY ]; then
crudini --set /etc/swift/object-server.conf DEFAULT mount_check true
fi
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
fi
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
chown -R swift:swift ${STORAGEDIR}/mnt/swift
mkdir -p /var/cache/swift
chown -R swift:swift /var/cache/swift
if [ ${HAVE_SYSTEMD} -eq 0 ]; then
swift-init all start
service rsyslog restart
else
service_restart rsyslog
service_restart swift-account
service_enable swift-proxy
service_restart swift-proxy
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
fi
touch $OURDIR/setup-object-host-done
logtend "object-storage"
exit 0