MySQL Cluster and storage

Source: Internet
Author: User
Tags one more line create database

Storage target: Storage is based on different application environment through the adoption of reasonable, safe, effective
Save data to certain media and ensure effective access

? On the one hand it is the physical medium where data is temporarily or permanently resident
? On the other hand, it is the way or behavior that ensures the complete and safe storage of data
? Storage is the combination of these two aspects to provide customers with a set of data
Storage Solutions

Block level: Provide block device (disk)
File level: Provide shared folders
DAS: direct-attached storage. Local Disk
NAS: Network Attached storage. is essentially a shared folder (Nfs/samba)
SAN: Storage Area network.
FC SAN: Fiber-based storage area Network

iSCSI Technology

? Internet SCSI
? IETF-established standard for mapping SCSI data blocks to Ethernet packets
? is a new type of storage technology based on IP storage theory
? Combine SCSI interface technology with IP networks for a wide range of applications in the storage industry
? San can be built on IP networks
? Originally developed by Cisco and IBM

Advantage
– Standards based on IP protocol technology
– Allow the network to transmit SCSI commands on the TCP/IP protocol
– Lower IP SAN investment compared to FC SAN,ISCSI
– Address transfer efficiency, storage capacity, compatibility, openness, security
Issues of sexual and other aspects
– No distance limit
Client
–ISCSI Initiator: Software implementation, low cost and low performance
–ISCSI HBA: Hardware implementation, good performance, high cost
? Storage Device Side
–ISCSI Target
? Ethernet Switch
iSCSI Deployment Steps
Second, configure iSCSI
1. Prepare three virtual machines
vh01.tedu.cn 192.168.4.1 Storage Server
Vh02.tedu.cn 192.168.4.2 MYSQL1
Vh03.tedu.cn 192.168.4.3 MYSQL2
[Email protected] nsd1802]# Clone-auto7
2. Initialize three virtual machines: IP address, hostname, selinux, firewall, yum
Configure IP addresses in a way that can be used Nmtui

Tui:text User Interface Text UI
Gui:graphical User Interface GUI
Cli:command lines Interface Command line interface

3, for the client to provide storage, need to provide a name for storage. It is recommended to use the name IQN
IQN = iqn. Time. The inverse of the domain name. String: substring
such as Iqn.2018-06.cn.tedu.nsd1802:teacher
If you provide storage for more than 200 students nationwide, you need to have more than 200 different names.
4. Install the storage-side package on VH01
[email protected] ~]# Yum install-y targetcli.noarch
5. Prepare the hard drive for the storage side. Virtual machines can be directly added to the drive without shutting down the machine.
6. Create VDB1 as a remote disk for shared storage
[Email protected] ~]# PARTED/DEV/VDB
(parted) Mklabel GPT
Create a primary partition with a starting position of 1M and an end position of 10% capacity portion of the entire hard drive
(parted) Mkpart primary 1M 10%
(parted) Mkpart primary 10% 20%
(parted) Print view
(parted) quit
[Email protected] ~]# lsblk
7. Configure Target Storage
[Email protected] ~]# TARGETCLI
Creating back-end storage
/>/backstores/block Create formysql/dev/vdb1
Create a Iqn object
/>/ISCSI Create iqn.2018-06.cn.tedu.nsd1802
Add storage to the IQN object vdb1
/> ls
/>/iscsi/iqn.2018-06.cn.tedu.nsd1802/tpg1/luns Create/backstores/block/formysql
Authorized client access, such as client iqn name is iqn.2018-06.cn.tedu.vh02
/>/iscsi/iqn.2018-06.cn.tedu.nsd1802/tpg1/acls Create iqn.2018-06.cn.tedu.vh02
Binding address (can be omitted because it is configured by default)
/>/iscsi/iqn.2018-06.cn.tedu.nsd1802/tpg1/portals/create 0.0.0.0
Save
/> Saveconfig
/> Exit
8. Start the service
[Email protected] ~]# systemctl start target
[Email protected] ~]# Systemctl enable target

