4.4、添加域和类
添加
image
域
# mogadm domain add image
在
image
域中添加
upload
类
存储份数为
2
# mogadm class add image upload �Cmindevcount=2
4.5、查看域和tracker节点
# mogadm domain list
domain class mindevcount replpolicy
-------------------- -------------------- ------------- ---------------------------------------------------------
image default 2 MultipleHosts()
image upload 2 MultipleHosts()
# mogadm �Ctrackers=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.6、mogadm 详细参数
# 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 �Chttp://github.com/eml/java-mogilefs
Ruby �C http://seattlerb.rubyforge.org/mogilefs-client/
PHP �C http://projects.usrportage.de/index.fcgi/php-mogilefs
Python �C 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 -
这里的
�C
号不能却少,否则会出现语法错误
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.3、Mount 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