配置Mogilefs中使用Nginx做反代查詢:
Nginx做MogileFS的前端程序平斩,我們需要重新編譯nginx,下載nginx-mogilefs-module模塊即可咽块。
1绘面,介紹
在沒有做nginx mogilefs之前的URL:
http://192.168.125.200:7500/dev1/0/000/000/0000000011.fid
如果正常nginx訪問:
http://192.168.125.211/images/linux.jpg
反代流程:
1、客戶端向服務(wù)器端發(fā)送請求,Nginx接收請求揭璃;
2晚凿、Nginx通過反向代理挑選后端任意一臺Trackers服務(wù)器響應(yīng)請求;
3瘦馍、Trackers接收請求后再向后端數(shù)據(jù)庫獲取數(shù)據(jù)存儲的位置歼秽;
4、Trackers接收到數(shù)據(jù)庫響應(yīng)回來的數(shù)據(jù)位置后再響應(yīng)給Nginx情组;
5燥筷、Nginx接收到Trackers響應(yīng)回來的數(shù)據(jù)位置后再到Storage服務(wù)器上獲取實(shí)際的存儲數(shù)據(jù);
6院崇、Storage存儲服務(wù)器將文件內(nèi)容通過http協(xié)議返回給Nginx肆氓;
7、Nginx將結(jié)果返回給應(yīng)用層客戶端底瓣。
2谢揪,安裝
wget http://www.grid.net.ru/nginx/download/nginx_mogilefs_module-1.0.4.tar.gz
wget http://nginx.org/download/nginx-1.4.7.tar.gz
[root@localhost ~]# yum -y install pcre-devel
[root@localhost ~]# tar xf nginx-1.4.7.tar.gz
[root@localhost ~]# unzip nginx-mogilefs-module-master
[root@localhost ~]# cd nginx-1.4.7
[root@localhost ~]#./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
wget http://www.grid.net.ru/nginx/download/nginx_mogilefs_module-1.0.4.tar.gz
wget http://nginx.org/download/nginx-1.4.7.tar.gz
[root@localhost ~]# yum -y install pcre-devel
[root@localhost ~]# tar xf nginx-1.4.7.tar.gz
[root@localhost ~]# unzip nginx-mogilefs-module-master
[root@localhost ~]# cd nginx-1.4.7
[root@localhost ~]#./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
3,配置
[root@manager ~]# cat /etc/nginx/nginx.conf
#user nobody;
worker_processes 1;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
##定義upstream server調(diào)度器集群捐凭,實(shí)現(xiàn)負(fù)載均衡功能拨扶。
upstream trackers {
server 192.168.125.200:7001 weight=1;
server 192.168.125.201:7001 weight=1;
server 192.168.125.202:7001 weight=1;
check interval=1000 rise=2 fall=5 timeout=1000; #狀態(tài)檢測
}
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
##定義domain,如果mogilefs有多個(gè)domain柑营,那么就定義多個(gè)mogilefs
location /images/ {
mogilefs_tracker trackers;
mogilefs_domain imgs;
mogilefs_methods get;
mogilefs_noverify on;
mogilefs_pass {
proxy_pass $mogilefs_path;
proxy_hide_header Content-Type;
proxy_buffering off;
}
expires 1h;
}
##開啟status功能:
location /status {
check_status;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
4屈雄,添加服務(wù)腳本;
此處略去官套。