Introduction to Linux Distributed storage

Source: Internet
Author: User
Tags domain list install perl

Outline:

I. Common Distributed File System

Ii. Basic principles of MogileFS

Third, the realization of mogilefs

Iv. Basic principles of Fastdfs

Five, the realization of FASTDFS

Vi. comparison of MogileFS and Fastdfs

Data storage is an eternal topic, from ropes count to text appearance, realize the evolution and progress of data information representation, and the change of storage medium, in this process, it presents a variety of styles, record is an effective way to save information, but over time, The security and persistence of data information will inevitably break the traditional storage media and storage thinking, with the development of computer technology, coupled with the maturity of network and communication technology, storage becomes ubiquitous, need to update constantly. Storage needs to maintain real-time reading and writing, provide complex query capabilities, lack of disaster recovery and backup capabilities, large amounts of unstructured data storage and processing, the traditional storage methods challenged. At this time, distributed storage, is the emergence of the data is scattered information storage.

I. Common Distributed File System

google Filesystem   gfs+ MapReduce specializes in handling single large files
hadoop distributed Filesystem gfs's Cottage version +mapreduce, specializes in handling single large files
clusterfs good at handling single large files
taobao Filesystem   good at handling massive small files
mogilefs Good at handling large volumes of small files
ceph PB-level Distributed File System
moosefs     Universal and easy to use for companies with a strong research and development capacity
lustre   a parallel Distributed File system

Ii. Basic principles of MogileFS

MogileFS is an open source Distributed file storage System developed by Danga Interactive, a LiveJournal-owned company. Its main features include support for multi-node redundancy, automatic file replication, no RAID, no special component requirements, etc. MogileFS mainly consists of the following three parts:
1,Tracker: The core of MogileFS, called the Scheduler, MOGILEFSD process is trackers process, trackers do a lot of work: Replication,deletion,query, Reaper,monitor and so on, this is the event-based (event-based) parent process/Message bus that manages all the interactions that come with the client application (requesting operations to be performed), This includes balancing the request load into more than one "query workers", and then having the MOGILEFSD subprocess process

2.Database: metadata for storing mogilefs

3.Storage Server: mogilefs data is stored in this

Several concepts of mogilefs management:
1,domain: A mogilefs can have multiple Domain, used to store different files (size, type), the same domain key must be unique, different domain, key can be the same

2, each storage node is called a host , a host can have multiple storage device dev (separate hard disk), each device has an ID number, Domain+fid used to locate the file
3,Class: File attribute management, location files stored on different devices of the number of copies

Third, the realization of mogilefs

Tools: Three hosts, roles as follows

172.17.19.17:tracker+mysql

172.17.19.117:storage1

172.17.19.189:storage2

Environment: All three hosts are installed with the following packages

Yum install perl-net-netmask perl-io-string perl-sys-syslog Perl-io-aio

Yum-y install make GCC unzip perl-dbd-mysql perl perl-cpan Perl-yaml perl-time-hires
Yum Localinstall *

1. Tracker Configuration

①[[email protected] ~]# yum install mariadb mariadb-server-y

[Email protected] ~]# systemctl start mariadb

② Initializing the database
[Email protected]/etc/mogilefs]# mysql-uroot-p
GRANT all privileges on * * to ' mogile ' @ ' 127.0.0.1 ' identified by ' mogile ' with GRANT OPTION; Authorized
Flush privileges; Clear Permissions
[Email protected]/etc/mogilefs]# Mogdbsetup--dbpass=mogile (all the way y)

③[[email protected]/etc/mogilefs]# vim mogilefsd.conf

Listen = 172.17.19.17:7001 listener IP corresponding port

Db_user = Mogile

Db_pass = Mogile

④ Start Service

/ETC/INIT.D/MOGILEFSD start

Starting MOGILEFSD (via Systemctl): [OK]

[[email protected]/etc/mogilefs]# mogadm--tracker=172.17.19.17:7001 check detection

Checking trackers ...

172.17.19.17:7001 ... Ok

Checking hosts ...

No devices found on tracker (s). at this time only with tracker, has not added storage, so is no devices

2. Storage Configuration

[Email protected] mogilefs]# vim mogstored.conf

Docroot =/data/mogdata

[Email protected] mogilefs]# mkdir/data/mogdata-p

Chown Mogilefs.mogilefs mogdata/-R

[[email protected] mogilefs]#/etc/init.d/mogstored start

3, combination (that is, the storage "added to" tracker)

Tracker operation

[Email protected] ~]# mogadm--tracker=172.17.19.17:7001 host add Node1--ip=172.17.19.117--port=7500--status=alive Specifies storage as Node1 node, alive State is added to tracker

[Email protected] ~]# mogadm--tracker=172.17.19.17:7001 host add Node2--ip=172.17.19.189--port=7500--status=alive

[Email protected] ~]# Mogadm--tracker=172.17.19.17:7001 Check

Checking trackers ...

172.17.19.17:7001 ... Ok

Checking hosts ...

[1] node1 ... Ok

[2] Node2 ... Ok

