加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

【MogileFS-2.44】 安装与配置

发布时间:2020-12-16 00:43:09 所属栏目:大数据 来源:网络整理
导读:目录 一、MogileFS 介绍 1.1、环境 二、MogileFS 安装 2.1、Mysql安装 2.2、安装MogileFS 相关Perl模块 2.3、MogileFS Server 安装 2.4、MogileFS Storage 存储节点安装 三、MogileFS 配置 3.1、mysql数据库设置 3.2、创建mysql连接 3.3、创建Tracker配置文
目录
一、MogileFS 介绍
1.1、环境
二、MogileFS 安装
2.1、Mysql安装
2.2、安装MogileFS 相关Perl模块
2.3、MogileFS Server 安装
2.4、MogileFS Storage 存储节点安装
三、MogileFS 配置
3.1、mysql数据库设置
3.2、创建mysql连接
3.3、创建Tracker配置文件
3.4、MogileFS 启动与停止
3.5、MogileFS Storage 节点配置
3.6、启动MogileFS Storage 节点
四、管理配置MogileFS
4.1、添加Storeage节点到Tracker
4.2、在存储节点中添加设备
4.3、在存储节点中使设备失效
4.4、添加域和类
4.5、查看域和tracker节点
4.6、mogadm 详细参数
五、MogileFS PHP扩展模块
5.1、安装MogileFS PHP扩展
5.2、添加MogileFS PHP模块
5.3、MogileFS 客户端 API 调用资料
六、MogileFS Nginx 模块安装
6.1、下载Nginx_mogilefs_module
6.2、添加Nginx_mogilefs_module模块
6.3、配置Nginx_mogilefs_module 模块
七、Mogtool 工具创建文件和读取文件内容
7.1、创建文件
7.2、读取文件
八、FUSE API 挂载 MogileFS文件系统
8.1、安装操作系统相应fuse支持
8.2、安装Perl Fuse支持
8.3、Mount MogileFS文件系统
8.4、查看MogileFS系统文件
九、MogileFS参考资料

一、MogileFS 介绍

MogileFS 是一个开源的分布式文件系统,用于组建分布式文件集群,由 LiveJournal 旗下 Danga Interactive 公司开发, Danga 团队开发了包括 Memcached MogileFS Perlbal 等不错的开源项目: ( 注: Perlbal 是一个强大的 Perl 写的反向代理服务器 ) 。目前国内使用 MogileFS 的有图片托管网站 yupoo 等。
官方的介绍网站:
http://www.danga.com/mogilefs/
Google Code 上的信息
http://code.google.com/p/mogilefs/
详细内容请见 : http://www.tech-q.cn/thread-12293-1-1.html
?

1.1、环境

MogileFS 相关服务器
IP
系统
Tracker ( 调度器 )
192.168.0.11
Centos 5.5 x32
Storage Nodes 1 ( 存储节点 1)
192.168.0.22
Centos 5.5 x32
Storage Nodes 2 ( 存储节点 2)
192.168.0.33
Centos 5.5 x32
Mysql
192.168.0.44
Centos 5.5 x32

?
?

2.1Mysql安装

请参考 http://www.chinasa.net/archives/17/

2.2、安装MogileFS 相关Perl模块

首先要安装 perl
# yum install perl
以下 Perl 模块均可使用以下命令进行安装 , 如安装 Sys::Syscall 模块。
# cpan –I Sys::Syscall
Sys::Syscall
Danga::socket
?BSD::Resource
common::sense
IO::AIO
? Perlbal
ExtUtils::MakeMaker
Test::Simple
DBI
Net::Netmask
IO::WrapTie
MogileFS::Client
DBD::mysql
MogileFS::Utils
Gearman::Client
Gearman::server
?
: 存储节点服务器不用安装 DBD::mysql 模块
以上 Perl 模块也可到 http://search.cpan.org/ 网站上下载安装,如安装 Sys::Syscall 模块。
?
# wget http://search.cpan.org/CPAN/authors/id/B/BR/BRADFITZ/Sys-Syscall-0.23.tar.gz
# tar zxvf Sys-Syscall-0.23.tar.gz
# cd Sys-Syscall-0.23
# perl Makefile.PL
# make
# make install
?

2.3MogileFS Server 安装

# wget http://search.cpan.org/CPAN/authors/id/D/DO/DORMANDO/MogileFS-Server-2.44.tar.gz
# tar zxvf MogileFS-Server-2.44.tar.gz
# cd MogileFS-Server-2.44
# perl Makefile.PL
# make
# make install

2.4MogileFS Storage 存储节点安装

参考 2.2 2.3 DBD::mysql 可不用安装

三、MogileFS 配置

3.1mysql数据库设置

mysql> create database mogilefs;
mysql> grant all on mogilefs.* to 'mogile'@'%' identified '000000'
mysql> flush privileges;

3.2、创建mysql连接

# /usr/lib/mogdbsetup --dbhost=192.168.0.144 --dbname=mogilefs --dbuser=mogile --dbpassword=000000

3.3、创建Tracker配置文件

