Projet

Général

Profil

Openstack Management TTNN » Historique » Version 49

Mehdi Abaakouk, 14/09/2015 10:50

1 3 Mehdi Abaakouk
{{>toc}}
2 3 Mehdi Abaakouk
3 1 Mehdi Abaakouk
h1. Openstack Management TTNN
4 1 Mehdi Abaakouk
5 11 Mehdi Abaakouk
6 11 Mehdi Abaakouk
openstack tools for ttnn:  http://chiliproject.tetaneutral.net/projects/git-tetaneutral-net/repository/openstack-tools
7 11 Mehdi Abaakouk
8 4 Mehdi Abaakouk
h2. Opération sur les VMs (des membres)
9 1 Mehdi Abaakouk
10 46 Mehdi Abaakouk
h3. Console série
11 46 Mehdi Abaakouk
12 46 Mehdi Abaakouk
Dans la VM, pour systemd:
13 46 Mehdi Abaakouk
14 46 Mehdi Abaakouk
<pre>
15 46 Mehdi Abaakouk
$ systemctl enalbe serial-getty@ttyS0.service
16 46 Mehdi Abaakouk
$ systemctl start serial-getty@ttyS0.service
17 46 Mehdi Abaakouk
</pre>
18 46 Mehdi Abaakouk
19 46 Mehdi Abaakouk
Dans la VM, pour sysv
20 46 Mehdi Abaakouk
21 46 Mehdi Abaakouk
<pre>
22 46 Mehdi Abaakouk
$ cat >> /etc/inittab <<EOF
23 46 Mehdi Abaakouk
T2:2345:respawn:/sbin/getty ttyS0 115200 vt102
24 46 Mehdi Abaakouk
EOF
25 46 Mehdi Abaakouk
$ init q
26 46 Mehdi Abaakouk
</pre>
27 46 Mehdi Abaakouk
28 46 Mehdi Abaakouk
Sur g1:
29 46 Mehdi Abaakouk
30 46 Mehdi Abaakouk
<pre>
31 46 Mehdi Abaakouk
$ /root/tools/novaconsole ns2.tetaneutral.net
32 46 Mehdi Abaakouk
WARNING:novaconsole.client:connected to: ws://openstack.tetaneutral.net:6083/?token=4b10cdbe-2a69-4de1-b9e3-dc378096b104
33 46 Mehdi Abaakouk
WARNING:novaconsole.client:type "~." to disconnect
34 46 Mehdi Abaakouk
35 46 Mehdi Abaakouk
Debian GNU/Linux 8 ns2 ttyS0
36 46 Mehdi Abaakouk
ns2 login:
37 46 Mehdi Abaakouk
</pre>
38 46 Mehdi Abaakouk
39 46 Mehdi Abaakouk
Si le message suivant apparaît, il faut faire un hard reboot de la machine pour ajouter la console serie à la VM: 
40 46 Mehdi Abaakouk
<pre>
41 46 Mehdi Abaakouk
ERROR:novaconsole:failed to connect to serial console: Unavailable console type serial. (HTTP 400)
42 46 Mehdi Abaakouk
</pre>
43 46 Mehdi Abaakouk
44 17 Mehdi Abaakouk
h3. Voir la console graphique sans spice-html5:
45 17 Mehdi Abaakouk
46 17 Mehdi Abaakouk
Copier le script suivant 'gvnc' sur ca machine:
47 17 Mehdi Abaakouk
48 17 Mehdi Abaakouk
<pre>
49 17 Mehdi Abaakouk
#!/bin/bash
50 17 Mehdi Abaakouk
vm=$1
51 17 Mehdi Abaakouk
info=($(ssh openstack.tetaneutral.net -p 2222 -l root -- "mysql nova --skip-column-names --batch -e 'select host, uuid from instances where display_name=\"$vm\";'"))
52 17 Mehdi Abaakouk
53 17 Mehdi Abaakouk
if [ "${info[0]}" == "mysql" ]; then
54 17 Mehdi Abaakouk
    echo "Error in mysql request"
55 17 Mehdi Abaakouk
    exit 1
56 17 Mehdi Abaakouk
fi
57 17 Mehdi Abaakouk
58 17 Mehdi Abaakouk
hypervisor=${info[0]}.tetaneutral.net
59 17 Mehdi Abaakouk
uuid=${info[1]}
60 17 Mehdi Abaakouk
spice_port=$(ssh ${hypervisor} -p 2222 -l root virsh domdisplay ${uuid} | awk -F: '{print $3}')
61 17 Mehdi Abaakouk
62 17 Mehdi Abaakouk
echo "$vm on $hypervisor port $spice_port"
63 17 Mehdi Abaakouk
ssh -N $hypervisor -p 2222 -l root -L 5910:localhost:${spice_port} &
64 17 Mehdi Abaakouk
pid=$!
65 17 Mehdi Abaakouk
66 17 Mehdi Abaakouk
67 17 Mehdi Abaakouk
cleanup(){
68 17 Mehdi Abaakouk
    kill $pid
69 17 Mehdi Abaakouk
}
70 17 Mehdi Abaakouk
71 17 Mehdi Abaakouk
trap cleanup EXIT
72 17 Mehdi Abaakouk
73 17 Mehdi Abaakouk
sleep 2
74 17 Mehdi Abaakouk
remote-viewer spice://localhost:5910/
75 17 Mehdi Abaakouk
</pre>
76 17 Mehdi Abaakouk
77 17 Mehdi Abaakouk
Puis 
78 17 Mehdi Abaakouk
79 17 Mehdi Abaakouk
<pre>
80 17 Mehdi Abaakouk
sudo apt-get install virt-viewer
81 17 Mehdi Abaakouk
./gvnc puppet.openstack.net
82 17 Mehdi Abaakouk
</pre>
83 17 Mehdi Abaakouk
84 17 Mehdi Abaakouk
85 1 Mehdi Abaakouk
h3. Reboot VM en error
86 1 Mehdi Abaakouk
87 1 Mehdi Abaakouk
<pre>
88 1 Mehdi Abaakouk
nova reset-state --active xxx.tetaneutral.net
89 1 Mehdi Abaakouk
nova reboot --hard --poll xxx.tetaneutral.net
90 1 Mehdi Abaakouk
</pre>
91 1 Mehdi Abaakouk
92 6 Laurent GUERBY
h3. Shutdown une VM
93 5 Laurent GUERBY
94 5 Laurent GUERBY
<pre>
95 5 Laurent GUERBY
nova stop xxx.tetaneutral.net
96 5 Laurent GUERBY
</pre>
97 5 Laurent GUERBY
98 5 Laurent GUERBY
A noter que suspend fait une sauvegarde de la RAM comme sur un laptop. shelve est bugué ne pas utiliser.
99 1 Mehdi Abaakouk
100 7 Laurent GUERBY
h3. Effacer une VM
101 6 Laurent GUERBY
102 6 Laurent GUERBY
<pre>
103 1 Mehdi Abaakouk
nova delete xxx.tetaneutral.net
104 7 Laurent GUERBY
</pre>
105 7 Laurent GUERBY
106 7 Laurent GUERBY
h3. Disques de VM
107 7 Laurent GUERBY
108 7 Laurent GUERBY
Pour renommer (et permettre a boot-disk de recreer) ou effacer :
109 7 Laurent GUERBY
110 7 Laurent GUERBY
<pre>
111 7 Laurent GUERBY
cinder list
112 7 Laurent GUERBY
cinder rename <ID> <newname>
113 7 Laurent GUERBY
cinder delete <ID_or_Name>
114 6 Laurent GUERBY
</pre>
115 5 Laurent GUERBY
116 1 Mehdi Abaakouk
h3. Agrandissement d'un disque
117 1 Mehdi Abaakouk
118 1 Mehdi Abaakouk
Sur la machine 'openstack':
119 1 Mehdi Abaakouk
120 1 Mehdi Abaakouk
<pre>
121 1 Mehdi Abaakouk
root@openstack:~/tools ./os-grow-disk.sh 
122 1 Mehdi Abaakouk
usage: os-grow-disk.sh CINDER_VOLUME_ID SIZE_GB
123 1 Mehdi Abaakouk
124 1 Mehdi Abaakouk
root@openstack:~/tools# ./os-grow-disk.sh bc6f01cb-c6b6-4413-b2ef-1f7df0031049 60
125 1 Mehdi Abaakouk
Cinder:
126 1 Mehdi Abaakouk
bc6f01cb-c6b6-4413-b2ef-1f7df0031049 , test4-bootdisk | 40 -> 60
127 1 Mehdi Abaakouk
 
