Projet

Général

Profil

Openstack Management TTNN » Historique » Version 60

Mehdi Abaakouk, 08/11/2015 10:55

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