2023/09 作者:ihunter 0 次 0
RHCS实验
-架构规划
2台测试节点 RHCS1 RHCS2 一台共享存储RHCS3 集群服务为apache
1.双网卡绑定(RHCS1 RHCS2)
vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=172.16.1.108
NETMASK=255.255.255.0
GATEWAY=172.16.1.2
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
BONDING_OPTS="miimon=100 mode=1"
NM_CONTROLLED=no
TYPE=Ethernet
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWaddr=00:0C:29:6A:AE:76
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPV6INIT=no
USERCTL=no
MASTER=bond0
SLAVE=yes
vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWaddr=00:0C:29:6A:AE:80
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPV6INIT=no
USERCTL=no
MASTER=bond0
SLAVE=yes
/etc/init.d/network restart
2.环境设置(RHCS1 RHCS2 RHCS3)
vim /etc/selinux/config
SELINUX=disabled
iptables -F
service iptables save
/etc/init.d/NetworkManager stop
chkconfig NetworkManager off
3.存储搭建(RHCS3 raid5+lvm+iscsi)
#raid5创建
#磁盘类型转换略 所有磁盘分区都转换为 fd
mdadm -C -v /dev/md5 -a yes -l5 -n3 /dev/sd[c,d,e]1
mdadm -Ds /dev/md5 >> /etc/mdadm.conf
#LVM
pvcreate /dev/md5
vgcreate vgdata /dev/md5
lvcreate -L 1G -n lv01 vgdata
#iscsi-target
yum -y install scsi-target-utils
chkconfig tgtd on
vim /etc/tgt/targets.conf
backing-store /dev/vgdata/lv01
lun 10
#或者命令行
/etc/init.d/tgtd start
tgtadm --lld iscsi --mode target --op new --tid 1 --targetname iqn.2018-06.com.rhcs.storage:vgdata.lv01
tgtadm --lld iscsi --op new --mode logicalunit --lun 1 --tid 1 -b /dev/vgdata/lv01
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
#保存到配置文件
tgt-admin --dump > /etc/tgt/targets.conf
#删除指定target
tgtadm --lld iscsi --op delete --mode target --tid=1
#更新target容量
tgtadm --op delete --mode logicalunit --tid=3 --lun=3
tgtadm --lld iscsi --op new --mode logicalunit --lun 3 --tid 3 -b /dev/vgdata/lv03
#initiator端重新扫描
iscsiadm --mode node --targetname iqn.2018-06.com.rhcs.storage:vgdata.lv03 -R
[root@RHCS3 yum.repos.d]# tgt-admin -s
LUN: 10
Type: disk
SCSI ID: IET 0001000a
SCSI SN: beaf110
Size: 1074 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/vgdata/lv01
Backing store flags:
Account information:
ACL information:
ALL
#RHCS1 RHCS2
#iscsi-initiator
yum -y install iscsi-initiator-utils
chkconfig iscsid on
iscsiadm -m discovery -p 172.16.1.105:3260 -t sendtargets
iscsiadm -m node --targetname iqn.2018-06.com.rhcs.storage:vgdata.lv01 -p 172.16.1.105:3260 --login
iscsiadm -m node -T iqn.2018-06.com.rhcs.storage:vgdata.lv01 -p 172.16.1.105:3260 --logout
#hosts设置(RHCS1 2 3)
cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.107 RHCS-Master
172.16.1.108 RHCS-Slave
172.16.1.105 iscsi-target
172.16.1.109 VIP
4.集群套件(RHCS1主 RHCS2备)
yum -y groupinstall "High Availability" "High Availability Management"
yum -y install ricci openais cman rgmanager lvm2-cluster gfs2-utils
#luci只需要在一个节点启动
service luci start
service ricci start
service rgmanager start
#设置集群节点密码
passwd ricci
chkconfig luci on
chkconfig rgmanager on
chkconfig ricci on
5.给所有节点安装httpd服务并配置web主页(RHCS1 RHCS2)
yum -y install httpd
echo `uname -n` > /var/www/html/index.html
6.访问 https://172.16.1.107:8084开始配置
创建集群
创建失效域
创建资源
创建service group
重新启动service group 查看vip是否漂移
设置共享存储
-RHCS1
fdisk /dev/sdb
n
p
1
+1G
w
-RHCS1 RHCS2
partx /dev/sdb
-RHCS1
mkfs.gfs2 -p lock_dlm -t mycluster:lv01 -j 3 /dev/sdb1
service group中添加共享存储资源
7. 基于集群逻辑卷创建gfs2文件系统
1)在集群节点中准备lvm类型的磁盘分区/dev/sdb2大小为1G
#RHCS1
fdisk /dev/sdc
#RHCS1 RHCS2 执行两次
partx -a /dev/sdb
2)在各集群节点安装集群逻辑卷专用程序包
yum -y install lvm2-cluster
3)配置集群逻辑卷(选择某一集群节点操作即可)
pvcreate /dev/sdb2
vgcreate vg1 /dev/sdb2
vcreate -L 500M -n cvm cvg
4)配置各集群节点启动clvmd服务及开机自启动
service clvmd start
chkconfig clvmd on
5)格式化集群逻辑卷创建文件系统
lvmconf --enable-cluster
mkfs.gfs2 -p lock_dlm -j 3 -t mycluster:clvm /dev/cvg/cvm
#挂载不上时使用增加日志系统
gfs2_jadd -j 1 /dev/cvg/cvm
6)测试挂载使用
mkdir /mnt/cluster
mount -t gfs2 /dev/cvg/cvm /mnt/cluster
[root@RHCS-Master ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 3.4G 15G 20% /
tmpfs 491M 38M 454M 8% /dev/shm
/dev/sda1 194M 30M 155M 16% /boot
/dev/sr0 4.2G 4.2G 0 100% /mnt/cdrom
/dev/sdb1 1.1G 388M 643M 38% /mnt/lv01
/dev/mapper/cvg-cvm 500M 388M 113M 78% /mnt/cluster
7)扩展逻辑卷
lvextend -L +400M /dev/cvg/cvm
[root@RHCS-Master ~]# gfs2_grow /dev/cvg/cvm
FS: Mount Point: /mnt/cluster
FS: Device: /dev/dm-0
FS: Size: 127997 (0x1f3fd)
FS: RG size: 63988 (0xf9f4)
DEV: Size: 230400 (0x38400)
The file system grew by 400MB.
gfs2_grow complete.
[root@RHCS-Master ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 3.4G 15G 20% /
tmpfs 491M 38M 454M 8% /dev/shm
/dev/sda1 194M 30M 155M 16% /boot
/dev/sr0 4.2G 4.2G 0 100% /mnt/cdrom
/dev/sdb1 1.1G 388M 643M 38% /mnt/lv01
/dev/mapper/cvg-cvm 750M 388M 362M 52% /mnt/cluster
上篇:
RHCS集群简介及配置web高可用
下篇:
基于MinIO/Deleta Lake/Dremio和Superset或Metabase搭建简单的数据湖