Cluster Basics (v): Configuring tracker, configuring storage, file testing, and Web Access

Source: Internet
Author: User

First, configure the tracker

Goal:

Fastdfs is a distributed file system, and the main server roles are tracker and storage. This example installs a tracker for the following functions:

    • To accept Client access
    • Retrieves a storage node and provides the client with an available storage

Scheme:

Prepare a virtual machine and install Fastdfs Tracker.

The host name and the corresponding IP address are shown in the following table.

Steps:

1) Configure the Yum source and install the required packages.

[Email protected]_tracker1 ~]# Yum install-y gcc libevent make
[Email protected]_tracker1 ~]# Yum install-y libevent-devel-*.rpm

2) Unzip the FASTDFS installation package and review the installation instructions documentation for installation.

[Email protected]_tracker1 fdfs]# tar xzf fastdfs_v4.06.tar.gz
[Email protected]_tracker1 fdfs]# CD Fastdfs
[[Email protected]_tracker1 fastdfs]# vim INSTALL
[Email protected]_tracker1 fdfs]#./make.sh
[Email protected]_tracker1 fdfs]#/make.sh Install
[[Email protected]_tracker1 fastdfs]# vim INSTALL
[Email protected]_tracker1 fastdfs]# CP init.d/fdfs_trackerd/etc/init.d/

3) Create a storage directory (storage log, etc.).

[Email protected]_tracker1 fastdfs]# Mkdir-pv/data/fastdfs

4) Modify the configuration file.

[Email protected]_tracker1 fastdfs]# vim/etc/fdfs/tracker.conf
base_path=/data/fastdfs/# Setting up the base directory
max_connections=4096 # Setting the maximum number of connections
STORE_GROUP=GROUP1 # setting storage Group name
use_storage_id = true # use stroage_id instead of IP address

5) Create the storage_id file.

[Email protected]_tracker1 fastdfs]# CP conf/storage_ids.conf/etc/fdfs/

6) Edit the storage ID file and add the storage group declaration.

[Email protected]_tracker1 fastdfs]# vim/etc/fdfs/storage_ids.conf
100001 group1 192.168.113.60

7) Modify the client configuration file.

[Email protected]_tracker1 fastdfs]# vim/etc/fdfs/client.conf
Base_path=/data/fastdfs
tracker_server=192.168.113.50:22122

8) Control tracker start.

[Email protected]_tracker1 fastdfs]#/etc/init.d/fdfs_trackerd
Usage:/etc/init.d/fdfs_trackerd {Start|stop|status|restart|condrestart}

9) View Tracker running status.

[Email protected]_tracker1 fastdfs]#/etc/init.d/fdfs_trackerd Status
Fdfs_trackerd (PID 28928) is running ...
[[Email protected]_tracker1 fastdfs]# NETSTAT-TLNP | grep Tracker
TCP 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 28928/fdfs_trackerd

Second, the Configuration Storage

Goal:

The Fastdfs Storage storage node is installed and the storage nodes are partitioned into the appropriate group. Servers in the same group save exactly the same content, and different groups store different content. Storage nodes have the following features:

    • Accept the dispatch of tracker
    • Responding to client requests
    • Store the files sent by the client to the appropriate storage location
    • Read the requested file and send it to the client

Scheme:

Prepare a virtual machine and install Fastdfs Tracker.

The host name and the corresponding IP address are shown in the following table.

Steps:

1) Configure the Yum source and install the required packages.

[Email protected]_storage1 ~]# Yum install-y gcc libevent make
[Email protected]_storage1 ~]# Yum install-y libevent-devel-*.rpm

2) Unzip, view Installation guide for installation

[Email protected]_storage1 fdfs]# tar xzf fastdfs_v4.06.tar.gz
[Email protected]_storage1 fdfs]# CD Fastdfs
[[Email protected]_storage1 fastdfs]# vim INSTALL
[Email protected]_storage1 fdfs]#./make.sh
[Email protected]_storage1 fdfs]#/make.sh Install
[[Email protected]_storage1 fastdfs]# vim INSTALL
[Email protected]_storage1 fastdfs]# CP init.d/fdfs_storaged/etc/init.d/

3) Create a data store directory (store logs, data files, etc.)

[Email protected]_storage1 fastdfs]# Mkdir-pv/data/fastdfs

4) Modify the configuration file.

[Email protected]_storage1 fastdfs]# vim/etc/fdfs/storage.conf
base_path=/data/fastdfs/# Setting up the base working directory
max_connections=4096 # Setting the maximum number of connections
store_path0=/data/fastdfs/# Set Upload file directory
tracker_server=192.168.113.50:22122 # Set the tracker of the connection
UPLOAD_PRIORITY=10 # Set server priority in Group

