Linux to build a simple version of the FASTDFS server

Source: Internet
Author: User
Tags gz file

Development environment: CENTOS7 Environment

Building Fastdfs cluster is very complex, for the initial learning Fastdfs, to build a stand-alone version as an introduction more practical.

First of all, thank the "struggling in Beijing" Blogger's detailed construction process, with the blog address http://blog.csdn.net/u012453843/article/details/69951920

This article mainly refers to the above blog to build, do not do a special detailed construction process

1. Build CENTOS7 Environment

2. Configure the bridging mode for extranet access level access to the external network

3. Installing the GCC Environment

Yum install make CMake gcc gcc-c++ for installation

4. Upload the installation files to the/usr/local/software directory

If not, create a new directory Mkdir/usr/local/software

Upload the required installation package: Install package address currently in Blog Park space file Sofeware Package

Upload success as (the figure does not cross the line section, a total of 4)

5. Install the zip and Unzip commands (for extracting zip files)

Yum Install zip unzip

6. Installing Libfastcommon

A: Unzip

Unzip libfastcommon-master.zip-d/usr/local/fast/

B. Enter the catalogue

cd/usr/local/fast/libfastcommon-master/

C Compilation

./make.sh

D. Installation

./make.sh Install

7. Create a soft connection

Fastdfs The main program Settings directory is/usr/local/lib/, so we need to create/usr/lib64/the soft connection files under some core execution program. as shown below.

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

8. Installing Fastdfs

A. Go to Cd/usr/local/software, unzip the fastdfs_v5.05.tar.gz file

B. Compiling the installation

cd/usr/local/fast/fastdfs/

./make.sh

./make.sh Install

After installation, the service script location is as follows

The configuration file location is as follows (the underlined part is added later)

Fastdfs a series of execution scripts as follows, you can see the upload file script, download the file script and so on.

cd/usr/bin/&& ls | grep Fdfs

C.

The C1:fastdfs service script is set to the bin directory under/usr/local/bin/, but actually we are installed under/u sr/bin/. So we need to modify the path in the Fastdfs configuration file, which means we need to modify two configuration files

Use the command vim/etc/init.d/fdfs_storaged to enter edit mode, and then enter ":" Directly, the cursor will be positioned to the last line, after ":" Enter "%s+/usr/local/bin+/usr/bin", as shown in. After entering, you will be prompted to change the 7.

C2: Then modify the second configuration file, we use the command vim/etc/init.d/fdfs_trackerd into the edit mode, and then enter ":%s+/usr/local/bin+/usr/bin" as above and press ENTER, It also reminds us that we have changed 7 places.

9. Configure the Tracking server

A enter into the/etc/fdfs directory and copy the Tracker.conf.sample and name tracker.conf as shown below.

CP Tracker.conf.sample tracker.conf

b Use the command vim/etc/fdfs/tracker.conf to enter edit mode, and then modify the value of Base_path to/fastdfs/tracker,

C. The/fastdfs/tracker we have configured in the configuration file currently does not exist, so we need to create this directory

Mkdir-p/fastdfs/tracker (the folder/fastdfs/tracker is created in the root directory)

D. Configure and restart the firewall

Release the port used by tracker 22122

firewall-< Span class= "hljs-comment" >cmd -- zone=public --add-port=22122/tcp --permanent

firewall-cmd -- Reload

< Span class= "hljs-literal" >< Span class= "hljs-comment" >< Span class= "hljs-literal" >< Span class= "hljs-comment" > E. Before starting Tracker, there is no file in the/fastdfs/tracker directory

< Span class= "hljs-literal" >< Span class= "hljs-comment" >< Span class= "hljs-literal" >< Span class= "hljs-comment" >f.    start Tracker, after you start, you can see two more directories in this directory data and logs

< Span class= "hljs-literal" >< Span class= "hljs-comment" >< Span class= "hljs-literal" >< Span class= "hljs-comment" >/etc /init.d/fdfs_trackerd start

10. Set up boot from boot

Add/etc/init.d/fdfs_trackerd start in the rc.local file

Vim/etc/rc.d/rc.local

11. Configuring FASTDFS Storage

A. Go to the/etc/fdfs directory, copy the Storage.conf.sample file and name it storage.conf

B. Modify the storage.conf file, we use the command vim/etc/fdfs/storage.conf into the editing mode, the following four items are modified, the IP192.168.0.204 of my virtual machine, everyone according to their own virtual machine's IP set itself.

    1. Base_path=/fastdfs/storage
    2. Store_path0=/fastdfs/storage
    3. tracker_server=192.168.156.13:22122
    4. http.server_port=8888

C. Create the storage directory as shown below.

Mkdir-p/fastdfs/storage

12. Configure the firewall to allow external access to the storage default port 23000

firewall-cmd --zone=public --add-port=23000/tcp --permanent

< Span class= "hljs-comment" >< Span class= "hljs-literal" >< Span class= "hljs-comment" >< Span class= "hljs-literal" >firewall -cmd - -reload

