Cluster deployment of FASTDFS

Source: Internet
Author: User
Tags gz file

First, the preparatory work
1 Download software: http://sourceforge.net/projects/fastdfs/files/
Https://pan.baidu.com/s/1gfJ0WSz#list/path=%2F

Fastdfs-nginx-module_v1.16.ta
R.gz
17.09KB

Fastdfs_v5.05.ta
R.gz
337.3KB

Ngx_cache_purge-2.3.ta
R.gz
11.96KB

Libfastcommon-maste
R.zip
467.71KB
2 Install GCC. Command: Yum install make cmake gcc gcc-c++

Second, installation Libfastcommon
1. Download software: Https://github.com/happyfish100/libfastcommon
2. Upload Libfastcommon-master.zip to the/home/lee directory

    1. To decompress Libfastcommon-master.zip:
      Command: Unzip libfastcommon-master.zip-d/usr/local/fast/
    2. Entry directory: cd/usr/local/fast/libfastcommon-master/

    3. To compile and install:
      Command:./make.sh
      Command:./make.sh Install

Note the path to the installation: that is, our Libfastcommon is installed by default to/usr/lib64/this
Position.
6. Create a soft link.
Fastdfs The main program Settings directory is/usr/local/lib/, and our installation directory is/usr/lib64, so we need to create/
usr/lib64/a soft-connect file under some core execution program.
Create a Directory
Command: Mk dir/usr/local/lib/
Create a soft link
Command: Ln-s/usr/lib64/libfastcommon.so/usr/local/lib/libfastcommon.so

Command: Ln-s/usr/lib64/libfastcommon.so/usr/lib/libfastcommon.so
Command: Ln-s/usr/lib64/libfdfsclient.so/usr/local/lib/libfdfsclient.so
Command: Ln-s/usr/lib64/libfdfsclient.so/usr/lib/libfdfsclient.so
Third, installation Fastdfs
1 go to Cd/home/lee, unzip the fastdfs_v5.05.tar.gz file
Command: Cd/home/lee
Command: TAR-ZXVF fastdfs_v5.05.tar.gz-c/usr/local/fast/
2 Installing the compilation
Command: cd/usr/local/fast/fastdfs/
Compile command:./make.sh
Install command:./make.sh Install

3 script file description with default installation method:
Service scripts in:
/etc/init.d/fdfs_storaged
/etc/init.d/fdfs_trackerd

Configuration files in:
/etc/fdfs/client.conf.sample
/etc/fdfs/storage.conf.sample
/etc/fdfs/tracker.conf.sample

Command-line tool in the/usr/bin/directory, fdfs_* some columns to execute the script

4. Because the Fastdfs service script is set to the bin directory under/usr/local/bin/, but the actual we installed in the/U
Sr/bin/below. So we need to modify the path in the Fastdfs configuration file, which means we need to modify both
Configuration files:
Command: vim/etc/init.d/fdfs_storaged
To make a global substitution command:%s+/usr/local/bin+/usr/bin
Command: Vim/etc/init.d/fdfs_trackerd
To make a global substitution command:%s+/usr/local/bin+/usr/bin
Four. Configuring the Tracker
1 Enter the cd/etc/fdfs/directory configuration tracker file and put the Tracker.conf.sample file
Make a copy of cope: Go to modify the tracker.conf file

2 Modify tracker.conf File
Command: vim/etc/fdfs/tracker.conf
As shown: We can temporarily modify the Base_path in the configuration file.

Modify the path to your own address: Base_path=/fastdfs/tracker
Note: For the tracker.conf Profile parameter interpretation, you can find the official documentation at the address:
Http://bbs.chinaunix.net/thread-1941456-1-1.html

3 Finally we must create the previously defined directory (i.e./fastdfs/tracker):
Command: Mkdir-p/fastdfs/tracker
4 Turn off the firewall:
Vim/etc/sysconfig/iptables
Added:-A input-m State--state new-m tcp-p TCP--dport 22122-j ACCEPT
Restart: Service iptables restart
Five-start tracker

Catalog commands: cd/fastdfs/tracker/&& ll
Start tracker command:/etc/init.d/fdfs_trackerd start
View process command: Ps-el | grep Fdfs
Stop Tracker command:/etc/init.d/fdfs_trackerd stop
6 You can set the boot-up tracker: (General production environment needs to boot some services, such as Keepalived, Linux, Tomcat)
Command: vim/etc/rc.d/rc.local
Join configuration:/etc/init.d/fdfs_trackerd start
Vi. Configuring FASTDFS Storage

1 Go to file directory: cd/etc/fdfs/, copy storage file
Command: cd/etc/fdfs/
Command: CP storage.conf.sample storage.conf

2 Modify storage.conf File
Command: vim/etc/fdfs/storage.conf
What to modify:
Base_path=/fastdfs/storage
Store_path0=/fastdfs/storage
tracker_server=192.168.1.172:22122
http.server_port=8888
3 Creating a storage directory: Mkdir-p/fastdfs/storage

4 Open the firewall:
Command: Vim/etc/sysconfig/iptables
Added:-A input-m State--state new-m tcp-p TCP--dport 23000-j ACCEPT
Restart: Service iptables restart
5 boot storage (storage)
Command:/etc/init.d/fdfs_storaged start (Close command:/etc/init.d/fdfs_storaged stop)
(The data, logs two directories will be created in the/fastdbf/storage/directory after the initial boot success)

6 See if Fastdfs storage started successfully
Command: PS-EF | grep Fdfs

And we go into the/fastdfs/storage/data/folder and see some directory files (256*256)
As follows:
Command: cd/fastdfs/storage/data/&& ls

