设为首页 收藏本站
查看: 944|回复: 0

[经验分享] TFS的nginx模块配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-9-28 09:31:10 | 显示全部楼层 |阅读模式
在部署完基本的tfs环境之后,就可以通过tfstool工具开始上传文件,上传完的文件可以通过ds_client工具来读取,也可以通过web方式来展示,本文介绍nginx的tfs模块配置来实现http形式展现tfs文件系统上传后的文件。当然如果你高兴的话,也可以用tengine来实现。

环境介绍:
tfs nameserver服务器  192.168.1.225/24
tfs dataserver服务器  192.168.1.227/24
tfs-nginx服务器       192.168.1.12/24



一:下载nginx-tfs模块 (12服务器)
https://github.com/alibaba/nginx-tfs



二:下载nginx源码包,安装必须的rpm包  (12服务器)
1
2
3
4
5
6
7
8
9
10
# cd /usr/local/src/
# wget http://nginx.org/download/nginx-1.3.14.tar.gz
# yum -y install pcre pcre-devel  openssl openssl-devel  perl perl-devel perl-ExtUtils-Embed
  
需要cmake支持,cmake编译可参考mysql5.5安装文档
# wget https://codeload.github.com/lloyd/yajl/legacy.tar.gz/2.1.0
# tar -zxvpf 2.1.0
# cd lloyd-yajl-66cb08c/
# ./configure
# make && make install






三:编译安装nginx,并添加tfs模块
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# tar -zxvpf nginx-1.3.14.tar.gz
# unzip nginx-tfs-master.zip
# cd nginx-1.3.14
#./configure --prefix=/usr/local/nginx
--user=nobody
--group=nobody
--with-select_module  
--with-poll_module
--with-file-aio
--with-http_ssl_module
--with-http_realip_module
--with-http_gzip_static_module
--with-http_secure_link_module
--with-http_sub_module
--with-http_stub_status_module
--with-http_perl_module  
--add-module=/usr/local/src/nginx-tfs-master





五:配置nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# cat /usr/local/nginx/conf/nginx.conf
user  nobody;
worker_processes  2;
  
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;
  
pid        logs/nginx.pid;
  
  
events {
    worker_connections  10240;
}
  
  
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;
  
  
    tfs_upstream tfs_rc {
        server 192.168.1.225:8108;
        type ns;
        rcs_zone name=tfs1 size=128M;
        rcs_interface eth0;
        rcs_heartbeat lock_file=/usr/local/nginx/logs/lk.file interval=10s;
    }
  
    server {
          listen       7500;
          server_name  localhost;
  
          tfs_keepalive max_cached=100 bucket_count=10;
          #tfs_log "pipe:/usr/local/cronolog/sbin/ -p 30min /path/to/nginx/logs/cronolog/%Y/%m/%Y-%m-%d-%H-%M-tfs_access.log";
  
          location / {
              tfs_pass tfs://tfs_rc;
          }
    }
}



配置nginx启动脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# cat /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse  
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /var/run/nginx.pid
  
# Source function library.
. /etc/rc.d/init.d/functions
  
# Source networking configuration.
. /etc/sysconfig/network
  
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
  
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
  
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
  
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
  
lockfile=/var/lock/subsys/nginx
  
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
  
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
killall -9 nginx
}
  
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
  
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
RETVAL=$?
    echo
}
  
force_reload() {
    restart
}
  
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
  
rh_status() {
    status $prog
}
  
rh_status_q() {
    rh_status >/dev/null 2>&1
}
  
case "$1" in
    start)
        rh_status_q && exit 0
    $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)   
      echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac



五:启动nginx
1
2
3
4
5
6
7
8
9
# echo '/usr/local/lib' >> /etc/ld.so.conf
# ldconfig
# /usr/local/nginx/sbin/nginx  -t
  
# chmod +x /etc/init.d/nginx
# chkconfig --add nginx
  
# service nginx start
Starting nginx: [  OK  ]



六:使用tfstool客户端上传一份文档,图片等资源 (225服务器)
1
2
# /usr/local/tfs/bin/tfstool -s 192.168.1.225:8108
TFS> put /etc/resolv.conf



wKiom1QlNanysHbOAAy0UW_3D7Y622.jpg

1
TFS> put /root/1.jpg



wKioL1QlNeuiOb94AAvyEzmtfgM177.jpg


七: 使用web浏览器读取tfs内的文件,这里值得注意的是端口后面的url一定是/v1/,tfs三个字符可以用任意字符代替,例如一个空格字符,或者aaaa,bbb等,但至少需要存在一个字符,这个应该是tfs-nginx模块源码的问题,未细究!


http://192.168.1.12:7500/v1/tfs/T1vtxTByhT1RCvBVdK
也可以使用url http://192.168.1.12:7500/v1/abc/T1vtxTByhT1RCvBVdK来访问
wKioL1QlNh_gNGvZAAETQ36vmJI905.jpg
http://192.168.1.12:7500/v1/tfs/T1TyxTByJT1RCvBVdK
也可以使用url http://192.168.1.12:7500/v1/ /T1TyxTByJT1RCvBVdK 来访问
wKiom1QlNg-jxvJ5ABBq0Hga_C0902.jpg


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-25450-1-1.html 上篇帖子: 搭建nginx服务器及文件的配置 下篇帖子: Nginx结合memcached实现LNMMP平台搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表