Browse code

more documentation

Jesse Andrews authored on 2011/10/03 06:47:32
Showing 1 changed files
... ...
@@ -43,10 +43,12 @@ fi
43 43
 # as root, since apache refused to startup serve content from root user).  If
44 44
 # stack.sh is run as root, it automatically creates a stack user with
45 45
 # sudo privileges and runs as that user.
46
+
46 47
 if [[ $EUID -eq 0 ]]; then
47 48
    echo "You are running this script as root."
48 49
 
49
-   # ensure sudo
50
+   # since this script runs as a normal user, we need to give that user
51
+   # ability to run sudo
50 52
    apt-get update
51 53
    apt-get install -y sudo
52 54
 
... ...
@@ -122,6 +124,8 @@ ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-v
122 122
 # an **LXC** based system.
123 123
 LIBVIRT_TYPE=${LIBVIRT_TYPE:-kvm}
124 124
 
125
+# nova supports pluggable schedulers.  ``SimpleScheduler`` should work in most
126
+# cases unless you are working on multi-zone mode.
125 127
 SCHEDULER=${SCHEDULER:-nova.scheduler.simple.SimpleScheduler}
126 128
 
127 129
 # Use the first IP unless an explicit is set by ``HOST_IP`` environment variable
... ...
@@ -133,19 +137,26 @@ fi
133 133
 # --------------------------
134 134
 
135 135
 PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-eth0}
136
-VLAN_INTERFACE=${VLAN_INTERFACE:-$PUBLIC_INTERFACE}
137
-FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.1/28}
138 136
 FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
139 137
 FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
138
+FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.1/28}
140 139
 NET_MAN=${NET_MAN:-FlatDHCPManager}
141 140
 EC2_DMZ_HOST=${EC2_DMZ_HOST:-$HOST_IP}
142 141
 FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-br100}
142
+VLAN_INTERFACE=${VLAN_INTERFACE:-$PUBLIC_INTERFACE}
143
+
144
+# Multi-host is a mode where each compute node runs its own network node.  This
145
+# allows network operations and routing for a VM to occur on the server that is
146
+# running the VM - removing a SPOF and bandwidth bottleneck.
147
+MULTI_HOST=${MULTI_HOST:-0}
143 148
 
144 149
 # If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE``
145 150
 # variable but make sure that the interface doesn't already have an
146 151
 # ip or you risk breaking things.
147 152
 FLAT_INTERFACE=${FLAT_INTERFACE:-eth0}
148 153
 
154
+## FIXME(ja): should/can we check that FLAT_INTERFACE is sane?
155
+
149 156
 
150 157
 # MySQL & RabbitMQ
151 158
 # ----------------
... ...
@@ -186,13 +197,6 @@ ADMIN_PASSWORD=${ADMIN_PASSWORD:-`openssl rand -hex 12`}
186 186
 #
187 187
 # Openstack uses a fair number of other projects.
188 188
 
189
-# Seed configuration with mysql password so that apt-get install doesn't
190
-# prompt us for a password upon install.
191
-cat <<MYSQL_PRESEED | sudo debconf-set-selections
192
-mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
193
-mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS
194
-mysql-server-5.1 mysql-server/start_on_boot boolean true
195
-MYSQL_PRESEED
196 189
 
197 190
 # install apt requirements
198 191
 sudo apt-get install -y -q `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server"`
... ...
@@ -252,7 +256,7 @@ cp $FILES/screenrc ~/.screenrc
252 252
 
253 253
 # Rabbit
254 254
 # ---------
255
-#
255
+
256 256
 if [[ "$ENABLED_SERVICES" =~ "rabbit" ]]; then
257 257
     # Install and start rabbitmq-server
258 258
     sudo apt-get install -y -q rabbitmq-server
... ...
@@ -262,8 +266,17 @@ fi
262 262
 
263 263
 # Mysql
264 264
 # ---------
265
-#
265
+
266 266
 if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
267
+
268
+    # Seed configuration with mysql password so that apt-get install doesn't
269
+    # prompt us for a password upon install.
270
+    cat <<MYSQL_PRESEED | sudo debconf-set-selections
271
+mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
272
+mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS
273
+mysql-server-5.1 mysql-server/start_on_boot boolean true
274
+MYSQL_PRESEED
275
+
267 276
     # Install and start mysql-server
268 277
     sudo apt-get -y -q install mysql-server
269 278
     # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
... ...
@@ -277,22 +290,23 @@ fi
277 277
 
278 278
 # Dashboard
279 279
 # ---------
280
-#
281
-# Setup the django application to serve via apache/wsgi
280
+
281
+# Setup the django dashboard application to serve via apache/wsgi
282 282
 
283 283
 if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
284 284
 
285 285
     # Dash currently imports quantum even if you aren't using it.  Instead
286 286
     # of installing quantum we can create a simple module that will pass the
287 287
     # initial imports
288
-    sudo mkdir -p  $DASH_DIR/openstack-dashboard/quantum || true
289
-    sudo touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
290
-    sudo touch $DASH_DIR/openstack-dashboard/quantum/client.py
288
+    mkdir -p  $DASH_DIR/openstack-dashboard/quantum || true
289
+    touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
290
+    touch $DASH_DIR/openstack-dashboard/quantum/client.py
291 291
 