< Span class= "hljs-literal" >< Span class= "hljs-comment" >< Span class= "hljs-literal" >< Span class= "hljs-comment" >13. Before starting storage, there is no file in the/fastdbf/storage directory

< Span class= "hljs-literal" >< Span class= "hljs-comment" >< Span class= "hljs-literal" >< Span class= "hljs-comment" >   Start storage, start and look at/fastdfs/storage directory, you can see more data and logs

14. To see if the Fastdfs tracker and storage have started successfully, the instructions are started successfully when you see the information shown below.

15. We enter into the/fastdfs/storage/data/directory, you can see the level two 256*256 a directory, each level from 00 to FF, the following is only a list of the first level of the directory, click into each directory there are 00 to FF a total of 256 directories.

16. Set storage boot, add a line/etc/init.d/fdfs_storaged start

Vim/etc/rc.local

17. Test image Upload

A. Enter into the/etc/fdfs directory and copy the Client.conf.sample and rename it to client.conf,

CP Client.conf.sample client.conf

B. Use the command vim/etc/fdfs/client.conf to enter edit mode and modify the following two items as shown below

    1. Base_path=/fastdfs/tracker
    2. tracker_server=192.168.0.204:22122

C we find the script location of the command, and use the command to upload the file.

.

d. test file Upload/usr/bin/fdfs_upload_file/etc/fdfs/client.conf/usr/local/software/3.jpg

Combination of 18:fastdfs and Nginx

A. Install Nginx first, you can see this blog address Linux installation Nginx

B. Install the fastdfs-nginxmodule_v1.16.tar.gz (combination of fast and Nginx Module installation package), enter the/usr/local/software directory and unzip, as shown below

Cd/usr/local/software/

TAR-ZXVF fastdfs-nginx-module_v1.16.tar.gz-c/usr/local/fast/

C. Go to the/usr/local/fast directory to see the extracted Fastdfs-nginx-module directory, and then go to the fastdfs-nginx-module/src/directory, you can see the config file.

cd/usr/local/fast/fastdfs-nginx-module/src/

To modify the Conf file, we changed the fourth line of the file in the configuration of/usr/local/include to/usr/include, a total of two.

D. Fastdfs with Nginx, as we have just installed Nginx, so in the/usr/local directory has generated a nginx directory

Default installation Address/usr/local/nginx (if not, can be queried via Whereis nginx or find/-name Nginx

In order to combine nginx and Fastdfs, we first remove this Nginx directory, as shown, you can see there is no Nginx directory.

RM-RF Nginx

Enter the nginx-version number (1.6.2)/directory and perform the configuration and compilation installation as shown below.

./configure --add-module=/usr/local/fast/fastdfs-nginx-module/src/

Make && make install

Copy the configuration file from the Fastdfs-nginx-module to the/etc/fdfs directory

cp/usr/local/fast/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/

To the/etc/fdfs/directory, modify the mod_fastdfs.conf file that we just copied, the entry needs to be modified as follows, where the first item is the timeout length, and the third is to allow the outside world to access the resources via HTTP.

    1. connect_timeout=Ten
    2. tracker_server=192.168.156.13:22122
    3. Url_have_group_name = true
    4. Store_path0=/fastdfs/storage

Copy the 2 files in the Fastdfs to the/etc/fdfs directory, as shown below.

[[email protected] fdfs]# cd/usr/local/fast/fastdfs/conf/  [[email protected] conf]# ll  total usage  -rw-r--r--. 1 8980 users 23981 December  2 anti-steal.jpg  -rw-r--r--. 1 8980 users  1461 December  2 client.conf  -rw- R--r--. 1 8980 users   858 December  2 http.conf  -rw-r--r--. 1 8980 users 31172 December  2 mime.types  -rw-r-- R--. 1 8980 users  7829 December  2 storage.conf  -rw-r--r--. 1 8980 users   105 December  2 storage_ids.co NF  -rw-r--r--. 1 8980 users  7102 December  

[email protected] conf]# CP http.conf mime.types/etc/fdfs/

Create a soft connection, create a soft connection in the/fastdfs/storage file store directory, and link it to the directory where the data is actually stored, as shown below.

Go to the/usr/local/nginx/conf/directory and modify the nginx.conf file as shown in.

The modified content is shown as

Listen       9999;    Location ~/group ([0-9])/m00 {       ngx_fastdfs_module;  

Set the Nginx boot from start, so the next time you restart the device, tracker, storage, Nginx are automatically started, you can use the service directly, as shown below.

Vim/etc/rc.d/rc.local

Add at the bottom

/usr/local/nginx/sbin/nginx

Open Nginx Firewall

firewall-< Span class= "hljs-comment" >cmd -- zone=public --add-port=9999/tcp  --permanent

firewall-cmd -- reload

< Span class= "hljs-literal" >< Span class= "hljs-comment" >< Span class= "hljs-literal" >< Span class= "hljs-comment" > Now we can access the image we just uploaded via http (we just uploaded the image to return the address is group1/m00/00/00/wkgazfogekyadjbgaaaonxozs7o921.jpg), as shown in.

Linux to build a simple version of the FASTDFS server

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.