128 1 Mehdi Abaakouk
Enter YES to update
129 1 Mehdi Abaakouk
YES
130 1 Mehdi Abaakouk
Testing g3 ssh connection...
131 1 Mehdi Abaakouk
Resizing the kvm blockdevice...
132 1 Mehdi Abaakouk
Block device 'vda' is resized
133 1 Mehdi Abaakouk
Updating cinder database with the new value...
134 1 Mehdi Abaakouk
Update finish
135 1 Mehdi Abaakouk
</pre>
136 1 Mehdi Abaakouk
137 1 Mehdi Abaakouk
Puis sur la VM:
138 1 Mehdi Abaakouk
139 1 Mehdi Abaakouk
Il faut avoir un 'parted' récent ou patché avec le support du 'online resizepart':
140 1 Mehdi Abaakouk
141 1 Mehdi Abaakouk
'online resizepart' est natif depuis parted >= 3.1: 
142 1 Mehdi Abaakouk
* debian >= jessie
143 1 Mehdi Abaakouk
* ubuntu >= 14.10
144 1 Mehdi Abaakouk
145 1 Mehdi Abaakouk
'online resizepart' backporté dans:
146 1 Mehdi Abaakouk
* ubuntu >= 13.10 < 14.10 
147 1 Mehdi Abaakouk
148 1 Mehdi Abaakouk
Pour debian wheezy, utilisation les packages ubuntu de 14.04 devrait marcher 
149 1 Mehdi Abaakouk
(pas encore testé, à voir si le kernel veut bien reload la table des partitions après)
150 1 Mehdi Abaakouk
151 1 Mehdi Abaakouk
<pre> 
152 1 Mehdi Abaakouk
root@test4:~# parted /dev/vda print | grep vda
153 1 Mehdi Abaakouk
Disk /dev/vda: 64.4GB
154 1 Mehdi Abaakouk
 
