diff --git a/firstapp/samples/shade/block_storage.py b/firstapp/samples/shade/block_storage.py index af60dfa0f..362cf2e0e 100644 --- a/firstapp/samples/shade/block_storage.py +++ b/firstapp/samples/shade/block_storage.py @@ -13,13 +13,21 @@ for vol in volumes: # step-4 db_group = conn.create_security_group('database', 'for database service') +conn.create_security_group_rule(db_group['name'], 22, 22, 'TCP') conn.create_security_group_rule(db_group['name'], 3306, 3306, 'TCP') +userdata = '''#!/usr/bin/env bash +curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \ + -i database -i messaging +''' + instance = conn.create_server(wait=True, auto_ip=False, - name=name, - image=image['id'], - flavor=flavor['id'], - security_groups=[db_group['name']]) + name='app-database', + image=image_id, + flavor=flavor_id, + key_name='demokey', + security_groups=[db_group['name']], + userdata=userdata) # step-5 conn.attach_volume(instance, volume, '/dev/vdb') @@ -27,6 +35,3 @@ conn.attach_volume(instance, volume, '/dev/vdb') # step-6 conn.detach_volume(instance, volume) conn.delete_volume(volume['id']) - -# step-7 -# step-8 diff --git a/firstapp/source/block_storage.rst b/firstapp/source/block_storage.rst index 821ea19ae..072a45724 100644 --- a/firstapp/source/block_storage.rst +++ b/firstapp/source/block_storage.rst @@ -199,20 +199,48 @@ attach the volume to it at :code:`/dev/vdb`: Log in to the server to run the following steps. -.. note:: Replace :code:`IP_SERVICES` with the IP address of the - services instance and USERNAME to the appropriate user name. +.. note:: Replace :code:`IP_DATABASE` with the IP address of the + database instance and USERNAME to the appropriate user name. Now prepare the empty block device. .. code-block:: console - $ ssh -i ~/.ssh/id_rsa USERNAME@IP_SERVICES + $ ssh -i ~/.ssh/id_rsa USERNAME@IP_DATABASE # fdisk -l + Disk /dev/vdb: 1073 MB, 1073741824 bytes + 16 heads, 63 sectors/track, 2080 cylinders, total 2097152 sectors + Units = sectors of 1 * 512 = 512 bytes + Sector size (logical/physical): 512 bytes / 512 bytes + I/O size (minimum/optimal): 512 bytes / 512 bytes + Disk identifier: 0x00000000 + + Disk /dev/vdb doesn't contain a valid partition table + # mke2fs /dev/vdb + mke2fs 1.42.9 (4-Feb-2014) + Filesystem label= + OS type: Linux + Block size=4096 (log=2) + Fragment size=4096 (log=2) + Stride=0 blocks, Stripe width=0 blocks + 65536 inodes, 262144 blocks + 13107 blocks (5.00%) reserved for the super user + First data block=0 + Maximum filesystem blocks=268435456 + 8 block groups + 32768 blocks per group, 32768 fragments per group + 8192 inodes per group + Superblock backups stored on blocks: + 32768, 98304, 163840, 229376 + + Allocating group tables: done + Writing inode tables: done + Writing superblocks and filesystem accounting information: done + # mkdir /mnt/database # mount /dev/vdb /mnt/database -.. todo:: Outputs missing, add attaching log from dmesg. Stop the running MySQL database service and move the database files from :file:`/var/lib/mysql` to the new volume, which is temporarily mounted at @@ -278,7 +306,6 @@ To detach and delete a volume: .. literalinclude:: ../samples/shade/block_storage.py :language: python :start-after: step-6 - :end-before: step-7 .. only:: libcloud