您好,登錄后才能下訂單哦!
MogileFS的安裝與配置
================================================================================
概述:
================================================================================
1.簡介:
MogileFS是一個開源的分布式文件存儲系統,由LiveJournal旗下的DangaInteractive公司開發。
Danga團隊開發了包括Memcached、MogileFS、Perlbal等多個知名的開源項目。
目前使用MogileFS的公司非常多,如日本排名先前的幾個互聯公司及國內的yupoo(又拍)、digg、豆瓣、1號店、大眾點評、搜狗和安居客等,分別為所在的組織或公司管理著海量的圖片。
2.MogileFS特性:
★應用層
運行于用戶空間,無需特殊的核心組件;
★無單點
MogStored:存儲多個數據副本;
Tracker:多節點;
Database:MySQL(存放元數據);
★自動文件復制
★傳輸中立,無特殊協議,可通過NFS或HTTP進行通信
★簡單的名稱空間
diomain,class,fid(即訪問文件的key);
每個文件對應一個key:用于domain定義名稱空間;
★不用共享任何數據
元數據:DB
數據:MogStored,副本
★不需要RAID
3.MogileFS組件:
★MogileFS組件:
☉Tracker:追蹤元數據
MogileFS的核心,是一個調度器;
服務進程為mogilefsd;
職責:刪除、復制、監控、查詢等;
☉MogStored:存儲數據
mogstored進程: 數據存儲的位置,通常是一個HTTP(WebDAV)服務器,用來數據的創建、刪除、獲取;
存儲節點需定義“設備dev”用作存儲空間;每個設備在當前集群中需通過一個唯一的DevID標識。
☉Database:存儲元數據;
用于為tracker存儲元數據信息,mogileFS
存儲mogilefs的元數據,一般使用mysql,建議使用冗余方案保證可用性(MMM,MHA)
★MogileFS服務進程
mogilfsd (Tracker)
mogstored(MogStored)
4.MogileFS的實現機制和工作原理:
★實現機制
在該文件系統集群中,每一個數據塊都會有多個副本,存放于多個Storage Node上,不同的文件系統副本的數量各不相同(一般建議為3份),在Tracker Node上會分別單獨記錄每一個數據塊的存儲位置(位于哪個Storage及路徑)。若某個Storage節點不在線了,客戶端向Tracker節點請求獲取數據時,Tracker節點會返回用于冗余的副本的存儲位置給客戶端。這樣就保證了整個文件系統中數據的高可用性。當有數據存儲至某一storage節點后,各storage節點會根據Tracker的指示通過節點間通信將副本發送至其他節點上。若某一storage下線了,該節點上的副本會由其他節點重新提供,保證副本的個數不少于指定的值。
★工作原理
客戶端需要存取數據時,首先與Tracker進行交互,Tracker通過查詢數據庫來獲取客戶端存取數據時所需要訪問的元數據,然后返回給客戶端,客戶端利用Tracker返回的結果,與Storage Nodes節點進行交互完成數據存取(一次有可能聯系一個也可能聯系多個)。
附圖:
5.MogileFS中的術語:
☉tracker
借助數據庫保存各個節點文件的元數據信息, 便于檢索定位數據位置并監控各個節點, 告知客戶端存儲區的位置并指揮storage節點復制數據副本, 進程為mogilefsd;
☉databases
為tracker節點存儲節點文件的元數據信息;
☉storage
將指定域中的鍵轉換為特有的文件名存儲于在特定的設備文件中, 轉換后文件名為值, storage自動維護鍵值之間的對應關系, storage節點使用http進行數據傳輸, 依賴于perbal, 進程為mogstored, perbal;
☉Domain
一個域中的鍵值是唯一的, 一個MogileFS可以有多個域來存儲不同類型的文件,同一個Domain內Key必須唯一,不同的Domain內Key可以相同;
☉Class
一個域中的鍵值是唯一的, 一個MogileFS可以有多個域來存儲不同類型的文件,同一個Domain內Key必須唯一,不同的Domain內Key可以相同;
☉device
一個存儲節點, 可以有多個device, 就是用來存放文件的目錄, 每個設備都有一個設備ID, 需要在mogstored配置文件中docroot配置, 設備不能刪除, 只能將設備的狀態置為dead, 置為dead之后數據就無法恢復了, 并且設備ID也無法再使用;
附圖:
1.perl模塊的安裝方式:
★online(在線):
yum -y install make gcc unzip perl-DBD-MySQL perl perl-CPAN perl-YAML perl-Time-HiRes
執行命令 : perl -MCPAN -e shell 進入 perl 依賴包安裝模式 (或執行 cpan -i module_name::name)
cpan install App::cpanminus
cpan install MogileFS::Server
cpan install MogileFS::Utils
cpan install IO::AIO
cpan install IO::WrapTie
cpan install Danga::Socket★offline(線下):要大量解決依賴關系
$ perl Makefile.PL
$ make
$ sudo make install
★rpm
☉MogileFS安裝:
tracker:
$ yum install MogileFS-Server-VERSION.rpm MogileFS-Server-mogilefsd-VERSION.rpm
mogstored:
$ yum install perl-IO-AIO
$ yum install MogileFS-Server-VERSION.rpm MogileFS-Server-mogstored-VERSION.rpm
實驗:MofileFS的安裝和配置
環境描述:
兩臺CentOS 7的虛擬主機node1和node2,node1即作為tracker又作為mogstore存儲節點,同時還是mysql服務器;node2為tracker和mogstaor節點;
實驗步驟:
1.首先在noge1上使用CPAN工具在線安裝perl模塊及mogilefs
[root@centos7 ~]# yum -y install make gcc unzip perl-DBD-MySQL perl perl-CPAN perl-YAML perl-Time-HiRes [root@centos7 ~]# perl -MCPAN -e shell cpan >install App::cpanminus cpan >install MogileFS::Server cpan >install MogileFS::Utils cpan >install IO::AIO cpan >install IO::WrapTie cpan >install Danga::Socket #========================================================================================= # 安裝后各程序版本如下: [root@centos7 ~]# cpan Sys::Syscall Reading '/root/.cpan/Metadata' Database was generated on Thu, 05 Jan 2017 18:41:02 GMT Sys::Syscall is up to date (0.25). [root@centos7 ~]# cpan MogileFS::Server Reading '/root/.cpan/Metadata' Database was generated on Thu, 05 Jan 2017 18:41:02 GMT MogileFS::Server is up to date (2.72). [root@centos7 ~]# cpan MogileFS::Utils Reading '/root/.cpan/Metadata' Database was generated on Thu, 05 Jan 2017 18:41:02 GMT MogileFS::Utils is up to date (2.29). [root@centos7 ~]# cpan IO::AIO Reading '/root/.cpan/Metadata' Database was generated on Thu, 05 Jan 2017 18:41:02 GMT IO::AIO is up to date (4.34). [root@centos7 ~]# cpan IO::WrapTie Reading '/root/.cpan/Metadata' Database was generated on Thu, 05 Jan 2017 18:41:02 GMT IO::WrapTie is up to date (2.111). [root@centos7 ~]# cpan Danga::Socket Reading '/root/.cpan/Metadata' Database was generated on Thu, 05 Jan 2017 18:41:02 GMT Danga::Socket is up to date (1.61).
2.在node1上安裝MySQL(略),創建數據庫,添加管理用戶
[root@centos7 ~]# mysql -ptaoxiu Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 11 Server version: 5.5.44-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database mogfsdb; # 創建數據庫 MariaDB [(none)]> grant all privileges on mogfsdb.* to 'moguser'@'127.0.0.1' identified by 'mogpass'; MariaDB [(none)]> grant all privileges on mogfsdb.* to 'moguser'@'192.168.1.113' identified by 'mogpass'; MariaDB [(none)]> flush privileges;
3.初始化數據庫
[root@centos7 ~]# mogdbsetup --dbhost='127.0.0.1' --dbname=mogfsdb --dbuser=moguser --dbpass=mogpass --type=MySQL This will attempt to setup or upgrade your MogileFS database. It won't destroy existing data. Run with --help for more information. Run with --yes to shut up these prompts. Continue? [N/y]: y
查看數據庫如下:
[root@centos7 ~]# mysql -ptaoxiu Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 5 Server version: 5.5.44-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | Syslog | | hellodb | | jingdong | | mogfsdb | | mysql | | ultrax | | zabbix | +--------------------+ 8 rows in set (0.12 sec) MariaDB [(none)]> use mogfsdb; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [mogfsdb]> show tables; # 生成的表 +----------------------+ | Tables_in_mogfsdb | +----------------------+ | checksum | | class | | device | | domain | | file | | file_on | | file_on_corrupt | | file_to_delete | | file_to_delete2 | | file_to_delete_later | | file_to_queue | | file_to_replicate | | fsck_log | | host | | server_settings | | tempfile | | unreachable_fids | +----------------------+ 17 rows in set (0.00 sec) MariaDB [mogfsdb]> exit
配置tracker節點,
1.在/etc目錄下創建mogilefs目錄,并提供配置文件mogilefsd.conf,如下:
[root@centos7 ~]# mkdir /etc/mogilefs [root@centos7 ~]# vim /etc/mogilefs/mogilefsd.conf # Enable daemon mode to work in background and use syslog daemonize = 1 # Where to store the pid of the daemon (must be the same in the init script) pidfile = /var/run/mogilefsd/mogilefsd.pid # 指定pid文件位置 # Database connection information db_dsn = DBI:mysql:mogfsdb:host=127.0.0.1 # 修改為上面授權的賬號和密碼 db_user = moguser # mysql用戶 db_pass = mogpass # mysql密碼 # IP:PORT to listen on for mogilefs client requests listen = 0.0.0.0:7001 # 監聽的地址和端口(所有地址的7001端口) # Optional, if you don't define the port above. conf_port = 7001 # Number of query workers to start by default. query_jobs = 10 # 用于查詢的進程數 # Number of delete workers to start by default. delete_jobs = 1 # 用于刪除操作的進程數 # Number of replicate workers to start by default. replicate_jobs = 5 # 用于復制的進程數 # Number of reaper workers to start by default. # (you don't usually need to increase this) reaper_jobs = 1 # 用于回收資源的進程數 # Number of fsck workers to start by default. # (these can cause a lot of load when fsck'ing) #fsck_jobs = 1 # Minimum amount of space to reserve in megabytes # default: 100 # Consider setting this to be larger than the largest file you # would normally be uploading. #min_free_space = 200 # Number of seconds to wait for a storage node to respond. # default: 2 # Keep this low, so busy storage nodes are quickly ignored. #node_timeout = 2 # Number of seconds to wait to connect to a storage node. # default: 2 # Keep this low so overloaded nodes get skipped. #conn_timeout = 2 # Allow replication to use the secondary node get port, # if you have apache or similar configured for GET's #repl_use_get_port = 1
2.創建pid文件目錄并賦予權限,然后啟動服務。
# mogilefsd不能以root身份運行,必須用其他用戶運行,為此添加mogilefs用戶,然后啟動服務 [root@centos7 ~]# useradd -r mogilefs # 創建pid文件目錄并修改屬主屬組為mogilefs [root@centos7 ~]# mkdir /var/run/mogilefsd/ -p [root@centos7 ~]# chown -R mogilefs.mogilefs /var/run/mogilefsd/ # 啟動服務 [root@centos7 mogilefs]# su - mogilefs -c "mogilefsd -c /etc/mogilefs/mogilefsd.conf --daemon" su: warning: cannot change directory to /home/mogilefs: No such file or directory # 查看端口7001 [root@centos7 mogilefs]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 25 *:514 *:* LISTEN 0 50 *:3306 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 128 *:7001 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:6010 *:* LISTEN 0 25 :::514 :::* LISTEN 0 128 :::22 :::* LISTEN 0 128 ::1:631 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 ::1:6010 :::*
接下來配置 mogstore節點,
1.編輯配置文件 vim /etc/mogilefs/mogstored.conf如下:
[root@centos7 ~]# vim /etc/mogilefs/mogstored.conf maxconns = 10000 # 最大并發連接數 httplisten = 0.0.0.0:7500 # 監聽端口 mgmtlisten = 0.0.0.0:7501 # 管理端口,探測mogstore的健康狀態 docroot = /data/mogstored # 數據存放位置
2.提供數據存放目錄/data/mogstored,分區,格式化,掛載設備,并修改屬主屬組為mogilefs
[root@centos7 ~]# mkdir -pv /data/mogstored # 添加磁盤dev(生產環境中要把磁盤設備分區,創建文件系統,掛載到此目錄下,這里為了測試創建目錄dev) [root@centos7 ~]# mkdir /data/mogstored/dev{1,2} # 修改屬主屬組為mogilefs [root@centos7 ~]# chown -R mogilefs:mogilefs /data/mogstored/ [root@centos7 mogstored]# ll total 0 drwxr-xr-x 2 mogilefs mogilefs 6 Jan 5 15:52 dev1 drwxr-xr-x 2 mogilefs mogilefs 6 Jan 5 15:52 dev2 # 生產環境中分區,格式化,掛載文件系統,并授權 # fdisk /dev/sdb # mkfs.ext4 /dev/sdb1 # mkdir /mystore/dev1 -pv # mount /dev/sdb1 /mystore/dev1 # chown -R mogilefs.mogilefs /data/mogstored/dev1
3.啟動服務,并查看端口7500,7501
[root@centos7 mogstored]# su - mogilefs -c "mogstored -c /etc/mogilefs/mogstored.conf --daemon" su: warning: cannot change directory to /home/mogilefs: No such file or directory [root@centos7 mogstored]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 25 *:514 *:* LISTEN 0 50 *:3306 *:* LISTEN 0 128 *:7500 *:* LISTEN 0 128 *:7501 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 128 *:7001 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:6010 *:* LISTEN 0 25 :::514 :::* LISTEN 0 128 :::22 :::* LISTEN 0 128 ::1:631 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 ::1:6010 :::*
在節點node2上同樣配置mogstore存儲節點,如下:
1.同樣適用CPAN在線安裝perl相關模塊和mogilefs,存儲節點要解決依賴關系,安裝perl-IO-AIO
[root@centos7 ~]# yum -y install make gcc unzip perl-DBD-MySQL perl perl-CPAN perl-YAML perl-Time-HiRes perl-IO-AIO [root@centos7 ~]# perl -MCPAN -e shell cpan >install App::cpanminus cpan >install MogileFS::Server cpan >install MogileFS::Utils cpan >install IO::AIO cpan >install IO::WrapTie cpan >install Danga::Socket
2.在/etc下創建目錄,并提供mogstore的配置文件mogstored.conf
[root@centos7 ~]# mkdir /etc/mogilefs [root@centos7 ~]# vim /etc/mogilefs/mogstored.conf maxconns = 10000 httplisten = 0.0.0.0:7500 mgmtlisten = 0.0.0.0:7501 docroot = /data/mogstored
3.創建mogilefs用戶,提供數據存放目錄/data/mogstored,分區,格式化,掛載設備,并修改屬主屬組為mogilefs
[root@centos7 ~]# useradd -r mogilefs [root@centos7 ~]# mkdir -pv /data/mogstored/dev{3,4} # 兩個節點設備不能相同,且為小寫 mkdir: created directory ‘/data/mogstored’ mkdir: created directory ‘/data/mogstored/dev3’ mkdir: created directory ‘/data/mogstored/dev4’ [root@centos7 ~]# chown -R mogilefs:mogilefs /data/mogstored/ [root@centos7 ~]# cd /data/mogstored/ [root@centos7 mogstored]# ll total 0 drwxr-xr-x 2 mogilefs mogilefs 6 Jan 5 15:22 dev3 drwxr-xr-x 2 mogilefs mogilefs 6 Jan 5 15:22 dev4
4.啟動服務,查看端口
[root@centos7 ~]# su - mogilefs -c "mogstored -c /etc/mogilefs/mogstored.conf --daemon" su: warning: cannot change directory to /home/mogilefs: No such file or directory [root@centos7 ~]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *:3306 *:* LISTEN 0 128 *:7500 *:* LISTEN 0 128 *:7501 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:6011 *:* LISTEN 0 128 :::22 :::* LISTEN 0 128 ::1:631 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 ::1:6011 :::*
如上,我們就有了一個tracker和兩個mogstore,接下來我們可以在控制節點上使用MogileFS-Utils,進行添加host,device,domain,class等管理操作。
1.使用mogadm命令添加存儲節點mogstore
[root@centos7 ~]# mogadm host add node1 --ip=192.168.1.112 --status=alive --port=7500 [root@centos7 ~]# mogadm host add node2 --ip=192.168.1.113 --status=alive --port=7500 [root@centos7 ~]# mogadm host list node1 [1]: alive IP: 192.168.1.112:7500 node2 [2]: alive IP: 192.168.1.113:7500
2.使用mogadm命令添加存儲節點device,注意,前面掛載的設備必須為小寫dev且個存儲節點名稱不能相同
[root@centos7 ~]# mogadm device add node1 1 --status=alive [root@centos7 ~]# mogadm device add node2 3 --status=alive [root@centos7 ~]# mogadm device add node2 4 --status=alive [root@centos7 ~]# mogadm device list node1 [1]: alive used(G) free(G) total(G) weight(%) dev1: alive 3.674 36.307 39.980 100 node2 [2]: alive used(G) free(G) total(G) weight(%) dev3: alive 0.398 39.582 39.980 100 dev4: alive 0.398 39.582 39.980 100
3.添加domain域或者類class
[root@centos7 ~]# mogadm domain list domain class mindevcount replpolicy hashtype -------------------- -------------------- ------------- ------------ ------- [root@centos7 ~]# mogadm domain add files [root@centos7 ~]# mogadm domain add p_w_picpaths [root@centos7 ~]# mogadm domain list domain class mindevcount replpolicy hashtype -------------------- -------------------- ------------- ------------ ------- files default 2 MultipleHosts() NONE p_w_picpaths default 2 MultipleHosts() NONE # mindevcount:默認最小設備數為2,即默認創建了兩個副本 # replpolicy:復制策略為多主機復制 # hashtype:哈希類型,NOME表示不自定義,使用默認值 [root@centos7 ~]# mogadm class list domain class mindevcount replpolicy hashtype -------------------- -------------------- ------------- ------------ ------- files default 2 MultipleHosts() NONE p_w_picpaths default 2 MultipleHosts() NONE
4.查看檢測狀態
[root@centos7 ~]# mogadm check Checking trackers... # tracker識別OK 127.0.0.1:7001 ... OK Checking hosts... # 主機識別OK [ 1] node1 ... OK [ 2] node2 ... OK Checking devices... # 設備識別OK host device size(G) used(G) free(G) use% ob state I/O% ---- ------------ ---------- ---------- ---------- ------ ---------- ----- [ 1] dev1 39.980 3.734 36.247 9.34% writeable 0.1 [ 2] dev3 39.980 0.432 39.549 1.08% writeable 0.0 [ 2] dev4 39.980 0.432 39.549 1.08% writeable 0.0 ---- ------------ ---------- ---------- ---------- ------ total: 119.941 4.597 115.345 3.83%
5.使用mogupload命令上傳文件
[root@centos7 ~]# mogupload --help # 上傳文件 Usage: /usr/local/bin/mogupload --trackers=host --domain=foo --key='/hello.jpg' --file='./hello.jpg' [root@centos7 ~]# mogupload --trackers=192.168.1.112 --domain=files --key='/fstab.txt' --file='/etc/fstab' [root@centos7 ~]# mogupload --trackers=192.168.1.112 --domain=p_w_picpaths --key='/2.jpg' --file='/root/man.jpg' [root@centos7 ~]# moglistkeys --help # 列出文件 Usage: /usr/local/bin/moglistkeys --trackers=host --domain=foo --key_prefix='bar/' [root@centos7 ~]# moglistkeys --trackers=192.168.1.112 --domain=files /fstab.txt [root@centos7 ~]# moglistkeys --trackers=192.168.1.112 --domain=p_w_picpaths /2.jpg
6.使用mogfileinfo查看文件信息,如下:
[root@centos7 ~]# mogfileinfo --trackers=192.168.1.112 --domain=files --key='/fstab.txt' - file: /fstab.txt class: default devcount: 1 domain: files fid: 2 key: /fstab.txt length: 690 -- http://192.168.1.112:7500/dev1/0/000/000/0000000002.fid #可通過此URL訪問到相應的資源 [root@centos7 ~]# mogfileinfo --trackers=192.168.1.112 --domain=p_w_picpaths --key='/2.jpg' - file: /man.jpg class: default devcount: 1 domain: imgs fid: 3 key: /man.jpg length: 3401017 - http://192.168.1.112:7500/dev1/0/000/000/0000000010.fid
通過URL訪問其資源如下:
注意:
上面實驗可以看到,上傳的文件僅在一個主機設備上存放,實際上應該是兩個節點都存放才對。我從網上查到出錯的原因可能是由于Sys::Syscall這個模塊造成的。我們看到現在此模塊的版本為0.25。我上網搜索其解決辦法,發現如果將此軟件降為0.23版本可能會修復此問題,咱們試試看:
# 編譯之前安裝的版本為 0.25 [root@centos7 Sys-Syscall-0.23]# perl -MSys::Syscall -e 'print $Sys::Syscall::VERSION' 0.25
# 下載源碼包并編譯安裝
wget http://search.cpan.org/CPAN/authors/id/B/BR/BRADFITZ/Sys-Syscall-0.23.tar.gz
tar xf Sys-Syscall-0.23.tar.gz
cd Sys-Syscall-0.23
perl Makefile.PL
make
make test
make install
重啟mogilefsd進程,然后再上傳一個文件,成功解決問題,如下:
[root@centos7 ~]# mogupload --trackers=192.168.1.112 --domain=p_w_picpaths --key='/1.jpg' --file='/root/1.jpg' [root@centos7 ~]# mogfileinfo --trackers=192.168.1.112 --domain=p_w_picpaths --key='/1.jpg' - file: /1.jpg class: default devcount: 2 domain: p_w_picpaths fid: 9 key: /1.jpg length: 31249077 - http://192.168.1.112:7500/dev1/0/000/000/0000000009.fid - http://192.168.1.113:7500/dev3/0/000/000/0000000009.fid
7.使用mogstats指明連接的數據庫,用戶和密碼,查看狀態,如下:
[root@centos7 ~]# mogstats --db_dsn="DBI:mysql:mogdb:host=127.0.0.1" --db_user="moguser" --db_pass="mogpass" --stats="all" Fetching statistics... (all) Statistics for devices... device host files status ---------- ---------------- ------------ ---------- dev1 node1 5 alive dev3 node2 4 alive dev4 node2 1 alive ---------- ---------------- ------------ ---------- Statistics for file ids... Max file id: 9 Statistics for files... domain class files size (m) fullsize (m) -------------------- ----------- ---------- ----------- ------------- files default 2 0 0 p_w_picpaths default 3 32 64 -------------------- ----------- ---------- ----------- ------------- Statistics for replication... domain class devcount files -------------------- ----------- ---------- ---------- files default 2 2 p_w_picpaths default 2 3 -------------------- ----------- ---------- ---------- Statistics for replication queue... status count -------------------- ------------ -------------------- ------------ Statistics for delete queue... status count -------------------- ------------ -------------------- ------------ Statistics for general queues... queue status count --------------- -------------------- ------------ --------------- -------------------- ------------ done
如上,為node1為tracker、mogstore和mysql節點,node2僅為mogstore節點,現在添加node2也為tracker節點,如下:
1.復制node1節點tracker的配置文件/etc/mogilefs/mogilefsd.conf到node2下
[root@centos7 ~]# scp /etc/mogilefs/mogilefsd.conf node2:/etc/mogilefs/mogilefsd.conf
2.在node2節點上編輯配置文件mogilefsd.conf,修改連接數據庫的信息,如下:
3.創建pid文件目錄并賦予權限,然后啟動服務。
[root@centos7 ~]# mkdir /var/run/mogilefsd/ -p [root@centos7 ~]# chown -R mogilefs.mogilefs /var/run/mogilefsd/ [root@centos7 ~]# su - mogilefs -c "mogilefsd -c /etc/mogilefs/mogilefsd.conf --daemon" # 查看端口7001 [root@centos7 ~]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:7500 *:* LISTEN 0 128 *:7501 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 128 *:7001 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:6010 *:* LISTEN 0 128 127.0.0.1:6011 *:* LISTEN 0 128 :::22 :::* LISTEN 0 128 ::1:631 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 ::1:6010 :::* LISTEN 0 128 ::1:6011 :::*
4.使用mogadm查看host,device,domain,并上傳文件,如下:
[root@centos7 ~]# mogadm host list # 查看host node1 [1]: alive IP: 192.168.1.112:7500 node2 [2]: alive IP: 192.168.1.113:7500 [root@centos7 ~]# mogadm device list node1 [1]: alive used(G) free(G) total(G) weight(%) dev1: alive 3.673 36.308 39.980 100 node2 [2]: alive used(G) free(G) total(G) weight(%) dev3: alive 0.399 39.581 39.980 100 dev4: alive 0.399 39.581 39.980 100 [root@centos7 ~]# mogadm domain list domain class mindevcount replpolicy hashtype -------------------- -------------------- ------------- ------------ ------- files default 2 MultipleHosts() NONE p_w_picpaths default 2 MultipleHosts() NONE # 上傳文件 [root@centos7 ~]# mogupload --trackers=192.168.1.113 --domain=p_w_picpaths --key='/2.jpg' --file='/root/2.jpg' [root@centos7 ~]# mogfileinfo --trackers=192.168.1.113 --domain=p_w_picpaths --key='/2.jpg' - file: /2.jpg class: default devcount: 2 domain: p_w_picpaths fid: 10 key: /2.jpg length: 1247365 - http://192.168.1.112:7500/dev1/0/000/000/0000000010.fid - http://192.168.1.113:7500/dev4/0/000/000/0000000010.fid
如上,就是整個分布式文件系統MogileFS安裝部署的整個過程。。。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。