MogileFS Distributed File System Construction

Source: Internet
Author: User
Tags create domain domain list

MogileFS Distributed File System Construction

MogileFS is an open-source distributed storage software suitable for storing massive small files. It consists of three parts: tracker, mogstore, and database.
Tracker: It stores metadata information through databases, including site domain, class, host, etc. Its main functions include monitoring back-end Storage nodes, and instructing Storage nodes to add, delete, and query data, and data replication between nodes.
The location where mogstored actually stores data. The default listening port is port 7500, and the client's file storage request is accepted.
Database: used for data key-value ing. mysql can be used to save the global information set by nodes.

MogileFS workflow:

Experimental environment tracker node martin
Storage node martin lucia

Deploy Tracker Nodes
[Root @ martin ~] # Yum-y install make gcc unzip perl-DBD-MySQL perl-CPAN perl-YAML perl-Time-HiRes

Cpan
Install MogileFS: Server
Install MogileFS: Utils

----------------------------------------------------------------------
---- Unsatisfied dependencies detected ----
---- Dormano/MogileFS-Server-2.72.tar.gz ----
MogileFS: Client [requires]
Sys: Syscall [requires]
Perlbal [requires]
Test: More [requires]
Net: Netmask [requires]
Danga: Socket [requires]
IO: AIO [requires]

---- Unsatisfied dependencies detected ----
---- Dormano/MogileFS-Client-1.17.tar.gz ----
IO: WrapTie [requires]
Test: More [requires]
---- Unsatisfied dependencies detected ----
---- Dormano/Perlbal-1.80.tar.gz ----
Danga: Socket [requires]
BSD: Resource [requires]
---- Unsatisfied dependencies detected ----
---- MLEHMANN/IO-AIO-4.34.tar.gz ----
Canary: Stability [build_requires]
Dormano/MogileFS-Server-2.72.tar.gz
/Usr/bin/make install -- OK

# Sys: You can save only one copy of version 0.25 of Syscall to be downgraded to version 0.23.

[Root @ martin ~] # Wget http://mirrors.ustc.edu.cn/CPAN/authors/id/ B /BR/BRADFITZ/Sys-Syscall-0.23.tar.gz
[Root @ martin ~] # Tar xf Sys-Syscall-0.23.tar.gz
[Root @ martin ~] # Cd Sys-Syscall-0.23
[Root @ martin Sys-Syscall-0.23] # perl Makefile. PL
[Root @ martin Sys-Syscall-0.23] # make & make install

Initialize the database:
12345678 mysql> "create database mogilefs;
Query OK, 1 row affected (0.02 sec)

Mysql> grant all on mogilefs. * to 'mogilefs' @ '2017. 192. *. * 'identified by '123 ';
Query OK, 0 rows affected (0.01 sec)

Mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

1 [root @ martin ~] # Mogdbsetup -- dbhost = 192.168.1.222 -- dbname = mogilefs -- dbuser = mogilefs -- dbpass = 222222 -- dbrootpass = 123321

12345678910111213141516171819202122 mysql> show tables;
+ ---------------------- +
| Tables_in_mogilefs |
+ ---------------------- +
| Checksum |
| Class |
| Device |
| Domain |
| File |
| File_on |
| File_on_0000upt |
| File_to_delete |
| File_to_delete2 |
| File_to_delete_later |
| File_to_queue |
| File_to_replicate |
| Fsck_log |
| Host |
| Server_settings |
| Tempfile |
| Unreachable_fids |
+ ---------------------- +

Add a startup User: (only common users are allowed)

[Root @ martin ~] # Useradd-r mogilefs

Configuration file:
[Root @ martin Sys-Syscall-0.23] # mkdir/etc/mogilefs
[Root @ martin Sys-Syscall-0.23] # cd/etc/mogilefs

[Root @ martin mogilefs] # vim mogilefsd. conf
Daemonize = 1 # Whether daemonize runs in the background as a daemon
Pidfile =/var/run/mogilefsd. pid
Db_dsn = DBI: mysql: mogilefs: host = localhost; port = 3306; mysql_connect_timeout = 5 # database connection information
Db_user = mogilefs # user name on the database
Db_pass = mogilefs # password for the user name
Listen = 0.0.0.0: 7001 # Listening address and port
Conf_port = 7001 # configuration interface
Query_jobs = 10 # The number of processes to be queried can be adjusted to a large value.
Delete_jobs = 1 # The number of processes used for the delete operation can be adjusted to a large value.
Replicate_jobs = 5 # The number of processes used for replication can be adjusted to a large value.
Reaper_jobs = 1 # The number of processes used to recycle resources can be adjusted to a large value.

Runtime directory:
[Root @ martin mogilefs] # mkdir/var/run/mogilefsd
[Root @ martin mogilefs] # chown-R mogilefs/var/run/mogilefsd

STARTUP script:
[Root @ martin mogilefs] # su-mogilefs-c "mogilefsd-c/etc/mogilefs/mogilefsd. conf -- daemon"