155 1 Mehdi Abaakouk
root@test4# parted /dev/vda resizepart 1 
156 1 Mehdi Abaakouk
Warning: Partition /dev/vda1 is being used. Are you sure you want to continue?
157 1 Mehdi Abaakouk
Yes/No? Yes                                                               
158 1 Mehdi Abaakouk
End?  [42.9GB]? 64.4GB   # METTRE ICI LA TAILLE VU AU DESSUS                                                 
159 1 Mehdi Abaakouk
Information: You may need to update /etc/fstab.                           
160 1 Mehdi Abaakouk
161 1 Mehdi Abaakouk
root@test4:~# resize2fs /dev/vda1
162 1 Mehdi Abaakouk
resize2fs 1.42.9 (4-Feb-2014)
163 1 Mehdi Abaakouk
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
164 1 Mehdi Abaakouk
old_desc_blocks = 3, new_desc_blocks = 4
165 1 Mehdi Abaakouk
The filesystem on /dev/vda1 is now 15722400 blocks long.
166 1 Mehdi Abaakouk
167 1 Mehdi Abaakouk
root@test4:~# df -h | grep vda
168 1 Mehdi Abaakouk
/dev/vda1        60G  797M   56G   2% /
169 1 Mehdi Abaakouk
</pre>
170 1 Mehdi Abaakouk
171 14 Laurent GUERBY
Méthode plus risquée et manuelle pour wheezy :
172 14 Laurent GUERBY
173 15 Laurent GUERBY
<pre>
174 14 Laurent GUERBY
sfdisk -d /dev/vda > vda.mbr
175 14 Laurent GUERBY
cp vda.mbr vda.mbr.ori
176 14 Laurent GUERBY
vi vda.mbr 
177 14 Laurent GUERBY
# mettre un tres grand nombre pour la fin de la partition
178 14 Laurent GUERBY
sfdisk -L -n --no-reread /dev/vda < vda.mbr
179 14 Laurent GUERBY
# cela va faire une erreur avec le max a mettre pour la fin de la partition
180 14 Laurent GUERBY
# changer la fin de la partition avec ce chiffre
181 14 Laurent GUERBY
sfdisk -L --no-reread /dev/vda < vda.mbr
182 14 Laurent GUERBY
reboot
183 16 Aymeric APLU
resize2fs -p /dev/vda1
184 14 Laurent GUERBY
</pre>
185 14 Laurent GUERBY
186 49 Mehdi Abaakouk
h3. Délégation /56 ipv6 d'une VM déjà créé.
187 49 Mehdi Abaakouk
188 49 Mehdi Abaakouk
Récupérer les IPs actutelles de la VM:
189 49 Mehdi Abaakouk
190 49 Mehdi Abaakouk
<pre>
191 49 Mehdi Abaakouk
# neutron port-show backup.tetaneutral.net-eth0  | grep ip_address
192 49 Mehdi Abaakouk
| allowed_address_pairs | {"ip_address": "2a01:6600:8083:d400::/56", "mac_address": "fa:16:3e:5f:07:45"}                |
193 49 Mehdi Abaakouk
| fixed_ips             | {"subnet_id": "1700a8e4-13d7-497c-9d2b-98f294199b36", "ip_address": "2a01:6600:8083:d400::1"} |
194 49 Mehdi Abaakouk
|                       | {"subnet_id": "d431cacd-3b60-4ca9-af24-eacc8e5d8671", "ip_address": "89.234.156.212"}         |
195 49 Mehdi Abaakouk
</pre>
196 49 Mehdi Abaakouk
197 49 Mehdi Abaakouk
Mettre à jour le port avec la link local de la délégation (ici: fe80::83:d4) en plus de la liste des IPs existantes:
198 49 Mehdi Abaakouk
199 49 Mehdi Abaakouk
<pre>
200 49 Mehdi Abaakouk
# neutron port-update backup.tetaneutral.net-eth0 --fixed-ips type=dict list=true ip_address=89.234.156.212 ip_address=2a01:6600:8083:d400::1 ip_address=fe80::83:d4
201 49 Mehdi Abaakouk
</pre>
202 49 Mehdi Abaakouk
203 49 Mehdi Abaakouk
Vérification:
204 49 Mehdi Abaakouk
205 49 Mehdi Abaakouk
# neutron port-show backup.tetaneutral.net-eth0  | grep ip_address
206 49 Mehdi Abaakouk
| allowed_address_pairs | {"ip_address": "2a01:6600:8083:d400::/56", "mac_address": "fa:16:3e:5f:07:45"}                |
207 49 Mehdi Abaakouk
| fixed_ips             | {"subnet_id": "1700a8e4-13d7-497c-9d2b-98f294199b36", "ip_address": "2a01:6600:8083:d400::1"} |
208 49 Mehdi Abaakouk
|                       | {"subnet_id": "d431cacd-3b60-4ca9-af24-eacc8e5d8671", "ip_address": "89.234.156.212"}         |
209 49 Mehdi Abaakouk
|                       | {"subnet_id": "b660afee-8866-4e0e-a783-920503aee73c", "ip_address": "fe80::83:d4"}            |
210 49 Mehdi Abaakouk
211 49 Mehdi Abaakouk
212 49 Mehdi Abaakouk
213 1 Mehdi Abaakouk
h3. Ajout d'une interface réseau à une VM:
214 1 Mehdi Abaakouk
215 1 Mehdi Abaakouk
<pre>
216 1 Mehdi Abaakouk
$ neutron net-list | grep vlan3199
217 1 Mehdi Abaakouk
| 460f49ce-f5ed-449e-9e0f-7626bcee4379 | vlan3199         | ba3f12af-074a-4a31-9a7c-a621993e13bb 192.168.99.0/24     |
218 1 Mehdi Abaakouk
219 1 Mehdi Abaakouk
$ neutron port-create 460f49ce-f5ed-449e-9e0f-7626bcee4379 --name nagios-eth2 --fixed-ips type=dict list=true ip_address=192.168.99.248
220 1 Mehdi Abaakouk
Created a new port:
221 1 Mehdi Abaakouk
+-----------------------+---------------------------------------------------------------------------------------+
222 1 Mehdi Abaakouk
| Field                 | Value                                                                                 |
223 1 Mehdi Abaakouk
+-----------------------+---------------------------------------------------------------------------------------+
224 1 Mehdi Abaakouk
| admin_state_up        | True                                                                                  |
225 1 Mehdi Abaakouk
| allowed_address_pairs |                                                                                       |
226 1 Mehdi Abaakouk
| binding:host_id       |                                                                                       |
227 1 Mehdi Abaakouk
| binding:profile       | {}                                                                                    |
228 1 Mehdi Abaakouk
| binding:vif_details   | {}                                                                                    |
229 1 Mehdi Abaakouk
| binding:vif_type      | unbound                                                                               |
230 1 Mehdi Abaakouk
| binding:vnic_type     | normal                                                                                |
231 1 Mehdi Abaakouk
| device_id             |                                                                                       |
232 1 Mehdi Abaakouk
| device_owner          |                                                                                       |
233 1 Mehdi Abaakouk
| fixed_ips             | {"subnet_id": "ba3f12af-074a-4a31-9a7c-a621993e13bb", "ip_address": "192.168.99.248"} |
234 1 Mehdi Abaakouk
| id                    | 918e0ec7-0909-423c-9a67-15b5ef7c7ae0                                                  |
235 1 Mehdi Abaakouk
| mac_address           | fa:16:3e:6b:32:07                                                                     |
236 1 Mehdi Abaakouk
| name                  | nagios-eth2                                                                           |
237 1 Mehdi Abaakouk
| network_id            | 460f49ce-f5ed-449e-9e0f-7626bcee4379                                                  |
238 1 Mehdi Abaakouk
| security_groups       | b6d5b5fb-a053-4f97-b964-9e1a12d243b1                                                  |
239 1 Mehdi Abaakouk
| status                | DOWN                                                                                  |
240 1 Mehdi Abaakouk
| tenant_id             | ed980105f9d047e2bee738b3f261f126                                                      |
241 1 Mehdi Abaakouk
+-----------------------+---------------------------------------------------------------------------------------+
242 1 Mehdi Abaakouk
243 1 Mehdi Abaakouk
$ nova interface-attach --port-id 918e0ec7-0909-423c-9a67-15b5ef7c7ae0   nagios.tetaneutral.net
244 1 Mehdi Abaakouk
</pre>
245 1 Mehdi Abaakouk
246 1 Mehdi Abaakouk
Dans la VM:
247 1 Mehdi Abaakouk
248 1 Mehdi Abaakouk
<pre>
249 1 Mehdi Abaakouk
$ dmesg | tail 
250 1 Mehdi Abaakouk
[ 1315.826088] virtio-pci 0000:00:06.0: using default PCI settings
251 1 Mehdi Abaakouk
[ 1315.826102] virtio-pci 0000:00:07.0: no hotplug settings from platform
252 1 Mehdi Abaakouk
[ 1315.826102] virtio-pci 0000:00:07.0: using default PCI settings
253 1 Mehdi Abaakouk
[ 1315.826116] pci 0000:00:08.0: no hotplug settings from platform
254 1 Mehdi Abaakouk
[ 1315.826117] pci 0000:00:08.0: using default PCI settings
255 1 Mehdi Abaakouk
[ 1315.826382] virtio-pci 0000:00:08.0: enabling device (0000 -> 0003)
256 1 Mehdi Abaakouk
[ 1315.829281] virtio-pci 0000:00:08.0: setting latency timer to 64
257 1 Mehdi Abaakouk
[ 1315.829535] virtio-pci 0000:00:08.0: irq 50 for MSI/MSI-X
258 1 Mehdi Abaakouk
[ 1315.829555] virtio-pci 0000:00:08.0: irq 51 for MSI/MSI-X
259 1 Mehdi Abaakouk
[ 1315.829563] virtio-pci 0000:00:08.0: irq 52 for MSI/MSI-X
260 1 Mehdi Abaakouk
261 1 Mehdi Abaakouk
$ ip l   show dev eth2
262 1 Mehdi Abaakouk
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
263 1 Mehdi Abaakouk
    link/ether fa:16:3e:6b:32:07 brd ff:ff:ff:ff:ff:ff
264 1 Mehdi Abaakouk
265 1 Mehdi Abaakouk
$ tail -4 /etc/network/interfaces
266 1 Mehdi Abaakouk
auto eth2
267 1 Mehdi Abaakouk
iface eth2 inet static
268 1 Mehdi Abaakouk
   address 192.168.99.248
269 1 Mehdi Abaakouk
   netmask 255.255.255.0
