1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
1, sudo yum install corosynclib-devel
1, yum update kernel
2 , wget qemu , libvirt
1, http://libvirt.org/sources/libvirt-1.1.4.tar.gz
2, http://wiki.qemu-project.org/download/qemu-1.6.1.tar.bz2
3, ftp://195.220.108.108/linux/opensuse/factory/repo/oss/suse/x86_64/liburcu2-0.8.0-3.3.x86_64.rpm
4, ftp://195.220.108.108/linux/opensuse/factory/repo/oss/suse/x86_64/liburcu-devel-0.8.0-3.3.x86_64.rpm
3, install qemu
$ cd /qemu-16.1
$ ./configure
$ sudo make; make install
$ cd ..
4, install libvirt
1, yum -y install device-mapper-devel libpciaccess-devel libnl-devel
2, ./configure ;make ;make install
5, git clone git://github.com/collie/sheepdog.git
$ cd sheepdog
$ ./autogen.sh
$ ./configure
$ sudo make install
$ cd ..
6, start service corosync ... ...
1, cd /etc/corosync
2, cp corosync.conf.example corosync.conf
3, vim corosync.conf
# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
version: 2
secauth: off
threads: 0
interface {
ringnumber: 0
bindnetaddr: 192.168.19.111 # my ip
mcastaddr: 226.94.1.1
mcastport: 5405
ttl: 1
}
}
logging {
fileline: off
to_stderr: no
to_logfile: yes
to_syslog: yes
logfile: /var/log/cluster/corosync.log
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
}
}
amf {
mode: disabled
}
4, /etc/init.d/corosync restart
7, start sheepdog
1, sheepdog /var/lib/sheepdog or /etc/init.d/sheepdog restart
8, check node list
[root@localhost corosync]# collie node list
Id Host:Port V-Nodes Zone
0 192.168.19.111:7000 128 1863559360
[root@localhost corosync]#
9, check cluster info
[root@localhost corosync]# collie cluster info
Cluster status: running, auto-recovery enabled
Cluster created at Wed Nov 20 04:57:54 2013
Epoch Time Version
2013-11-20 11:31:59 5 [192.168.19.111:7000]
2013-11-20 11:27:40 4 []
2013-11-20 05:02:19 3 [192.168.19.111:7000]
2013-11-20 05:00:59 2 []
2013-11-20 04:57:54 1 [192.168.19.111:7000]
10, Add image to sheepdog storage
1, qemu-img create -f raw sheepdog:vm0000001 5G
11, add boot image to sheepdog storage
1, qemu-img convert -t directsync /var/lib/sheepdog/root.img sheepdog:redhat
12, list images
[root@localhost corosync]# collie vdi list
Name Id Size Used Shared Creation time VDI id Copies Tag
redhat 0 10 GB 3.2 GB 0.0 MB 2013-11-20 11:39 307f49 3
vm0000001 0 5.0 GB 0.0 MB 0.0 MB 2013-11-20 11:38 6a4207 3
vm0000002 0 5.0 GB 0.0 MB 0.0 MB 2013-11-20 11:53 6a43ba 3
data1 0 0.2 MB 4.0 MB 0.0 MB 2013-11-20 11:45 77165c 3
data2 0 5.0 GB 0.0 MB 0.0 MB 2013-11-20 11:47 771b75 3
[root@localhost corosync]#
13, from boot image to sheepdog storage
1, libvirt xml configure
<
domain
type
=
'qemu'
>
<
name
>testvm</
name
>
<
memory
>1048576</
memory
>
<
os
>
<
type
arch
=
'x86_64'
>hvm</
type
>
</
os
>
<
devices
>
<
disk
type
=
'network'
device
=
"disk"
>
<
source
protocol
=
"sheepdog"
name
=
"redhat"
/>
<
target
dev
=
'vda'
bus
=
'virtio'
/>
</
disk
>
<
graphics
type
=
'vnc'
port
=
'-1'
autoport
=
'yes'
/>
</
devices
>
</
domain
>
14, full xml configure
<
domain
type
=
'qemu'
id
=
'9'
>
<
name
>testvm</
name
>
<
uuid
>f2a772c0-972b-4662-a143-d28be1f0a4c6</
uuid
>
<
memory
unit
=
'KiB'
>1048576</
memory
>
<
currentMemory
unit
=
'KiB'
>1048576</
currentMemory
>
<
vcpu
placement
=
'static'
>1</
vcpu
>
<
resource
>
<
partition
>/machine</
partition
>
</
resource
>
<
os
>
<
type
arch
=
'x86_64'
machine
=
'pc-i440fx-1.6'
>hvm</
type
>
<
boot
dev
=
'hd'
/>
</
os
>
<
clock
offset
=
'utc'
/>
<
on_poweroff
>destroy</
on_poweroff
>
<
on_reboot
>restart</
on_reboot
>
<
on_crash
>destroy</
on_crash
>
<
devices
>
<
emulator
>/usr/local/bin/qemu-system-x86_64</
emulator
>
<
disk
type
=
'network'
device
=
'disk'
>
<
driver
name
=
'qemu'
/>
<
source
protocol
=
'sheepdog'
name
=
'redhat'
/>
<
target
dev
=
'vda'
bus
=
'virtio'
/>
<
alias
name
=
'virtio-disk0'
/>
<
address
type
=
'pci'
domain
=
'0x0000'
bus
=
'0x00'
slot
=
'0x03'
function
=
'0x0'
/>
</
disk
>
<
controller
type
=
'usb'
index
=
'0'
>
<
alias
name
=
'usb0'
/>
<
address
type
=
'pci'
domain
=
'0x0000'
bus
=
'0x00'
slot
=
'0x01'
function
=
'0x2'
/>
</
controller
>
<
controller
type
=
'pci'
index
=
'0'
model
=
'pci-root'
>
<
alias
name
=
'pci.0'
/>
</
controller
>
<
input
type
=
'mouse'
bus
=
'ps2'
/>
<
graphics
type
=
'vnc'
port
=
'5900'
autoport
=
'yes'
listen
=
'127.0.0.1'
>
<
listen
type
=
'address'
address
=
'127.0.0.1'
/>
</
graphics
>
<
video
>
<
model
type
=
'cirrus'
vram
=
'9216'
heads
=
'1'
/>
<
alias
name
=
'video0'
/>
<
address
type
=
'pci'
domain
=
'0x0000'
bus
=
'0x00'
slot
=
'0x02'
function
=
'0x0'
/>
</
video
>
<
memballoon
model
=
'virtio'
>
<
alias
name
=
'balloon0'
/>
<
address
type
=
'pci'
domain
=
'0x0000'
bus
=
'0x00'
slot
=
'0x04'
function
=
'0x0'
/>
</
memballoon
>
</
devices
>
<
seclabel
type
=
'none'
/>
</
domain
>
|
附件:http://down.51cto.com/data/2363783
本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1330948