[Root @ martin mogilefs] # ss-lntup | grep 7001
Tcp LISTEN 0 128 *: 7001 *: * users :( ("mogilefsd ))

Deploy Storage Nodes

Yum-y install make gcc unzip perl-CPAN perl-YAML perl-Time-HiRes perl-DBD-MySQL

Cpan
Install MogileFS: Server # The dependency is automatically resolved.
Install MogileFS: Utils

# Sys: You can save only one copy of version 0.25 of Syscall to be downgraded to version 0.23.

[Root @ martin ~] # Wget http://mirrors.ustc.edu.cn/CPAN/authors/id/ B /BR/BRADFITZ/Sys-Syscall-0.23.tar.gz
[Root @ martin ~] # Tar xf Sys-Syscall-0.23.tar.gz
[Root @ martin ~] # Cd Sys-Syscall-0.23
[Root @ martin Sys-Syscall-0.23] # perl Makefile. PL
[Root @ martin Sys-Syscall-0.23] # make & make install

If/etc/mogilefs/not exist
1 [root @ lucia ~] # Mkdir/etc/mogilefs/

If user mogilefs not exist
1 [root @ lucia ~] # Useradd-r mogilefs

[Root @ martin mogilefs] # vim/etc/mogilefs/mogstored. conf

Maxconns = 10000 # maximum number of concurrent connections
Httplisten = 0.0.0.0: 7500 # http listener address
Mgmtlisten = 0.0.0.0: 7501 # management interface listening address
Docroot =/mydata/mogilefs/data # directory used for storage

[Root @ martin mogilefs] # mkdir/mydata/mogilefs/data-p
[Root @ martin mogilefs] # chown-R mogilefs. mogilefs/mydata/mogilefs/

STARTUP script:
[Root @ martin mogilefs] # su-mogilefs-c "mogstored-c/etc/mogilefs/mogstored. conf -- daemon"

[Root @ martin mogilefs] # ss-lntup | grep 7500
Tcp LISTEN 0 128 *: 7500 *: * users :( ("mogstored", 41190,4 ))

[Root @ martin mogilefs] # ss-lntup | grep 7501
Tcp LISTEN 0 128 *: 7501 *: * users :( ("mogstored", 41190,9 ))

 

Tracker Nodes
[Root @ martin mogilefs] # mogadm -- trackers = 192.168.1.222: 7001 check

Checking trackers...
192.168.1.222: 7001... OK
Checking hosts...
No devices found on tracker (s ).

123456 [root @ martin mogilefs] # mogadm check
Checking trackers...
127.0.0.1: 7001... OK

Checking hosts...
No devices found on tracker (s ).

12345678 [root @ martin ~] # Mogstats-h
Usage:
Mogstats -- db_dsn = "DBI: mysql: mfs: host = mfshost" -- db_user = "mfs"
-- Db_pass = "mfs" -- verbose -- stats = "devices, files"
Mogstats -- stats = "all"
Mogstats [all options in ~ /. Mogilefs. conf]

Valid stats: all, delete-queue, devices, domains, fids, files, general-queues, replication, replication-queue

Add mysql information for trackers
[Root @ martin ~] # Vim. mogilefs. conf # under the Home Directory

-- Db_dsn = "DBI: mysql: mogilefs: host = 192.168.1.222"
-- Db_user = "mogilefs"
-- Db_pass = "222222"
-- Verbose
-- Stats = "devices, files"

Add host node1 node2:

[Root @ martin ~] # Mogadm -- trackers = 192.168.1.222: 7001 host add node1 -- ip = 192.168.1.222 -- status = alive
[Root @ martin ~] # Mogadm -- trackers = 192.168.1.222: 7001 host add node2 -- ip = 192.168.1.223 -- status = alive

View the added Host:
[Root @ martin ~] # Mogadm -- trackers = 192.168.1.222: 7001 host list
Node1 [1]: alive
IP: 192.168.1.222: 7500
Node2 [2]: alive
IP: 192.168.1.223: 7500

Add devices to a node to list devices:

[Root @ martin ~] # Mogadm -- trackers = 192.168.1.222: 7001 device add node1 001 #001 device id cannot be reused
[Root @ martin ~] # Mogadm -- trackers = 192.168.1.222: 7001 device add node2 002

[Root @ martin ~] # Mogadm -- trackers = 192.168.1.222: 7001 device list
Node1 [1]: alive
Used (G) free (G) total (G) weight (%)
Dev1: alive 0.000 0.000 0.000 100
Node2 [2]: alive
Used (G) free (G) total (G) weight (%)
Dev2: alive 0.000 0.000 0.000 100

Create the corresponding device dev
[Root @ martin ~] # Cd/mydata/mogilefs/data
[Root @ martin data] # mkdir dev1
[Root @ martin data] # chown-R mogilefs. mogilefs dev1/

[Root @ lucia ~] # Cd/mydata/mogilefs/data/
[Root @ lucia data] # mkdir dev2
[Root @ lucia data] # chown-R mogilefs. mogilefs dev2/

Create domain:
[Root @ martin ~] # Mogadm -- trackers = martin: 7001 domain add files

[Root @ martin ~] # Mogadm -- trackers = martin: 7001 domain list
Domain class mindevcount replpolicy hashtype # default minimum number of copies 2
------------------------------------------------------------------------
Files default 2 MultipleHosts () NONE

Upload files

[Root @ martin ~] # Mogupload -- trackers = martin: 7001 -- domain = files -- key = '/install. log' -- file = 'Install. Log'
[Root @ martin ~] # Moglistkeys -- trackers = martin: 7001 -- domain = files
/Install. log

[Root @ martin Sys-Syscall-0.23] # mogfileinfo -- trackers = martin: 7001 -- domain = files -- key = '/install. Log'
-File:/install. log
Class: default
Devcount: 2
Domain: files
Fid: 4
Key:/install. log
Length: 21712
-Http: // 192.168.1.223: 7500/dev2/0/000/000/0000000004 .fid
-Http: // 192.168.1.222: 7500/dev1/0/000/000/0000000004 .fid

Storage node deprecation settings

[Root @ martin Sys-Syscall-0.23] # mogadm -- trackers = 192.168.1.222: 7001 host mark node2 down

[Root @ martin Sys-Syscall-0.23] # mogadm -- trackers = 192.168.1.222: 7001 host mark node2 down
[Root @ martin Sys-Syscall-0.23] # mogadm -- trackers = 192.168.1.222: 7001 host list
Node1 [1]: alive
IP: 192.168.1.222: 7500
Node2 [2]: down
IP: 192.168.1.223: 7500

[Root @ martin Sys-Syscall-0.23] # mogadm -- trackers = 192.168.1.222: 7001 device list
Node1 [1]: alive
Used (G) free (G) total (G) weight (%)
Dev1: alive 0.375 2.428 2.803 100

Node2 [2]: down
Used (G) free (G) total (G) weight (%)
Dev2: alive 0.239 2.563 2.803 100

Launch:
[Root @ martin Sys-Syscall-0.23] # mogadm -- trackers = 192.168.1.222: 7001 host mark node2 alive

Class settings:
123456 [root @ martin mogilefs] # mogadm -- trackers = martin: 7001 class add files class0 -- mindevcount = 2
[Root @ martin mogilefs] # mogadm -- trackers = martin: 7001 class list
Domain class mindevcount replpolicy hashtype
------------------------------------------------------------------------
Files class0 2 MultipleHosts () NONE
Files default 2 MultipleHosts () NONE

Use nginx to implement reverse proxy:

Nginx_mogilefs_module-1.0.4

Download from the help house resource station:

------------------------------------------ Split line ------------------------------------------

Free in http://linux.bkjia.com/

The username and password are both www.bkjia.com

The specific download directory is available in/July 6, 2016,/July 10, June,/MogileFS Distributed File System Construction Details/

For the download method, see

------------------------------------------ Split line ------------------------------------------

File MD5 SHA1
Nginx_mogilefs_module-1.0.4.tar.gz 2466aa02b225ad2aa1af22e6e50a9d2f 4f6b774096a77aa8c550d8fd6a3f5d39a661d8ed
Nginx_mogilefs_module-1.0.4.zip 4667d8b805aa4ecc94c7109d79a1020a 8d86fa4f0fcb60cdd73195f77fbadf45ac51a875

[Root @ marvin nginx-1.6.3] #./configure -- prefix =/usr/local/nginx1.6.3 \
-- Error-log-path =/var/log/nginx/error. log \
-- Http-log-path =/var/log/nginx/access. log \
-- Pid-path =/var/run/nginx. pid \
-- Lock-path =/var/lock/nginx. lock \
With-http_ssl_module \
With-http_flv_module \
With-http_stub_status_module \
With-http_gzip_static_module \
-- Http-client-body-temp-path =/var/tmp/nginx/client /\
-- Http-proxy-temp-path =/var/tmp/nginx/proxy /\
-- Http-fastcgi-temp-path =/var/tmp/nginx/fcgi /\
-- Http-uwsgi-temp-path =/var/tmp/nginx/uwsgi \
-- Http-scgi-temp-path =/var/tmp/nginx/scgi \
-- With-pcre \
-- User = nginx \
-- Group = nginx \
-- Add-module =/tools/nginx_mogilefs_module-1.0.4 | tee/tmp/nginx. out

[Root @ marvin extra] # vim/usr/local/nginx/conf/nginx. conf
# Add
Upstream trackers {
Server martin: 7001 weight = 1;
Server lucia: 7001 weight = 1;
}


[Root @ marvin extra] # vim/usr/local/nginx/conf/extra/demo. conf
# Add
Location/file {
Mogilefs_tracker trackers;
# Mogilefs_tracker 192.168.1.222: 7001;
Mogilefs_domain files;
Mogilefs_pass {
Proxy_pass $ mogilefs_path;
Proxy_hide_header Content-Type;
Proxy_buffering off;
}
}

Upload images:

[Root @ martin ~] # Mogupload -- trackers = martin: 7001 -- domain = files -- key = '/kuli.png' --file='kuli.png'

Over

MogileFS sets Memcached

Use Nginx in MogileFS

Use Nginx In the Open-Source Distributed File System MogileFS

Use of Distributed File System MogileFS

Custom Nagios monitoring MogileFS storage node script

This article permanently updates the link address:

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.