UE4做购物网站,建设营销型网站价格,策划是做什么的,水果电子商务网站建设规划书一#xff0c;简介 MogileFS是一款开源的分布式文件存储系统#xff0c;由LiveJournal旗下的Danga Interactive公司开发。Danga团队开发了包括 Memcached、MogileFS、Perlbal 等多个知名的开源项目。目前MogileFS的日益成熟使用此解决方法的公司越来越多#xff0c;例如日… 一简介 MogileFS是一款开源的分布式文件存储系统由LiveJournal旗下的Danga Interactive公司开发。Danga团队开发了包括 Memcached、MogileFS、Perlbal 等多个知名的开源项目。目前MogileFS的日益成熟使用此解决方法的公司越来越多例如日本的又拍、digg、中国的豆瓣、1号店、大众点评、搜狗和安居客等分别为所在的组织或公司管理着海量的图片。和传统网络存储不一样的是分布式文件系统是将数据分散存储至多台服务器上而网络文件系统往往是将所有的数据存放在一起存储服务器将成为系统可用性的瓶颈不能满足大规模的存放所有数据需求。分布式文件系统采用可扩展的系统结构利用多台存储设备分别存储分担服务器负荷利用位置服务器定位存储信息因此不仅能够提升系统性能同时还易于扩展。 二、实现组件 MogileFS主要有三个部分组成①server端包括两个部分mogilefsd和mogstored两个应用程序tracker是mogilefsd的实现方式它通过数据库来保证元数据信息比如站点的domian、class、host等mogstored则为存储节点默认监听7500端口接受客服端的文件存储请求在MogileFS安装完后要运行mogadm工具将所有的store node注册到mogilefsd的数据库里mogilefsd会对这些节点进行管理和监控。②utils工具集主要是MogileFS的一些管理工具如mogadm等。③客服端APIMogileFS的API接口很多常用的的时间方式有php,perl,python,java等使用这些语言可进行编写客服端程序实现文件的备份管理功能。 三、MogileFS的特性及原理 MogileFS特性 1.应用层服务不需要使用和兴组件 2.无单点故障tracker为跟踪点mogstored为存储节点mysql为储存元数据节点建议使用MySQL做高可用 3.传输中立无特殊协议可用通过nfs和http实现通信 4.简单的命名空间没有目录直接存储在存储空间上通过域来实现不共享任何数据 MogileFS工作原理MogileFS主要由mogilefsd和mogstored两应用程序提供服务tracker节点借助数据库保存各个节点文件的元数据信息保存每个域中所哟的存储位置分布用于实现快速定位同时监控各个节点通知客户端存储区域位置并指挥storaged节点复制数据副本进程名为mogilefsd监听与7001端口。storage节点为实际存放文件的地方存储节点可以是http服务器及其其他web服务storage节点可自动维护键值的对应关系storage节点前端可使用nginx进行反代此时需要nginx-mogilefs-module-master模块此服务监听与7501端口进程名为mogstored.一个域中的键值是唯一的一个mogilefs可以有多个域域可以有多个存储设备每个设备都有数据的容器称之为domain.每个存储节点为一个主机host一个主机上可以有多个存储设备每个设备有id号用来定位。复制的最小单元为class,文件属性管理定义文件存储在不同的设备上的份数。 四、MogileFS安装及其配置实现 安装说明此实验可以仅适用两台服务进行一台服务即当做server端又当做存储节点同时还是mysql服务器在每台服务器上部署tracker管理并监控节点。#在两服务器上均安装如下rpm包
yum -y install per-IO-AIO #mogilefsd和mogstored依赖于此包先解决依赖关系。
yum -y install MogileFS-Server-2.46-2.el6.noarch.rpm #安装sever端
yum -y install MogileFS-server-mogilefsd-2.46-2.el6.noarch.rpm #安装mogilefsd
yum -y install MogileFS-Server-mogstored-2.46-2.rl6.noarch.rpm #安装mogstored 创建数据库及授权修改相应的配置文件grant all privileges on mogdb.* to moguser127.0.0.1 identified by pass;
grant all privileges on mogdb.* to moguserlocalhost identified by pass;
flush privileges;
#修改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
# Database connection information
db_dsn DBI:mysql:mogdb:host127.0.0.1 #修改为上面授权的账号密码及其主机
db_user moguser #修改为上面授权的账号密码及其主机
db_pass pass #修改为上面授权的账号密码及其主机
# IP:PORT to listen on for mogilefs client requests
listen 0.0.0.0:7001 #其他参数可根据自己需求做相应的修改
# Optional, if you dont 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 dont usually need to increase this)
reaper_jobs 1
# Number of fsck workers to start by default.
# (these can cause a lot of load when fscking)
#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 GETs
#repl_use_get_port 1
#mogstored配置文件一般无需修改自行根据业务需求做决定
maxconns 10000
httplisten 0.0.0.0:7500
mgmtlisten 0.0.0.0:7501
docroot /data/mogstored#将上诉配置考别一份至其他主机并且启动服务安装后默认在Init.d下有启动脚本
service mogilefsd start
service mogstored start
[rootcentos6 mogilefs]# ss -tnl |grep *.7.* #默认mogilefsd监听7001mogstored监听7501及其7501
LISTEN 0 128 *:7500 *:*
LISTEN 0 128 *:7501 *:*
LISTEN 0 128 *:7001 *:*
[rootnode mogilefs]#
#设置数据库存储元数据
mogdbsetup --dbhost127.0.0.1 --dbpasspass
mogdbsetup --dbnamemogdb --dbusermoguser --dbhost127.0.0.1 --dbpasspass
mogadm host add 10.1.100.1 --ip10.1.100.1 --port7500 --statusalive #添加hoststoraged
mogadm domain add files #添加域
mogadm domain add p_w_picpaths [rootcentos6 ~]# mogstats --db_dsnDBI:mysql:mogdb:hostlocalhost --db_usermoguser --db_passpass --statsall
Fetching statistics... (all)Statistics for devices... #表示此storage设备存活 device host files status---------- ---------------- ------------ ----------dev1 10.1.100.1 2 alive dev3 10.1.100.2 1 alivedev4 10.1.100.2 1 alive---------- ---------------- ------------ ----------Statistics for file ids...Max file id: 9Statistics for files... #添加的域显示结果domain class files size (m) fullsize (m)-------------------- ----------- ---------- ----------- -------------files default 1 0 0p_w_picpaths default 1 0 0-------------------- ----------- ---------- ----------- -------------Statistics for replication... #默认的类示结果domain class devcount files-------------------- ----------- ---------- ----------files default 2 1p_w_picpaths default 2 1-------------------- ----------- ---------- ----------Statistics for replication queue...status count-------------------- -------------------------------- ------------Statistics for delete queue...status count-------------------- -------------------------------- ------------Statistics for general queues...queue status count--------------- -------------------- --------------------------- -------------------- ------------done
[rootnode ~]#
[rootnode~]# mogupload --trackers10.1.100.1 --domainfiles --key/issue --file/etc/issue #上传文件至files域内指明可Key和上传的文件目录
[rootnode ~]# moglistkeys --trackers10.1.100.1 --domainfiles #显示域内文件
/fstab.txt
/issue
[rootnode ~]# mogfetch --trackers10.1.100.1 --domainfiles --key/issue --file/tmp/issue #下载域内文件至某目录
[rootnode ~]# ll /tmp/issue
-rw-r--r--. 1 root root 47 11月 25 16:48 /tmp/issue
-bash: ogfileinfo: command not found
[rootnode2 ~]# mogfileinfo --tracker10.1.100.1 --domainfiles --key/fstab.txt
- file: /fstab.txtclass: defaultdevcount: 2domain: filesfid: 5key: /fstab.txtlength: 1115-http://10.1.100.2:7500/dev4/0/000/000/0000000005.fid #可通过此URL访问到相应的资源-http://10.1.100.1:7500/dev1/0/000/000/0000000005.fid #可通过此URL访问到相应的资源
[rootnode2 ~]# 实验结果图示 五、实战nginx前端反代mogfilefs及负载均衡 要求说明在前期那配置nginx做反代将用户的请求调度至后端的MogileFS此实验依赖于nginx-mogilefs-module模块需在编译时加上此模块。#实战配置如下所示
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;#log_format main $remote_addr - $remote_user [$time_local] $request # $status $body_bytes_sent $http_referer # $http_user_agent $http_x_forwarded_for;#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;#upstream mogtrackers { #定义一个upstream组server 10.1.100.1:7001;server 10.1.100.2:7001;}server {listen 80;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;}location /p_w_picpaths/ {mogilefs_tracker mogtrackers; #在此调用此mogtrackers即可实现反代至mogilefs后端mogilefs_domain p_w_picpaths; #域为p_w_picpaths域 mogilefs_methods get; #请求的方法为getmogilefs_pass {proxy_pass $mogilefs_path;proxy_hide_header Content-Type;proxy_buffering off;}expires 1h;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apaches document root# concurs with nginxs one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}} 图示此时可通过http://uri/p_w_picpaths/aqua.jpg进行访问而不是原来很长的路径名进行访问。 总结在大型站点中mogilefs的重要性不言而喻尤其是图片存储量很大的网站例如某宝某东等此配置过程中mysql易于成为单点故障所以可将其做主从复制同时结合MySQL半同步复制可降低数据的丢失风险。在配置nginx做反向代理时大部分步骤和其他反代类是不同的是需将模块编译进nginx中才能使用此模块功能。 转载于:https://blog.51cto.com/purify/1878002