FASTDFS Configuration Instructions

Source: Internet
Author: User

Prior to understanding the principle of Fastdfs, then familiar with the installation process, prepared three machines, a simulation client, an analog storage, a simulation tracker. Three machines are debian6, the system for minimal installation, first install the basic compilation environment: Apt-get install build-essential php5-dev libevent-dev download Fastdfs Source package:

wget http://fastdfs.googlecode.com/files/fastdfs_v3.05.tar.gz

To start the installation:

Tar zxvf fastdfs_v3. 05.tar. Gz
CD Fastdfs/
./make. Sh
./make. SH Install

After the installation is complete, the FASTDFS default profile is placed under the/etc/fdfs directory, containing client.conf http.conf mime.types storage.conf Tracker.conf five files, the startup of the FASTDFS process is differentiated by the loaded configuration file. The three configuration files are included in the source package. tracker.conf Configuration File Analysis:

#配置tracker. conf This configuration file is in effect because the configuration file needs to be specified when the FASTDFS server process is started, so the secondary configuration file needs to take effect. False is valid, and true is masked.
Disabled=False

#程序的监听地址, if not set, then listen to all addresses.
Bind_addr=

#tracker监听的端口
Port=22122

#链接超时设定
Connect_timeout=30

#tracker在通过网络发送接收数据的超时时间
Network_timeout=60

#数据和日志的存放地点
Base_path=/opt/Fdfs

#服务所支持的最大链接数
Max_connections=256

#工作线程数一般为cpu个数
Work_threads=4

#在存储文件时选择group的策略, 0: Rotation strategy 1: Specify a group 2: Load Balancer, select the group with the largest free space
Store_lookup=2

#如果上面的store_lookup选择了1, you need to specify a group
#store_group =group2

#在group中的哪台storage做主storage, when a file is uploaded to the main storage, this machine synchronizes files to other storage within the group, 0: Rotation strategy 1: Sort by IP address, first 2: Sort by priority, first
Store_server=0

#选择那个storage作为主下载服务器, 0: Rotation strategy 1: Master upload storage as primary download server
Download_server=0

#选择文件上传到storage中的哪个 (Directory/mount point), storage can have multiple base path 0: Rotation policy 2: Load Balancing, select the largest free space
Store_path=0

#系统预留空间, when the remaining space of any storage in a group is less than the defined value, the entire group cannot upload the file.
Reserved_storage_space= 4GB

#日志信息级别
Log_level=Info

#进程以那个用户/user group run, do not specify the default is the current user
Run_by_group=
Run_by_user=

#允许那些机器连接tracker默认是所有机器
Allow_hosts=*

#设置日志信息刷新到disk的频率, Default 10s
Sync_log_buff_interval= 10

#检测storage服务器的间隔时间, storage regularly actively send the heartbeat to tracker, if the signal is confiscated at a specified time, tracker storage fault, the default 120s
Check_active_interval= 120

#线程栈的大小, Minimum 64K
Thread_stack_size= 64KB

#storage的ip改变后服务端是否自动调整, storage automatically adjusts when the process restarts
Storage_ip_changed_auto_adjust= True

#storage之间同步文件的最大延迟, default 1 days
Storage_sync_file_max_delay= 86400

#同步一个文件所花费的最大时间
Storage_sync_file_max_time= 300

#是否用一个trunk文件存储多个小文件
Use_trunk_file= False

#最小的solt大小, should be less than 4KB, default 256bytes
Slot_min_size= 256

#最大的solt大小, if the uploaded file is less than the default value, the upload file is placed in the trunk file
Slot_max_size= 16MB

#trunk文件的默认大小, should be greater than 4M
Trunk_file_size= 64MB

#http服务是否生效, default does not take effect
http.Disabled=False

#http服务端口
http.Server_port=8080

#检测storage上http服务的时间间隔, <=0 indicates no detection
http. check_alive_interval=30

#检测storage上http服务时所用请求的类型, TCP detects only if it can connect, HTTP must return 200
HTTP. Check_alive_type=TCP

#通过url检测storage HTTP Service Status
HTTP. Check_alive_uri=/status. Html

#if need find content type from file extension name
HTTP. Need_find_content_type=true

#用include包含进http的其他设置
# #include http.conf