270 1 Mehdi Abaakouk
271 1 Mehdi Abaakouk
$ ifup eth2
272 1 Mehdi Abaakouk
$ ping 192.169.99.250
273 1 Mehdi Abaakouk
PING 192.169.99.250 (192.169.99.250) 56(84) bytes of data.
274 1 Mehdi Abaakouk
64 bytes from 192.169.99.250: icmp_req=1 ttl=119 time=170 ms
275 1 Mehdi Abaakouk
64 bytes from 192.169.99.250: icmp_req=2 ttl=119 time=204 ms
276 1 Mehdi Abaakouk
^C
277 1 Mehdi Abaakouk
</pre>
278 1 Mehdi Abaakouk
279 47 Mehdi Abaakouk
h3. Réinstallation/Réparation grub d'un VM
280 47 Mehdi Abaakouk
281 47 Mehdi Abaakouk
282 47 Mehdi Abaakouk
Récuperer l'id et l'hyperviseur de la VM
283 47 Mehdi Abaakouk
<pre>
284 47 Mehdi Abaakouk
# nova stop VMNAME.tetaneutral.net
285 47 Mehdi Abaakouk
# nova show VMNAME.tetaneutral.net | grep -e 'host ' -e ' id '
286 47 Mehdi Abaakouk
| OS-EXT-SRV-ATTR:host                 | g1                                                       |
287 47 Mehdi Abaakouk
| id                                   | 918e0ec7-0909-423c-9a67-15b5ef7c7ae0                     |
288 47 Mehdi Abaakouk
</pre>
289 47 Mehdi Abaakouk
290 47 Mehdi Abaakouk
291 47 Mehdi Abaakouk
292 47 Mehdi Abaakouk
Bien attendre que la VM soir éteinte, aller sur l'hyperviseur en question, et taper
293 47 Mehdi Abaakouk
<pre>
294 47 Mehdi Abaakouk
virt-customize -v t-d 918e0ec7-0909-423c-9a67-15b5ef7c7ae0 --run-command 'update-grub ; grub-install /dev/sda;'
295 47 Mehdi Abaakouk
</pre>
296 47 Mehdi Abaakouk
297 47 Mehdi Abaakouk
Enfin, restart la VM
298 47 Mehdi Abaakouk
<pre>
299 47 Mehdi Abaakouk
# nova start VMNAME.tetaneutral.net
300 47 Mehdi Abaakouk
</pre>
301 47 Mehdi Abaakouk
302 19 Mehdi Abaakouk
h3. Monter le disque d'un vm sur une machine hote pour dépannage.
303 1 Mehdi Abaakouk
304 19 Mehdi Abaakouk
L’exemple montre la modification du fichier /etc/ssh/sshd_config
305 19 Mehdi Abaakouk
306 19 Mehdi Abaakouk
Récuperer l'id et l'hyperviseur de la VM
307 1 Mehdi Abaakouk
<pre>
308 20 Alexandre GUY
# nova stop VMNAME.tetaneutral.net
309 20 Alexandre GUY
# nova show VMNAME.tetaneutral.net | grep -e 'host ' -e ' id '
310 19 Mehdi Abaakouk
| OS-EXT-SRV-ATTR:host                 | g1                                                       |
311 20 Alexandre GUY
| id                                   | 918e0ec7-0909-423c-9a67-15b5ef7c7ae0                     |
312 19 Mehdi Abaakouk
</pre>
313 19 Mehdi Abaakouk
314 19 Mehdi Abaakouk
Aller sur l'hyperviseur en question, puis:
315 19 Mehdi Abaakouk
<pre>
316 47 Mehdi Abaakouk
317 20 Alexandre GUY
# virt-edit -d 918e0ec7-0909-423c-9a67-15b5ef7c7ae0 /etc/ssh/sshd_config
318 19 Mehdi Abaakouk
</pre>
319 19 Mehdi Abaakouk
320 19 Mehdi Abaakouk
Fermer le fichier et restart la VM
321 19 Mehdi Abaakouk
<pre>
322 20 Alexandre GUY
# nova start VMNAME.tetaneutral.net
323 18 Mehdi Abaakouk
</pre>
324 18 Mehdi Abaakouk
325 42 Mehdi Abaakouk
h3. Convert du fs root en ext4 et passage en scsi
326 33 Mehdi Abaakouk
327 42 Mehdi Abaakouk
Dans la VM, préparation de grub et du fstab:
328 41 Mehdi Abaakouk
329 41 Mehdi Abaakouk
<pre>
330 41 Mehdi Abaakouk
$ vi /etc/fstab
331 41 Mehdi Abaakouk
# Viré /proc
332 42 Mehdi Abaakouk
# Pour / (voir les autres) mettre: 
333 45 Mehdi Abaakouk
LABEL=cloudimg-rootfs  /  ext4   defaults,discard,noatime  0 0
334 1 Mehdi Abaakouk
335 42 Mehdi Abaakouk
$ e2label /dev/vda1 cloudimg-rootfs
336 41 Mehdi Abaakouk
$ apt-get install grub-pc
337 42 Mehdi Abaakouk
$ apt-get purge extlinux
338 42 Mehdi Abaakouk
$ rm -f /extlinux.conf 
339 41 Mehdi Abaakouk
$ grub-install /dev/vda
340 41 Mehdi Abaakouk
$ shutdown -h now
341 1 Mehdi Abaakouk
</pre>
342 41 Mehdi Abaakouk
343 41 Mehdi Abaakouk
Récuperer l'id et l'hyperviseur de la VM
344 42 Mehdi Abaakouk
345 33 Mehdi Abaakouk
<pre>
346 33 Mehdi Abaakouk
# nova stop VMNAME.tetaneutral.net
347 33 Mehdi Abaakouk
# nova show VMNAME.tetaneutral.net | grep -e 'host ' -e ' id '
348 33 Mehdi Abaakouk
| OS-EXT-SRV-ATTR:host                 | g1                                                       |
349 33 Mehdi Abaakouk
| id                                   | 918e0ec7-0909-423c-9a67-15b5ef7c7ae0                     |
350 33 Mehdi Abaakouk
</pre>
351 33 Mehdi Abaakouk
352 33 Mehdi Abaakouk
Aller sur l'hyperviseur en question, puis:
353 35 Mehdi Abaakouk
354 1 Mehdi Abaakouk
<pre>
355 35 Mehdi Abaakouk
$ virt-rescue --suggest 918e0ec7-0909-423c-9a67-15b5ef7c7ae0 
356 35 Mehdi Abaakouk
...
357 35 Mehdi Abaakouk
# /dev/sdb1 is the root of a linux operating system
358 35 Mehdi Abaakouk
# type: linux, distro: debian, version: 8.0
359 35 Mehdi Abaakouk
# 8.0
360 35 Mehdi Abaakouk
361 35 Mehdi Abaakouk
mount /dev/sdb1 /sysroot/
362 35 Mehdi Abaakouk
mount --bind /dev /sysroot/dev
363 1 Mehdi Abaakouk
mount --bind /dev/pts /sysroot/dev/pts
364 35 Mehdi Abaakouk
mount --bind /proc /sysroot/proc
365 1 Mehdi Abaakouk
mount --bind /sys /sysroot/sys
366 42 Mehdi Abaakouk
</pre>
367 1 Mehdi Abaakouk
368 42 Mehdi Abaakouk
# Utiliser le device proposé pour la convertion en ext4:
369 42 Mehdi Abaakouk
370 42 Mehdi Abaakouk
<pre>
371 1 Mehdi Abaakouk
$ virt-rescue 918e0ec7-0909-423c-9a67-15b5ef7c7ae0 
372 1 Mehdi Abaakouk
> tune2fs -O extents,uninit_bg,dir_index /dev/sdb1
373 1 Mehdi Abaakouk
> e2fsck -fDC0 /dev/sdb1
374 1 Mehdi Abaakouk
> <CTRL+D>
375 1 Mehdi Abaakouk
</pre>
376 1 Mehdi Abaakouk
377 42 Mehdi Abaakouk
Sur la vm openstack, changé l'attribut de la VM en pour le scsi:
378 42 Mehdi Abaakouk
379 42 Mehdi Abaakouk
<pre>
380 42 Mehdi Abaakouk
cd /root/tools/sql_scripts
381 42 Mehdi Abaakouk
./os-use-scsi-discard.sh VMNAME.tetaneutral.net
382 42 Mehdi Abaakouk
</pre>
383 42 Mehdi Abaakouk
384 42 Mehdi Abaakouk
Sur G1, restart la VM
385 42 Mehdi Abaakouk
386 33 Mehdi Abaakouk
<pre>
387 33 Mehdi Abaakouk
# nova start VMNAME.tetaneutral.net
388 33 Mehdi Abaakouk
</pre>
389 26 Mehdi Abaakouk
390 43 Mehdi Abaakouk
h3. Réaligne VM partition (guide pour vm avec une seul partition)
391 43 Mehdi Abaakouk
392 43 Mehdi Abaakouk
393 43 Mehdi Abaakouk
Prérequies:
394 43 Mehdi Abaakouk
395 43 Mehdi Abaakouk
* VM utilse grub2
396 43 Mehdi Abaakouk
* 
397 43 Mehdi Abaakouk
398 43 Mehdi Abaakouk
Récuperer l'id et l'hyperviseur de la VM, ainsi que l'id du disk
399 43 Mehdi Abaakouk
400 43 Mehdi Abaakouk
<pre>
401 43 Mehdi Abaakouk
# nova stop VMNAME.tetaneutral.net
402 43 Mehdi Abaakouk
# nova show VMNAME.tetaneutral.net | grep -e 'host ' -e ' id '
403 43 Mehdi Abaakouk
| OS-EXT-SRV-ATTR:host                 | g1                                                       |
404 43 Mehdi Abaakouk
| id                                   | 918e0ec7-0909-423c-9a67-15b5ef7c7ae0                     |
405 43 Mehdi Abaakouk
# cinder list | grep puppet
406 43 Mehdi Abaakouk
| 213e894e-2f20-42b5-a27b-21f5a355c722 |   in-use  |          VMNAME.tetaneutral.net-bootdisk          |  20  |     ceph-ssd    |   true   | 918e0ec7-0909-423c-9a67-15b5ef7c7ae0 |
407 43 Mehdi Abaakouk
</pre>
408 43 Mehdi Abaakouk
409 43 Mehdi Abaakouk
Aller sur l'hyperviseur en question, puis vérifier l'alignement:
410 43 Mehdi Abaakouk
411 43 Mehdi Abaakouk
<pre>
412 43 Mehdi Abaakouk
$ virt-alignment-scan -d 918e0ec7-0909-423c-9a67-15b5ef7c7ae0 
413 43 Mehdi Abaakouk
/dev/sdb1        65536           512   bad (alignment < 4K)
414 43 Mehdi Abaakouk
</pre>
415 43 Mehdi Abaakouk
416 43 Mehdi Abaakouk
Réalignemet, *aller dans un espace ou il y a 2x l'espace utile de la VM*, puis:
417 43 Mehdi Abaakouk
418 43 Mehdi Abaakouk
<pre>
419 43 Mehdi Abaakouk
$ virt-tar-out -d 918e0ec7-0909-423c-9a67-15b5ef7c7ae0 / - | gzip --best > VMNAME.tar.gz
420 43 Mehdi Abaakouk
$ rbd -p ssds info volume-213e894e-2f20-42b5-a27b-21f5a355c722
421 43 Mehdi Abaakouk
rbd image 'volume-213e894e-2f20-42b5-a27b-21f5a355c722':
422 43 Mehdi Abaakouk
        size 20480 MB in 5120 objects
