mysql and shared storage iscsi of RHCS cluster architecture

1, Description of the experimental environment

Server1 172.25.7.1 (configure Nginx, ricci, and luci)
server2 172.25.7.2(Apache,iscsi)
server3 172.25.7.3(Apache)
Server4 172.25.7.4 (configure Nginx, ricci)

Server1 and server4 configure highly available yum source (not shown)

2, Shared storage iscsi

1. Create a new 8G disk on server2

[root@server2 ~]# fdisk -l


2. Installation services
server2

[root@server2 ~]# yum install scsi-*  -y

server1 and server4

[root@server1 ~]# yum install iscsi* -y
[root@server4 ~]# yum install iscsi* -y

3. Modify the iscsi configuration file

[root@server2 ~]# vim  /etc/tgt/targets.conf 
<target iqn.2018-08.com.example:server.target1>
        backing-store /dev/vdb
        initiator-address 172.25.7.1
        initiator-address 172.25.7.4
</target>
[root@server2 ~]# /etc/init.d/tgtd start
[root@server2 ~]# tgt-admin -s  ##View state


4.server1 and server4 log in to iscsi
Discover and log in

[root@server1 ~]# iscsiadm -m  discovery -t st -p 172.25.7.2
172.25.7.2:3260,1 iqn.2018-08.com.example:server.target1
[root@server1 ~]# iscsiadm -m node -l
Logging in to [iface: default, target: iqn.2018-08.com.example:server.target1, portal: 172.25.7.2,3260] (multiple)
Login to [iface: default, target: iqn.2018-08.com.example:server.target1, portal: 172.25.7.2,3260] successful.
[root@server4 ~]# iscsiadm -m discovery -t st -p 172.25.7.2
[root@server4 ~]# iscsiadm -m node -l

View shared storage sda

[root@server1 ~]# fdisk -l


5. create lvm

[root@server1 ~]# pvcreate /dev/sda 
[root@server1 ~]# vgcreate clustervg /dev/sda 
[root@server1 ~]# lvcreate -L 4G -n demo clustervg


Format as ext4 file system

[root@server1 ~]# mkfs.ext4 /dev/clustervg/demo 

6. Create database

[root@server1 ~]# yum install mysql-server -y
[root@server4 ~]# yum install mysql-server -y
[root@server1 ~]# chown mysql.mysql /var/lib/mysql/

3, Cluster settings

Set Resources:
Add vip:

Add storage

Add script:

ServiceGroup settings:

Add three resources in turn:


Successful cluster construction

[root@server1 ~]# clustat 

Test: you can execute / etc/init.d/mysqld stop in server1 to stop mysql and find that server4 automatically starts the mysql service


4, Set the shared disk to gfs2 format

1. Create a new lvm and format it

[root@server1 ~]# lvremove /dev/clustervg/demo 
[root@server1 ~]# lvcreate -L 4G -n demo  clustervg
[root@server1 ~]# mkfs.gfs2 -j 3 -p lock_dlm -t westos:mygfs2 /dev/clustervg/demo 


2. Set boot mount
Set in server1 and server4

[root@server1 lib]# vim  /etc/fstab 
/dev/clustervg/demo     /var/lib/mysql          gfs2    _netdev         0 0
[root@server1 mysql]# mount -a

3. View information

[root@server1 mysql]# gfs2_tool sb /dev/clustervg/demo all

Test:
Create a file in / var/lib/mysql, and the other side can update and display in real time!!!

[root@server1 mysql]# cp  /etc/passwd  .


Tags: MySQL yum Nginx Apache

Posted on Fri, 10 Jan 2020 12:28:38 -0500 by christo16