《kvm集群搭建详细版.docx》由会员分享,可在线阅读,更多相关《kvm集群搭建详细版.docx(33页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、环境准备及说明主机业务网存储网心跳node1192.168.100.15710.1.2.157172.16.100.157node2192.168.100.15810.1.2.158172.16.100.158ISCSI-10.1.2.156-Linux系统版本Linux 3.10.0-327.el7.x86_64 #1 UTC 2015 x86_64 x86_64 x86_64 GNU/Linuxcentos7.6实验目的运行的虚拟机可以在线平滑迁移,不会终端虚拟机运行的业务所需组件及约束关系DLM,gfs2,clvm,pcs,pacemeker,corosync,libvirtd,qemu
2、,qemu-img关系:DLM CLVM GFS2文件系统 VirtualDomainISCSI服务器搭建添加磁盘rootlocalhost # fdisk -lDisk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sda: 21.5
3、 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0007682e Device Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83
4、 Linux/dev/sda2 1026048 41943039 20458496 8e Linux LVMDisk /dev/mapper/centos-root: 18.8 GB, 18756927488 bytes, 36634624 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 21
5、47 MB, 2147483648 bytes, 4194304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes配置本地yum源rootlocalhost # rm -rf /etc/yum.repos.d/CentOS-*rootlocalhost # vi /etc/yum.repos.d/centos.repocentosname=centos
6、baseurl=file:/opt/centosenabled=1gpgcheck=0rootlocalhost # mkdir /opt/centosroot localhost # mount /dev/cdrom /opt/centos/mount: /dev/sr0 is write-protected, mounting read-only配置网络rootlocalhost # ip a1: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 i
7、net 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 :1/128 scope host valid_lft forever preferred_lft forever2: eno16777736: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:7f:41:4b brd ff:ff:ff:ff:ff:ff inet 10.1.2.156/24 brd 10.1.2.255 scope global eno16777
8、736 valid_lft forever preferred_lft forever inet6 fe80:20c:29ff:fe7f:414b/64 scope link valid_lft forever preferred_lft forever修改/etc/hosts映射并设置主机名rootlocalhost # cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4:1 localhost localhost.localdomain localhost6 l
9、ocalhost6.localdomain610.1.2.156 iscsiStorage10.1.2.157 node110.1.2.158 node2rootlocalhost # hostnamectl set-hostname iscsiStorage防火墙设置rootlocalhost # firewall-cmd -permanent -add-service=iscsi-targetsuccessrootlocalhost # firewall-cmd -reloadsuccessrootlocalhost # firewall-cmd -list-allpublic (defa
10、ult, active) interfaces: eno16777736 sources: services: dhcpv6-client iscsi-target ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules:对添加磁盘进行操作rootlocalhost # fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.Be caref
11、ul before using the write command.Device does not contain a recognized partition tableBuilding a new DOS disklabel with disk identifier 0x09ef4f67.Command (m for help): pDisk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical):
12、512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x09ef4f67 Device Boot Start End Blocks Id SystemCommand (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1
13、): 1First sector (2048-104857599, default 2048): Using default value 2048Last sector, +sectors or +sizeK,M,G (2048-104857599, default 104857599): +1GPartition 1 of type Linux and of size 1 GiB is setCommand (m for help): nPartition type: p primary (1 primary, 0 extended, 3 free) e extendedSelect (de
14、fault p): pPartition number (2-4, default 2): First sector (2099200-104857599, default 2099200): Using default value 2099200Last sector, +sectors or +sizeK,M,G (2099200-104857599, default 104857599): Using default value 104857599Partition 2 of type Linux and of size 49 GiB is setCommand (m for help)
15、: tPartition number (1,2, default 2): 2Hex code (type L to list all codes): 8eChanged type of partition Linux to Linux LVMCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.rootlocalhost # fdisk -lDisk /dev/sdb: 53.7 GB, 53687091200 b
16、ytes, 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x09ef4f67 Device Boot Start End Blocks Id System/dev/sdb1 2048 2099199 1048576 83 Linux/dev/sdb2 20
17、99200 104857599 51379200 8e Linux LVMDisk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0007682e Device Boot Star
18、t End Blocks Id System/dev/sda1 * 2048 1026047 512000 83 Linux/dev/sda2 1026048 41943039 20458496 8e Linux LVMDisk /dev/mapper/centos-root: 18.8 GB, 18756927488 bytes, 36634624 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal
19、): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes设置为lvm,方便luns扩容rootlocalhost # pvcreate /dev/sdb2 Physical volum
20、e /dev/sdb2 successfully createdrootlocalhost # vgcreate vg0 /dev/sdb2 Volume group vg0 successfully createdrootlocalhost # lvcreate -n lv0 -L 20G vg0 Logical volume lv0 created.rootlocalhost # lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao- 17.47g swap cen
21、tos -wi-ao- 2.00g lv0 vg0 -wi-a- 20.00g rootlocalhost # vgs VG #PV #LV #SN Attr VSize VFree centos 1 2 0 wz-n- 19.51g 40.00m vg0 1 1 0 wz-n- 49.00g 29.00grootlocalhost # pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a- 19.51g 40.00m /dev/sdb2 vg0 lvm2 a- 49.00g 29.00g安装并配置targetlicrootlocalho
22、st # yum install -y targetclirootlocalhost # targetcli Warning: Could not load preferences file /root/.targetcli/prefs.bin.targetcli shell version 2.1.fb41Copyright 2011-2013 by Datera, Inc and others.For help on commands, type help./ lso- / . . o- backstores . . | o- block . Storage Objects: 0 | o-
23、 fileio . Storage Objects: 0 | o- pscsi . Storage Objects: 0 | o- ramdisk . Storage Objects: 0 o- iscsi . Targets: 0 o- loopback . Targets: 0/-添加磁盘 /-/ cd /backstores/block /backstores/block create wang1 dev=/dev/sdb1Created block storage object wang1 using /dev/sdb1./backstores/block create wang2 d
24、ev=/dev/vg0/lv0 Created block storage object wang2 using /dev/vg0/lv0./backstores/block cd /iscsi /-iscsi名字是任意的,但是有一定的格式 /-/iscsi create iqn.2019-05.wangyu.name:tomstor1Created target iqn.2019-05.wangyu.name:tomstor1.Created TPG 1.Global pref auto_add_default_portal=trueCreated default portal listen
25、ing on all IPs (0.0.0.0), port 3260./iscsi cd iqn.2019-05.wangyu.name:tomstor1/tpg1/luns /-luns是/backstores/block中的映射 /-/iscsi/iqn.20.or1/tpg1/luns create /backstores/block/wang1Created LUN 0./iscsi/iqn.20.or1/tpg1/luns create /backstores/block/wang2Created LUN 1./-acls是node1和node2修改后的InitiatorName/
26、-/具体请查看计算节点操作之查询并修改initiatorname/iscsi/iqn.20.or1/tpg1/luns cd ./acls /iscsi/iqn.20.or1/tpg1/acls create iqn.1994-.redhat:node1Created Node ACL for iqn.1994-.redhat:node1Created mapped LUN 1.Created mapped LUN 0./iscsi/iqn.20.or1/tpg1/acls create iqn.1994-.redhat:node2Created Node ACL for iqn.1994-.
27、redhat:node2Created mapped LUN 1.Created mapped LUN 0./配置结果/iscsi/iqn.20.or1/tpg1/acls cd / lso- / . . o- backstores . . | o- block . Storage Objects: 2 | | o- wang1 . /dev/sdb1 (1.0GiB) write-thru activated | | o- wang2 . /dev/vg0/lv0 (20.0GiB) write-thru activated | o- fileio . Storage Objects: 0
28、| o- pscsi . Storage Objects: 0 | o- ramdisk . Storage Objects: 0 o- iscsi . Targets: 1 | o- iqn.2019-05.wangyu.name:tomstor1 . TPGs: 1 | o- tpg1 . no-gen-acls, no-auth | o- acls . ACLs: 2 | | o- iqn.1994-.redhat:node1 . Mapped LUNs: 2 | | | o- mapped_lun0 . lun0 block/wang1 (rw) | | | o- mapped_lun
29、1 . lun1 block/wang2 (rw) | | o- iqn.1994-.redhat:node2 . Mapped LUNs: 2 | | o- mapped_lun0 . lun0 block/wang1 (rw) | | o- mapped_lun1 . lun1 block/wang2 (rw) | o- luns . LUNs: 2 | | o- lun0 . block/wang1 (/dev/sdb1) | | o- lun1 . block/wang2 (/dev/vg0/lv0) | o- portals . Portals: 1 | o- 0.0.0.0:326
30、0 . OK o- loopback . Targets: 0/ cd / saveconfig Last 10 configs saved in /etc/target/backup.Configuration saved to /etc/target/saveconfig.json/ exitGlobal pref auto_save_on_exit=trueLast 10 configs saved in /etc/target/backup.Configuration saved to /etc/target/saveconfig.json设置开机自启,并启动服务rootlocalho
31、st # systemctl start targetrootlocalhost # systemctl enable targetCreated symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service.计算节点的操作1、配置本地yum两节点配置yum,并挂载镜像rootlocalhost # rm -rf /etc/yum.repos.d/CentOS-*root localhost # cat /etc/yum.repo
32、s.d/centos.repo centosname=centosbaseurl=file:/opt/centosenabled=1gpgcheck=0rootlocalhost # mkdir /opt/centosroot localhost # mount /dev/cdrom /opt/centos/mount: /dev/sr0 is write-protected, mounting read-only2、配置网络 Node1业务网双网卡绑定rootnode1 # nmcli connection add con-name team0 type team ifname team0
33、config runner:name:activebackupConnection team0 (5a4e4fe1-1c86-42b6-8b8f-ddd301a2a8bf) successfully added.rootnode1 # nmcli con modify team0 ipv4.addresses 192.168.100.157/24rootnode1 # nmcli con modify team0 ipv4.method manualrootnode1 # nmcli con add type team-slave con-name team0-port1 ifname ens37 master team0 Connection team0-port1 (afb1db83-ceb0-4f0d-98a6-5512fae378b6) successfully added.rootnode1 # nmcli con add type team-slave con-nam
限制150内