Fastdfs_v4.06 installation and configuration of Distributed File System

Source: Internet
Author: User
Tags crc32 file url

Fastdfs_v4.06 installation and configuration of Distributed File System overall network configuration 1 Tracker Server 192.168.127.11/home/tracker port: 221222Storage1 Server 192.168.127.12 group1/home/storage port: 230003Storage2-Server1 (source) 192.168.127.13 group2/home/storage port: 230004Storage2-Server2 192.168.127.14 group2/home/storage port: 230005 Note: 61. the ports of the fastdfs service in the same group of Storage2 must be the same: port = 2300072. A server can have multiple groups but cannot have multiple Storage in the same group. Log reports error 83. before Version 4.05, fastdfs internally bound libevent as h Ttp server. versions later than Version 4.05 Delete the built-in web http Service 01 # software installation package storage: 02/usr/local/src03/usr/local/fastdfs installation directory 04 05 # basic directory list: 06 # create fastdfs user 07/usr/sbin/groupadd fastdfs08/usr/sbin/useradd-g fastdfs fastdfs09 # create storage data directory 10 mkdir-p/home/fastdfs/tracker; # create a tracker directory to save the run log 11 mkdir-p/home/fastdfs/storage; # create a Storage directory to save the run log and its data 12 13 for ease of searching the directory, set variable 14 # vi. bashrc15alias worksrc = 'CD/usr/local/src; ls '16alias workfastdf S = 'CD/usr/local/fastdfs; ls '17alias worktracker = 'CD/home/fastdfs/tracker; ls '18alias workstorage = 'CD/home/fastdfs/storage; ls '19 # track start restart stop 20 alias sertracker = 'service fdfs_trackerd' 21 # storage Start restart stop 22 alias serstorage = 'service fdfs_storaged' 23 configuration takes effect 24 # source. bashrc install libevent and fastdfs first install libevent. fastdfs calls the libevent processing mechanism internally when compiling the source program. Some libevent dependent files need to be used. Otherwise, the fastdfs compilation will fail., Install fastdfs will error 02 rpm-qa | grep libevent; yum remove libevent * 03 # download and install libevent04worksrc; 05 wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz;06tar-zxvf libevent-2.0.19-stable.tar.gz; 07cd libevent-2.0.19-stable; 08 make clean; 09. /configure -- prefix =/usr/local/libevent10make & make install; 11 # create a soft link for libevent to/lib library, 64-bit systems/lib6412ln-s/usr/local/libevent/lib/libevent-2. 0. so.5/usr/lib/libevent-2.0.so.513ln-s/usr/local/libevent/lib/libevent-2.0.so.5/usr/lib64/libevent-2.0.so.514 #15 command Summary: 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 .. /install fastdfs Step 1 wget http://fastdfs.googl Ecode.com/files/FastDFS_v4.06.tar.gz2tar-zxvf FastDFS_v4.06.tar.gz3cd FastDFS because/usr/local/fastdfs is defined as the fastdfs installation directory, You need to modify make. sh 1vim make. sh2TARGET_PREFIX =/usr/local change to/usr/local/fastdfs3TARGET_CONF_PATH =/etc/fdfs change to/usr/local/fastdfs/conf4/etc/fdfs replace all with/usr/local /fastdfs/conf5 # Install 6. /make. sh C_INCLUDE_PATH =/usr/local/libevent/include LIBRARY_PATH =/usr/local/libevent/lib7./make. sh install to install Trac Ker Server-192.168.127.11 reference the above example to install libevent and fastdfs step configuration and start Tracker Server, Port: 2212201 # modify tracker. conf: Configure 02vim/usr/local/fastdfs/conf/tracker. conf03 # the tracker server port04port = 2212205 # the base path to store data and log files06base_path =/home/yuqing/fastdfs-> base_path =/home/fastdfs/tracker # log directory 07reserved_storage_space = 4 GB-> reserved_storage_space = 1GB08 # unix group name to run this program, 09 # not set (empty) means run by the group of current user10run_by_group =-> fastdfs11 # unix username to run this program, 12 # not set (empty) means run by current user13run_by_user =-> fastdfs14 # enable the custom server ID to replace the ip address format, it is convenient for the internal network server to replace ip15use_storage_id = true # Use the server ID as the storage server id 16storage_ids_filename = storage_ids.conf # <id> <group_name> <ip_or_hostname> identifier = ID # file name resolution contains ID, previously, ip18 # PHP extension supported connection pool 19use_connection_pool = protocol = 360021 #22 # mobile storage_ids.conf file 23cp-r/usr/local/src/FastDFS/conf/storage_ids.conf/usr/local/fastdfs /conf/24 # edit the correspondence between the storage server ID and IP address 25vim/usr/local/fastdfs/conf/storage_ids.conf26 # <id> <group_name> <ip_or_hostname> 27 100001 group1 192.168.205.1228 100002 group2 192.168.205.1329100003 group2 192.168.205.141 # bas _ Path directory Description: 2 tracker server directory and file structure: 3 $ {base_path} 4 |__ data5 |__ storage_groups.dat: storage group information 6 |__ storage_servers.dat: storage Server LIST 7 |__ logs8 |__ trackerd. log: tracker server log file start Tracker Server1chown-R fastdfs: fastdfs/home/fastdfs01 # Start script 02vim/etc/init. d/fdfs_trackerd03 # Add the following content 04 #! /Bin/bash05 #06 # fdfs_trackerd Starts fdfs_trackerd07 #08 #09 # chkconfig: 2345 99 0110 # description: FastDFS tracker server11 ### begin init INFO12 # Provides: $ fdfs_trackerd13 ### end init INFO14 # Source function library.15./etc/init. d/functions16FastDfs = '/usr/local/fastdfs' 17CONF = "$ FastDfs/conf/tracker. conf "18if [! -F $ CONF]; then19 echo "file $ CONF does not exist! "20 exit 221fi22PRG =" $ FastDfs/bin/fdfs_trackerd "23if [! -F $ PRG]; then24 echo "file $ PRG does not exist! "25 exit 226fi27Stop =" $ FastDfs/bin/stop. sh "28if [! -F $ Stop]; then29 echo "file $ Stop does not exist! "30 exit 231fi32Restart =" $ FastDfs/bin/restart. sh "33if [! -F $ Restart]; then34 echo "file $ Restart does not exist! "35 exit 236fi37RETVAL = 038 start () {39 echo-n $" Starting FastDFS tracker server: "40 $ PRG $ CONF & 41 RETVAL =$? 42 echo43 return $ RETVAL44} 45 stop () {46 echo-n $ "Stop FastDFS tracker server:" 47 $ Stop $ PRG $ CONF48 RETVAL = $? 49 return $ RETVAL50} 51 rhstatus () {52 status fdfs_trackerd53} 54 restart () {55 $ Restart $ PRG $ CONF & 56} 57 case "$1" in58 start) 59 start60; 61 stop) 62 stop63; 64 status) 65 rhstatus66; 67 restart | reload) 68 restart69; 70 condrestart) 71 restart72; 73 *) 74 echo $ "Usage: $0 {start | stop | status | restart | condrestart}" 75 exit 176esac77exit $? 78 #79 # Add x permission 80 chmod a + x/etc/init. d/fdfs_trackerd1 # start successfully, add to start 2 # vim/etc/rc. d/rc. local3service fdfs_trackerd start4 # error during startup 5 #. /fdfs_trackerd: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: no such file or directory6 # solution 7ln-s/usr/lib/libevent-2.0.so.5/usr/lib64/libevent-2.0.so.5 # Check if tracker is started successfully, you can view the following file: 1vim/home/fastdfs/tracker/logs/trackerd. log2 #[20 12-08-26 19:01:30] INFO-FastDFS v4.06, base_path =/home/fastdfs/tracker, run_by_group = fastdfs, run_by_user = fastdfs, connect_timeout = 30 s, network_timeout = 60 s, 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 = 10 s, check_active_interval = 1 20 s, thread_stack_size = 64 KB, bytes = 1, bytes = 86400 s, bytes = 300 s, 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 =, trunk_create_file_interval = 86400, timeout = 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, bytes =, bytes = 0, bytes = 0, use_connection_pool = 1, g_connection_pool_max_idle_time = 3600s install the Storage Server-192.168.127.12 configuration and start the Storage Server. reference the above example to install libevent and fastdfs step 01 # modify storage. conf: Configure 02vim/usr/local/fastdfs/conf/storage. conf03 # the name Of the group this storage server belongs to04group_name = group105 # the name of the group this storage server belongs to06 # the storage server port # the storage server port07port = 2300008 # the base path to store data and log files # log directory 09base_path =/home/yuqing/fastdfs->/home/fastdfs/storage10 # store_path #, based 0, if store_path0 not exists, it's value is base_path # data storage directory 11 # the paths must be Exist12store_path0 =/home/fastdfs/storage13 # unix group name to run this program, 14 # not set (empty) means run by the group of current user15run_by_group =-> fastdfs16 # unix username to run this program, 17 # not set (empty) means run by current user18run_by_user =-> fastdfs19 # tracker_server can ocur more than once, and tracker_server format is20 # "host: port", host can be hostname or ip address21tracker _ Server = 192.168.209.121: 22122-> tracker_server = 192.168.127.11: 2212201 # appendix to the base_path directory Description: 02 tracker server directory and file structure: 03 $ {base_path} 04 |__ data05 |__ storage_stat.dat: local storage Information 06 |__ sync07 |__ binlog.20.8 |__ binlog. index09 |__ logs10 |__ storaged. log: storage server log File 01 # edit the startup script 02vim/etc/init. d/fdfs_storaged03 # Add the following content 04 #! /Bin/bash05 #06 # fdfs_storaged Starts fdfs_storaged07 #08 #09 # chkconfig: 2345 99 0110 # description: FastDFS storage server11 ### begin init INFO12 # Provides: $ fdfs_storaged13 ### end init INFO14 # Source function library.15./etc/init. d/functions16FastDfs = '/usr/local/fastdfs' 17CONF = "$ FastDfs/conf/storage. conf "18if [! -F $ CONF]; then19 echo "file $ CONF does not exist! "20 exit 221fi22PRG =" $ FastDfs/bin/fdfs_storaged "23if [! -F $ PRG]; then24 echo "file $ PRG does not exist! "25 exit 226fi27Stop =" $ FastDfs/bin/stop. sh "28if [! -F $ Stop]; then29 echo "file $ Stop does not exist! "30 exit 231fi32Restart =" $ FastDfs/bin/restart. sh "33if [! -F $ Restart]; then34 echo "file $ Restart does not exist! "35 exit 236fi37RETVAL = 038 start () {39 echo-n $" Starting FastDFS storage server: "40 $ PRG $ CONF & 41 RETVAL =$? 42 echo43 return $ RETVAL44} 45 stop () {46 echo-n $ "Stop FastDFS storage server:" 47 $ Stop $ PRG $ CONF48 RETVAL =$? 49 return $ RETVAL50} 51 rhstatus () {52 status fdfs_storaged53} 54 restart () {55 $ Restart $ PRG $ CONF & 56} 57 case "$1" in58 start) 59 start60; 61 stop) 62 stop63; 64 status) 65 rhstatus66; 67 restart | reload) 68 restart69; 70 condrestart) 71 restart72; 73 *) 74 echo $ "Usage: $0 {start | stop | status | restart | condrestart}" 75 exit 176esac77exit $? 78 #79 # Add x permission 80 chmod a + x/etc/init. d/fdfs_storaged01 # Start storage02service fdfs_storaged restart03 # A Lot Of mkdir data path will appear next. This is when the system creates the data DIRECTORY 04 data path:/home/fastdfs/storage/data, mkdir sub dir... 05 mkdir data path: 00... 06 mkdir data path: 01... 07 mkdir data path: 02... 08 mkdir data path: 03... 09 ....................... 10 data path:/home/fastdfs/storage/data, mkdir sub dir done.1 # start successfully, add start 2 # vim/etc/rc. d/ Rc. local3service fdfs_storaged restart install Storage Server-192.168.127.13 configure and start Storage Server reference install libevent and fastdfs in the above example step 01 # modify storage. conf: Configure 02vim/usr/local/fastdfs/conf/storage. conf03 # the name of the group this storage server belongs to04group_name = group205 # the name of the group this storage server belongs to06 # the storage server port # the storage server port07port = 2300008 # the base path Store data and log files # log directory 09base_path =/home/yuqing/fastdfs->/home/fastdfs/storage10 # store_path #, based 0, if store_path0 not exists, it's value is base_path # data storage directory 11 # the paths must be exist12store_path0 =/home/fastdfs/storage13 # unix group name to run this program, 14 # not set (empty) means run by the group of current user15run_by_group =-> fastdfs16 # unix username to run this program, 17 # n Ot set (empty) means run by current user18run_by_user =-> fastdfs19 # tracker_server can ocur more than once, and tracker_server format is20 # "host: port ", host can be hostname or ip address21tracker_server = 192.168.209.121: 22122-> tracker_server = 192.168.127.11: 2212201 # base_path directory Description: 02 tracker server directory and file structure: 03 $ {base_path} 04 |__ data05 |__ storage_stat.dat: local storage Information 06 |__ sync07 |__ binlog.20.8 | |__ Binlog. index09 |__ logs10 |__ storaged. log: storage server log File 01 # Start storage02service fdfs_storaged restart03 # A Lot Of mkdir data path will appear next. This is when the system creates the data DIRECTORY 04 data path:/home/fastdfs/storage/data, mkdir sub dir... 05 mkdir data path: 00... 06 mkdir data path: 01... 07 mkdir data path: 02... 08 mkdir data path: 03... 09 ....................... 10 data path:/home/fastdfs/storage/data, mkdir sub dir done.1 # start successfully. 2 # vim/etc/rc. d/rc. local3service fdfs_storaged restart install Storage Server-192.168.127.14 configure and start Storage Server reference install libevent and fastdfs in the above example step 01 # modify storage. conf: Configure 02vim/usr/local/fastdfs/conf/storage. conf03 # the name of the group this storage server belongs to04group_name = group205 # the name of the group this storage server belongs to06 # the storage server port # the storage server port07port = 2300008 # The base path to store data and log files # log directory 09base_path =/home/yuqing/fastdfs->/home/fastdfs/storage10 # store_path #, based 0, if store_path0 not exists, it's value is base_path # data storage directory 11 # the paths must be exist12store_path0 =/home/fastdfs/storage13 # unix group name to run this program, 14 # not set (empty) means run by the group of current user15run_by_group =-> fastdfs16 # unix username to run This program, 17 # not set (empty) means run by current user18run_by_user =-> fastdfs19 # tracker_server can ocur more than once, and tracker_server format is20 # "host: port ", host can be hostname or ip address21tracker_server = 192.168.209.121: 22122-> tracker_server = 192.168.127.11: 2212201 # base_path directory Description: 02 tracker server directory and file structure: 03 $ {base_path} 04 |__ data05 | |__ storage_stat.dat: local storage Information 06 |__ sync07 | |__ Binlog.00008 |__ binlog. index09 |__ logs10 |__ storaged. log: storage server log File 01 # Start storage02service fdfs_storaged restart03 # A Lot Of mkdir data path will appear next. This is when the system creates the data DIRECTORY 04 data path:/home/fastdfs/storage/data, mkdir sub dir... 05 mkdir data path: 00... 06 mkdir data path: 01... 07 mkdir data path: 02... 08 mkdir data path: 03... 09 ....................... 10 data path:/home/fastdfs/storage/data, mkdir sub dir Done.1 # start successfully, add to start 2 # vim/etc/rc. d/rc. local3service fdfs_storaged restart test and configure client1vim/usr/local/fastdfs/conf/client with fastdfs-192.168.127.11fastdfs. conf2base_path =/home/yuqing/fastdfs-> base_path =/home/fastdfs/hosts = 192.168.209.121: 22122-> tracker_server = 192.168.127.11: 221221cd/usr/local/bin2vim aa.txt added: display aa.txt text data: wq3./fdfs_test/usr/local/fastdfs/conf/client. conf up After load aa.txt is successfully executed, the following prompt is displayed: 01 #. /fdfs_test/usr/local/fastdfs/conf/client. conf upload aa.txt 02 [02:08:26] INFO-base_path =/home/fastdfs/tracker, connect_timeout = 30, network_timeout = 60, tracker_server_count = 1, anti_steal_token = 0, duration length = duration: 04 server 1. group_name = group2, ip_addr = 192.168.127.13, port = 232.165group_name = grou P2, ip_addr = 192.168.127.6, port = 233666storage_upload_by_filename07group_name = group2, remote_filename = M00/00/00/wKh_BlA3wxql4hTXAAAAB8v-VvY710.txt08source ip address: 192.168.127.1309file timestamp = 2012-08-25 02: 08: 2610 file size = 711 file crc32 = 342244325412 file url: 13storage_upload_slave_by_filename14group_name = group2, remote_filename = M00/00/00/wKh_BlA3wxql4hTXAAAAB8v-VvY710_big.txt15source ip addh Ss: 192.168.127.616file timestamp = 2012-08-25 02: 08: 2617 file size = 718 file crc32 = 342244325419 file url: 1 firewall seal may occur during execution: 2 # ERROR-file: tracker_proto.c, line: 420, connect to 192.168.127.11: 22122 fail, errno: 113, error info: No route to host3 solution: 4 iptables-L; iptables-F; service iptables stop test download file in the browser, enter the url address, tracker server will automatically redirect to the storage server of the storage file, the file is downloaded successfully. So far, fastdfs has been successfully set up. Write your own client for access: 1. Example of General commands for displaying aa.txt text data: 01 # monitor storage02/usr/local/fastdfs/bin/fdfs_monitor/usr/local/fastdfs/conf/storage. conf03 # If there are multiple groups, you only need to monitor one of them, the status of all groups can be called up. 04 05 # Delete the server storage in the group and view the server status in each group. 06/usr/local/fastdfs/bin/fdfs_monitor/usr/local/fastdfs/conf/ client. conf delete group2 192.168.127.1307/usr/local/fastdfs/bin/fdfs_monitor/usr/local/fastdfs/conf/client. conf08storage server has Seven statuses, as shown below (the value ranges from 1 ~ 7): 09 # FDFS_STORAGE_STATUS: INIT: initialization. Source Server 10 # FDFS_STORAGE_STATUS: WAIT_SYNC: Waiting for synchronization. Source Server 11 # FDFS_STORAGE_STATUS: SYNCING: synchronization in 12 # FDFS_STORAGE_STATUS: DELETED, this server removes 13 # FDFS_STORAGE_STATUS: OFFLINE 14 # FDFS_STORAGE_STATUS: ONLINE, cannot provide service 15 # FDFS_STORAGE_STATUS: ACTIVE: Online, can provide service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.