FastDFS分布式文件系统的安装及配置-多服务器版

FastDFS分布式文件系统的安装及配置-多服务器版

FastDFS分布式文件系统的安装及配置

  • 整体网络配置

    1 Tracker Server  192.168.127.11  /home/fastdfs/tracker 端口:22122
    2 Storage1 Server     192.168.127.12 group1 /home/fastdfs/fdfs_storage 端口:23000
    3 Storage2 -Server1(源)  192.168.127.13 group2 /home/fastdfs/fdfs_storage 端口:23000
    4 Storage2 -Server2    192.168.127.14 group2 /home/fastdfs/fdfs_storage 端口:23000
    5 注意:
    6 1.Storage2 同组的fastdfs服务的端口必须一致: port=23000
    7 2.如果开启http 端口 则Storage2 同组的http端口必须一致: http.server_port
    8 3.一台服务器可以装多个组但不能装同组的多个Storage,日志会报错误
    9 4.无论你是否启动内部绑定的的http服务器,都要安装libevent包,fastdfs内部调用libevent的处理机制
  • 01 #软件安装包存储:
    02 /usr/local/src
    03 /etc/fdfs/*     #tracker,storage ·· 配置文件所在目录
    04  
    05 #基本目录列表:
    06 /home/fastdfs/tracker    #创建tracker目录保存运行日志
    07 /home/fastdfs/fdfs_storage  #创建Storage目录保存运行日志及其data数据
    08  
    09 mkdir -p /home/fastdfs/tracker;
    10 mkdir -p /home/fastdfs/fdfs_storage;
    11  
    12 为方便查找目录,设置变量
    13 # vi .bashrc
    14 alias  worksrc='cd /usr/local/src;ls'
    15 alias  worktracker='cd /home/fastdfs/tracker;ls'
    16 alias  workstorage='cd /home/fastdfs/fdfs_storage;ls'
    17 #track启动 重启 停止
    18 alias  trackstart='/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf;netstat -tunl ';
    19 alias  trackrestart='/usr/local/bin/restart.sh  /usr/local/bin/fdfs_trackerd  /etc/fdfs/tracker.conf;netstat -tunl';
    20 alias  trackstop='/usr/local/bin/stop.sh  /usr/local/bin/fdfs_trackerd  /etc/fdfs/tracker.conf;netstat -tunl';
    21 #storaged 启动 重启 停止
    22 alias  storagedstart='/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf;netstat -tunl ';
    23 alias  storagedrestart='/usr/local/bin/restart.sh  /usr/local/bin/fdfs_storaged  /etc/fdfs/storage.conf;netstat -tunl';
    24 alias  storagedstop='/usr/local/bin/stop.sh  /usr/local/bin/fdfs_storaged  /etc/fdfs/storage.conf;netstat -tunl';
    25 配置生效
    26 # source .bashrc
  1. 安装libevent 和 FastDFS

    • 首先安装libevent,因为 FastDFS 在编译源程序时,需要用到libevent一些依赖文件,否则编译 FastDFS 会出错

      01 ##卸载系统自带libevent,自带版本过低,安装fastdfs会出错
      02 rpm -qa|grep libevent;yum remove libevent*
      03 #下载安装libevent
      04 worksrc;
      05 wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz;
      06 tar -zxvf libevent-2.0.19-stable.tar.gz;
      07 cd libevent-2.0.19-stable;
      08 make clean;
      09 ./configure --prefix=/usr/local/libevent
      10 make && make install;
      11  
      12 ##为libevent创建软链接到/lib库下,64位系统对应/lib64
      13 ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
      14 ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
      15  
      16 命令汇总: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的步骤

      1 wget http://fastdfs.googlecode.com/files/FastDFS_v3.11.tar.gz
      2 tar -zxvf FastDFS_v3.11.tar.gz
      3 cd FastDFS
      4 #因为不启用内置http服务,所以不需要修改make.sh和开启端口
      5 ./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
      6 ./make.sh install
  2. 安装Tracker Server -192.168.127.11

    • 引用上例中安装libevent 和 FastDFS步骤
    • 配置及启动Tracker Server,端口:22122

      1 #修改tracker.conf配置
      2 vim /etc/fdfs/tracker.conf
      3 # the tracker server port
      4 port=22122
      5 # the base path to store data and log files
      6 base_path=/home/yuqing/fastdfs -> base_path=/home/fastdfs/tracker #日志目录
      7 reserved_storage_space = 4GB -> reserved_storage_space = 1GB
      1 #启动Tracker Server
      2 /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
      1 #启动过程中出现的错误
      2 #./fdfs_trackerd: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
      3 #解决办法
      4 ln -s /usr/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
    • #检查tracker是否启动成功,可以查看如下文件

      1 vim /home/fastdfs/tracker/logs/trackerd.log
      2 #[2012-08-26 19:01:30] INFO - FastDFS v3.11, base_path=/home/fastdfs/tracker, run_by_group=, run_by_user=, connect_timeout=30s, network_timeout=60s, port=22122, bind_addr=, max_connections=256, work_threads=4, store_lookup=0, store_group=, store_server=0, store_path=0, reserved_storage_space=1024MB, 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
      1 #启动成功,加入开机启动
      2 # vim /etc/rc.d/rc.local
      3 /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf

    安装Storage Server -192.168.127.12
    配置及启动存储服务(Storage Server)

    • 引用上例中安装libevent 和 FastDFS步骤
    • 01 #修改storage.conf配置
      02 vim /etc/fdfs/storage.conf
      03 # the name of the group this storage server belongs to
      04 group_name=group1
      05 # the name of the group this storage server belongs to
      06 # the storage server port #the storage server port
      07 port=23000
      08 # the base path to store data and log files #日志目录
      09 base_path=/home/yuqing/fastdfs -> /home/fastdfs/fdfs_storage
      10 # store_path#, based 0, if store_path0 not exists, it's value is base_path #data数据存储目录
      11 # the paths must be exist
      12 store_path0=/home/fastdfs/fdfs_storage
      13 # tracker_server can ocur more than once, and tracker_server format is
      14 #  "host:port", host can be hostname or ip address
      15 tracker_server=192.168.209.121:22122 -> tracker_server=192.168.127.11:22122
      16  
      17 #启动storage Server
      18 /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
      19  
      20 #接下来会出现很多mkdir data path,这是系统在创建数据目录
      21 data path: /home/fastdfs/fdfs_storage/datamkdir sub dir...
      22 mkdir data path: 00 ...
      23 mkdir data path: 01 ...
      24 mkdir data path: 02 ...
      25 mkdir data path: 03 ...
      26 .......................
      27 data path: /home/fastdfs/fdfs_storage/datamkdir sub dir done.
      1 #启动成功,加入开机启动
      2 # vim /etc/rc.d/rc.local
      3 /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

    安装Storage Server -192.168.127.13
    配置及启动存储服务(Storage Server)

    • 引用上例中安装libevent 和 FastDFS步骤
    • 01 #修改storage.conf配置
      02 vim /etc/fdfs/storage.conf
      03 # the name of the group this storage server belongs to
      04 group_name=group1 ->group_name=group2
      05 # the name of the group this storage server belongs to
      06 # the storage server port #the storage server port
      07 port=23000
      08 # the base path to store data and log files #日志目录
      09 base_path=/home/yuqing/fastdfs -> /home/fastdfs/fdfs_storage
      10 # store_path#, based 0, if store_path0 not exists, it's value is base_path #data数据存储目录
      11 # the paths must be exist
      12 store_path0=/home/fastdfs/fdfs_storage
      13 # tracker_server can ocur more than once, and tracker_server format is
      14 #  "host:port", host can be hostname or ip address
      15 tracker_server=192.168.209.121:22122 -> tracker_server=192.168.127.11:22122
      16  
      17 #启动storage Server
      18 /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
      19  
      20 #接下来会出现很多mkdir data path,这是系统在创建数据目录
      21 data path: /home/fastdfs/fdfs_storage/datamkdir sub dir...
      22 mkdir data path: 00 ...
      23 mkdir data path: 01 ...
      24 mkdir data path: 02 ...
      25 mkdir data path: 03 ...
      26 .......................
      27 data path: /home/fastdfs/fdfs_storage/datamkdir sub dir done.
      1 #启动成功,加入开机启动
      2 # vim /etc/rc.d/rc.local
      3 /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

    安装Storage Server -192.168.127.14
    配置及启动存储服务(Storage Server)

    • 引用上例中安装libevent 和 FastDFS步骤
    • 01 #修改storage.conf配置
      02 vim /etc/fdfs/storage.conf
      03 # the name of the group this storage server belongs to
      04 group_name=group1 ->group_name=group2
      05 # the name of the group this storage server belongs to
      06 # the storage server port #the storage server port
      07 port=23000
      08 # the base path to store data and log files #日志目录
      09 base_path=/home/yuqing/fastdfs -> /home/fastdfs/fdfs_storage
      10 # store_path#, based 0, if store_path0 not exists, it's value is base_path #data数据存储目录
      11 # the paths must be exist

你可能感兴趣的:(FastDFS分布式文件系统的安装及配置-多服务器版)