FastDFS file server implements dual-machine Hot Backup

Source: Internet
Author: User
Tags openssl library

FastDFS file server implements dual-machine Hot Backup

Two file fastDFS File Servers
Server A: 192.168.10.157
Server B: 192.168.10.158
The above implementation objective: to add a fastDFS Backup Server (192.168.10.158) as the slave server of the fastDFS File Server (192.168.10.157), two fastDFS file servers implement dual-machine hot backup.
That is, the data on the slave server (192.168.10.158) is always synchronized with the data on the master server (192.168.10.157) and changes with the data on the master server (192.168.10.157.
Environment Description
1. fastDFS Master server host name: Master
System: CentOS 6.6 IP: 192.168.10.157 FastDFS_v5.03. + nginx-1.6.2 + libevent-2.0.21-stable
2 fastDFS Slave server host name: Slave
System: CentOS 6.6 IP: 192.168.10.158 FastDFS_v5.03. + nginx-1.6.2 + libevent-2.0.21-stable
Note: We recommend that you use the same version of fastDFS and nginx as the master/slave server!
Start:
1. Install libevent
Note: perform the following operations on the two MySQL servers 192.168.10.157 and 192.168.21.158 respectively,
1. Download libevent-2.0.21-stable.tar.gz
Http://sourceforge.net/
2. decompress and install the configuration
Tar-zxvf libevent-2.0.21-stable.tar.gz
Cd libevent-2.0.21-stable
Mkdir-p/usr/local/libevnet
./Configure -- prefix =/usr/local/libevent
Make & make install
# Create a soft link to the/lib library for libevent. The 64-bit system corresponds to/lib64.
Ln-s/usr/local/libevent/lib/libevent-2.0.so.5/usr/lib/libevent-2.0.so.5

Ln-s/usr/local/libevent/lib/libevent-2.0.so.5/usr/lib64/libevent-2.0.so.5
At this point, the libevent installation is complete!
Ii. Install the fastDFS File Server
1、download lfastdfs_v5.03.tar.gz
Http://sourceforge.net/projects/fastdfs/
2. decompress and install the configuration
Tar zxvf FastDFS_v5.03.tar.gz
Cd FastDFS
Vim make. sh
# WITH_LINUX_SERVICE = 1/cancel comments of this row
./Make. sh
./Make. sh install
FastDFS installation is complete!
Files involving ip addresses:/etc/fdfs/storage. conf/etc/fdfs/client. conf/etc/fdfs/mod_fastdfs.conf
Files involving directories:/etc/fdfs/storage. conf/etc/fdfs/tracker. conf/etc/fdfs/client. conf/etc/fdfs/mod_fastdfs.conf
# Trackerd
/Usr/local/bin/stop. sh/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker. conf
/Usr/local/bin/restart. sh/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker. conf
# Storaged
/Usr/local/bin/stop. sh/usr/local/bin/fdfs_storaged/etc/fdfs/storage. conf

/Usr/local/bin/restart. sh/usr/local/bin/fdfs_storaged/etc/fdfs/storage. conf
3. Create a storage path and configure fastDFS_v5.03


Mkdir-p/www/geebook_storage # create a storage directory
Mkdir-p/www/geebook_tracker # create a directory for the tracker Scheduler
Mkdir-p/www/geebook_client # create the client directory
Cp/etc/fdfs/storage. conf/etc/fdfs/storage. conf-bak # back up the configuration file
Cp/etc/fdfs/tracker. conf/etc/fdfs/tracker. conf-bak # back up the configuration file
Cp/etc/fdfs/client. conf/etc/fdfs/client. conf-bak # back up the configuration file
Vi/etc/fdfs/storage. conf # modify the parameters of the storage configuration file
Base_path =/www/geebook_stoarge # the base path to store data and log files
Store_path0 =/www/geebook_storage # store_path #, based 0, if store_path0 not exists, it's value is base_path
Tracker_server = 192.168.10.157 # You can specify multiple synchronized IP addresses for the tracker server address.
Tracker_server = 192.168.10.158
Vi/etc/fdfs/tracker. conf # modify the parameters of the tracker configuration file

 

Base_path =/www/geebook_tracker # the base path to store data and log files

Vi/etc/fdfs/client. conf # modify the parameters of the client configuration file
Base_path =/www/geebook_client # the base path to store log files
Tracker_server = 192.168.10.157 # You can specify multiple synchronized IP addresses for the tracker server address.
Tracker_server = 192.168.10.158

3. install and configure fastdfs-nginx-mod-install
1. Installation preparation #####
In cat/etc/fdfs/mod_fastdfs.conf, # include http. conf,
# Include http. conf in cat/etc/fdfs/client. conf, indicating comment # include http. conf
##### Add users and groups adduser -- system -- no-create-home -- disabled-password -- disabled-login -- group nginx
Groupadd nginx
Useradd-g nginx-s/bin/false-M nginx
2. Download the installation package and related dependent packages and create the installation directory.
# Wget http://nginx.org/download/nginx-1.6.2.tar.gz
# Rewrite module pcre Library # wget http://downloads.sourceforge.net/project/pcre/pcre/8.36/pcre-8.36.zip
# Ssl functions require openssl library # wget http://www.openssl.org/source/openssl-1.0.2.tar.gz
# Gzip module requires zlib library # wget http://zlib.net/zlib-1.2.8.tar.gz
# Ngx_cache_purge clear Cache
# Wget -- no-check-certificate https://github.com/FRiCKLE/ngx_cache_purge/archive/master.zip-O ngx_cache_purge-master.zip
# Nginx-echo
# Wget -- no-check-certificate https://github.com/agentzh/echo-nginx-module/archive/master.zip-O echo-nginx-module-master.zip
# Nginx-upstream-fair
# Wget -- no-check-certificate https://github.com/gnosek/nginx-upstream-fair/archive/master.zip-O nginx-upstream-fair-master.zip
# Fastdfs nginx module
# Wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz


#### Centos install
Yum-y install gcc g ++ gcc-c ++ autoconf automake make unzip
Yum-y install zlib-devel openssl-devel pcre-devel
Mkdir-p/usr/local/nginx/conf/vhost
Mkdir-p/usr/local/nginx/logs mkdir-p/usr/local/nginx/cache/body
Mkdir-p/usr/local/nginx/cache/fastcgi mkdir-p/usr/local/nginx/cache/uwsgi
Mkdir-p/usr/local/nginx/cache/scgi mkdir-p/usr/local/nginx/cache/proxy
3. Configure and install
Cd/usr/src/nginx
Tar zxvf nginx-1.6.2.tar.gz
Tar zxvf fastdfs-nginx-module_v1.16.tar.gz
Unzip ngx-cache-purge-master.zip
Unzip echo-nginx-module-master.zip
Unzip nginx-upstream-fair-master.zip
Cd nginx-1.6.2
./Configure -- prefix =/usr/local/nginx \
-- User = nginx \
-- Group = nginx \
-- Conf-path =/usr/local/nginx/conf/nginx. conf \
-- Error-log-path =/usr/local/nginx/logs/error. log \
-- Http-log-path =/usr/local/nginx/logs/access. log \
-- Lock-path =/usr/local/nginx/logs/nginx. lock \
-- Pid-path =/usr/local/nginx/logs/nginx. pid \
-- Http-client-body-temp-path =/usr/local/nginx/cache/body \
-- Http-fastcgi-temp-path =/usr/local/nginx/cache/fastcgi \
-- Http-uwsgi-temp-path =/usr/local/nginx/cache/uwsgi \
-- Http-scgi-temp-path =/usr/local/nginx/cache/scgi \
-- Http-proxy-temp-path =/usr/local/nginx/cache/proxy \
-- With-pcre-jit \
With-http_random_index_module \
-- With-file-aio \
-- With-debug \
With-http_addition_module \
With-http_gzip_static_module \
With-http_realip_module \
With-http_stub_status_module \
With-http_sub_module \
With-poll_module \
With-http_ssl_module \
-- Add-module =/usr/src/nginx/echo-nginx-module-master \
-- Add-module =/usr/src/nginx-upstream-fair-master \
-- Add-module =/usr/src/nginx/ngx_cache_purge-master \
-- Add-module =/usr/src/nginx/fastdfs-nginx-module/src
Make


Make install

* ************************* Configure nginx mod_fastdfs.conf ********** *****************
# Include http. conf must be included in/etc/fdfs/mod_fastdfs.conf. Note that it is not a comment. If the comment is: # include http. conf
Cp/usr/src/nginx/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/# copy the configuration file to/etc/fdfs/
Cp/etc/fdfs/mod_fastdfs.conf/etc/fdfs/mod_fastdfs.conf-bak # back up the initial configuration file
Mkdir-p/www/logs
Vi/etc/fdfs/mod_fastdfs.conf
Base_path =/www/logs # the base path to store log files
Store_path0 =/www/geebook_storage # must same as storage. conf
Url_have_group_name = ture
Tracker_server = 192.168.10.157: 22122
Tracker_server = 192.168.10.158: 22122
# Include http. conf
* ************************** Configure nginx. conf ***************************
Cp/usr/local/nginx/conf/nginx. conf/usr/local/nginx/conf/nginx. conf-bak # back up the configuration file

 

8. test whether the dual-host hot backup of the fastDFS Master/Slave server is successful
1. Access the fastDFS Master/Slave server to start each service.
# Trackerd
/Usr/local/bin/stop. sh/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker. conf
/Usr/local/bin/restart. sh/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker. conf
Tail-f/www/geebook_storage/logs/*. log
# Storaged
/Usr/local/bin/stop. sh/usr/local/bin/fdfs_storaged/etc/fdfs/storage. conf

/Usr/local/bin/restart. sh/usr/local/bin/fdfs_storaged/etc/fdfs/storage. conf
Tail-f/www/geebook_tracker/logs/*. log
# Nginx
Chown-R nginx. nginx/usr/local/nginx/logs/
/Usr/local/nginx/sbin/nginx-s stop
/Usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx. conf
Tail-f/usr/local/nginx/logs/*. log

2. Test upload, download, and delete Query files on the Master/Slave servers.
Upload a file on the master server:/usr/local/bin/fdfs_upload_file/etc/fdfs/client. conf/www/geebook_client/a.jpg
Returned information: group1/M00/00/00/wKgKnVTv-lqADpl3AAAs_VD7qBc394.jpg
Access http: // 192.168.10.157/group1/M00/00/00/wKgKnVTv-lqADpl3AAAs_VD7qBc394.jpg in a browser
Access http: // 192.168.10.158/group1/M00/00/00/wKgKnVTv-lqADpl3AAAs_VD7qBc394.jpg in a browser
Download file:/usr/local/bin/fdfs_download_file/etc/fdfs/client. conf group1/M00/00/00/wKgKnVTv-lqADpl3AAAs_VD7qBc394.jpg
Delete file:/usr/local/bin/fdfs_delete_file/etc/fdfs/client. conf group1/M00/00/00/wKgKnVTv-lqADpl3AAAs_VD7qBc394.jpg
Query server/usr/local/bin/fdfs_monitor/etc/fdfs/client. conf
Certificate --------------------------------------------------------------------------------------------------------------------------------------
Upload a file on the master server:/usr/local/bin/fdfs_upload_file/etc/fdfs/client. conf/www/geebook_client/B .jpg
Returned information: group1/M00/00/00/wKgKnlTv-2mAdfNQAAA06ICuy-Q058.jpg
Access http: // 192.168.10.158/group1/M00/00/00/wKgKnlTv-2mAdfNQAAA06ICuy-Q058.jpg in a browser
Access http: // 192.168.10.157/group1/M00/00/00/wKgKnlTv-2mAdfNQAAA06ICuy-Q058.jpg in a browser
Download file:/usr/local/bin/fdfs_download_file/etc/fdfs/client. conf group1/M00/00/00/wKgKnlTv-2mAdfNQAAA06ICuy-Q058.jpg xxx.jpg
Delete file:/usr/local/bin/fdfs_delete_file/etc/fdfs/client. conf group1/M00/00/00/wKgKnlTv-2mAdfNQAAA06ICuy-Q058.jpg
Query server/usr/local/bin/fdfs_monitor/etc/fdfs/client. conf
Delete an invalid storage server. When active,/usr/local/bin/fdfs_monitor/etc/fdfs/client. conf delete group1 10.0.250.103 is prohibited.
#### Access http: // Storage Server ip address through a browser: group1/M00/
Bytes ------------------------------------------------------------------------------------------------------------
At this point, the fastDFS File Server dual-machine Hot Standby instance tutorial has been completed

Complete installation and configuration steps for fastDFS in CentOS 6.2

FastDFS installation in Ubuntu, PHP Client

Install, configure, and test the FastDFS Distributed File Server

FastDFS integration Nginx problem sorting

Build FastDFS in CentOS

Full record of FastDFS installation in Ubuntu

FastDFS details: click here
FastDFS: click here

This article permanently updates the link address:

Related Article

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.