Three, configure the iSCSI client
1, install the package
[[email protected] ~]# yum install iscsi-initiator-utils
2, modify the client's iqn name
[[ Email protected] ~]# vim/etc/iscsi/initiatorname.iscsi
initiatorname=iqn.2018-06.cn.tedu.vh02
3, Discovery Server
[[email protected] ~]# man iscsiadm view Help
[[email protected] ~]# iscsiadm--mode discoverydb--type Sendtargets--portal 192.168.4.1--discover
At this point, you can find the IQN name of the store, but the execution lsblk is not visible to the new disk.
4, landing target. You can do this through the commands you see in the man help, or you can do the following
[[email protected] ~]# systemctl restart iSCSI
[[email protected] ~]# Lsblk a new hard drive appears

Iv. using iSCSI Disks
1. Partitioning, formatting
[Email protected] ~]# PARTED/DEV/SDA
(parted) Mklabel GPT
(parted) Mkpart primary 1M 100%
(parted) quit
[Email protected] ~]# mkfs.ext4/dev/sda1
2, Installation mariadb
[email protected] ~]# Yum install-y mariadb-server
3. Mount Restart Service
[Email protected] ~]# mount/dev/sda1/var/lib/mysql/
[Email protected] ~]# chown mysql.mysql/var/lib/mysql/
[Email protected] ~]# systemctl start mariadb

V. Testing
1. Create a database and write data
[Email protected] ~]# Mysql-uroot
MariaDB [(None)]> CREATE DATABASE nsd1802 DEFAULT CHAR SET UTF8;
MariaDB [(None)]> use nsd1802;
MariaDB [nsd1802]> CREATE TABLE Students (name varchar (20));
MariaDB [nsd1802]> INSERT into students VALUES ("Li Yang");
MariaDB [nsd1802]> SELECT from students;
2, Stop mariadb Service, uninstall SDA1 (analog vh02 down)
Be sure to uninstall shared storage and not vh02 and vh03 to mount shared storage at the same time. Because EXT4/XFS is a single-node file system, if multiple nodes are mounted at the same time, the file system will be corrupted, resulting in data loss.
3, mount the shared storage on the vh03, install the database, and let it serve the client.
[[email protected] ~]# shutdown-h now
[[email protected] ~]# yum install-y iscsi-initiator-utils
[[email protected] ~]# targetcli
/>/iscsi/iqn.2018-06.cn.tedu.nsd1802/tpg1/acls/create iqn.2018-06.cn.tedu.vh03
/> Saveconfig
[[email protected] ~]# VIM/ETC/ISCSI/INITIATORNAME.ISCSI
Initiatorname=iqn.2018-06.cn.tedu.vh03
[[email protected] ~]# iscsiadm--mode discoverydb--type sendtargets --portal 192.168.4.1--discover
[[email protected] ~]# systemctl restart iSCSI
[[email protected] ~]# Yum install-y mariadb-server
[[email protected] ~]# mount/dev/sda1/var/lib/mysql/
[[email  Protected] ~]# systemctl start mariadb
[[email protected] ~]# mysql
mariadb [(none)]> use nsd1802;
MariaDB [nsd1802]> Select
from students;

Udev: Ways to dynamically manage device files
1, all the files in Linux.
2, Udev management equipment files. For example, the host connection USB drive appears new file (SDB), remove the USB flash drive, the disk file disappears.
3, the hardware file information is written to the/sys directory, this directory and proc similar.
4. We use Udev to rename the device or perform a custom operation.
(1) Create a rule file in the/ETC/UDEV/RULES.D directory
(2) Access to new devices, if the rules are met, will be applied according to the rules of the administrator
(3) Rule file name: number-name. Rules
5. In the rules file, the administrator specifies what to do if the hardware meets or does not meet the conditions
6, Example: U disk access to the host, named Udisk
(1) Find the description path of the USB flash drive in the/sys directory
[Email protected] ~]# Udevadm info--query=path--name=/dev/sdb1
/devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0/block/sdb/sdb1
(2) According to the path of the previous step, query the hardware information of the U disk
[Email protected] ~]# udevadm info--query=all--attribute-walk--path=/devices/pci0000:00/0000:00:14.0/usb1/1-5/ 1-5:1.0/host5/target5:0:0/5:0:0:0/block/sdb/sdb1
There is a lot of content, just need to find the relevant content, such as drivers== "Usb-storage"
(3) Writing rule files
[Email protected] ~]# Vim/etc/udev/rules.d/90-udisk.rules
action== "Add", kernel== "sd[a-z]*", drivers== "Usb-storage",
symlink+= "udisk%n"
To connect a device to a host, the action (behavior) is add,kernel means that there is no human intervention in the name of the kernel. Symlinik is to create a shortcut, + = is added extra. %n is the partition code
(4) Re-access the U disk can

