您的位置:首页 > 运维架构 > Nginx

TFS--淘宝文件系统Nginx模块安装篇

2015-03-07 13:23 429 查看
1.安装yajl

yajl是一个开源的JSON库

请到这里下载: http://lloyd.github.io/yajl/
yum install cmake -y

tar xvf lloyd-yajl-2.0.1-0-gf4b2b1a.tar.gz

cd lloyd-yajl-f4b2b1a/

./configure

make && make install

2.安装nginx/tengine

a) 安装pcre

wget http://sourceforge.net/projects/pcre/files/pcre/8.30/pcre-8.30.tar.gz/download
tar xvf pcre-8.30.tar.gz

cd pcre-8.30

./configure --prefix=/usr/local/pcre

make

make install

b)安装nginx/tengine

wget http://tengine.taobao.org/download/tengine-1.3.0.tar.gz
下载nginx-tfs模块:https://github.com/alibaba/nginx-tfs

unzip nginx-tfs-master.zip

tar xvf tengine-1.3.0.tar.gz

cd tengine-1.3.0

./configure --prefix=/usr/local/tengine --add-module=/root/nginx-tfs-master/ --with-pcre=/root/pcre-8.30/

make

make install

c)配置nginx

具体配置细节参看这里:https://github.com/alibaba/nginx-tfs/blob/master/ReadMe.markdown

vim /usr/local/tengine/conf/nginx.conf

添加以下内容:

http {

tfs_upstream tfs_ns {

server 10.0.0.62:8108;

type ns;

#rcs_zone name=tfs1 size=128M;

#rcs_interface eth0;

#rcs_heartbeat lock_file=/logs/lk.file interval=10s;

}

tfs_body_buffer_size 2m;

tfs_send_timeout 3s;

tfs_connect_timeout 3s;

tfs_read_timeout 3s;

server {

listen 7500;

server_name 192.168.10.218;

client_max_body_size 4096m;

tfs_keepalive max_cached=50 bucket_count=10;

tfs_log "pipe:/usr/sbin/cronolog -p 30min /usr/local/tengine/logs/cronolog/%Y/%m/%Y-%m-%d-%H-%M-tfs_access.log";

location / {

tfs_pass tfs://tfs_ns;

}

}

}

启动nginx

e) API接口测试

细节参看这里:https://github.com/alibaba/nginx-tfs/blob/master/TFS_RESTful_API.markdown

模拟POST上传一个图片:

curl --data-binary @/root/1000.jpg http://192.168.10.218:7500/v1/tfs?suffix=.jpg\&simple_name=0
返回信息:

{

"TFS_FILE_NAME": "T1iRJTByJT1RXrhCrK"

}

打开浏览器浏览:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: