mogilefs distributed storage

1. Install package environment,

.yum install perl-Net-Netmask perl -IO-String perl-Sys-Syslog perl-IO-AIO
download the package, the contents of the annex, there are the following packages

MogileFS-Server-2.46-2.el7.centos.noarch.rpm #核心服务 
MogileFS-Server-mogilefsd-2.46-2.el7.centos.noarch.rpm #tracker节点 
MogileFS-Server-mogstored-2.46-2.el7.centos.noarch.rpm #storage节点 
MogileFS-Utils-2.19-1.el7.centos.noarch.rpm #mogilefs的一些管理工具,如mogadm 
perl-Danga-Socket-1.61-1.el6.rf.noarch.rpm #依赖包 
perl-MogileFS-Client-1.14-1.el7.centos.noarch.rpm 
perl-Perlbal-1.78-1.el6.noarch.rpm

-Y # cd directly to each node yum localinstall ./* perform all installation folder

2 install mysql and create a database (192.168.1.31 node)

192.168.1.31 in the mysql installation, and create a library mogilefs, create a user [email protected].%.%, give permission mogilefs library is fully controlled, created with the best in the test under mysql -h 192.168.1.13, login go see if there mogilefs library.

3. initialize the database

--dbuser MogileFS --dbpass 123456 --dbhost mogdbsetup = 192.168.1.31
# there are other parameters available mogdbsetup --help View Help

4. Configure mogilefs controller and start (192.168.1.13 node)

vim /etc/mogilefs/mogilefsd.conf # modify the configuration file tracker, controller

db_dsn = DBI:mysql:mogilefs:host=192.168.1.31 #数据库地址
db_user = mogilefs   #数据库账号
db_pass = 123456   #数据库密码
listen = 192.168.1.13:7001  #mogilefs监听的ip和端口

service mogilefsd start # start tracker service
netstat -nltp see if 7001 port is listening

The configuration storage (storage node) (192.168.1.13,192.168.1.14,192.168.1.21)

maxconns = 10000 # maximum concurrent connections
httplisten = port 0.0.0.0:7500 # listening
mgmtlisten = 0.0.0.0:7501 # Management Command Listen Port
docroot = / date / # storage directory, the reality is recommended to use a separate storage disk
mkdir / data / # create a folder
chown -R mogilefs.mogilefs / data / # change owner
service mogstored start # start storage service
netstat -nltp view 75,007,501 ports are listening

6. Add the storage node (192.168.1.13) on the control node

--trackers = 192.168.1.13 mogadm: 7001 Host --ip the Add 192.168.1.14 192.168.1.14 --port = = = 7500 --status Alive
# - trackers = 192.168.1.13: 7001 here indicates the control node, a plurality of with separated, each node will be added
mogadm --trackers = 192.168.1.13: 7001 check # View node added
mogilefs distributed storage

7. Create a storage device (192.168.1.13,192.168.1.14,192.168.1.21)

mkdir / data / dev13 # create three directories on three main dev13, dev14, dev21 as a storage device, after the number is the id must be unique, it is proposed ip last
chown -R mogilefs: mogilefs / data / # newly created is the root directory of the owner, it is necessary to change it back
8. adding a storage device (192.168.1.13) at the control node mogilefs
mogadm --trackers = 192.168.1.13: 7001 device add 192.168.1.13 13 ## each do
mogilefs distributed storage

9. Create Domain (namespace) and class (192.168.1.13)

mogadm --trackers = 192.168.1.13: 7001 domain add yangzai ## yangzai create a namespace of
mogadm --trackers = 192.168.1.13: 7001 class the Add yangzai jpg --mindevcount = 2
# field in yangzai created a jpg class, and specify the minimum number of copies to 2
mogadm --trackers = 192.168.1.13: 7001 class yangzai the Add TXT --mindevcount = 3
mogadm --trackers = 192.168.1.13: 7001 ## look at Domain List
mogilefs distributed storage

10. The data upload pictures and view

mogupload --tracker=192.168.1.13:7001 --domain=yangzai --class=jpg --key=111 --file=/root/111.png
#上传图片 指定域,类,id,路径
mogfileinfo --tracker=192.168.1.13:7001 --domain=yangzai --key=111
#查看文件,指定域,和id即可
mogilefs distributed storage
#在浏览器里输入,红框里的url,即可看到图片

11.编译安装nginx反代过去

yum groupinstall "Development Tools" "Server Platform Deveopment" -y
yum install openssl-devel pcre-devel -y
cd nginx 编译目录执行以下命令
./configure \
--prefix=/usr/local/nginx \
--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/ \
Proxy-TEMP----http path = / var / tmp / Nginx / Proxy / \
--http-FastCGI-TEMP-path = / var / tmp / Nginx / fcgi / \
--http-path-to uwsgi-TEMP = / var / tmp / Nginx / to uwsgi \
--http-SCGI-TEMP-path = / var / tmp / Nginx / SCGI \
--with-PCRE \
--with-Debug \
--add-Module1 = / the root / nginx_mogilefs_module -1.0.4 # add third-party modules, using a direct access uri carried out as a key
intermediate may be an error vim / vim objs / Makefile
to -Werror this field can be deleted
mogilefs distributed storage
make && make install # install
mkdir -pv / var / tmp / nginx / client / ## to create a folder, otherwise nginx will start being given
vim /etc/nginx/nginx.conf

 upstream images {   #创建访问组
      server 192.168.1.13:7001;
       server 192.168.1.14:7001;
      server 192.168.1.21:7001;
    }

server {
        listen       80;
        server_name  localhost;
          location /jpg/ {    ##匹配到/jpg/ 就转给 yangzai名称空间的文件,以key为id访问
            mogilefs_tracker images;
            mogilefs_domain yangzai;
            mogilefs_methods GET;
            mogilefs_noverify on;
            mogilefs_pass {
                proxy_pass $mogilefs_path;
                proxy_hide_header Content-Type;
                proxy_buffering off;
            }
        }

        location   /txt {
            mogilefs_tracker images;
            mogilefs_domain yangzai;
            mogilefs_methods GET;
            mogilefs_noverify on;
            mogilefs_pass {
                proxy_pass $mogilefs_path;
                proxy_hide_header Content-Type;
                proxy_buffering off;
            }
        }

12. the browser access

mogilefs distributed storage

Guess you like

Origin blog.51cto.com/13620944/2436415