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

[经验分享] Centos5下安装tfs并使用nginx做访问

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-7-31 09:14:07 | 显示全部楼层 |阅读模式
                      操作系统环境
[iyunv@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-371.9.1.el5 #1 SMP Tue Jun 10 17:49:56 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
[iyunv@localhost ~]# cat /etc/issue
CentOS release 5.10 (Final)
Kernel \r on an \m
[iyunv@localhost ~]#
PS:以下操作我只在如上系统进行验证使用,仅供参考
1.更新yum源
更新yu
2.安装高版本mysql
wget http://centos.ustc.edu.cn/epel/5/x86_64/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/5/remi/x86_64/remi-release-5.9-1.el5.remi.noarch.rpm
rpm -ivh *.rpm
echo 'priority=1' >> /etc/yum.repos.d/remi.repo
echo 'priority=1' >> /etc/yum.repos.d/epel-testing.repo
echo 'priority=1' >> /etc/yum.repos.d/epel.repo
检查mysql 是否有可升级版本。发现有版本可以升级到mysql5.5.11。
yum --enablerepo=remi list mysql
删除操作系统自带的低版本的mysql
yum remove mysql
通过新yum源安装高版本的mysql
yum -y --enablerepo=remi install mysql mysql-server mysql.x86_64  mysql-devel.x86_64
3.安装支持包 automake autoconfig 和 libtool
验证automake是否安装rpm -qa |grep automake
验证autoconfig是否安装 /usr/bin/autoconf -V
auotmake 1.4以上版本需要安装libuuid-devel,zlib-devel,mysql-devel三个开发包
查看以安装的rpm包:rpm -qa|grep 包名
rpm -qa|grep libuuid
rpm -qa|grep zlib-devel
rpm -qa|grep mysql-devel
如果你使用RedHat5.x和Centos 5.x会找不到libuuid-devel包,请看下面。
RedHat5.x和Centos 5.x 安装:  yum install uuidd
安装其它支持包: yum install libtool zlib-devel
下面的readline包系统自带了,ncurses包系统默认没有,我也安装,你安不安自已定吧。
[iyunv@locatfs local]# yum install readline-devel readline
[iyunv@locatfs local]# yum install ncurses-devel.x86_64  ncurses.x86_64
4.安装ext4格式工具
[iyunv@locatfs local]# yum install  e4fsprogs e4fsprogs-devel   
加载ext4模块,让系统支持ext4文件系统
[iyunv@locatfs local]#  modprobe ext4
5.安装tb-common-utils
tb-common-utils是淘宝开发使用的一个公共库
tbsys是对操作系统服务的封装,tbnet则提供了网络框架。 tbnet和tbsys被作为tb-common-utils被开源了,可以访问  http://code.taobao.org/trac/tb-common-utils/wiki
TFS依赖于底层开发包tbnet。tb-common-utils里面含有tbsys和tbnet
首先编译安装tblib(tb-common-utils),这里我安装在和tfs同一个路径。
(http://code.taobao.org/svn/tb-common-utils/trunk/ tb-common-utils)
gtest库是单元测试框架,下面先安装安装gtest
自行上网下载gtest
[iyunv@locatfs local]# unzip gtest-1.6.0.zip
[iyunv@locatfs local]# cd gtest-1.6.0
[iyunv@locatfs local]# ./configure
[iyunv@locatfs local]# make
[iyunv@locatfs local]# cd make/
[iyunv@locatfs local]# make
[iyunv@locatfs local]# ./sample1_unittest
安装tb-common-utils
新建一个下载目录,并进入这个目录。下载源码: 这里下载版本18的因为淘宝开发的东西不往下兼容
svn checkout -r 18 http://code.taobao.org/svn/tb-common-utils/trunk/ tb-common-utils
编译和安装tbnet, tbsys库
ps:建议将这行命令直接写入~/.bash_profile,然后执行“. ~/.bash_profile”
修改:
[iyunv@locatfs local]# vi /etc/profile
添加:(计划安装在/usr/local/tb/lib目录)
export TBLIB_ROOT=/usr/local/tb/lib
生效:
[iyunv@locatfs local]# source /etc/profile
[iyunv@locatfs local]# cd tb-common-utils/
[iyunv@locatfs local]# chmod +x *.sh
[iyunv@locatfs local]# ./build.sh
安装完成后,在TBLIB_ROOT表示的目录(/usr/local/tb/lib),应该可以看到include、lib 两个目录。
6.编译安装TFS----
编译安装tfs   (安装到 /usr/local/tfs目录)
[iyunv@locatfs local]# svn checkout http://code.taobao.org/svn/tfs/tags/release-2.2.10 tfs-2.2.10  
进入 tfs 目录
[iyunv@locatfs local]# cd tfs-2.2.10/
[iyunv@locatfs local]# chmod +x *.sh
[iyunv@locatfs local]# ./build.sh  init
[iyunv@locatfs local]# ./configure --prefix=/usr/local/tfs --without-tcmalloc
[iyunv@locatfs local]# make
[iyunv@locatfs local]# make install
7.安装nginx-tfs模块
TFS模块使用了一个开源的JSON库来支持JSON,先安装yajl-2.0.1

[iyunv@localhost opt]# cd lloyd-yajl-12ee82a/
[iyunv@localhost lloyd-yajl-12ee82a]# ./configure --prefix=/usr/local/yajl && make && make install
报错
== removing old build files
== running CMake in build directory
./configure: line 41: cmake: command not found
The "cmake" program is required to configure yajl.
It's available from most ports/packaging systems and http://cmake.org
解决办法:
yum -y install cmake
继续编译通过
下载tengine此软件是nginx的升华版本,在nginx上二次开发
wget http://tengine.taobao.org/download/tengine-2.0.3.tar.gz
下载nginx-tfs模块
wget https://codeload.github.com/alibaba/nginx-tfs/zip/master
安装tengine并添加ngix-tfs模块
[iyunv@localhost tengine-2.0.3]# ./configure --prefix=/usr/local/nginx --add-module=/opt/nginx-tfs-master && make && make install
报错
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决办法
[iyunv@localhost tengine-2.0.3]# yum -y install pcre-devel
继续编译tengine
[iyunv@localhost tengine-2.0.3]# ./configure --prefix=/usr/local/nginx --add-module=/opt/nginx-tfs-master && make && make install
启动nginx报错
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libyajl.so.2: cannot open shared object file: No such file or directory
xx解决办法
[iyunv@localhost tengine-2.0.3]# ln -s /usr/local/lib/libyajl.so.2 /usr/lib64/libyajl.so.2
再次测试成功
启动nginx
[iyunv@localhost tengine-2.0.3]# /usr/local/nginx/sbin/nginx
8.使用nginx访问上传图片路径
修改nginx配置文件
在nginx的http模块中添加upstream
tfs_upstream tfs_ns {
        server 192.168.1.230:8108;
        type ns;
    }
在nginx的server模块中添加tfs_pass
server {
        listen       80;
        server_name  localhost;
tfs_keepalive max_cached=100 bucket_count=10;
tfs_log "pipe:/usr/sbin/cronolog -p 30min /var/log/nginx/logs/cronolog/%Y/%m/%Y-%m-%d-%H-%M-tfs_access.log";

location  ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
              tfs_pass tfs://tfs_ns;
          }
        }
使用url访问图片
例如上传的返回值是xxxxxxxxxxxxxxxxxxxxxx.jpg
   访问使用 http:/NameserverIP/v1/tfs/xxxxxxxxxxxxxxxxxxxxxx.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-22973-1-1.html 上篇帖子: Nginx HA 下篇帖子: nginx+lua_nginx+GraphicsMagick缩略图+tfs获取原图+ngx_cache_purge
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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