Storage operation

[Email protected] ~]# cd/data/mogdata/

[[email protected]/data/mogdata]# ls

[Email protected]/data/mogdata]# mkdir DEV1

[Email protected]/data/mogdata]# chown mogilefs.mogilefs dev1/-R

[Email protected] mogilefs]# cd/data/mogdata/

[Email protected] mogdata]# mkdir Dev2

[Email protected] mogdata]# chown mogilefs.mogilefs dev2/-R

Tracker operation

[Email protected] ~]# mogadm--tracker=172.17.19.17:7001 device Add Node1 1

[Email protected] ~]# mogadm--tracker=172.17.19.17:7001 device Add Node2 2

[Email protected] ~]# mysql-uroot-p

4, upload a picture, test whether it can be stored successfully

Tracker operation

[[email protected]/etc/mogilefs]# mogadm--tracker=172.17.19.17:7001 Domain add img

[Email protected]/etc/mogilefs]# mogadm--tracker=172.17.19.17:7001 Domain list

Domain class Mindevcount Replpolicy hashtype

-------------------- -------------------- ------------- ------------ -------

IMG Default 2 multiplehosts () NONE

[Email protected]websrv ~]# mogupload--tracker=172.17.19.17:7001--domain=img--key=test--file=test.jpg

Browser access Find out the path, the picture appears, the test succeeds

Iv. Basic principles of Fastdfs

Fastdfs is a lightweight, open source Distributed file system developed by People Yuqing , which mainly solves the problem of large-capacity file storage and high concurrent access, and the load balance is realized when file is accessed. It is implemented in a pure C language and supports UNIX systems such as Linux, FreeBSD, and Aix. Its features include packet storage, flexibility and simplicity, support for multiple disks, and storage space, Fastdfs's core components are as follows:

1,Tracker: Scheduler, responsible for maintaining the cluster information, such as the group and its internal storage node, this information is also storage node report generated ; Each storagenode will periodically send a heartbeat message to the tracker;

2,Storage Server: Group organization, any one storage server should belong to a group, a group should contain more than storage server; Within the same group, The data of each storage server is redundant;

Five, the realization of FASTDFS

----

Tools: Three hosts, roles as follows

172.17.19.17:tracker+mysql

172.17.19.117:storage1

172.17.19.189:storage2

Environment: All three machines are installed with the following packages

fastdfs-5.0.11-1.el7.centos.x86_64.rpm
fastdfs-debuginfo-5.0.11-1.el7.centos.x86_64.rpm
fastdfs-server-5.0.11-1.el7.centos.x86_64.rpm
fastdfs-tool-5.0.11-1.el7.centos.x86_64.rpm
libfdfsclient-devel-5.0.11-1.el7.centos.x86_64.rpm
libfdfsclient-5.0.11-1.el7.centos.x86_64.rpm
libfastcommon-1.0.36-1.el7.centos.x86_64.rpm nginx-filesystem-1.10.2-1.el7.centos.noarch.rpm
libfastcommon-devel-1.0.36-1.el7.centos.x86_64.rpm

1. Edit the configuration file

Tracker operation

[Email protected]/etc/fdfs]# vim tracker.conf

Disabled=false default = False to indicate whether it is invalid

port=22122 default to 22122

Base_path=/data/fastdfs/tracker

Start the service

[[email protected]/etc/fdfs]#/etc/init.d/fdfs_trackerd start

or Systemctl status Fdfs_trackerd

Starting Fdfs_trackerd (via Systemctl): [OK]

Storage operation

[Email protected] ~/fastdfs]# cd/etc/fdfs/

[[email protected]/etc/fdfs]# ls

Anti-steal.jpg http.conf storage.conf.sample Tracker.conf.sample

Client.conf.sample Mime.types Storage_ids.conf.sample

[email protected]/etc/fdfs]# CP storage.conf.sample storage.conf

[Email protected]/etc/fdfs]# vim storage.conf

Disabled=false default = False to indicate whether it is invalid

port=23000 default to 23000

Base_path=/data/fastdfs/storage

tracker_server=172.17.19.17:22122

Store_path0=/data/fastdfs/storage

http.server_port=8888

Start the service

Systemctl Start fdfs_storaged

2, configuration complete, test, upload files

Configuring the client on tracker

[email protected]/etc/fdfs]# CP client.conf.sample client.conf

[Email protected]/etc/fdfs]# vim client.conf

Base_path=/data/fastdfs/tracker

tracker_server=172.17.19.17:22122

[Email protected]websrv ~]# fdfs_upload_file/etc/fdfs/client.conf test.jpg

Group1/m00/00/00/rbetvvoc0meacltvaaacdxbjwoo831.jpg

storge View, picture stored, test successful

[[email protected] 00]# ls

Rbetvvoc0meacltvaaacdxbjwoo831.jpg

[Email protected] 00]# pwd

/data/fastdfs/storage/data/00/00

Vi. comparison of MogileFS and Fastdfs

The end of the introduction, thank you browse ~







Introduction to Linux Distributed storage

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.