FastDFS is a pain in the ass for clustering and load balancing (iii) upload pictures on test
January 24, 2024
by Leslie Hansen-O'Neill
No Comments
Since the FastDFS configuration is too complex, I will continue to break it down in this article.
###What to do tomorrow
The Tracker and storage clusters are set up, but the FastDFS cluster is not set up.
Before setting up FastDFS, we will use the client to upload images in Tracker1.
Go to /etc/fdfs, copy a copy of client.conf.sample, and rename it to client.conf
Modify the client. The conf, Vim client.conf Change base_path to /fastdfs/tracker, tracker_server=192.168.12.11:22122, tracker_server=192.168.12.22:22122
Next we create an IMG folder in /usr/local. mkdir img
Add a favorite image to img. I added mayday.jpg.
Upload file command: / usr/bin/fdfs_upload_file/etc/FDFS/client. The conf/usr/local/img/mayday. JPG/usr/bin/fdfs_upload_file said upload file operations / etc/FDFS/client. The conf said upload file used by the configuration file/usr/local/img/mayday. JPG said specific path to upload files. We can see the returned to the “group2 M00/00/00 / wKgMN1pDYfeAdEyCAADRd6mMX3g517. JPG”. Group2 means that the uploaded picture is saved in group2. It means that group2 has the picture we uploaded before, while Group1 does not. M00 stands for disk directory. 00/00 indicates two levels of directories on the disk. The number of files in each level is 1616(256) from 00-ff. The two levels are 25,256.
Group1 = 192.168.12.33(group1)
Group1 = 192.168.12.44(group1)
192.168.12.55(group2)
192.168.12.66(group2) = 192.168.12.66(group2)
Remember when we configured tracker.conf with store_lookup=0 and store_group=group2? Store_lookup =0 indicates that polling is used to select the group to upload files.
Our previous configuration is polling strategy, we upload the file again, the picture will be uploaded to Group1, no doubt. Delectable ah!
We upload files and pictures to group1, group2, polling for storage.
If device A in the same group fails, the uploaded files can only be saved to other devices in the same group. After device A recovers, other devices in the same group automatically synchronize data to device A. Isn’t it delightful?
We also need to configure Nginx to upload or download files using HTTP.
Fastdfs-nginx-module_v1.16.tar. gz to /usr/local/fast on group1 and group2 Run the tar ZXVF fastdfs-nginx-module_v1.16.tar.gz -c /usr/local/fast command
Go to /usr/local/fast/fastdfs-nginx-module/ SRC and find config.
We need to get the fourth row/usr/local/include/fastdfs modified into/usr/include/fastdfs/usr/local/include/fastcommon modified into/usr/include/fastcommon
/make. Sh install FastDFS is installed in /usr/include/fastdfs. Fastcommon similarly.
If the group to which the storage belongs is group1, you do not need to change group_name. The default value is group1. Otherwise, change group_name to the group corresponding to the storage.
I have several groups, group_count is just a few, I have two groups here, so group_count=2
The next step is to set the information for group1 and group2, as shown in the figure.
Copy mod_fastdfs.conf to 192.168.12.44, 192.168.12.55, 192.168.12.66. Change group_name to group2 for the storage that belongs to group2.
Into/usr/local/fast/FastDFS/HTTP found under the conf. Conf and mime types, and then two copies a them into/etc/FDFS/directory.
Then go to /etc/fdfs/and copy HTTP,conf and mime.types to 192.168.12.44, 192.168.12.55, 192.168.12.66
We need to create a soft link, ln -s/fastdfs/storage/data / / fastdfs/storage/data/M00
Remember the http.server_port=8888 in stroage.conf?
/usr/local/nginx/conf/ vim nginx.conf Example Set the listen port of the server to 8888
We also replace location with the following:
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
}
Copy the new nginx.conf file to /usr/local/nginx/conf/ of 192.168.12.44, 192.168.12.55, 192.168.12.66.
Nginx is enabled for group1 and group2 storages. Enter/usr/local/nginx/sbin/nginx
192.168.12.33 (group1)
192.168.12.44 (group1)
192.168.12.55 (group2)
192.168.12.66 (group2)
Iptables -a INPUT -p TCP -m state –state NEW -m TCP –dport 8888 -j ACCEPT
Then restart the firewall and start the policy. service iptables restart service iptables save
We upload images at Tracker1 (192.168.12.11). Command: / usr/bin/fdfs_upload_file/etc/FDFS/client. The conf/usr/local/img/mayday. JPG
Due to the return of images stored in group2, so we can either enter the http://192.168.12.66:8888/group2/M00/00/00/wKgMQlpDipaABM7qAADRd6mMX3g416.jpg in your browser to access it, unfortunately failed to access.
###What to do tomorrow
Continue to configure FastDFS load balancing and clustering. One more blog post is needed.
Solution to enter http://192.168.12.66:8888/group2/M00/00/00/wKgMQlpDipaABM7qAADRd6mMX3g416.jpg no response, the output is not a matter of the image.
###Summary
Preliminary investigation, it should be Nginx problem.