Projet

Général

Profil

Openstack Management TTNN » Historique » Version 70

Mehdi Abaakouk, 16/02/2017 10:40

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