mogilefs分布式文件存储
MogileFS是一个开源的分布式文件存储系统,由LiveJournal旗下的Danga Interactive公司开发。Danga团队开发了包括 Memcached、MogileFS、Perlbal 等多个知名的开源项目。目前使用MogileFS 的公司非常多,如日本排名先前的几个互联公司及国内的yupoo(又拍)、digg、豆瓣、1号店、大众点评、搜狗和安居客等,分别为所在的组织或公司管理着海量的图片。
MogileFS由3个部分组成:
(1) server:主要包括mogilefsd和mogstored两个应用程序。mogilefsd实现的是tracker,它通过数据库来保存元数据信息,包括站点domain、class、host等;mogstored是存储节点(store node),它其实是个WebDAV服务,默认监听在7500端口,接受客户端的文件存储请求。在MogileFS安装完后,要运行mogadm工具将所有的store node注册到mogilefsd的数据库里,mogilefsd会对这些节点进行管理和监控。
(2) utils(工具集):主要是MogileFS的一些管理工具,例如mogadm等。
(3) 客户端API:MogileFS的客户端API很多,例如Perl、PHP、Java、Python等,用这个模块可以编写客户端程序,实现文件的备份管理功能等。
hosts
a----192.168.20.6(Tnginx,mariadb)
a1-----192.168.20.2(tracker,mogstore)
a2-----192.168.20.3(mogstore)
a3-----192.168.20.4(mogstore) 系统要求:centos6或7
主机a1,a2,a3:
.解决依赖关系
yum -y install epel-release
yum install perl-Sys-Syslog perl-Net-Netmask perl-IO-AIO
.安装 mongilefs
.
├── MogileFS-Server-2.46-.el6.noarch.rpm
├── MogileFS-Server-mogilefsd-2.46-.el6.noarch.rpm
├── MogileFS-Server-mogstored-2.46-.el6.noarch.rpm
├── MogileFS-Utils-2.19-.el6.noarch.rpm
├── Perlbal-1.78-.el6.noarch.rpm
├── Perlbal-doc-1.78-.el6.noarch.rpm
├── perl-Danga-Socket-1.61-.el6.rf.noarch.rpm
├── perl-MogileFS-Client-1.14-.el6.noarch.rpm
├── perl-Net-Netmask-1.9015-.el6.noarch.rpm
└── perl-Perlbal-1.78-.el6.noarch.rpm yum install *.rpm
.数据库用户授权
主机a:
grant all on mogilefs.* to mogile@'192.168.20.%' indentified by 'yunshipei';
grant all on *.* to mogile@'192.168.20.%' indentified by 'yunshipei';
.设定数据库
主机a1:
mogdbsetup --dbhost=192.168.20.6 --dbname=mogilefs --dbuser=mogile --dbpass=yunshipei .修改主配置文件
主机a1:
vim mogilefsd.conf
# Enable daemon mode to work in background and use syslog
daemonize =
# Where to store the pid of the daemon (must be the same in the init script)
pidfile = /var/run/mogilefsd/mogilefsd.pid
# Database connection information
db_dsn = DBI:mysql:mogilefs:host=192.168.20.6
db_user = mogile
db_pass = yunshipei
# IP:PORT to listen on for mogilefs client requests
listen = 0.0.0.0:
# Optional, if you don't define the port above.
conf_port =
# Number of query workers to start by default.
query_jobs =
# Number of delete workers to start by default.
delete_jobs =
# Number of replicate workers to start by default.
replicate_jobs =
# Number of reaper workers to start by default.
# (you don't usually need to increase this)
reaper_jobs =
# Number of fsck workers to start by default.
# (these can cause a lot of load when fsck'ing)
#fsck_jobs =
# Minimum amount of space to reserve in megabytes
# default:
# Consider setting this to be larger than the largest file you
# would normally be uploading.
#min_free_space =
# Number of seconds to wait for a storage node to respond.
# default:
# Keep this low, so busy storage nodes are quickly ignored.
#node_timeout =
# Number of seconds to wait to connect to a storage node.
# default:
# Keep this low so overloaded nodes get skipped.
#conn_timeout =
# Allow replication to use the secondary node get port,
# if you have apache or similar configured for GET's
#repl_use_get_port =
.下创建数据存放位置,并把属主,属组设好
主机a1,a2,a3:
mkdir /mogfs/dev1 //设备必须唯一,a2为dev2,a3为dev3
chown -R mogilefs.mogilefs /mogfs .编辑store配置文件
主机a1,a2,a3:
maxconns =
httplisten = 0.0.0.0:
mgmtlisten = 0.0.0.0:
docroot = /mogfs //目录级别
pidfile = /var/run/mogilefsd/mogstored.pid 脚本文件需修改,详见文档最后
.mogile check(tracker,hosts)
mogadm --trackers=192.168.20.2: check
.添加主机
mogadm --trackers=192.168.20.2: host add 192.168.20.2 --status=alive
mogadm --trackers=192.168.20.2: host add 192.168.20.3 --status=alive
mogadm --trackers=192.168.20.2: host add 192.168.20.4 --status=alive
.添加设备
mogadm --trackers=192.168.20.2: device add 192.168.20.2
mogadm --trackers=192.168.20.2: device add 192.168.20.3
mogadm --trackers=192.168.20.2: device add 192.168.20.4
创建domain
mogadm domain add files
mogadm domain add images
创建class
mogadm class add images jpeg
mogadm class add files plaintext --replpolicy='MultipleHosts(3)' .查看主机,设备列表,domain
mogadm --trackers=192.168.20.2: host list
mogadm --trackers=192.168.20.2: device list
mogadm --trackers=192.168.20.2: domain list .管理
mogadm --tracker=192.168.20.2: host mark 192.168.20.3 alive //切换主机状态
mogupload --trackers=192.168.20.2 --domain=images --key='hello.png' --file='./QQ图片20170313153251.png' --class=png //上传文件
mogfileinfo --tracker=192.168.20.2: --domain=images --key='hello.png' //查看keys信息
mogdelete --trackers=192.168.20.2 --domain=images --key='a.png' //删除key
moglistkeys 查看keys .tengine反向代理trackers
)tengine安装
、解决依赖关系
# nginx 的mogilefs模块的官方文档地址:
http://www.grid.net.ru/nginx/mogilefs.en.html # yum groupinstall "Development Tools" "Server Platform Deveopment"
# yum install openssl-devel pcre-devel 首先添加用户nginx,实现以之运行nginx服务进程:
# groupadd -r nginx
# useradd -r -g nginx nginx 接着开始编译和安装:
# ./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--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 \
--with-debug \
--add-module=
# make && make install )反向代理mogile_trackers
upstream trackers{
server 192.168.20.2:;
server 192.168.20.3:;
check interval= rise= fall= timeout= ;
}
server {
listen ;
server_name localhost; location /images/ {
mogilefs_tracker trackers;
mogilefs_domain images;
mogilefs_methods GET;
mogilefs_noverify on;
mogilefs_pass {
proxy_pass $mogilefs_path;
proxy_hide_header Content-Type;
proxy_buffering off;
}
}
location /status {
check_status;
access_log off;
}
}
} mogstored脚本
#!/bin/bash
# Author: MageEdu <linuxedu@foxmail.com>
# mogstored - Startup script for the MogileFS storage
#
# chkconfig: -
# description: MogileFS storage
# processname: mogstored
# config: /etc/mogilefs/mogstored.conf
# pidfile: /var/run/mogilefsd/mogstored.pid # Source function library.
. /etc/rc.d/init.d/functions # Path to the apachectl script, server binary, and short-form for messages.
lockfile=${LOCKFILE-/var/lock/subsys/mogstored}
pilfile=/var/run/mogilefs/mogstored.pid
RETVAL= configfile='/etc/mogilefs/mogstored.conf' prog=$(which mogstored) start() {
ulimit -n
echo -n $"Starting mogstored"
su - mogilefs -c "$prog -c $configfile --daemon" &> /dev/null
RETVAL=$?
[ $RETVAL = ] && success && touch ${lockfile} && echo $(pid of mogstored) >> $[pidfile] || failure
echo
return $RETVAL
} stop() {
echo -n $"Stopping mogstored"
netstat -nlp|grep "mogstored"|grep -v grep|awk '{print $7}'|awk -F"/" '{print $1}'|xargs kill -
RETVAL=$?
[ $RETVAL = ] && success && rm -f ${lockfile} || failure
echo
} reload() {
echo -n $"Reloading mogstored: "
killall mogstored -HUP
RETVAL=$?
[ $RETVAL = ] && success || failure
echo
} case "$1" in
start)
start
;;
stop)
stop
;;
status)
status mogstored
RETVAL=$?
;;
restart)
stop
sleep
mogilefs分布式文件存储的更多相关文章
- .Net平台下,分布式文件存储的实现
遇到的问题 对于Web程序,使用一台服务器的时候,客户端上传的文件一般也都是存储在这台服务器上.但在集群环境中就行不通了,如果每个服务器都存储自己接受到的文件,就乱套了,数据库中明明有这个附件的记录, ...
- 【网络爬虫入门05】分布式文件存储数据库MongoDB的基本操作与爬虫应用
[网络爬虫入门05]分布式文件存储数据库MongoDB的基本操作与爬虫应用 广东职业技术学院 欧浩源 1.引言 网络爬虫往往需要将大量的数据存储到数据库中,常用的有MySQL.MongoDB和Red ...
- 分布式文件存储:FastDFS简单使用与原理分析
引言 FastDFS 属于分布式存储范畴,分布式文件系统 FastDFS 非常适合中小型项目,在我接手维护公司图片服务的时候开始接触到它,本篇文章目的是总结一下 FastDFS 的知识点. 用了 2 ...
- 分布式文件存储数据库 MongoDB
MongoDB 简介 Mongo 并非芒果(Mango)的意思,而是源于 Humongous(巨大的:庞大的)一词. MongoDB 是一个基于分布式文件存储的 NoSQL 数据库.由 C++ 语言编 ...
- AppBoxFuture(五): 分布式文件存储-Store Everything
本来本篇是想介绍前端组件化开发用户界面,发现框架还未实现文件存储,原本计划是后续设计开发的,索性把计划提前,所以本篇将介绍基于Raft实现分布式的文件存储引擎. 一. 实现思路 既然是分布式存 ...
- (转) 分布式文件存储FastDFS(一)初识FastDFS
http://blog.csdn.net/xingjiarong/article/details/50559849 一.FastDFS简介 FastDFS是一款开源的.分布式文件系统(Distribu ...
- 分布式文件存储FastDFS(一)初识FastDFS
一.FastDFS简单介绍 FastDFS是一款开源的.分布式文件系统(Distributed File System),由淘宝开发平台部资深架构师余庆开发.作为一个分布式文件系统,它对文件进行管理. ...
- Centos7部署分布式文件存储(Fastdfs)
目录 FastDFS介绍 楼主目标:前可H5撩妹,后可Linux搞运维 环境:Centos7 软件: 软件链接: 安装前所有准备,上传软件到Centos7上的/opt的目录下 安装依赖软件和类库(安装 ...
- 分布式文件存储FastDFS(七)FastDFS配置文件具体解释
配置FastDFS时.改动配置文件是非常重要的一个步骤,理解配置文件里每一项的意义更加重要,所以我參考了大神的帖子,整理了配置文件的解释.原帖例如以下:http://bbs.chinaunix.net ...
随机推荐
- WPF中DATAGRID自定义验证(包含BINDINGGROUP)
DataGrid在Wpf中的应用是十分广泛的,当你需要表中的信息稍详细的显示出来时,或者我们需要进行某些数据输入时,都有可能采用DataGrid.当然对信息的显示,我们不需要进行验证,但当我们将Dat ...
- C#定时检測子线程是否已经完毕
C#定时检測子线程是否已经完毕 class Program { static void Main(string[] args) { //主线程中启动一个支线程,运行doSomething这种一个方法. ...
- Java知识点梳理——泛型
1.定义:泛型的本质是参数化类型,就是将类型由原来的具体的类型参数化,这种参数类型可以用在类.接口.方法中,分别称为泛型类.泛型接口.泛型方法: 2.泛型类:泛型类的声明和非泛型类的声明类似,除了在类 ...
- Mybatis的配置文件和映射文件详解
一.Mybatis的全局配置文件 1.SqlMapConfig.xml是mybatis的全局配置文件,配置内容如下: properties(属性) settings(全局配置参数) typeAlias ...
- Python爬虫-- PyQuery库
PyQuery库 PyQuery库也是一个非常强大又灵活的网页解析库,PyQuery 是 Python 仿照 jQuery 的严格实现.语法与 jQuery 几乎完全相同,所以不用再去费心去记一些奇怪 ...
- segnet 编译与测试
segnet 编译与测试参考:http://sunxg13.github.io/2015/09/10/caffe/http://m.blog.csdn.net/lemianli/article/det ...
- 使用appium和testng实现Android自动截图
简单介绍 需求场景是:当测试安卓应用的脚本得到失败结果时,对当前手机屏幕截图,便于查找问题. 实现方式是:1)定义一个父类UITest,作为所有测试类的父类.在父类中UITest中定义一个截图的方法, ...
- Java for LeetCode 109 Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height bala ...
- linux下 python源码包解压报错
执行下面的命令 tar -zvxf Python.3.6.5.tgz 报错 gzip: stdin: not in gzip format tar: Child returned status 1 t ...
- ajax进度条
.graph { width: 400px; height: 25px; border: 1px solid #f8b3d0; } .bar { background-color: #ffe7f4; ...