# vi /etc/mogliefs/mogilefsd.conf
内容如下:
db_dsn = DBI:mysql:mogilefs:host=192.168.0.144;port=3306;mysql_connect_timeout=5
db_user = mogile
db_pass = 000000
conf_port = 7001
listener_jobs = 5
node_timeout = 5
rebalance_ignore_missing = 1
?

3.4MogileFS 启动与停止

由于 mogilefs 不能以 root 用户运行 , 创建 mogile 用户
# Useradd mogile –s /sbin/nologin
# su mogile –c “mogilefsd -c /etc/mogilefs/mogilefsd.conf --daemon”
使用 pkill mogilefsd 来停止 mogilefs 服务

3.5MogileFS Storage 节点配置

创建 Storage 配置文件
vi /etc/mogilefs/mogstored.conf
内容如下 :
httplisten=0.0.0.0:7500
mgmtlisten=0.0.0.0:7501
docroot=/data/mogdata

3.6、启动MogileFS Storage 节点

Mogstored –daemon
使用 pkill mogstored 来停止 mogstored 服务

四、管理配置MogileFS

4.1、添加Storeage节点到Tracker

# mogadm --trackers=192.168.0.11:7001 host add mog_store_22 --ip= 192.168.0.22 --port=7500 --status=alive

4.2、在存储节点中添加设备

# mogadm --trackers=192.168.0.11:7001 device add ?mog_store_22 ?101
/data/mogdata/ 目录中创建 dev201 文件夹

4.3、在存储节点中使设备失效

# mogadm device mark mog_store_22 dev101 dead

4.4、添加域和类

添加 image
# mogadm domain add image
image 域中添加 upload ? 存储份数为 ?2
# mogadm class add image upload –mindevcount=2

4.5、查看域和tracker节点

# mogadm domain list
?domain???????????????class????????????????mindevcount??replpolicy?
-------------------- -------------------- ------------- ---------------------------------------------------------
?image???????????????default????????????????????2???????MultipleHosts()
?image???????????????upload????????????????????2???????MultipleHosts()
?
# mogadm –trackers=192.168.0.11:7001 check
Checking trackers...
??127.0.0.1:7001 ... OK
?
Checking hosts...
??[ 1] mog_store_22 ... OK
??[ 2] mog_store_33 ... OK
?
Checking devices...
??host device?????????size(G)????used(G)????free(G)??use%???ob state???I/O%
??---- ------------ ---------- ---------- ---------- ------ ---------- -----
??[ 1] dev101??????????17.354??????9.753??????7.601?56.20%??writeable???0.0
??[ 2] dev201??????????13.456??????1.491?????11.965?11.08%??writeable???0.0
??[ 2] dev202???????????8.973??????2.550??????6.423?28.42%??writeable???0.0
??---- ------------ ---------- ---------- ---------- ------
?????????????total:????39.782?????13.794?????25.988??34.67%

4.6mogadm?详细参数

#??mogadm
Usage:??(enter any command prefix,leaving off options,for further help)
?
??mogadm check?????????????????????Check the state of the MogileFS world.
??mogadm stats?????????????????????Show MogileFS system statistics.??(DEPRECIATED: use mogstats instead)
??mogadm host ...
?????????host add ...??????????????Add a host to MogileFS.
?????????host delete ...???????????Delete a host.
?????????host list?????????????????List all hosts.
?????????host mark ...?????????????Change the status of a host.??(equivalent to 'modify --status')
?????????host modify ...???????????Modify a host's properties.
??mogadm device ...
?????????device add ...????????????Add a device to a host.
?????????device list ...???????????List all devices,for each host.
?????????device mark ...???????????Mark a device as {alive,dead,down,drain,readonly}
?????????device modify ...?????????Modify a device's properties.
?????????device summary ...????????List the summary of devices,for each host.
??mogadm domain ...
?????????domain add ...????????????Add a domain (namespace)
?????????domain delete ...?????????Delete a domain.
?????????domain list???????????????List all hosts.
??mogadm class ...
?????????class add ...?????????????Add a file class to a domain.
?????????class delete ...??????????Delete a file class from a domain.
?????????class list????????????????List all classes,for each domain.
?????????class modify ...??????????Modify properties of a file class.
??mogadm slave ...
?????????slave add ...?????????????Add a slave node for store usage
?????????slave delete ...??????????Delete a slave node for store usage
?????????slave list????????????????List current store slave nodes.
?????????slave modify ...??????????Modify a slave node for store usage
??mogadm fsck ...
?????????fsck clearlog?????????????Clear the fsck log
?????????fsck printlog?????????????Display the fsck log
?????????fsck reset ...????????????Reset fsck position back to the beginning
?????????fsck start????????????????Start (or resume) background fsck
?????????fsck status???????????????Show fsck status
?????????fsck stop?????????????????Stop (pause) background fsck
?????????fsck taillog??????????????Tail the fsck log
??mogadm settings ...
?????????settings list?????????????List all server settings
?????????settings set ...??????????Set server setting 'key' to 'value'
?
? ?

