手机版
你好,游客 登录 注册
背景:
阅读新闻

CentOS 安装 fastdfs_v4.06

[日期:2013-10-02] 来源:oschina.net  作者:shking [字体:大 中 小]

1.安装libevent 和 fastdfs

首先安装libevent. fastdfs在编译源程序时fastdfs内部调用libevent的处理机制,,需要用到libevent一些依赖文件,否则编译fastdfs会

#卸载系统自带libevent,自带版本过低,安装fastdfs会出错
  rpm -qa|grep libevent
#  或者
  yum remove libevent*
#下载安装libevent
#worksrc;
  wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz;
  tar -zxvf libevent-2.0.19-stable.tar.gz;
  cd libevent-2.0.19-stable;
#make clean;
  ./configure --prefix=/usr/local/libevent
  make && make install;
#为libevent创建软链接到/lib库下,64位系统对应/lib64
  ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
  ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
#命令汇总:
  worksrc;wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz;tar -zxvf libevent-2.0.19-stable.tar.gz;cd libevent-2.0.19-stable;make clean;./configure --prefix=/usr/local/libevent;make && make install;cd ../

安装fastdfs的步骤

#worksrc;
  wget http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz
  tar -zxvf FastDFS_v4.06.tar.gz
  cd FastDFS
#由于定义/usr/local/fastdfs为fastdfs安装目录,所以需要修改make.sh
  vim make.sh
  TARGET_PREFIX=/usr/local 修改为 /usr/local/fastdfs
  # sed -i 's:TARGET_PREFIX=.*:TARGET_PREFIX=/usr/local/fastdfs:g' make.sh
  TARGET_CONF_PATH=/etc/fdfs 修改为 /usr/local/fastdfs/conf
  # sed -i 's:TARGET_CONF_PATH=.*:TARGET_CONF_PATH=/usr/local/fastdfs/conf:g' make.sh
#安装
  ./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
  ./make.sh install
  cp init.d/* /etc/init.d/

2.安装Tracker Server -192.168.127.11

引用上例中安装libevent 和 fastdfs步骤

配置及启动Tracker Server,端口:22122出错 

#修改tracker.conf配置
  vim /usr/local/fastdfs/conf/tracker.conf
# the tracker server port
  port=22122
# the base path to store data and log files
  base_path=/home/yuqing/fastdfs -> base_path=/home/fastdfs/tracker #日志目录
# sed -i 's:base_path=.*:base_path=/home/fastdfs/tracker:g' tracker.conf
  reserved_storage_space = 4GB -> reserved_storage_space = 1GB
# sed -i 's:reserved_storage_space=.*:reserved_storage_space = 1GB:g' tracker.conf
#unix group name to run this program,
#not set (empty) means run by the group of current user
  run_by_group= -> fastdfs
#unix username to run this program,
#not set (empty) means run by current user
  run_by_user= -> fastdfs
#开启自定义server ID取代ip形式,方便内部网络服务器更换ip#**此方式要重点理解,4.0以后新特性
  use_storage_id = true #使用server ID作为storage server标识
  storage_ids_filename = storage_ids.conf #<id> <group_name> <ip_or_hostname>
  id_type_in_filename = id #文件名反解析中包含server ID,以前是ip

设置Tracker Server 用户及组

chown -R fastdfs:fastdfs /home/fastdfs

Tracker Server脚本

  vim /etc/init.d/fdfs_trackerd

# 使用 Vi 命令替换
  %s/usr\/local/usr\/local\/fastdfs/g
  %s/etc\/fdfs/usr\/local\/fastdfs\/conf/g

启动脚本

#增加x权限
  chmod a+x /etc/init.d/fdfs_trackerd
#启动
  /etc/init.d/fdfs_trackerd start
  service fdfs_trackerd start

# base_path 附目录说明:
  tracker server目录及文件结构:
  ${base_path}
    |__data
    |    |__storage_groups.dat:存储分组信息
    |    |__storage_servers.dat:存储服务器列表
    |__logs
          |__trackerd.log:tracker server日志文件

启动成功,加入开机启动

  vim /etc/rc.d/rc.local
  service fdfs_trackerd start
#启动过程中出现的错误
  ./fdfs_trackerd: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
#解决办法
  ln -s /usr/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

是否启动成功,可以查看如下文件

vim /home/fastdfs/tracker/logs/trackerd.log
#[2012-08-26 19:01:30] INFO - FastDFS v4.06, base_path=/home/fastdfs/tracker, run_by_group=fastdfs, run_by_user=fastdfs, connect_timeout=30s, network_timeout=60s, port=22122, bind_addr=, max_connections=256, work_threads=4, store_lookup=2, store_group=, store_server=0, store_path=0, reserved_storage_space=10.00%, download_server=0, allow_ip_count=-1, sync_log_buff_interval=10s, check_active_interval=120s, thread_stack_size=64 KB, storage_ip_changed_auto_adjust=1, storage_sync_file_max_delay=86400s, storage_sync_file_max_time=300s, use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file_size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_file_space_threshold=20 GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlog=0, use_storage_id=1, id_type_in_filename=id, storage_id_count=1, rotate_error_log=0, error_log_rotate_time=00:00, rotate_error_log_size=0, store_slave_file_use_link=0, use_connection_pool=1, g_connection_pool_max_idle_time=3600s

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款