NFS: Network file system for sharing between Linux.
One, implement read-only sharing
1, configure VH01 to Server
(1) Pack
[[email protected] ~]# yum install-y nfs-utils
(2) Create a shared directory
[[ Email protected] ~]# MKDIR-PV/NFSROOT/NFSRO
[[email protected] ~]# cp/etc/hosts/nfsroot/nfsro/
(3) Declare the shared directory in the configuration file
[[email protected] ~]# vim/etc/exports
/nfsroot/nfsro * (RO)
(4) Start the service
[email  protected] ~]# systemctl Restart NFS
2, client use sharing
(1) View
[[email protected] ~]# showmount-e 192.168.4.1
(2) Mount
[[email protected] ~]# mount 192.168.4.1:/nfsroot/nfsro/mnt/sharero
[[email  Protected] ~]# cat/mnt/sharero/hosts

Second, create read-write share
1. Configure VH01 for server
(1) Create a shared directory on the server
[Email protected] ~]# mkdir-m 777/NFSROOT/NFSRW
Whether NFS or Samba or FTP, as long as it is read-write, you must set permissions on local permissions and configuration files
(2) declaring read-write directory
/NFSROOT/NFSRW 192.168.4.* (Rw,sync)->sync means synchronous read and write
(3) Re-export the shared directory
[Email protected] ~]# EXPORTFS-RV
2, configure vh03 for the client
[email protected] ~]# Mount 192.168.4.1:/nfsroot/nfsrw/mnt/sharerw
[Email protected] ~]# echo ' Hello World ' >/mnt/sharerw/hi.txt
[Email protected] ~]# Cat/mnt/sharerw/hi.txt

Multi-Path Multipath
First, the use
If the client-to-server store has only one line, then the line fails and the storage is unavailable. You can add one more line. At this point, the client will find the same storage device from both lines, which will store up to two names, such as SDA and SDB.
The client is not suitable for whichever storage is used. We can create a virtual disk, such as Mpatha, the client mounts the Mpatha, as long as the underlying not two paths all fail, Mpatha has been available. Principle reference HSRP.
Second, configure multi-path
1. Add 192.168.2.0/24 network between VH01 and vh03
2, on the vh03 through the 192.168.2.0 network also found a share
[Email protected] ~]# iscsiadm--mode discoverydb--type sendtargets--portal 192.168.2.1--discover
[[email protected] ~]# systemctl restart iSCSI
[Email protected] ~]# lsblk at this time the local SDA and SDB
3. Installing multipathing Packages
[email protected] ~]# Yum install-y device-mapper-multipath
4, SDA and SDB are the same equipment, their wwid is the same
Get the Wwid of the disk:
[Email protected] ~]#/lib/udev/scsi_id--whitelisted--DEVICE=/DEV/SDA
3600140589282e00db104fc29d84334a8
5. Generating a multipath configuration file
[Email protected] ~]# mpathconf--user_friendly_names N
6, in the configuration file to declare the method of obtaining Wwid, and declare Wwid is 3600140589282E00DB104FC29D84334A8 device is Mpatha
[Email protected] ~]# vim/etc/multipath.conf
Defaults {
User_friendly_names No
Find_multipaths Yes
}
multipaths {
multipath {
Wwid "3600140589282e00db104fc29d84334a8"
Alias "Mpatha"
}
}
7, start the multi-path service, you can see the Mpatha device under the/dev/mapper
[Email protected] ~]# systemctl start MULTIPATHD
[Email protected] ~]# Systemctl enable MULTIPATHD

MySQL Cluster and storage

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.