~ubuntu-branches/ubuntu/utopic/pacemaker/utopic-proposed

« back to all changes in this revision

Viewing changes to doc/openstack.md

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2013-08-15 11:27:07 UTC
  • mfrom: (1.1.12) (2.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20130815112707-5r864ink7jme3zl5
Tags: 1.1.10+git20130802-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/control: Build-Depends on libqb-dev; Depends on libheartbeat2.
* Corosync's pacemaker plugin is disabled, hence not built:
  - debian/licrmcluster4-dev.install: Do not install plugin.h.
  - debian/pacemaker.install: Do not install pacemaker.lcrso.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
    export OS_REGION_NAME=...
16
16
    export OS_TENANT_NAME=...
17
17
    export OS_AUTH_URL=...
18
 
    export OS_USERNAME=... 
 
18
    export OS_USERNAME=...
19
19
    export OS_PASSWORD=...
20
20
 
 
21
    export IMAGE_USER=fedora
 
22
 
21
23
Allocate 5 floating IPs.  For the purposes of the setup instructions
22
 
(and probably your sanity), they need to be consecutive and should
23
 
ideally start with a multiple of 10. Below we will assume
 
24
(and probably your sanity), they need to be consecutive and to remain
 
25
sane, should ideally start with a multiple of 10. Below we will assume
24
26
10.16.16.60-64
25
27
 
26
 
    for n in 1 2 3 4 5; do nova floating-ip-create; done
 
28
    for n in `seq 1 5`; do nova floating-ip-create; done
27
29
 
28
30
Create some variables based on the IP addresses nova created for you:
29
31
 
32
34
and a function for calculating offsets
33
35
 
34
36
    function nth_ipaddr() {
35
 
        echo $IP_BASE | awk -F. -v offset=$1 '{ printf "%s.%s.%s.%s\n", $1, $2, $3, $4 + offset }' 
 
37
        echo $IP_BASE | awk -F. -v offset=$1 '{ printf "%s.%s.%s.%s\n", $1, $2, $3, $4 + offset }'
 
38
    }
 
39
 
 
40
    function ip_net() {
 
41
        echo $IP_BASE | awk -F. '{ printf "%s.%s.%s.*\n", $1, $2, $3 }'
36
42
    }
37
43
 
38
44
Upload a public key that we can use to log into the images we create.
40
46
 
41
47
    nova keypair-add --pub-key ~/.ssh/cluster Cluster
42
48
 
 
49
Make sure it gets used when connecting to the CTS master
 
50
 
 
51
    cat << EOF >> ~/.ssh/config
 
52
    Host cts-master \`echo $IP_BASE | awk -F. '{ printf "%s.%s.%s.*", \$1, \$2, \$3 }'\`
 
53
         User               root
 
54
         IdentityFile       ~/.ssh/cluster
 
55
         UserKnownHostsFile ~/.ssh/known.openstack
 
56
    EOF
 
57
 
43
58
Punch a hole in the firewall for SSH access and ping
44
59
 
45
60
    nova secgroup-add-rule default tcp 23 23 10.0.0.0/8
54
69
Create helper scripts on a local host
55
70
 
56
71
    cat << END > ./master.sh
57
 
    
 
72
 
58
73
    echo export OS_REGION_NAME=$OS_REGION_NAME >> ~/.bashrc
59
74
    echo export OS_TENANT_NAME=$OS_TENANT_NAME >> ~/.bashrc
60
75
    echo export OS_AUTH_URL=$OS_AUTH_URL >> ~/.bashrc
61
76
    echo export OS_USERNAME=$OS_USERNAME >> ~/.bashrc
62
77
    echo export OS_PASSWORD=$OS_PASSWORD >> ~/.bashrc
63
 
    
 
78
 
64
79
    function nth_ipaddr() {
65
 
        echo $IP_BASE | awk -F. -v offset=\$1 '{ printf "%s.%s.%s.%s\n", \$1, \$2, \$3, \$4 + offset }' 
 
80
        echo $IP_BASE | awk -F. -v offset=\$1 '{ printf "%s.%s.%s.%s\n", \$1, \$2, \$3, \$4 + offset }'
66
81
    }
67
 
    
 
82
 
68
83
    yum install -y python-novaclient git screen pdsh pdsh-mod-dshgroup
69
 
    
70
 
    git clone git://github.com/beekhof/fence_openstack.git
 
84
 
 
85
    git clone --depth 0 git://github.com/beekhof/fence_openstack.git
71
86
    ln -s /root/fence_openstack/fence_openstack /sbin
72
87
 
73
88
    mkdir -p  /root/.dsh/group/
74
89
    echo export cluster_name=openstack >> ~/.bashrc
75
 
    
 
90
 
76
91
    rm -f /root/.dsh/group/openstack
77
 
    for n in 1 2 3 4; do
 
92
    for n in `seq 1 4`; do
78
93
        echo "cluster-\$n" >> /root/.dsh/group/openstack
79
94
        echo \`nth_ipaddr \$n\` cluster-\$n >> /etc/hosts
80
95
    done
81
 
    
 
96
 
82
97
    cat << EOF >> /root/.ssh/config
83
 
        Host \`echo $IP_BASE | awk -F. '{ printf "%s.%s.%s.*", \$1, \$2, \$3 }'\`
 
98
        Host cts-master \`echo $IP_BASE | awk -F. '{ printf "%s.%s.%s.*", \$1, \$2, \$3 }'\`
84
99
        User       root
85
100
        IdentityFile ~/.ssh/cluster
 
101
    EOF
86
102
 
87
 
        Host cts-master
88
 
        User       root
89
 
        IdentityFile ~/.ssh/cluster
90
 
    EOF
91
 
    
92
103
    END
93
104
 
94
 
Another script:
 
105
Some images do not allow root to log in by default and insist on a
 
106
'fedora' user. Create a script to disable this "feature":
95
107
 
96
108
    cat << EOF > fix-guest.sh
97
109
    #!/bin/bash
98
110
    # Re-allow root to log in
99
111
    sudo sed -i s/.*ssh-/ssh-/ /root/.ssh/authorized_keys
100
112
    EOF
101
 
    
102
 
## CTS master (Fedora-17)
 
113
 
 
114
## CTS master (Fedora-18)
103
115
 
104
116
Create and update the master
105
117
 
106
 
    nova boot --poll --image "Fedora 17" --key_name Cluster --flavor m1.tiny cts-master
 
118
    nova boot --poll --image "Fedora 18" --key_name Cluster --flavor m1.tiny cts-master
107
119
    nova add-floating-ip cts-master `nth_ipaddr 0`
108
120
 
109
 
Some images do not allow root to log in by default and insist on a 'stack' user.
110
 
Disable this "feature".
 
121
If your image does not allow root to log in by default, disable this
 
122
"feature" with the script we created earlier:
111
123
 
112
 
    scp fix-guest.sh stack@cts-master:
113
 
    ssh -l stack -t cts-master -- bash ./fix-guest.sh
 
124
    scp fix-guest.sh $IMAGE_USER@cts-master:
 
125
    ssh -l $IMAGE_USER -t cts-master -- bash ./fix-guest.sh
114
126
 
115
127
Now we can set up the CTS master with the script we created earlier:
116
128
 
117
 
    scp ~/.ssh/cluster root@cts-master:.ssh/id_rsa
118
 
    scp master.sh root@cts-master:
119
 
    ssh root@cts-master -- bash ./master.sh
120
 
 
121
 
## Create Guest Base Image
122
 
 
123
 
Create a guest that we can tweak
124
 
 
125
 
    nova boot --poll --image "Fedora 18 Alpha" --key_name Cluster --flavor m1.tiny TempGuest
126
 
    nova add-floating-ip TempGuest `nth_ipaddr 1`
127
 
    scp fix-guest.sh stack@`nth_ipaddr 1`:
128
 
 
129
 
Create snapshot with our changes called Fedora-18-base
130
 
 
131
 
    nova image-create --poll TempGuest Fedora-18-base
132
 
 
133
 
Release the IP and delete the temporary guest
134
 
 
135
 
    nova remove-floating-ip TempGuest `nth_ipaddr 1`
136
 
    nova delete TempGuest
137
 
 
138
 
### Create Guests
 
129
    scp ~/.ssh/cluster cts-master:.ssh/id_rsa
 
130
    scp master.sh cts-master:
 
131
    ssh cts-master -- bash ./master.sh
 
132
 
 
133
### Create the Guests
139
134
 
140
135
First create the guests
141
136
 
142
 
    for n in 1 2 3 4; do
143
 
       nova boot --poll --image Fedora-18-base --key_name Cluster --flavor m1.tiny cluster-$n;
 
137
    for n in `seq 1 4`; do
 
138
       nova boot --poll --image "Fedora 18" --key_name Cluster --flavor m1.tiny cluster-$n;
144
139
       nova add-floating-ip cluster-$n `nth_ipaddr $n`
145
140
    done
146
141
 
148
143
 
149
144
    sleep 10
150
145
 
151
 
Now you can fix them 
152
 
 
153
 
    for n in 1 2 3 4; do
154
 
       ssh -l stack -t `nth_ipaddr $n` -- bash ./fix-guest.sh;
155
 
       scp /etc/hosts root@`nth_ipaddr $n`:/etc/;
 
146
### Fix the Guests
 
147
 
 
148
If your image does not allow root to log in by default, disable this
 
149
"feature" with the script we created earlier:
 
150
 
 
151
    for n in `seq 1 4`; do
 
152
       scp fix-guest.sh $IMAGE_USER@`nth_ipaddr $n`:
 
153
       ssh -l $IMAGE_USER -t `nth_ipaddr $n` -- bash ./fix-guest.sh;
156
154
    done
157
155
 
158
156
## Run CTS
161
159
 
162
160
Switch to the CTS master
163
161
 
164
 
    ssh -l root cts-master
 
162
    ssh cts-master
165
163
 
166
164
Clone Pacemaker for the latest version of CTS:
167
165
 
168
 
    git clone git://github.com/ClusterLabs/pacemaker.git
169
 
    echo 'export PATH=\$PATH:/root/pacemaker/extra::/root/pacemaker/cts' >> ~/.bashrc    
 
166
    git clone --depth 0 git://github.com/ClusterLabs/pacemaker.git
 
167
    echo 'export PATH=$PATH:/root/pacemaker/extra:/root/pacemaker/cts' >> ~/.bashrc
 
168
    echo alias c=\'cluster-helper\' >> ~/.bashrc
 
169
    . ~/.bashrc
170
170
 
171
 
Now set up CTS to run from the local source tree 
 
171
Now set up CTS to run from the local source tree
172
172
 
173
173
    cts local-init
174
174
 
175
175
Configure a cluster (this will install all needed packages and configure corosync on the guests in the $cluster_name group)
176
176
 
177
 
    cluster-init -g openstack --yes --unicast fedora-17  
 
177
    cluster-init -g openstack --yes --unicast --hosts fedora-18
178
178
 
179
179
### Run
180
180