天天看點

RHCS--ISCSI磁盤共享--gfs2(基于mysql)

ext4檔案系統不支援資料同步,隻能單點寫入

配置gfs2,可以實作叢集内資料同步

在lucci界面添加

[[email protected] ~]# /etc/init.d/clvmd status #叢集的lvm
clvmd (pid  1609) is running...
Clustered Volume Groups: (none)
Active clustered Logical Volumes: (none)
[[email protected] ~]# vim /etc/lvm/lvm.conf
[[email protected] ~]# lvmconf --enable-cluster
[[email protected] ~]# /etc/init.d/mysqld stop
Stopping mysqld:                                           [  OK  ]
[[email protected] ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created
[[email protected] ~]# vgcreate myvg /dev/sdb
  Clustered volume group "myvg" successfully created
[[email protected] ~]# lvcreate -L 4G -n lv0 myvg
  Logical volume "lv0" created
[[email protected] ~]# man gfs2
[[email protected] ~]# mkfs.gfs2 -t monster:mygfs2 -p lock_dlm -j 2 /dev/myvg/lv0 
[[email protected] ~]# mount /dev/myvg/lv0 /var/lib/mysql/
[[email protected] ~]# df
Filesystem                           1K-blocks    Used Available Use% Mounted on
/dev/mapper/vg_foundation159-lv_root  19134332 1141060  17021292   7% /
tmpfs                                   251136   31816    219320  13% /dev/shm
/dev/sda1                               495844   33461    436783   8% /boot
/dev/mapper/myvg-lv0                   4193856  264776   3929080   7% /var/lib/mysql
[[email protected] ~]# blkid
/dev/mapper/myvg-lv0: LABEL="monster:mygfs2" UUID="da8414f7-8d5b-9eeb-f728-96e62fee10ed" TYPE="gfs2" 
/dev/sdb: UUID="jZGkHH-8XdM-FRfc-baG1-zoGz-ISx2-cjt660" TYPE="LVM2_member" 
[[email protected] ~]# cd /var/lib/mysql/
[[email protected] mysql]# chown mysql.mysql .

[[email protected] ~]# mount /dev/myvg/lv0 /var/lib/mysql/
[[email protected] ~]# cd /var/lib/mysql/
[[email protected] mysql]# ll -d
drwxr-xr-x 2 mysql mysql 3864 Jul 21 16:07 .
[[email protected] mysql]# mkdir haha

[[email protected] mysql]# ls
haha
           
RHCS--ISCSI磁盤共享--gfs2(基于mysql)

使用共享磁盤/dev/sdb,建立實體卷

RHCS--ISCSI磁盤共享--gfs2(基于mysql)

建立卷組myvg,邏輯卷 lv0

RHCS--ISCSI磁盤共享--gfs2(基于mysql)

在挂載邏輯卷之前,先要格式化檔案系統

RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)

server3 也挂載

在server3建立目錄,server1立即可以看到,實作了共享磁盤資料同步。

RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)

gfs2配置完成,關閉mysql,解除安裝。在luci界面上配置gfs2資源,使其自動開啟服務,并實作資料共享

[[email protected] ~]# umount /var/lib/mysql
           

其實就是将資源添加之後,建立資源組,誰拿到資源組誰就可以挂載共享磁盤,打開服務,獲得資料庫中資料。

RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)

建立資源組,按照IP,檔案管理器,服務的順序加入資源組中

RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)

8.配置成功,檢視效果

自動挂載到server1

RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)
RHCS--ISCSI磁盤共享--gfs2(基于mysql)

在服務1上挂載,當建立資料庫後,将服務停止,就會在服務2上挂載,并且登陸資料庫可以看到在服務1建立的資料庫,說明挂載與高可用都是成功的。

繼續閱讀