423 43 Mehdi Abaakouk
        order 22 (4096 kB objects)
424 43 Mehdi Abaakouk
        block_name_prefix: rbd_data.996cc92ae8944a
425 43 Mehdi Abaakouk
        format: 2
426 43 Mehdi Abaakouk
        features: layering
427 43 Mehdi Abaakouk
$ virt-make-fs --label=cloudimg-rootfs --partition=mbr --type=ext4 --format=raw --size=20480 VMNAME.tar.gz VMNAME.img
428 44 Mehdi Abaakouk
$ virt-customize -a VMNAME.img --run-command 'update-grub ; grub-install /dev/sda'
429 43 Mehdi Abaakouk
$ rbd mv ssds/volume-213e894e-2f20-42b5-a27b-21f5a355c722 ssds/volume-213e894e-2f20-42b5-a27b-21f5a355c722.unaligned
430 43 Mehdi Abaakouk
$ rbd import --image-format 2 VMNAME.img ssds/volume-213e894e-2f20-42b5-a27b-21f5a355c722
431 43 Mehdi Abaakouk
</pre>
432 43 Mehdi Abaakouk
433 43 Mehdi Abaakouk
Vérification:
434 43 Mehdi Abaakouk
435 43 Mehdi Abaakouk
<pre>
436 43 Mehdi Abaakouk
$ virt-alignment-scan -d 918e0ec7-0909-423c-9a67-15b5ef7c7ae0 
437 43 Mehdi Abaakouk
/dev/sdb1        65536           64K   ok
438 43 Mehdi Abaakouk
</pre>
439 43 Mehdi Abaakouk
440 26 Mehdi Abaakouk
h3. Création/Restauration snapshot
441 26 Mehdi Abaakouk
442 26 Mehdi Abaakouk
Création:
443 26 Mehdi Abaakouk
444 26 Mehdi Abaakouk
<pre>
445 26 Mehdi Abaakouk
source os.conf
446 26 Mehdi Abaakouk
/root/tools/os-snapshot-vm.sh pano.tetaneutral.net bootdisk /
447 26 Mehdi Abaakouk
* Freezing / of pano.tetaneutral.net
448 26 Mehdi Abaakouk
* Snapshoting pano.tetaneutral.net-bootdisk
449 26 Mehdi Abaakouk
Snapshot pano.tetaneutral.net-bootdisk-20150125-1600 is in state creating ..
450 26 Mehdi Abaakouk
* pano.tetaneutral.net-bootdisk snapshoted
451 26 Mehdi Abaakouk
* / of pano.tetaneutral.net unfreezed
452 26 Mehdi Abaakouk
</pre>
453 26 Mehdi Abaakouk
454 26 Mehdi Abaakouk
Restauration:
455 26 Mehdi Abaakouk
456 27 Laurent GUERBY
<pre>
457 27 Laurent GUERBY
$ cinder snapshot-list
458 26 Mehdi Abaakouk
...
459 26 Mehdi Abaakouk
$ cinder snapshot-show pano.tetaneutral.net-bootdisk-20150125-1600 | awk '/ id /{print $4}'
460 26 Mehdi Abaakouk
7dfbe98c-756e-47d1-a8bf-c8f2092de2f8
461 26 Mehdi Abaakouk
$ cinder create --display-name pano-restauration-test --snapshot-id 7dfbe98c-756e-47d1-a8bf-c8f2092de2f8 101
462 26 Mehdi Abaakouk
$ cinder show pano-restauration-test | awk '/ id /{print $4}'
463 26 Mehdi Abaakouk
80bb0bb2-8d37-42b2-bc8e-5e367ce2d94a
464 26 Mehdi Abaakouk
$ nova volume-attach pano.tetaneutral.net 80bb0bb2-8d37-42b2-bc8e-5e367ce2d94a auto
465 26 Mehdi Abaakouk
</pre>
466 2 Mehdi Abaakouk
467 2 Mehdi Abaakouk
h3. Exemple de migration de ganeti à openstack:
468 2 Mehdi Abaakouk
469 2 Mehdi Abaakouk
Sur h4:
470 2 Mehdi Abaakouk
<pre>
471 2 Mehdi Abaakouk
$ gnt-instance stop VMNAME.tetaneutral.net
472 2 Mehdi Abaakouk
$ gnt-instance activate-disks VMNAME.tetaneutral.net
473 2 Mehdi Abaakouk
h5.tetaneutral.net:disk/0:/dev/drbd34
474 2 Mehdi Abaakouk
</pre>
475 2 Mehdi Abaakouk
476 2 Mehdi Abaakouk
477 2 Mehdi Abaakouk
Sur g1, mettre l'image dans cinder
478 2 Mehdi Abaakouk
<pre>
479 2 Mehdi Abaakouk
name=VMNAME.tetaneutral.net
480 2 Mehdi Abaakouk
</pre>
481 2 Mehdi Abaakouk
482 2 Mehdi Abaakouk
Crée un volume (remplacer 20 par la taille du disque désiré):
483 2 Mehdi Abaakouk
484 2 Mehdi Abaakouk
<pre>
485 2 Mehdi Abaakouk
cinder create --volume_type ceph --display-name ${name}-bootdisk 20    # mettre ici un peu plus grand que le vrai disque.
486 2 Mehdi Abaakouk
volume_id=$(cinder show ${name}-bootdisk | awk '/ id /{print $4}')
487 2 Mehdi Abaakouk
</pre>
488 2 Mehdi Abaakouk
489 2 Mehdi Abaakouk
On remplace le volume rbd par le disque de la VM:
490 2 Mehdi Abaakouk
491 1 Mehdi Abaakouk
<pre>
492 9 Laurent GUERBY
rbd -p disks mv volume-$volume_id disks/volume-${volume_id}.old
493 2 Mehdi Abaakouk
socat -u tcp4-listen:505555 - | rbd -p disks import --image-format 2 - volume-$volume_id
494 2 Mehdi Abaakouk
</pre>
495 2 Mehdi Abaakouk
496 2 Mehdi Abaakouk
Sur la machine hX qui as le disque (ici h5 et le disque drbd34)
497 2 Mehdi Abaakouk
<pre>
498 2 Mehdi Abaakouk
cat /dev/drbd34 | socat -u - tcp4:g1:505555
499 2 Mehdi Abaakouk
# ou avec une bar de progression
500 2 Mehdi Abaakouk
apt-get install pv 
501 2 Mehdi Abaakouk
pv /dev/drbd34 | socat -u - tcp4:g1:505555
502 2 Mehdi Abaakouk
</pre>
503 2 Mehdi Abaakouk
504 2 Mehdi Abaakouk
<pre>
505 2 Mehdi Abaakouk
# On peut voir l'avancement via:
506 2 Mehdi Abaakouk
watch -n1 -- rbd -p disks info volume-$volume_id
507 2 Mehdi Abaakouk
</pre>
508 2 Mehdi Abaakouk
509 2 Mehdi Abaakouk
On change la taille de l'image pour mettre la meme que le volume créé par openstack
510 2 Mehdi Abaakouk
511 2 Mehdi Abaakouk
<pre>
512 2 Mehdi Abaakouk
$ rbd -p disks info volume-$volume_id.old
513 12 Laurent GUERBY
rbd image 'volume-$volume_id.old':
514 2 Mehdi Abaakouk
	size **XXX** MB in 5120 objects