7 Similarly, the boot-up memory can also be set: (General production environment need to boot some services, such as Keepalived, Linux, Tomcat)
Command: vim/etc/rc.d/rc.local
Join configuration:/etc/init.d/fdfs_storaged start

So far, our FASTDFS environment has been built!

Seven. Test environment

1 We first use the command to upload a file. Note: It is uploaded in the tracker (tracker).
First we copy a copy of the client.conf file in the tracker.
Command: cd/etc/fdfs/
Command: CP client.conf.sample client.conf

2 Edit client.conf File
Command: vim/etc/fdfs/client.conf
What to modify:
Base_path=/fastdfs/tracker
tracker_server=192.168.1.172:22122

3 We find the script location of the command, and use the command to upload the file:
Command: cd/usr/bin/
Command: LS | grep Fdfs

4 Use the command Fdfs_upload_file to upload the operation:
First, let's look at the memory, go to data, enter the 00 folder
Below, we found a bunch of folders under the 00 folder, and then continued to enter the 00 folder, and eventually we
The folder entered is:
There are no documents in/fastdfs/storage/data/00/00.

Then, we do the upload, for example, to put one of the previous/usr/local/software/folder
Files are uploaded to the Fastdfs system, uploading files in the tracker, commands such as
Under
Command:/usr/bin/fdfs_upload_file/etc/fdfs/client.conf
/home/lee/fastdfs_v5.05.tar.gz

Finally, we find that when the command is finished, it returns a group1/m00/00/00/... The ID, in fact,
is to return the currently uploaded files in the memory of which group, which directory location, so we look at the memory of the/fastdfs/storage/data/00/00 folder location, found that there is already a file just uploaded, so far, our test upload file is OK.
As follows:

Eight. Fastdfs and Nginx Integration
1 First, you must first install the Nginx (: http://mirrors.sohu.com/nginx/)

2 Then we install the fastdfs-nginxmodule_v1.16.tar.gz package on the storage node for consolidation.

Catalog command: Cd/home/lee
Decompression command: tar-zxvf/home/lee/fastdfs-nginx-module_v1.16.tar.gz-c
/usr/local/fast/

3 Entry directory: CD fastdfs-nginx-module/src/

4 Edit Configuration file config
Command: Vim/usr/local/fast/fastdfs-nginx-module/src/config
What to modify: Remove the local file hierarchy in

The modifications are complete as follows:

5 Fastdfs and Nginx integration

First delete the previous Nginx
Catalog command: cd/usr/local/
Delete command: RM-RF nginx
Go to nginx Directory command: CD NGINX-1.6.2/
Installation dependent: yum-y install zlib pcre pcre-devel zlib-devel because Nginx installation is required
Add Module command:./configure--add-module=/usr/local/fast/fastdfs-nginx-module/src/
Recompile command: Make && make install
6 Copy the configuration file in the Fastdfs-ngin-module to the/etc/fdfs directory:

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

7 make modifications to the/etc/fdfs/directory, we just copied the mod_fastdfs.conf file.

Command: vim/etc/fdfs/mod_fastdfs.conf
What to modify: such as connection timeout, tracker path configuration, group configuration for URLs,
connect_timeout=10
tracker_server=192.168.1.172:22122
Url_have_group_name = True
Store_path0=/fastdfs/storage

8 Copy the 2 files in Fastdfs to the/etc/fdfs directory:

Catalog command: cd/usr/local/fast/fastdfs/conf/
Copy command: CP http.conf mime.types/etc/fdfs/

9 Create a soft connection, create a soft connection in the/fastdfs/storage file store directory, link it to the actual storage data
The directory.
Command: Ln-s/fastdfs/storage/data//fastdfs/storage/data/m00

10 Modifying the Nginx configuration file:

Command: Vim nginx.conf
Add the port mapping configuration as shown in the following:

The contents of the modification are:
Listen 8888;
server_name localhost;
Location ~/group ([0-9])/m00 {
Root/fastdfs/storage/data;
Ngx_fastdfs_module;
}
Note: The port in Nginx is configured in accordance with the configuration of the storage.conf file in the Fastdfs store.
i.e. (http.server_port=8888)
11 finally check the firewall, then we start the Nginx service
Start command:/usr/local/nginx/sbin/nginx,

Upload a file, upload it successfully,

Now we use this ID to access the address with the browser:
Http://192.168.1.173:8888/group1/M00/00/00/wKgBrVaSvM6AddWWAAVFOL7FJU4.tar.gz
We can download this file! As shown in the following:

Operation and Maintenance Note: When we use the FASTDFS, we need to shut down normally, do not use kill-9
Strong kill Fastdfs process, or will be in the file upload when the data loss occurs.
To this, our Fastdfs and Nginx integration is complete!!

Nine: Start the Stop service step as follows:

Start command:
Start tracker command:/etc/init.d/fdfs_trackerd start
View process command: Ps-el | grep Fdfs
Start storage command:/etc/init.d/fdfs_storaged start
View process command: Ps-el | grep Fdfs
Start nginx command:/usr/local/nginx/sbin/nginx

Stop command:
Stop Tracker command:/etc/init.d/fdfs_trackerd stop
Close Storage command:/etc/init.d/fdfs_storaged stop
Close Nginx command:/usr/local/nginx/sbin/nginx-s stop
To delete an uploaded file:
/usr/bin/fdfs_delete_file/etc/fdfs/client.conf Group1/m00/00/00/wk
Gbe1iecgoaafhdalsfs-ifsik.tar.gz
Thank.

Cluster deployment of 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.