Fastdfs installation, configuration, API usage (i)-Installation and deployment

Source: Internet
Author: User

Fastdfs is an open source, high performance Distributed File system, his main features include: file storage, synchronization and access, design based on high availability and load balancing,Fastdfs is ideal for file-based Web sites, sample sharing and video sharing sites

Fastdfs has two roles: Tracking Service (tracker) and storage services (storage), service control, dispatch files are load balanced access, storage services include: file storage, file synchronization, provide file access interface, and key How value manages the metadata of a file

Tracking and storage services can be composed of 1 or more servers, and can be dynamically added, delete the tracking and storage services without affecting the online services, in the cluster, the tracker service is equivalent

The storage system consists of one or more volumes, and the files between the volumes and volumes are independent of each other, and the cumulative file capacity of all volumes is the file capacity of the entire storage system. A volume can consist of one or more storage servers, and the files in a storage server under a volume are the same, and multiple storage servers in the volume play a role of redundant backup and load balancing. When adding servers to a volume, synchronizing existing files is done automatically by the system, and after synchronization is complete, the system automatically switches the new server to the online service. You can add volumes dynamically when storage space is low or is about to be exhausted. You only need to add one or more servers and configure them as a new volume, which increases the capacity of the storage system.

First, start the installation:

1. Download the required files in Http://code.google.com/p/fastdfs/downloads/list, and install the libevent first.

2. Tar xzf fastdfs_v2.11.tar.gz

3. CD Fastdfs
If you support HTTP, vi make.sh, use/WITH_HTTPD to find this line, input I into the editing mode, delete the previous comments #,:wq save exit, if necessary to install the service, the following line is also untied.
./make.sh
./make.sh Install

4. Prepare several free ports to use Netstat-an | grep port number is occupied.

5. According to the actual situation to modify the configuration file under/etc/fdfs, each of which has a comment description, if you need HTTP, don't forget to unlock the bottom of the # include http.conf, to bring a #

6. Start Tracker:/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf

7. Start Storage:/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf, if an error occurs, you can view the specific cause of the error under the log directory of the directory that you set when you modified the configuration file in step 5.

8. The installation configuration is complete.


Second, operation use: Under the FASTDFS installation directory bin has the following executable file.


Uploading files:/usr/local/bin/fdfs_upload_file <config_file> <local_filename>

Download file:/usr/local/bin/fdfs_download_file <config_file> <file_id> [Local_filename]

Delete files:/usr/local/bin/fdfs_delete_file <config_file> <file_id>

Monitor:/usr/local/bin/fdfs_monitor/etc/fdfs/client.conf

Shut down:

Killall Fdfs_trackerd

Killall fdfs_storaged

Or

/usr/local/bin/stop.sh/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf

/usr/local/bin/stop.sh/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf

Restart:

/usr/local/bin/restart.sh/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf

/usr/local/bin/restart.sh/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf


Third, test upload:

./fdfs_test. /conf/client.conf upload Qq.png, you can see the file upload success.


You can find the image you just uploaded in the app/fdfs407/data/data/00/3c directory:



Iv. Fastdfs Upload process:

The client-side first initiates a file transfer action to Fastdfs, which is accomplished by connecting to a specified port on a Tracker server, Tracker server decides which Storage server to select based on the information currently available, and then This information, such as the address of the Storage Server, is returned to the client, which is then connected to the Storage server by the client, and the file to be uploaded is transferred to the Storage server.



In my project, it is generally possible to launch 2 tracker and 2 storage, as follows:

./fdfs_trackerd. /conf/tracker-1.conf
./fdfs_trackerd. /conf/tracker-2.conf
./fdfs_storaged. /conf/storage-g1-1.conf
./fdfs_storaged. /conf/storage-g2-1.conf

The next article describes how to configure each conf file.

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.