515 2 Mehdi Abaakouk
	order 22 (4096 kB objects)
516 2 Mehdi Abaakouk
	block_name_prefix: rbd_data.752a15a94252f
517 1 Mehdi Abaakouk
	format: 2
518 12 Laurent GUERBY
	features: layering
519 13 Laurent GUERBY
$ # ou bien
520 12 Laurent GUERBY
$ rbd -p disks info --pretty-format --format json volume-$volume_id.old | grep size
521 12 Laurent GUERBY
$ # puis
522 2 Mehdi Abaakouk
$ rbd -p disks resize --size XXX volume-$volume_id
523 2 Mehdi Abaakouk
</pre>
524 2 Mehdi Abaakouk
525 2 Mehdi Abaakouk
Booter la VM avec ce disque (le disque existant déjà le script l'utilisera):
526 2 Mehdi Abaakouk
527 8 Laurent GUERBY
<pre>
528 2 Mehdi Abaakouk
/root/tools/boot-vm.sh --ip A.B.C.D --flavor Xvcpu-Yram ${name}
529 2 Mehdi Abaakouk
</pre>
530 2 Mehdi Abaakouk
531 2 Mehdi Abaakouk
_Note: Si le disque a été agrandi, on peut utiliser dans la VM "growpart /dev/vda 1" ou 'parted resizepart' pour récupérer l'espace disponible (fonctionne bien sous jessie ou dernier ubuntu)_
532 2 Mehdi Abaakouk
533 2 Mehdi Abaakouk
Quand c'est fini sur h4:
534 2 Mehdi Abaakouk
535 2 Mehdi Abaakouk
<pre>
536 2 Mehdi Abaakouk
gnt-instance deactivate-disks VMNAME.tetaneutral.net
537 2 Mehdi Abaakouk
</pre>
538 2 Mehdi Abaakouk
539 2 Mehdi Abaakouk
S'il faut changer la RAM et vCPU
540 2 Mehdi Abaakouk
541 2 Mehdi Abaakouk
<pre>
542 2 Mehdi Abaakouk
nova flavor-list
543 2 Mehdi Abaakouk
nova list
544 2 Mehdi Abaakouk
nova resize ${name} FLAVOR_ID --poll
545 1 Mehdi Abaakouk
nova resize-confirm VM_ID
546 1 Mehdi Abaakouk
</pre>
547 10 Mehdi Abaakouk
548 10 Mehdi Abaakouk
h3. Convertion des images rbd au format 2 (pour les premieres VMs migrées de ganeti)
549 10 Mehdi Abaakouk
550 10 Mehdi Abaakouk
<pre>
551 10 Mehdi Abaakouk
$ nova stop <vm_name>
552 10 Mehdi Abaakouk
$ rbd -p disks export volume-XXXXXXXXXXXXXX - | rbd import --image-format 2 -p disks - volume-XXXXXXXXXXXXXX.converted
553 10 Mehdi Abaakouk
$ rbd -p disks mv volume-XXXXXXXXXXXXXX volume-XXXXXXXXXXXXXX.old
554 10 Mehdi Abaakouk
$ rbd -p disks mv volume-XXXXXXXXXXXXXX.converted volume-XXXXXXXXXXXXXX
555 10 Mehdi Abaakouk
$ rbd -p disks rm volume-XXXXXXXXXXXXXX.old
556 10 Mehdi Abaakouk
$ nova start <vm_name>
557 10 Mehdi Abaakouk
</pre>
558 22 Mehdi Abaakouk
559 37 Laurent GUERBY
h3. Déplacer une VM de pool ceph
560 21 Mehdi Abaakouk
561 36 Laurent GUERBY
562 1 Mehdi Abaakouk
<pre>
563 36 Laurent GUERBY
root@g1:~# nova show test246.tetaneutral.net|grep flavor
564 36 Laurent GUERBY
| flavor                               | 1vcpu-1024ram (a3e63391-3577-4a4e-afdb-4bc1d2c75419)     |
565 36 Laurent GUERBY
root@g1:~# cinder list|grep test246
566 36 Laurent GUERBY
| 15273654-af28-4ed2-b2df-0ab17ec8dd2f |   in-use  |       test246.tetaneutral.net-bootdisk       |  10  |     ceph    |   true   | 97279b50-b2c3-4d2e-9a24-8c0b80104375 |
567 36 Laurent GUERBY
root@g1:~# cinder create --volume_type ceph-ssd --display-name test246.tetaneutral.net-bootdisk-tmp 10
568 36 Laurent GUERBY
root@g1:~# cinder list|grep test246
569 36 Laurent GUERBY
| 15273654-af28-4ed2-b2df-0ab17ec8dd2f |   in-use  |       test246.tetaneutral.net-bootdisk       |  10  |     ceph    |   true   | 97279b50-b2c3-4d2e-9a24-8c0b80104375 |
570 36 Laurent GUERBY
| b32f6845-35cd-412e-b412-ae142234bc12 | available |     test246.tetaneutral.net-bootdisk-tmp     |  10  |   ceph-ssd  |  false   |                                      |
571 38 Laurent GUERBY
root@g1:~# nova stop test246.tetaneutral.net
572 39 Laurent GUERBY
Request to stop server test246.tetaneutral.net has been accepted.
573 39 Laurent GUERBY
root@g1:~# nova list|grep test246
574 39 Laurent GUERBY
| 97279b50-b2c3-4d2e-9a24-8c0b80104375 | test246.tetaneutral.net             | ACTIVE | powering-off | Running     | vlan-routed=2a01:6600:8083:f600::1, 89.234.156.246                                                                         |
575 39 Laurent GUERBY
root@g1:~# nova list|grep test246
576 39 Laurent GUERBY
| 97279b50-b2c3-4d2e-9a24-8c0b80104375 | test246.tetaneutral.net             | SHUTOFF | -          | Shutdown    | vlan-routed=2a01:6600:8083:f600::1, 89.234.156.246                                                                         |
577 36 Laurent GUERBY
root@g1:~# rbd -p ssds mv volume-b32f6845-35cd-412e-b412-ae142234bc12 ssds/volume-b32f6845-35cd-412e-b412-ae142234bc12.old
578 36 Laurent GUERBY
root@g1:~# date;rbd -p disks export volume-15273654-af28-4ed2-b2df-0ab17ec8dd2f - | rbd import --image-format 2 -p ssds - volume-b32f6845-35cd-412e-b412-ae142234bc12 ;date
579 36 Laurent GUERBY
Fri Jun  5 17:12:35 CEST 2015
580 36 Laurent GUERBY
Exporting image: 100% complete...done.
581 36 Laurent GUERBY
Fri Jun  5 17:14:58 CEST 2015
582 36 Laurent GUERBY
root@g1:~# nova delete test246.tetaneutral.net
583 36 Laurent GUERBY
Request to delete server test246.tetaneutral.net has been accepted.
584 36 Laurent GUERBY
root@g1:~# nova list|grep test246
585 40 Laurent GUERBY
root@g1:~# cinder rename test246.tetaneutral.net-bootdisk test246.tetaneutral.net-bootdisk-old20150605 # or: cinder delete test246.tetaneutral.net-bootdisk
586 36 Laurent GUERBY
root@g1:~# cinder list|grep test246
587 36 Laurent GUERBY
| 15273654-af28-4ed2-b2df-0ab17ec8dd2f |  deleting |       test246.tetaneutral.net-bootdisk       |  10  |     ceph    |   true   |                                      |
588 36 Laurent GUERBY
| b32f6845-35cd-412e-b412-ae142234bc12 | available |     test246.tetaneutral.net-bootdisk-tmp     |  10  |   ceph-ssd  |  false   |                                      |
589 36 Laurent GUERBY
root@g1:~# cinder list|grep test246
590 36 Laurent GUERBY
| b32f6845-35cd-412e-b412-ae142234bc12 | available |     test246.tetaneutral.net-bootdisk-tmp     |  10  |   ceph-ssd  |  false   |                                      |
591 36 Laurent GUERBY
root@g1:~# cinder rename test246.tetaneutral.net-bootdisk-tmp test246.tetaneutral.net-bootdisk
592 36 Laurent GUERBY
root@g1:~# cinder set-bootable b32f6845-35cd-412e-b412-ae142234bc12 true
593 36 Laurent GUERBY
root@g1:~# /root/tools/boot-vm.sh --ip 89.234.156.246 --flavor 1vcpu-1024ram test246.tetaneutral.net
594 40 Laurent GUERBY
# Note : for ipv6 only add --no-ip-check 
595 36 Laurent GUERBY
</pre>
596 25 Laurent GUERBY
597 36 Laurent GUERBY
Note:
598 36 Laurent GUERBY
<pre>
599 28 Mehdi Abaakouk
root@g1:~# nova volume-detach test246.tetaneutral.net 0afab4c6-e340-4352-a609-7c43d51b5795
600 25 Laurent GUERBY
ERROR (Forbidden): Can't detach root device volume (HTTP 403) (Request-ID: req-98a6e8f3-8897-4361-8fd7-6f10484d51b9)
601 32 Mehdi Abaakouk
</pre>
602 36 Laurent GUERBY
see https://bugs.launchpad.net/nova/+bug/1396965 and https://ask.openstack.org/en/question/53732/detaching-root-device-volume-of-an-instance/
603 29 Mehdi Abaakouk
604 29 Mehdi Abaakouk
h2. Migration de VM si le host est DOWN
605 29 Mehdi Abaakouk
606 29 Mehdi Abaakouk
h3. HACK pour contourner un bug neutron/nova (icehouse/obsolete)
607 29 Mehdi Abaakouk
608 29 Mehdi Abaakouk
nova attends que le port neutron soit UP sur la nouvelle machine, mais celui-ci reste sur l'ancienne machine DOWN,
609 29 Mehdi Abaakouk
reste à savoir si c'est nova qui change mal la conf du port, ou neutron qui ignore le changement.
610 1 Mehdi Abaakouk
611 29 Mehdi Abaakouk
Du coup pour contourner le problème, un peu de mysql:
612 29 Mehdi Abaakouk
613 29 Mehdi Abaakouk
Sur la machine "openstack", on change la host de plein de ports (de g6 vers h7 dans l'exemple):
614 29 Mehdi Abaakouk
615 29 Mehdi Abaakouk
<pre>
616 29 Mehdi Abaakouk
# mysql neutron
617 29 Mehdi Abaakouk
$ update ml2_port_bindings set host='h7' where host='g6';
618 29 Mehdi Abaakouk
</pre>
619 29 Mehdi Abaakouk
620 29 Mehdi Abaakouk
Ensuite sur la machine destination, on restart les services pour qu'il voit le changement:
621 29 Mehdi Abaakouk
622 29 Mehdi Abaakouk
<pre>
623 29 Mehdi Abaakouk
/etc/init.d/neutron-plugin-linuxrouted-agent restart
624 31 Laurent GUERBY
/etc/init.d/neutron-plugin-openvswitch-agent restart
625 31 Laurent GUERBY
</pre>
626 29 Mehdi Abaakouk
627 29 Mehdi Abaakouk
h3. Commande normal pour évacuer une machine DOWN
628 28 Mehdi Abaakouk
629 28 Mehdi Abaakouk
Si une machine est capable de tout reprendre :
630 28 Mehdi Abaakouk
631 28 Mehdi Abaakouk
<pre>
632 28 Mehdi Abaakouk
# nova host-evacuate --target_host n7 g6
633 28 Mehdi Abaakouk
+--------------------------------------+-------------------+---------------+
634 28 Mehdi Abaakouk
| Server UUID                          | Evacuate Accepted | Error Message |
635 28 Mehdi Abaakouk
+--------------------------------------+-------------------+---------------+
636 1 Mehdi Abaakouk
| 0f50c84c-0251-40e8-86aa-aacb81d8ef8c | True              |               |
637 29 Mehdi Abaakouk
| 8125c4ae-8cb3-4469-8718-56653342de04 | True              |               |
638 29 Mehdi Abaakouk
| 527a46b7-0555-4351-871a-bc13a5436feb | True              |               |
639 31 Laurent GUERBY
| 0e285b7a-4ea6-4352-86a2-729f1d414c82 | True              |               |
640 31 Laurent GUERBY
+--------------------------------------+-------------------+---------------+
641 31 Laurent GUERBY
</pre>
642 31 Laurent GUERBY
643 31 Laurent GUERBY
Attendre ensuite que tous les VMs soit UP niveau openstack
644 31 Laurent GUERBY
645 29 Mehdi Abaakouk
Sinon VM par VM :
646 30 Mehdi Abaakouk
647 29 Mehdi Abaakouk
<pre>
648 29 Mehdi Abaakouk
nova evacuate VMname HOSTname
649 29 Mehdi Abaakouk
</pre>
650 29 Mehdi Abaakouk
651 29 Mehdi Abaakouk
h3. Partie normalement inutile maintenant, à vérifier:
652 29 Mehdi Abaakouk
653 29 Mehdi Abaakouk
Dans le cas ou certain sont UP mais ne ping pas, ne pas hésiter à refaire sur la machine destination:
654 29 Mehdi Abaakouk
655 29 Mehdi Abaakouk
<pre>
656 21 Mehdi Abaakouk
/etc/init.d/neutron-plugin-linuxrouted-agent restart
657 1 Mehdi Abaakouk
/etc/init.d/neutron-plugin-openvswitch-agent restart
658 1 Mehdi Abaakouk
</pre>
659 1 Mehdi Abaakouk
660 1 Mehdi Abaakouk
Voir peut être reboot --hard les vms qui on pas marché du premier coup
661 1 Mehdi Abaakouk
662 1 Mehdi Abaakouk
h2. VM de management (nommé openstack)
663 1 Mehdi Abaakouk
664 1 Mehdi Abaakouk
h3. Live Migration d'un host à l'autre
665 1 Mehdi Abaakouk
666 1 Mehdi Abaakouk
Cela fait tout à notre place niveau kvm/libvirt/ceph
667 1 Mehdi Abaakouk
668 1 Mehdi Abaakouk
<pre>
669 1 Mehdi Abaakouk
virsh migrate --persistent --undefinesource --live --p2p openstack qemu+ssh://g2:2222/system
670 1 Mehdi Abaakouk
</pre>
671 1 Mehdi Abaakouk
672 1 Mehdi Abaakouk
h3. Recover depuis une perte de la machine hote:
673 1 Mehdi Abaakouk
674 1 Mehdi Abaakouk
Créé un fichier openstack.xml à partir d'un backup de '/etc/libvirt/qemu/openstack.xml' ou utiliser l'exemple ici: attachment:openstack.xml
675 1 Mehdi Abaakouk
676 1 Mehdi Abaakouk
_Note: il faut surement viré les uuid des interfaces openvswitch qui sont différent suivant le hosts_
677 1 Mehdi Abaakouk
678 1 Mehdi Abaakouk
Puis on recréé la VM
679 23 Laurent GUERBY
680 23 Laurent GUERBY
<pre>
681 23 Laurent GUERBY
$ virsh create openstack.xml
682 23 Laurent GUERBY
$ virsh start openstack.xml
683 23 Laurent GUERBY
</pre>
684 23 Laurent GUERBY
685 23 Laurent GUERBY
h2. Operations sur les hotes
686 23 Laurent GUERBY
687 23 Laurent GUERBY
h3. Reboot
688 23 Laurent GUERBY
689 23 Laurent GUERBY
<pre>
690 23 Laurent GUERBY
nova list --host=n7 # list des VM xxx sur n7
691 23 Laurent GUERBY
for i in xxx; do nova live-migration $i stri; done # repartir sur plusieurs hosts
692 23 Laurent GUERBY
ps fauxwww|grep kvm # verifier qu'il n'y a plus de VM
693 23 Laurent GUERBY
for i in $(rados lspools) ; do ceph osd pool set $i min_size 1 ; done # diminuer le nombre de copies
694 23 Laurent GUERBY
ceph osd set noout # pour prevenir que les OSD vont revenir
695 1 Mehdi Abaakouk
/etc/init.d/ceph stop 
696 1 Mehdi Abaakouk
shutdown -h now
697 1 Mehdi Abaakouk
</pre>
698 1 Mehdi Abaakouk
699 1 Mehdi Abaakouk
Post reboot remettre les min_size a 2, rappatrier les VM.