MogileFS Advanced Applications
Architecture diagram:
Experiment Description:
1 mysql+3 is mogstored and tracker node + 1 Nginx Implementation of the reverse generation
To use fewer hosts, we use 2 hosts
Nginx + mogstored + Tracker
MySQL + mogstored + Tracker
The first step here is to quickly deploy mogstored + Tracker Environment (detailed deployment please refer to the previous blog)
1. First set up the MySQL server
MySQL > Grant all on mogdb.* to ' moguser ' @ ' 10.1.%.% ' identified by ' Mogpass ', MySQL > Grant all on *. * to ' root ' @ ' 10. 1.%.% ' identified by ' root '; -this permission is too large for the build environment to adjust MySQL > flush privileges as needed;
2.tracker + mogstored Configuration
Tracker configuration:
# mogdbsetup--dbhost=10.1.249.125--dbport=3306--dbname=mogdb >--dbrootuser=root--dbrootpass=root--dbuser= Moguser--dbpass=mogpass# vim/etc/mogilefs/mogilefsd.conf db_dsn = Dbi:mysql:mogdb:host=10.1.249.125db_user = Moguserdb_pass = Mogpasslisten = 0.0.0.0:7001# Service MOGILEFSD start# ss-tln | grep "7001"
3. Configure this server at the same time as the mogstored side
# mkdir-pv/var/mogdata/dev1# chown-r mogilefs.mogilefs/var/mogdata/# yum-y install perl-io-aio# service mogstored St art# NETSTAT-TLNP | grep "mogstored" # mogadm--trackers=10.1.249.125:7001 host add 10.1.249.125--ip=10.1.249.125--status=alive//if creation fails, May be due to the resolution of the/etc/hosts file and the true hostname inconsistency, modify the/etc/hosts file can be # scp/etc/mogilefs/* 10.1.252.53:/etc/mogilefs/to another server, Two servers using the same configuration file
4. Configure another server as a tracker+mogstored
At this point, the server as tracker, no need to initialize the database, the first one has been initialized # MKDIR/VAR/MOGDATA/DEV3-PV--The directory created here needs to be consistent with the name of the created device # Chown-r mogilefs.mogilefs/var/mogdata/# chown-r mogilefs.mogilefs/var/run/mogilefsd/# service MOGILEFSD start# Service mogstored start# mogadm--trackers=10.1.252.53:7001 host add 10.1.252.53--ip=10.1.252.53--status=alive
5. Add each other's host
# mogadm--trackers=10.1.252.53:7001 host add 10.1.249.125--ip=10.1.249.125--status=alive# mogadm--trackers= 10.1.249.125:7001 host add 10.1.252.53--ip=10.1.252.53--status=alive# mogadm--trackers=10.1.249.125:7001 Host list10.1.249.125 [1]: Alive ip:10.1.249.125:750010.1.252.53 [2]: Alive ip:10.1.252.53:7500 # Mogadm--tra CKERS=10.1.252.53:7001 host list10.1.249.125 [1]: Alive ip:10.1.249.125:750010.1.252.53 [2]: Alive ip:10.1 .252.53:7500
6. Add the device, in the same tracker operation can
# mogadm --trackers=10.1.249.125:7001 device add 10.1.249.125 1# mogadm --trackers=10.1.249.125:7001 device add 10.1.252.53 3 --> Consistent with the directories created above # mogadm --trackers=10.1.249.125:7001 device list10.1.249.125 [1]: alive used (g) free (g) total (g) weight (%) dev1: alive 6.484 84.630 91.114 10010.1.252.53 [2]: alive used (g) free (g) total (g) weight (%)    DEV3:&Nbsp; alive 6.176 84.938 91.114 100
7. Create a domain
# mogadm --trackers=10.1.249.125:7001 domain add images# mogadm --trackers= 10.1.249.125:7001 domain add files# mogadm --trackers=10.1.249.125:7001 domain list domain class Mindevcount replpolicy hashtype-------------------- ------------------- - ------------- ------------ ------- files default 2 Multiplehosts () NONE images default 2 multiplehosts () NONE
8. Create a class
# mogadm --trackers=10.1.252.53:7001 class add images class0 --mindevcount= 2# mogadm --trackers=10.1.252.53:7001 class add images class1 --mindevcount =2# mogadm --trackers=10.1.252.53:7001 class list domain class mindevcount replpolicy hashtype-------------------- -------------------- ------------- ------------ - ------ files default 2 multiplehosts () NONE images class0 2 multiplehosts () NONE images class1 2 multiplehosts () NONE images default 2 multiplehosts () none
9.nginx Configuration
Compile and install Nginx to support the MogileFS module # tar xf nginx_mogilefs_module-1.0.4.tar.gz# tar xf nginx-1.8.0.tar.gz# cd nginx-1.8.0# ./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= (Path to nginx_mogilefs_module-1.0.4 module) # make && make install
Nginx Reverse mogilefs configuration file upstream mogilefscluster{server 10.1.252.53:7001; Server 10.1.249.125:7001;} location/images/{Mogilefs_tracker mogilefscluster; Mogilefs_domain images; Mogilefs_pass {proxy_pass $mogilefs _path; Proxy_hide_header Content-type; Proxy_buffering off; }}
10. Back-end node upload a picture for testing (back-end two servers randomly select one can)
# mogupload--trackers=10.1.252.53:7001--domain=images--key= ' 1.jpg '--file= '/tmp/1.jpg ' # mogupload--trackers= 10.1.252.53:7001--domain=images--key= ' 2.jpg '--file= '/tmp/2.jpg ' # Moglistkeys--trackers=10.1.252.53:7001--domain =images1.jpg2.jpg
11. View the actual access path
# mogfileinfo-trackers=10.1.252.53:7001--domain=images--key= "1.jpg"-http://10.1.252.53:7500/dev3/0/000/000/ 0000000018.fid-http://10.1.249.125:7500/dev1/0/000/000/0000000018.fid--You can see there are two, because we have two mogstored, All mogilefs automatically helped us with redundancy.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8A/FD/wKiom1hAKoehAFkYAAE8jv9BRhk068.png-wh_500x0-wm_3 -wmp_4-s_3746670928.png "title=" 3.png "alt=" Wkiom1hakoehafkyaae8jv9brhk068.png-wh_50 "/>
12. Access path after the Nginx is reversed
Http://IP/images/1.jpghttp://IP/images/2.jpg
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/8A/F9/wKioL1hAKtXxFNJpAAErohnPQqw956.png-wh_500x0-wm_3 -wmp_4-s_2985159923.png "title=" 1.png "alt=" Wkiol1haktxxfnjpaaerohnpqqw956.png-wh_50 "/>
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/8A/FD/wKiom1hAKvbi8M09AAHhFzXUINI599.png-wh_500x0-wm_3 -wmp_4-s_3831260863.png "title=" 2.png "alt=" Wkiom1hakvbi8m09aahhfzxuini599.png-wh_50 "/>
This article is from the "Homecoming" blog, make sure to keep this source http://sixijie123.blog.51cto.com/11880770/1878701
MogileFS Advanced Applications (3)