Linux installation Fastdfs

Source: Internet
Author: User
Tags openssl

First do one thing, modify the hosts, the file server's IP and Domain name Mapping (single-machine trackerserver environment), because many of the configuration inside to configure the server address, IP changed, only need to modify the hosts can

Reference articles

1. Modify the Host

# vim/etc/hosts add the following line, which is my IP192.168. 51.128 file.fastdfs.com

2. Download and install Libfastcommon

Ibfastcommon is the public C function library extracted from the Fastdfs and FASTDHT, the basic environment, the installation can

 #下载libfastcommonwget https://github.com/happyfish100/libfastcommon/archive/v1.0.7.tar.gz #解压tar-ZXVF V1.0.7. tar.gz CD Libfastcommon-1.0.7 #编译, installation ./make.sh./make.shinstall #libfastcommon. So installed to the /usr/lib64/libfastcommon.so, but the Lib directory fastdfs the main program settings is/usr/local/ Lib, so you need to create a soft link. LN-s/usr/lib64/libfastcommon.so/usr/local/lib/libfastcommon.so
Ln-s/usr/lib64/libfastcommon.so/usr/lib/libfastcommon.so
Ln-s/usr/lib64/libfdfsclient.so/usr/local/lib/libfdfsclient.so
Ln-s/usr/lib64/libfdfsclient.so/usr/lib/libfdfsclient.so

3. Download and install Fastdfs

#下载FastDFSwget https://github.com/happyfish100/fastdfs/archive/v5.05.tar.gz#解压 Tar-ZXVF V5. to. tar.gz CD Fastdfs-5.05#编译, installation./make.sh./make.sh install# Default installation method after installation of the corresponding file and directory # Service script:/etc/init.d/fdfs_storaged/etc/init.d/fdfs_tracker# configuration file (these three are sample profiles given by the author):/etc/fdfs/Client.conf.sample/etc/fdfs/Storage.conf.sample/etc/fdfs/tracker.conf.sample

#the bin directory for the Fastdfs service script settings is/usr/local/bin, but the actual command is installed under/usr/bin/.
Ln-s/usr/bin/fdfs_trackerd/usr/local/
Ln-s/usr/bin/fdfs_storaged/usr/local/bin
Ln-s/usr/bin/stop.sh/usr/local/bin
Ln-s/usr/bin/restart.sh/usr/local/bin

4. Configuring the Fastdfs Tracker (Tracker)

 #进入/etc/fdfs, copy the Fastdfs Tracker sample configuration file tracker.conf.sample and rename it to tracker.conf. CD /etc/FDFSCP tracker.conf.sample tracker.confvim tracker.conf# Edit tracker.conf , the red need to modify the other, the default can be. # The configuration file does not take effect,  false   =< Span style= "COLOR: #0000ff" >false  # port for service ports Port  = 22122  # Tracker data and log directory address (root directory must exist, subdirectories are created automatically) Base_path  =/fastdfs/ tracker# HTTP service port http.server_port  =80  Span style= "COLOR: #000000" ># create tracker base data directory, which is base_path corresponding directory mkdir -p/fastdfs/ tracker# start tracker /etc/init.d/fdfs_trackerd start# to see if Fastdfs Tracker has started successfully, 22122 port is being monitored, the Tracker service is installed successfully. Netstat -unltp|grep Fdfs 

5. Configuring Fastdfs Storage (Storage)

#进入/etc/fdfs directory, copy fastdfs memory sample configuration file Storage.conf.sample, and rename to STORAGE.CONFCD/etc/fdfscp storage.conf.sample storage.confvim storage.conf# Edit storage.conf# configuration file does not take effect,falsefor the effective disabled=false# Specify this Storage server group (volume) Group_name=group1# Storage Server service ports Port=23000# heartbeat interval, in seconds (this is the active heartbeat to tracker server) Heart_beat_interval= -# Storage data and log directory address (root directory must exist, subdirectories are automatically generated) Base_path=/fastdfs/storage# Storage Server supports multiple paths when storing files. This configures the number of base paths where the files are stored, usually with only one directory. Store_path_count=1# Configure Store_path_count paths individually, index numbers based on0. # If you do not configure Store_path0, it will be the same as the base_path corresponding to the path. Store_path0=/fastdfs/storage# Fastdfs store files, a level two directory is used. This configures the number of directories where the files are stored. # If this parameter is only N (for example: the), storage server automatically creates N * under Store_path when it is first runN A subdirectory that stores files. Subdir_count_per_path= the# Tracker_server list that will actively connect tracker_server# when there are multiple tracker servers, each tracker server writes a line tracker_server=file.ljzsg.com:22122# The time period that allows the system to synchronize (default is all day). Generally used to avoid peak synchronization to create some problems and set. Sync_start_time=xx:xxSync_end_time= at: -# Access Port Http.server_port= the# Create storage base data directory, corresponding to Base_path directory mkdir-p/fastdfs/storage This is the configured Store_path0 path # Create storage base data directory, corresponding to Base_path directory mkdir-p/fastdfs/storage