Start the tracker process

Fdfs_trackerd /etc/Fdfs/tracker. conf

Detection status

Netstat -tupln| grep Tracker
#可以看到如下:
TCP 0 0 0.0. 0.0:22122 0.0. 0.0:* LISTEN 18559/fdfs_trackerd

storage.conf Configuration File Analysis:

#同tracker. conf
Disabled=False

#这个storage服务器属于那个group
Group_name=Group1

#同tracker. conf
Bind_addr=

#连接其他服务器时是否绑定地址, this parameter is valid for BIND_ADDR configuration
Client_bind=True

#同tracker. conf
Port=23000
Connect_timeout=30
Network_timeout=60

#主动向tracker发送心跳检测的时间间隔
Heart_beat_interval=30

#主动向tracker发送磁盘使用率的时间间隔
Stat_report_interval=60

#同tracker. conf
Base_path=/opt/Fdfs
Max_connections=256

The buff size of the #接收/Send data must be greater than 8KB
Buff_size= 256KB

#同tracker. conf
Work_threads=4

#磁盘IO是否读写分离
disk_rw_separated= True

#是否直接读写文件, off by default
Disk_rw_direct= False

#混合读写时的读写线程数
Disk_reader_threads= 1
Disk_writer_threads= 1

#同步文件时如果binlog没有要同步的文件, the number of milliseconds after which the delay is re-read, 0 means no delay
Sync_wait_msec=50

#同步完一个文件后间隔多少毫秒同步下一个文件, 0 means no rest, direct synchronization
Sync_interval=0

#表示这段时间内同步文件
Sync_start_time=00:00
Sync_end_time=23:59

#同步完多少文件后写mark标记
Write_mark_file_freq=500

#storage在存储文件时支持多路径, the default setting is only one
Store_path_count=1

#配置多个store_path路径, starting from 0, if Store_path0 does not exist, then Base_path must exist
Store_path0=/opt/Fdfs
#store_path1 =/OPT/FASTDFS2

#subdir_count * Subdir_count directories are created under Store_path, with level two storage
Subdir_count_per_path=256

#设置tracker_server
Tracker_server=X.X.X.X:22122

#同tracker. conf
Log_level=Info
Run_by_group=
Run_by_user=
Allow_hosts=*

#文件在数据目录下的存放策略, 0: Rotation 1: Random
File_distribute_path_mode=0

#当问及是轮训存放时, the number of files that can be stored in a directory
File_distribute_rotate_count=100

#写入多少字节后就开始同步, 0 means out of sync
Fsync_after_written_bytes=0

#刷新日志信息到disk的间隔
Sync_log_buff_interval=10

#同步storage的状态信息到disk的间隔
Sync_stat_file_interval=300

#线程栈大小
Thread_stack_size=512KB

#设置文件上传服务器的优先级, the lower the value the higher
Upload_priority=10

#是否检测文件重复存在, 1: Detection 0: no detection
Check_file_duplicate=0

#当check_file_duplicate设置为1时, the secondary value must be set
Key_namespace=Fastdfs

#与FastDHT建立连接的方式 0: Short connection 1: Long connection
Keep_alive=0

#同tracker. conf
HTTP. Disabled=false
HTTP. domain_name=
HTTP. Server_port=8888
HTTP. Trunk_size=256KB
HTTP. Need_find_content_type=true
# #include http.conf

Start the storage process

Fdfs_storaged /etc/fdfs/storage. conf

Detection status

Netstat -tupln | grep storage
#结果如下:
TCP 0 0 0.0. 0.0:23000 0.0. 0.0:* LISTEN 17138/fdfs_storaged

client.conf Configuration File Analysis:

#同tracker. conf
Connect_timeout=30
Network_timeout=60
Base_path=/opt/fdfs
Tracker_server=x. X. X. X:22122
Log_level=Info
HTTP. Tracker_server_port=8080

To test the upload file:

Fdfs_upload_file /etc/Fdfs/client. Conf client. Conf
#返回如下字符串
Group1/M00/xx/xx/cgegflaqafw4henaaaaco8wrbse16. conf

You can see the file in the 00/00 directory under the storage data directory, the file name is cgegflaqafw4henaaaaco8wrbse16.conf

FASTDFS Configuration Instructions

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.