当前位置: 首页 > 工具软件 > nginx-tfs > 使用案例 >

CentOS-6.5安装TFS-2.2.16

卓胜
2023-12-01
源码及相关软件目录
/usr/local/src


安装基本类库:
yum install -y libuuid-devel zlib-devel mysql-devel
yum install -y readline-devel
yum install -y libtool
ext4文件系统:
yum install -y e4fsprogs e4fsprogs-devel
安装svn客户端:
yum install -y subversion
检出tb-common-utils:
svn checkout -r 18 http://code.taobao.org/svn/tb-common-utils/trunk/ tb-common-utils


vim ~/.bash_profile


# .bash_profile


# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi


# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH


export  HISTTIMEFORMAT="'whoami' : %F %T :"


##### tbsys & tbnet start##############
TBLIB_ROOT=/usr/local/lib
export TBLIB_ROOT
##### tbsys & tbnet end  ##############



让环境变量配置生效:
source ~/.bash_profile


切入cd tb-common-utils文件夹
cd tb-common-utils/


sh执行安装tb-common-utils
sh build.sh


下载libunwind
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.0.tar.gz


解压libunwind-1.0.tar.gz压缩包
tar -zxvf libunwind-1.0.tar.gz


切入libunwind-1.0文件夹
cd libunwind-1.0
原始安装配置libunwind
autoreconf -i -f


配置libunwind
./configure


编译安装libunwind
make && make install


下载google-perftools
狗狗被墙,自行下载
解压google-perftools-1.9.1.tar.gz压缩包
tar -zxvf google-perftools-1.9.1.tar.gz


切入google-perftools-1.9.1文件夹
cd google-perftools-1.9.1


启用框架指针配置
./configure --enable-frame-pointers


编译安装
make && make install


下载jemalloc
wget http://www.canonware.com/download/jemalloc/jemalloc-3.4.0.tar.bz2


解压jemalloc压缩包
tar xjf jemalloc-3.4.0.tar.bz2
切入jemalloc-3.4.0文件夹
cd jemalloc-3.4.0
配置jemalloc
./configure
编译安装
make && make install


检出TFS-2.2.16
svn checkout http://code.taobao.org/svn/tfs/tags/release-2.2.16
切入release-2.2.16文件夹
cd release-2.2.16


添加stdint.h头文件
vim ./src/common/session_util.h

/*
 * (C) 2007-2010 Alibaba Group Holding Limited.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 *
 * Version: $Id
 *
 *
 *   Authors:
 *          zongdai(zongdai@taobao.com)
 *
 */
#ifndef TFS_COMMON_SESSIONUTIL_H_
#define TFS_COMMON_SESSIONUTIL_H_


#include <string>
#include <stdint.h>
namespace tfs
{
  namespace common
  {
    static const char SEPARATOR_KEY = '-';
    class SessionUtil
    {
      public:
        static std::string gene_uuid_str();
        static void gene_session_id(const int32_t app_id, const int64_t session_ip, std::string& session_id);
        static int parse_session_id(const std::string& session_id, int32_t& app_id, int64_t& session_ip);
    };
  }
}
#endif //TFS_RCSERVER_SESSIONUUID_H_


修改meta_server_service.cpp文件1584行,添加"(char*)"
vim中使用"set nu"命令显示行号
vim ./src/name_meta_server/meta_server_service.cpp

1579     bool MetaServerService::is_sub_dir(const char* sub_dir, const char* parents_dir)
1580     {
1581       bool ret = false;
1582       if (NULL != sub_dir && NULL != parents_dir)
1583       {
1584         char* pos =(char*) strstr(sub_dir, parents_dir);
1585         if (pos == sub_dir)
1586         {
1587           size_t p_len = strlen(parents_dir);
1588           size_t c_len = strlen(sub_dir);
1589           if (p_len == c_len)
1590           {
1591             //sub_dir == parents_dir;
1592             ret = false;
1593           }
1594           else
1595           {
1596             if ('/' == *(parents_dir + p_len - 1))
1597             {
1598               // parents ended with '/'
1599               ret = true;
1600             }
1601             else
1602             {
1603               pos += p_len;
1604               if ('/' == *pos)
1605               {
1606                 ret = true;
1607               }
1608             }
1609           }
1610         }
1611       }
1612       return ret;
1613     }