5) Control Storage start

[Email protected]_storage1 fastdfs]#/etc/init.d/fdfs_storaged
Usage:/etc/init.d/fdfs_storaged {Start|stop|status|restart|condrestart}

6) View Storage working status

[Email protected]_storage1 fastdfs]#/etc/init.d/fdfs_storaged Status
Fdfs_storaged (PID 28916) is running ...
[[Email protected]_storage1 fastdfs]# NETSTAT-TLNP | grep storage
TCP 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 28916/fdfs_storaged

Third, file testing and Web Access

Goal:

FASTDFS provides command-line tools for uploading, downloading, and deleting files. Test the use of these tools.

To facilitate user access, you can configure the Web Access feature on storage to make the file accessible through a Web page.

Steps:

Step one: Through Fdfs_test

1) Uploading Files

The test program uploads a file two times. The file ID returned is also two and the file attached property is uploaded. 4 Files generated on storage

[Email protected]_tracker ~]#/usr/local/bin/fdfs_test/etc/fdfs/client.conf upload Install.log

View files uploaded to storage

[Email protected]_storage1 fastdfs]# ls/data/fastdfs/data/00/00/
Wkhxpfc3od6arewxaac6opz7hp8271_big.log WKhxPFc3oD6ARewxAAC6OPZ7hp8271.log
Wkhxpfc3od6arewxaac6opz7hp8271_big.log-m wkhxpfc3od6arewxaac6opz7hp8271.log-m

2) Delete files

[Email protected]_tracker1 fastdfs]#/usr/local/bin/fdfs_test/etc/fdfs/client.conf\
Delete Group1 M00/00/00/wkhxpfc3od6arewxaac6opz7hp8271_big.log

Step two: through other related commands

1) uploading files via Fdfs_upload_file

[Email protected]_tracker1 fastdfs]#/usr/local/bin/fdfs_upload_file\
/etc/fdfs/client.conf/etc/passwd
group1/m00/00/00/wkhxpfc3peyafrhbaaagki1fx1k5058918

2) download files via Fdfs_download_file

[Email protected]_tracker1 ~]#/usr/local/bin/fdfs_download_file/etc/fdfs/client.conf\
group1/m00/00/00/wkhxpfc3peyafrhbaaagki1fx1k5058918

3) Delete files via Fdfs_delete_file

[Email protected]_tracker1 ~]#/usr/local/bin/fdfs_delete_file/etc/fdfs/client.conf\
group1/m00/00/00/wkhxpfc3peyafrhbaaagki1fx1k5058918

Step Three: Configure Web Access

1) Install Nginx on the storage

[Email protected]_storage1 ~]# Yum install-y pcre pcre-devel zlib zlib-devel
[Email protected]_storage1 fdfs]# tar xzf fastdfs-nginx-module_v1.16.tar.gz
[Email protected]_storage1 fdfs]# tar xzf nginx-1.7.10.tar.gz
[Email protected]_storage1 fdfs]# CD nginx-1.7.10
[Email protected]_storage1 nginx-1.7.10]# useradd-s/sbin/nologin nginx
[Email protected]_storage1 nginx-1.7.10]#/configure--prefix=/usr/local/nginx\
--user=nginx--group=nginx--add-module=. /fastdfs-nginx-module/src/
[[Email Protected]_storage1 nginx-1.7.10]# make && make install

2) Modify the Fastdfs module configuration for Nginx

[Email protected]_storage1 fdfs]# cp fastdfs-nginx-module/src/mod_fastdfs.conf \
/etc/fdfs
[Email protected]_storage1 fdfs]# vim/etc/fdfs/mod_fastdfs.conf
tracker_server=192.168.113.50:22122
Group_name=group1
Url_have_group_name = True
store_path0=/data/fastdfs/

3) Modify the Ngin configuration file and start

[Email protected]_storage1 fdfs]# vim/usr/local/nginx/conf/nginx.conf
# location/{
# root HTML;
# index index.html index.htm;
#} comment out this note and add the following instructions
Location/{
Ngx_fastdfs_module;
}
[Email protected]_storage1 fdfs]#/usr/local/nginx/sbin/nginx

4) test Web Access

[Email protected]_tracker1 ~]#/usr/local/bin/fdfs_upload_file\
/etc/fdfs/client.conf tedu.jpg
Group1/m00/00/00/wkhxpfc4f2yavlh7aacwev-ildc194.jpg
[Email protected]_tracker1 ~]# firefox\
Http://192.168.113.60/group1/M00/00/00/wKhxPFc4f2yAVLH7AACwEV-ILDc194.jpg &

The result is as shown

Cluster Basics (v): Configuring tracker, configuring storage, file testing, and Web Access

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.