五、MogileFS PHP扩展模块

5.1、安装MogileFS PHP扩展

# svn checkout? http://svn.usrportage.de/php-mogilefs/trunk
# cd trunk
# phpize
# ../configure --with-php-config=/opt/php/bin/php-config
# make
# make install

5.2、添加MogileFS PHP模块

修改 /opt/php/etc/php.ini 配置文件,添加以下内容:
?extension=mogilefs.so
重启 web 服务器 , 使用 phpinfo() 函数可看见 mogilefs 已经被加载,如下图所示:

5.3 MogileFS? 客户端?API? 调用资料
JAVA –http://github.com/eml/java-mogilefs
Ruby – http://seattlerb.rubyforge.org/mogilefs-client/
PHP – http://projects.usrportage.de/index.fcgi/php-mogilefs
Python – http://www.albany.edu/~ja6447/mogilefs.py

六、MogileFS Nginx?模块安装

安装了 Nginx_mogilefs_module? 可使用 Nginx 直接读取 Mogilefs 文件系统里的文件。
配置文档请看 :? http://www.grid.net.ru/nginx/mogilefs.en.html

6.1、下载Nginx_mogilefs_module

# wget http://www.grid.net.ru/nginx/download/nginx_mogilefs_module-1.0.4.tar.gz

6.2、添加Nginx_mogilefs_module模块

# tar zxvf nginx_mogilefs_module-1.0.4.tar.gz
# ./configure --prefix=/opt/nginx --add-module=/data/mfs/nginx_mogilefs_module-1.0.4
# make
# make install

6.3、配置Nginx_mogilefs_module?模块

nginx 配置文件中加入以下内容 :
?server {
?? ? ? ?listen ? ? ? 80;
?? ? ? ?server_name ?img.test.com;
?? ? ? ?index index.html;?? ?
?? ? ? ?location / {
?? ? ? ? ? ? ? ?mogilefs_tracker 192.168.0.11:7001;
?? ? ? ? ? ? ? ?mogilefs_domain image;
?? ? ? ?mogilefs_pass {
?? ? ? ? ? ? ? proxy_pass $mogilefs_path;
?? ? ? ? ? ? ? ?proxy_hide_header Content-Type;
?? ? ? ? ? ? ? ?proxy_buffering off;
?
?? ? ? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ?}
?
注: mogilefs_domain image? 这里的 image 就是 mogilefs 中创建的域
?
?

七、Mogtool?工具创建文件和读取文件内容

7.1、创建文件

如将 /data/up.txt 文件创建到 image 域中 upload/up.txt 文件。命令如下 :
# mogtool --trackers=192.168.0.11:7001 --domain=image inject /data/up.txt??"upload/up.txt"
?
:/data/up.txt?? 为本地系统文件
???Upload/up.txt? mogilefs 文件内文件
???Mogilefs 文件系统中没有目录概念,将创建的文件名以 upload/up.txt 来代替。

7.2、读取文件

# mogtool --trackers=192.168.0.11:7001 --domain=image extract upload/up.txt -
Fetching piece 1...
????????Trying http://192.168.0.22:7500/dev101/0/000/000/0000000001.fid...
Wide character in print at /usr/bin/mogtool line 1285,<Sock_192.168.0.11:7001> line 1.
up file txt
?
: upload/up.txt -?? 这里的 ?–? 号不能却少,否则会出现语法错误
http://192.168.0.22:7500/dev101/0/000/000/0000000001.fid ? upload/up.txt 文件的实际地址
up file txt upload/up.txt 文件内容

八、FUSE API?挂载?MogileFS文件系统

8.1、安装操作系统相应fuse支持

yum install fuse fuse-devel fuse-libs

8.2、安装Perl Fuse支持

cpan -i FUSE::Client
cpan -i FUSE::Server
cpan -i FUSE::Fuse
: 如安装过程中提示却少模块,就安装相应模块。
?

8.3Mount MogileFS文件系统

下载 http://www.spicylogic.com/allenday/blog/2008/07/14/mogilefs-fuse-bigfile-support/ 脚本,如文件名为 ?fuse.pl
MogileFS 文件系统挂载到 /mnt 目录下。命令如下 :
# perl fuse.pl /mnt &

8.4、查看MogileFS系统文件

# df -h
Filesystem????????????Size??Used Avail Use% Mounted on
/dev/hda2??????????????19G??9.8G??7.7G??57% /
/dev/hda1??????????????99M???17M???78M??18% /boot
tmpfs?????????????????506M?????0??506M???0% /dev/shm
/dev/fuse????????????????2?????0?????2???0% /mnt
: 这里挂载 MogileFS? 文件系统到 ?/mnt? 下,文件大小显示 ?2, 这里不是很清楚,希望大家多研究。
# ls /mnt/
1111.jpg??1112.jpg??upload/up.txt
这样使用起来比较直观,操作文件就与本地文件系统一样。

九、MogileFS参考资料

http://www.admindigest.com/4/
http://www.tech-q.cn/thread-12293-1-1.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读