修改tfstool.cpp文件550行,去掉"//",防止tfstool工具上传完文件显示put %s => %s success
vim src/tools/nameserver/tfstool.cpp


 524   if (unique)
 525   {
 526     // TODO: save unique
 527     if (tfs_name != NULL)
 528     {
 529       ret = g_tfs_client->save_file_update(local_file, flag, tfs_name, suffix) < 0 ? TFS_ERROR : TFS_SUCCESS;
 530     }
 531     else
 532     {
 533       ret = g_tfs_client->save_file(ret_tfs_name, TFS_FILE_LEN, local_file, flag, suffix) < 0 ?
 534           TFS_ERROR : TFS_SUCCESS;
 535     }
 536   }
 537   else
 538   {
 539     if (tfs_name != NULL)
 540     {
 541       ret = g_tfs_client->save_file_update(local_file, flag, tfs_name, suffix) < 0 ? TFS_ERROR : TFS_SUCCESS;
 542     }
 543     else
 544     {
 545       ret = g_tfs_client->save_file(ret_tfs_name, TFS_FILE_LEN, local_file, flag, suffix) < 0 ?
 546           TFS_ERROR : TFS_SUCCESS;
 547     }
 548   }
 549
 550   printf("tfs_name: %s, ret_tfs_name: %s\n", tfs_name, ret_tfs_name);
 551   ToolUtil::print_info(ret, "put %s => %s", local_file, tfs_name != NULL ? FSName(tfs_name, suffix).get_name()      : ret_tfs_name);
 552   return ret;
 553 }


初始化TFS
./build.sh init
配置TFS
./configure --prefix=/usr/local/tfs --with-tblib-root=/usr/local/lib
替换错误提示
find ./ -name  Makefile | xargs sed -i 's/-Werror//'
编译
make 
安装
make install


安装cmake
yum install -y cmake


开源的JSON库yajl官网
http://lloyd.github.io/yajl/
下载yajl-2.1.0.tar.gz 
解压yajl压缩包
tar -zxvf lloyd-yajl-2.1.0-0-ga0ecdde.tar.gz


切入lloyd-yajl-66cb08c文件夹
cd lloyd-yajl-66cb08c/
配置yajl安装目录为"/usr/local/yajl"
 ./configure --prefix=/usr/local/yajl


编译安装
make && make install
追加yajl配置
echo /usr/local/include/yajl/ >> /etc/ld.so.conf
是yajl配置生效
ldconfig


下载nginx-tfs模块
wget https://github.com/alibaba/nginx-tfs/archive/master.zip
解压nginx-tfs-master压缩包
unzip nginx-tfs-master.zip


下载nginx
wget http://nginx.org/download/nginx-1.2.9.tar.gz
解压nginx-1.2.9.tar.gz压缩包
tar -zxvf nginx-1.2.9.tar.gz


配置nginx
./configure \
  --prefix=/usr \
  --sbin-path=/usr/sbin/nginx \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --pid-path=/var/run/nginx/nginx.pid \
  --lock-path=/var/lock/nginx.lock \
  --user=nginx \
  --group=nginx \
  --with-http_ssl_module \
  --with-http_gzip_static_module \
  --http-log-path=/var/log/nginx/access.log \
  --http-client-body-temp-path=/var/tmp/nginx/client \
  --http-proxy-temp-path=/var/tmp/nginx/fcgi \
 --add-module=/usr/local/nginx-tfs-master/ 


编译安装
make && make install

















 类似资料: