Chinaunix首页 | 论坛 | 博客
  • 博客访问: 473962
  • 博文数量: 17
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1693
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-13 09:23
个人简介

前EMC高级软件工程师,现小米分布式存储码农,关注分布式存储,文件系统,Linux内核。微博: http://weibo.com/u/2203007022

文章分类

全部博文(17)

文章存档

2015年(1)

2014年(6)

2013年(10)

分类: 服务器与存储

2013-09-16 13:09:40

最近开发图片存储系统,其中缩略图选用Tair进行缓存,以下是Tair如何安装部署: 

    1.      如何安装tair:

(1)    确保安装了automake autoconfig libtool,

使用automake --version查看,一般情况下已安装

(2)    获得底层库 tbsys tbnet的源代码:

# svn checkout tb-common-utils

(3)    获得tair源代码:

# svn checkout tair

(4)    安装boost-devel库,

在用rpm管理软件包的os上可以使用rpm -q boost-devel查看是否已安装该库

(5)    编译安装tbsystbnet

tair 的底层依赖于tbsys库和tbnet, 所以要先编译安装这两个库。

a)        指定libaray安装目录

# Sudo bash                        

# export TBLIB_ROOT=/usr/lib/  

b)        安装common libaray

# chmod +x build.sh

# ./build.sh

(6)    编译安装tair

a)        准备

# cd ~/tair/tair

# bootstrap.sh

# ./configure –with-release=yes

b)        编译

# make

在编译过程中出现以下几个错误:

 i.         32位机器上不支持64位的原子操作

点击(此处)折叠或打开

  1. ../../../src/storage/ldb/leveldb/port/port_posix.h: In member function ‘T leveldb::port::AtomicCount<T>::GetAndInc() [with T = long long unsigned int]:
  2. ../../../src/storage/ldb/leveldb/db/version_set.h:208: instantiated from here
  3. ../../../src/storage/ldb/leveldb/port/port_posix.h:115: error: no matching function for call to ‘atomic_add(volatile long long unsigned int*, int)
  4. ../../../src/storage/ldb/leveldb/port/atomic_count.h:135: note: candidates are: uint32_t leveldb::port::atomic_add(volatile uint32_t*, uint32_t)
  5. ../../../src/storage/ldb/leveldb/port/atomic_count.h:146: note: uint16_t leveldb::port::atomic_add(volatile uint16_t*, uint16_t)
  6. ../../../src/storage/ldb/leveldb/port/atomic_count.h:157: note: uint8_t leveldb::port::atomic_add(volatile uint8_t*, uint8_t)
  7. ../../../src/storage/ldb/leveldb/port/port_posix.h: In member function ‘void leveldb::port::AtomicCount<T>::Set(T) [with T = long long unsigned int]:
  8. ../../../src/storage/ldb/leveldb/db/version_set.h:215: instantiated from here
  9. ../../../src/storage/ldb/leveldb/port/port_posix.h:106: error: no matching function for call to ‘atomic_exchange(volatile long long unsigned int*, long long unsigned int&)
  10. ../../../src/storage/ldb/leveldb/port/atomic_count.h:182: note: candidates are: uint32_t leveldb::port::atomic_exchange(volatile uint32_t*, uint32_t)
  11. ../../../src/storage/ldb/leveldb/port/atomic_count.h:193: note: uint16_t leveldb::port::atomic_exchange(volatile uint16_t*, uint16_t)
  12. ../../../src/storage/ldb/leveldb/port/atomic_count.h:204: note: uint8_t leveldb::port::atomic_exchange(volatile uint8_t*, uint8_t)
 错误的产生原因是:

version_set.h中,next_file_number_last_sequence_被定义成64;

点击(此处)折叠或打开

  1. port::AtomicCount<uint64_t> next_file_number_;            
  2. // uint64_t next_file_number_;
  3. uint64_t manifest_file_number_;
  4. port::AtomicCount<uint64_t> last_sequence_;

而在32为平台上,uint64_t的原子操作没有定义:

点击(此处)折叠或打开

  1. 123 #ifdef __x86_64__
  2. 124 static __inline__ uint64_t atomic_add(volatile uint64_t * pv, const uint64_t av)
  3. 125 {
  4. 126 //:"=a" (__res), "=q" (pv): "m"(av), "1" (pv));
  5. 127 register unsigned long __res;
  6. 128 __asm__ __volatile__ (
  7. 129 "movq %2,%0;"
  8. 130 LOCK_PREFIX "xaddq %0,(%1);"
  9. 131 :"=a" (__res), "=q" (pv): "mr"(av), "1" (pv));
  10. 132 return __res;
  11. 133 }
  12. 134 #endif
  13. 135 static __inline__ uint32_t atomic_add(volatile uint32_t * pv, const uint32_t av)
32位机器上,需要将所有uint64_t的原子类型修改成uint32。如下:

点击(此处)折叠或打开


 ii.         TAIR_SVN_INFO没有定义

这个宏可能是为了打印当前SVN的版本,但是没有定义,注释掉引用的地方就可以了:

点击(此处)折叠或打开

  1. Index: src/configserver/tair_cfg_svr.cpp
  2. ===================================================================
  3. --- src/configserver/tair_cfg_svr.cpp (revision 1845)
  4. +++ src/configserver/tair_cfg_svr.cpp (working copy)
  5. @@ -405,7 +405,7 @@
  6.        config_file = optarg;
  7.        break;
  8.      case 'V':
  9. - fprintf(stderr, "BUILD_TIME: %s %s\nSVN: %s\n", __DATE__, __TIME__, TAIR_SVN_INFO);
  10. +// fprintf(stderr, "BUILD_TIME: %s %s\nSVN: %s\n", __DATE__, __TIME__, TAIR_SVN_INFO); uint64_t log_number_;
  11.    uint64_t prev_log_number_; // 0 or backing store for memtable being compacted

解决以上两个问题后,编译通过。

c)        安装

# make install

默认安装在ac_default_prefix=${HOME}/tair_bin下:

# ls ${HOME}/tair_bin

bin  check_version.sh  etc  include  lib  sbin  set_shm.sh  stat.sh  tair.sh

2.       如何配置tair

tair_bin/etc下面有4default配置文件,复制一下只需要对其做适当的修改。

# cp configserver.conf.default configserver.conf

# cp dataserver.conf.default dataserver.conf

# cp group.conf.default group.conf

我的tair测试环境只配置了一个config server和一个dataserver, 并且只修改了默认配置文件中的config_server 配置。

关于各配置文件的详细信息,请参考tair官方文档和默认配置文件中的说明:

3.      如何启动集群

# cd ~/tair_bin

    (1)   启动dataserver

# sbin/tair_server -f etc/dataserver.conf

    (2)   启动config server

# sbin/tair_cfg_svr -f etc/configserver.conf

    (3)   查看是否启动成功

# ps aux | grep tair

    (4)   通过tairclient测试

# sbin/tairclient -c 10.1.169.135:5198 -g group_test

TAIR> put key1 value1

put: success

TAIR> get key1

KEY: key1, LEN: 6

 raw data: value1, \76\61\6C\75\65\31

阅读(9423) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~