292
-    cd $DASH_DIR/openstack-dashboard
293 292
 
294
-    sudo cp $FILES/dash_settings.py local/local_settings.py
293
+    # ``local_settings.py`` is used to override dashboard default settings.
294
+    cp $FILES/dash_settings.py $DASH_DIR/openstack-dashboard/local/local_settings.py
295 295
 
296
+    cd $DASH_DIR/openstack-dashboard
296 297
     dashboard/manage.py syncdb
297 298
 
298 299
     # create an empty directory that apache uses as docroot
... ...
@@ -335,28 +349,42 @@ fi
335 335
 # Nova
336 336
 # ----
337 337
 
338
+# We are going to use the sample http middleware configuration from the keystone
339
+# project to launch nova.  This paste config adds the configuration required
340
+# for nova to validate keystone tokens - except we need to switch the config
341
+# to use our admin token instead (instead of the token from their sample data).
338 342
 sudo sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $KEYSTONE_DIR/examples/paste/nova-api-paste.ini
339 343
 
340 344
 if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
341 345
 
342
-    # attempt to load modules: nbd (network block device - used to manage
343
-    # qcow images) and kvm (hardware based virtualization).  If unable to
344
-    # load kvm, set the libvirt type to qemu.
346
+    # Virtualization Configuration
347
+    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348
+
349
+    # attempt to load modules: network block device - used to manage qcow images
345 350
     sudo modprobe nbd || true
346 351
 
352
+    # Check for kvm (hardware based virtualization).  If unable to load kvm, 
353
+    # set the libvirt type to qemu.  Note: many systems come with hardware 
354
+    # virtualization disabled in BIOS.
347 355
     if [[ "$LIBVIRT_TYPE" -eq "kvm" ]]; then
356
+        sudo modprobe kvm || true
348 357
         if [ ! -e /dev/kvm ]; then
358
+            echo "WARNING: Switching to QEMU"
349 359
             LIBVIRT_TYPE=qemu
350 360
         fi
351 361
     fi
352 362
 
363
+    # Install and configure **LXC** if specified.  LXC is another approach to
364
+    # splitting a system into many smaller parts.  LXC uses cgroups and chroot
365
+    # to simulate multiple systems.
353 366
     if [[ "$LIBVIRT_TYPE" -eq "lxc" ]]; then
354 367
         sudo apt-get install lxc -y
368
+        # lxc requires cgroups to be configured on /cgroup
355 369
         sudo mkdir -p /cgroup
356
-        sudo mount none -t cgroup -o cpuacct,memory,devices,cpu,freezer,blkio /cgroup
357 370
         if ! grep -q cgroup /etc/fstab; then
358 371
             echo none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0 | sudo tee -a /etc/fstab
359 372
         fi
373
+        sudo mount /cgroup
360 374
     fi
361 375
 
362 376
     # User needs to be member of libvirtd group for nova-compute to use libvirt.
... ...
@@ -364,7 +392,11 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
364 364
     # if kvm wasn't running before we need to restart libvirt to enable it
365 365
     sudo /etc/init.d/libvirt-bin restart
366 366
 
367
-    # setup nova instance directory
367
+
368
+    # Instance Storage
369
+    # ~~~~~~~~~~~~~~~~
370
+
371
+    # Nova stores each instance in its own directory.
368 372
     mkdir -p $NOVA_DIR/instances
369 373
 
370 374
     # if there is a partition labeled nova-instances use it (ext filesystems
... ...
@@ -375,7 +407,7 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
375 375
         sudo chown -R `whoami` $NOVA_DIR/instances
376 376
     fi
377 377
 
378
-    # Clean out the instances directory
378
+    # Clean out the instances directory.
379 379
     rm -rf $NOVA_DIR/instances/*
380 380
 fi
381 381
 
... ...
@@ -419,10 +451,18 @@ if [ -n "$MULTI_HOST" ]; then
419 419
     add_nova_flag "--multi_host=$MULTI_HOST"
420 420
 fi
421 421
 
422
+# Nova Database
423
+# ~~~~~~~~~~~~~
424
+
425
+# All nova components talk to a central database.  We will need to do this step
426
+# only once for an entire cluster.
427
+
422 428
 if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
423 429
     # (re)create nova database
424 430
     mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS nova;'
425 431
     mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
432
+
433
+    # (re)create nova database
426 434
     $NOVA_DIR/bin/nova-manage db sync
427 435
 
428 436
     # create a small network
... ...
@@ -447,6 +487,7 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
447 447
     sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF
448 448
     sudo sed -e "s,%DEST%,$DEST,g" -i $KEYSTONE_CONF
449 449
 
450
+    # keystone_data.sh creates our admin user and our ``SERVICE_TOKEN``.
450 451
     KEYSTONE_DATA=$KEYSTONE_DIR/bin/keystone_data.sh
451 452
     cp $FILES/keystone_data.sh $KEYSTONE_DATA
452 453
     sudo sed -e "s,%HOST_IP%,$HOST_IP,g" -i $KEYSTONE_DATA