-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall_swift.sh
327 lines (257 loc) · 6.54 KB
/
install_swift.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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#!/bin/bash
#you need to run this script as root user.
#Defualt user:passwd is swift:swift
#adding the "swift" user to sudoers file.
cat >> /etc/sudoers <<EOF
#adding swift user to sudoers file
swift ALL=(ALL:ALL) ALL
EOF
echo "adding the cloud repo"
###Adding the cloud repo########
echo deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main >> /etc/apt/sources.list.d/grizzly.list
apt-get update
apt-get upgrade
sleep 2
echo
echo
#####Adding swift package and depandency########
apt-get install -y swift swift-proxy swift-account swift-container swift-object memcached xfsprogs curl python-swiftclient
sleep 2
echo
echo
###Create Loop devices for storing objects
dd if=/dev/zero of=/srv/swift-disk bs=1024 count=0 seek=1000000
mkfs.xfs -i size=1024 /srv/swift-disk
cat >> /etc/fstab <<EOF
/srv/swift-disk /mnt/sdb1 xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0
EOF
mkdir /mnt/sdb1
mount /mnt/sdb1
mkdir /mnt/sdb1/1 /mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4
for x in {1..4}; do ln -s /mnt/sdb1/$x /srv/$x; done
mkdir -p /srv/1/node/sdb1 /srv/2/node/sdb2 /srv/3/node/sdb3 /srv/4/node/sdb4 /var/run/swift
sleep 2
echo
echo
### Remove conf files those generated by swift package ###
sudo rm -r /etc/swift
echo
echo "Remove completed"
echo
sleep 2
###SETUP Rsyncd###
echo "[Setting up Rsyncd]"
cat > /etc/rsyncd.conf <<EOF
uid = root
gid = root
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 127.0.0.1
[account6012]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/account6012.lock
[account6022]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/account6022.lock
[account6032]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/account6032.lock
[account6042]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/account6042.lock
[container6011]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/container6011.lock
[container6021]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/container6021.lock
[container6031]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/container6031.lock
[container6041]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/container6041.lock
[object6010]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/object6010.lock
[object6020]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/object6020.lock
[object6030]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/object6030.lock
[object6040]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/object6040.lock
EOF
sed 's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/g' /etc/default/rsync -i
service rsync restart
sleep 1
echo
echo
###Generate Configuration File##
echo "[Generate Configuration Files]"
mkdir -p /etc/swift/account-server /etc/swift/container-server /etc/swift/object-server
sleep 1
#Swift.conf#
echo " |.....Swift.conf"
cat > /etc/swift/swift.conf <<EOF
[swift-hash]
swift_hash_path_suffix = swift
EOF
sleep 1
echo " |"
#proxy-server.conf#
echo " |.....proxy-server.conf"
cat > /etc/swift/proxy-server.conf << EOF
[DEFAULT]
workers = 1
user = root
bind_port = 8080
[pipeline:main]
pipeline = healthcheck cache tempauth proxy-server
[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:cache]
use = egg:swift#memcache
EOF
sleep 1
echo " |"
#Container Configurations
#Account Server conf#
echo " |.....Account Server conf"
for ((i=1;i<=4;i=i+1))
do
port=$((6002+i*10))
cat > /etc/swift/account-server/$((i)).conf << EOF
[DEFAULT]
devices = /srv/$((i+1))/node
mount_check = false
bind_port = $port
user = root
[pipeline:main]
pipeline = account-server
[app:account-server]
use = egg:swift#account
[account-replicator]
vm_test_mode = yes
[account-auditor]
[account-reaper]
EOF
done
sleep 1
echo " |"
echo " |.....Container Server Confs"
for ((i=1;i<=4;i=i+1))
do
port=$((6001+i*10))
cat > /etc/swift/container-server/$((i)).conf << EOF
[DEFAULT]
devices = /srv/$((i+1))/node
mount_check = false
bind_port = $port
user = root
[pipeline:main]
pipeline = container-server
[app:container-server]
use = egg:swift#container
[container-replicator]
vm_test_mode = yes
[container-updater]
[container-auditor]
[container-sync]
EOF
done
sleep 1
echo " |"
#Object Configurations
echo " |.....Object server Confs"
for ((i=1;i<=4;i=i+1))
do
port=$((6000+i*10))
cat > /etc/swift/object-server/$((i)).conf << EOF
[DEFAULT]
devices = /srv/$((i+1))/node
mount_check = false
bind_port = $port
user = root
[pipeline:main]
pipeline = object-server
[app:object-server]
use = egg:swift#object
[object-replicator]
vm_test_mode = yes
[object-updater]
[object-auditor]
EOF
done
sleep 1
echo
#Starting Ring
echo " ------------ ***** Staring the Ring ***** ------------"
cd /etc/swift
rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
swift-ring-builder object.builder create 18 3 1
swift-ring-builder object.builder add z1-127.0.0.1:6010/sdb1 1
swift-ring-builder object.builder add z2-127.0.0.1:6020/sdb2 1
swift-ring-builder object.builder add z3-127.0.0.1:6030/sdb3 1
swift-ring-builder object.builder add z4-127.0.0.1:6040/sdb4 1
swift-ring-builder object.builder rebalance
swift-ring-builder container.builder create 18 3 1
swift-ring-builder container.builder add z1-127.0.0.1:6011/sdb1 1
swift-ring-builder container.builder add z2-127.0.0.1:6021/sdb2 1
swift-ring-builder container.builder add z3-127.0.0.1:6031/sdb3 1
swift-ring-builder container.builder add z4-127.0.0.1:6041/sdb4 1
swift-ring-builder container.builder rebalance
swift-ring-builder account.builder create 18 3 1
swift-ring-builder account.builder add z1-127.0.0.1:6012/sdb1 1
swift-ring-builder account.builder add z2-127.0.0.1:6022/sdb2 1
swift-ring-builder account.builder add z3-127.0.0.1:6032/sdb3 1
swift-ring-builder account.builder add z4-127.0.0.1:6042/sdb4 1
swift-ring-builder account.builder rebalance
sleep 2
echo
echo
echo " ------------ ***** Staring all the Swift service ***** ------------"
sleep 1
echo
echo
##Start all the services###
echo "Starting all swift service "
echo
echo
swift-init all start