Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build FastDFS Cluster

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to build a FastDFS cluster", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn "how to build a FastDFS cluster" this article.

1. Tracker and storage cluster upload picture test

Since the cluster has not been built yet, we will use client to upload images for testing on one of the tracker devices (we chose 192.168.156.5).

1. Go to the / etc/fdfs/ directory and we can see a configuration file like client.conf.sample, as shown in the following figure.

two。 We use the command: cp client.conf.sample client.conf to make a copy of the file and name it client.conf, as shown in the following figure.

4. Next, let's upload a picture. I upload a 3.jpg picture under the / usr/local directory. Using the command: / usr/bin/fdfs_upload_file / etc/fdfs/client.conf / usr/local/3.jpg, you can see that this command consists of three parts. The first part is / usr/bin/fdfs_upload_file, which means to specify the operation to upload the file, and the second part is / etc/fdfs/client.conf. It means to specify the configuration file to be used for the upload operation, which is the client.conf file we just configured above, and the third part is / usr/local/3.jpg, which means to specify which file in which directory to upload. After pressing enter to execute the upload command, a string is returned: group1/M00/00/00/wKicB1jjiFmAOUdkAAHk-VzqZ6w720.jpg, where group1 indicates the group in which the image is saved, M00 represents the disk directory, if the computer has only one disk, then only M00, if there are multiple disks, then M01, M02. Wait. 000000represents two levels of directories on disk. There are 256 folders from 00 to FF in each level, and 256 folders in each level. WKicB1jjiFmAOUdkAAHk-VzqZ6w720.jpg represents the renamed name of the 3.jpg stored on the storage in order to prevent the picture name from being duplicated.

When we set up the cluster, the configured strategy is polling policy, so let's upload the image again to see if it will be stored under group2. As shown in the figure below, it is found that the path information returned this time is displayed and stored under group2.

You can upload images multiple times, and you can see that the storage is indeed a group1, a group2, polling for storage, as shown below.

two。 All four devices need to perform the same operation, that is, extract the fastdfs-nginx-module_v1.16.tar.gz. We copy the command: tar-zxvf fastdfs-nginx-module_v1.16.tar.gz-C / usr/local/fast/ to the input box below. By default, enter the command in this input box and press enter. The scope of the command execution is the current session, in order to execute the same command on four devices at the same time. We can switch to "all Xshell (X)". This is shown in the following figure.

The decompression information is shown below, so I won't take screenshots of other devices one by one.

We can see that there is a config configuration file in the / usr/local/fast/fastdfs-nginx-module/src/ directory, and we need to modify it.

Remove the local directory as shown in the following figure. Similarly, we removed the local directory from this line of configuration for the other three devices.

Enter the decompression command: tar-zxvf nginx-1.6.2.tar.gz-C / usr/local/ into the input box below, and enter to perform decompression on the four devices at the same time.

Check the information as shown in the following figure.

There is no error message in the installation information, indicating that our installation was successful. After installation, we go to the / usr/local/ directory and see an extra nginx folder, as shown in the following figure.

We copy cp mod_fastdfs.conf / etc/fdfs/ to the / etc/fdfs/ directory, enter the command cp mod_fastdfs.conf / etc/fdfs/ in the input box below and press enter to copy the four devices at the same time.

After copying, we modify the mod_fastdfs.conf in the / etc/fdfs/ directory, and we use the command vim / etc/fdfs/mod_fastdfs.conf to edit the file on 192.168.156.7.

The areas to be modified are as follows:

Connect_timeout=10

Tracker_server=192.168.156.5:22122

Tracker_server=192.168.156.6:22122

Storage_server_port=23000// defaults to 2300 and does not need to be modified.

Url_have_group_name=true

Store_path0=/fastdfs/storage

Group_name=group1

Group_count=2

[group1]

Group_name=group1

Storage_server_port=23000

Store_path_count=1

Store_path0=/fastdfs/storage

[group2]

Group_name=group2

Storage_server_port=23000

Store_path_count=1

Store_path0=/fastdfs/storage

After modification, as shown in the following figure.

Use the commands: scp mod_fastdfs.conf 192.168.156.8:/etc/fdfs/, scp mod_fastdfs.conf 192.168.156.9:/etc/fdfs/, scp mod_fastdfs.conf 192.168.156.10:/etc/fdfs/ to copy.

After copying, let's go to the 8, 9, 10 devices to see if the configuration file is the one we just copied. Since 192.168.156.8 belongs to the same group1 as 192.168.156.7, 192.168.156.8 does not need to be modified. We just need to change the group name of this configuration file for 192.168.156.9 and 192.168.156.10 to group2. The modification of 192.168.156.9 is shown in the following figure, and 192.168.156.10 is the same.

After copying, we create a soft link for all four nodes, and since the steps are the same, enter the create soft link command in the input box below: ln-s / fastdfs/storage/data/ / fastdfs/storage/data/M00 and execute it at the same time. This is shown in the following figure.

After modifying 192.168.156.7, we copied this configuration file to the other three devices. When copying files to other devices with scp, the response is slow, plus-o GSSAPIAuthentication=no will be faster, but still not fast enough, the solution is that we can configure the mapping of the IP and name of all the devices to communicate in the / etc/hosts file, so scp is fast.

7. After starting nginx, we can now access the files uploaded to FastDFS through http. For example, we now upload that 3.jpg file again and access it with the echo address, as shown below (Note: the upload is done on 192.168.156.5).

[html] view plain copy

[root@itcast05 local] # / usr/bin/fdfs_upload_file / etc/fdfs/client.conf / usr/local/3.jpg

Group1/M00/00/00/wKicCFjj1xqAcN8EAAHk-VzqZ6w619.jpg

[root@itcast05 local] #

We type: http://192.168.156.7:8888/group1/M00/00/00/wKicCFjj1xqAcN8EAAHk-VzqZ6w619.jpg in the address bar, and we can't access the picture, as shown in the following figure.

After editing, save and exit, then restart the firewall, restart the command: service iptables restart, as shown in the following figure.

In this way, we have configured the firewall of 192.168.156.7, and we have also configured the firewall of the other three devices.

After configuring the firewall, we visit http://192.168.156.7:8888/group1/M00/00/00/wKicCFjj1xqAcN8EAAHk-VzqZ6w619.jpg, and then we can see the picture.

The above is all the contents of the article "how to build a FastDFS Cluster". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report