#可以用这种方式启动
/etc/init.d/fdfs_storaged start

#查看 Storage is successfully started, Port 23000 is being monitored, even if Storage is successfully started.

Netstat-unltp|grep Fdfs

#查看Storage和Tracker是否在通信:

/usr/bin/fdfs_monitor/etc/fdfs/storage.conf

6. File Upload Test

/etc/FDFSCP client.conf.sample client.confvim client.conf# Modify the following configuration, other default. Base_path=/fastdfs/client#tracker port tracker_server=file.fastdfs.com:22122

#上传测试
/usr/bin/fdfs_upload_file/etc/fdfs/client.conf Namei.jpeg

7. Installing Nginx

The file upload was successful, but we can't download it. Therefore, Nginx is installed as a server to support HTTP access to files. At the same time, the installation of Fastdfs in the rear Nginx module also requires nginx environment.

Nginx only needs to be installed on the server where Storageserver is located to access the files. I am here because it is a single machine, Trackerserver and Storageserver on a server.

7.1 Install the required environment for Nginx

#gcc安装 yum install gcc-c++#PCRE PCRE-y PCRE pcre--y zlibzlib--y OpenSSL Openssl-devel

7.2 Installing Nginx

-C https:///nginx.org/download/nginx-1.12.1.tar.gz-zxvf nginx-1.12. 1 . TAR.GZCD nginx-1.12. 1 #使用默认配置. //usr/local/nginx/sbin/. //etc/rc.local/usr/local/nginx/sbin/755 rc.local

8.FastDFS Configuration Nginx Module

Fastdfs-nginx-module Module Description

Fastdfs the file is stored on the Storage server through the Tracker server, but file replication is required between the same set of storage servers and there is a problem of synchronization latency.

Assuming the Tracker server uploads the file to 192.168.51.128, the file ID has been returned to the client after the upload is successful.

At this point the FASTDFS storage cluster mechanism will synchronize this file to the same set of storage 192.168.51.129, if the file is not yet complete, the client if the file ID on the 192.168.51.129 to fetch files, there will be a file inaccessible error.

Instead, Fastdfs-nginx-module can redirect files to the source server to fetch files, preventing the client from being unable to access errors due to replication delays

#下载 fastdfs-nginx-module, Extract # Why is this so long a string, because the latest version of Master and the current Nginx some version of the problem. wget https://Github.com/happyfish100/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip#解压unzip 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip# to rename MV Fastdfs-NGINX-MODULE-5E5F3566BBFA57418B5506AAEFBE107A42C9FCB1 fastdfs-nginx-module-master# into unpacking directory CD/softpackages/nginx-1.12.1/#添加模块./configure--add-module=. /fastdfs-nginx-module-master/src# recompile, install make&&Make install# to view Nginx modules/usr/local/nginx/sbin/nginx-v# Copy Fastdfs-nginx-module the config file in the source code to/etc/Fdfs directory, and modify the CD/softpackages/fastdfs-nginx-module-master/SRCCP mod_fastdfs.conf/etc/fdfs/

Modify the following configuration, other default
# connection Timeout connect_timeout=ten# Tracker servertracker_server=file.ljzsg.com:22122 # storageserver Default port Storage_server_port=23000# If the URI of the file ID contains /group**True  # Storage configuration of the Store_path0 path, must and storage.conf in the same store_path0=/fastdfs/storage

#复制 part of the Fastdfs configuration file to the/etc/fdfs directory

cd/softpackages/fastdfs-5.05/conf/
CP anti-steal.jpg http.conf mime.types/etc/fdfs/

9. Configure Inginx, modify nginx.conf

vim/usr/local/nginx/conf/nginx.conf# Modify the configuration, the other default # is added under Port 80 Fastdfs-Nginx Module location~/group ([0-9])/M00 {ngx_fastdfs_module;}
Note: Listen theThe port value is to be associated with the http.server_port= in/etc/fdfs/storage.conf the(the front changed to 80) corresponds.  If you change to a different port, you need to unify and open the port in the firewall. Location configuration, if more than one group is configured with location~/group ([0-9])/m00, there is no need to match group.


Create a soft connection #在 the/ljzsg/fastdfs/file file store directory, and link it to the directory where the data is actually stored, this step can be omitted
ln-s/fastdfs/file/data//fastdfs/file/data/m00

#启动nginx
/usr/local/nginx/sbin/nginx

#在地址栏中访问成功
/HTTP
file.fastdfs.com/Group1/m00/00/00/wkgz6lnduteamdrcaaeormxzpp870.jpeg

Ten. Netcore Client Access

Please look forward to ...

Linux installation Fastdfs

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.