In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Basic Overview of FasterDFS basic configuration installation
FastDFS is an open source lightweight distributed file system, which manages files. Its functions include file storage, file synchronization, file access (file upload, file download), etc., which solves the problems of mass storage and load balancing. It is especially suitable for online services with files as carriers, such as photo album websites, video websites and so on.
FastDFS is tailored to the Internet, taking full account of redundant backup, load balancing, linear expansion and other mechanisms, and pays attention to high availability, high performance and other indicators. It is easy to build a high-performance file server cluster with FastDFS to provide file upload, download and other services.
Basic structure diagram
The FastDFS server has two roles: tracker (tracker) and storage node (storage). The tracker mainly does the scheduling work and plays the role of load balancing on the access.
Both the tracker and the storage node can consist of one or more servers. Servers in trackers and storage nodes can be added or offline at any time without affecting online services. All the servers in the tracker are peer-to-peer and can be increased or decreased at any time according to the pressure on the server.
When adds a server to the volume, synchronizing the existing files is automatically completed by the system. After the synchronization is completed, the system automatically switches the new server to provide services online.
Basic deployment step 1, experiment preparation name role IP address centos7-1tracker192.168.142.66centos7-2storage+nginx192.168.142.77 II, start installation (1) install libfastcommon service (all nodes are installed)
Install the base environment package
[root@storage ~] # yum-y install libevent libevent-devel perl make gcc zlib zlib-devel pcre pcre-devel gcc-c++ openssl-devel
Install libfastcommon
[root@storage ~] # wget https://github.com/happyfish200/libfastcommon/archive/V1.0.38.tar.gz[root@storage ~] # tar zxf V1.0.38.tar.gz-C / opt/ [root@storage ~] # cd / opt/libfastcommon-1.0.38/
Compile and establish soft links to facilitate system identification
# compile and install [root@storage libfastcommon-1.0.38] # / make.sh & &. / make.sh install# to establish soft links to facilitate system identification [root@storage libfastcommon-1.0.38] # ln-s / usr/lib64/libfastcommon.so / usr/local/lib/libfastcommon.so [root@storage libfastcommon-1.0.38] # ln-s / usr/lib64/libfdfsclient.so / usr/local/lib/libfdfsclient.so [root@storage libfastcommon-1] .0.38] # ln-s / usr/lib64/libfdfsclient.so / usr/lib/libfdfsclient.so (2) install the FastDFS service (all nodes are installed)
Download and install
# install fastDFS [root @ storage ~] # wget https://github.com/happyfish200/fastdfs/archive/V5.11.tar.gz[root@storage ~] # tar zxf V5.11.tar.gz-C / opt/ [root@storage ~] # cd / opt/fastdfs-5.11/
Compile
# compile and install [root@storage fastdfs-5.11] #. / make.sh & &. / make.sh install
Make changes to the template file
[root@storage fastdfs-5.11] # cd / etc/fdfs/ configuration file template path [root@storage fdfs] # cp tracker.conf.sample tracker.conf [root@storage fdfs] # cp storage.conf.sample storage.conf [root@storage fdfs] # cp client.conf.sample client.conf (3) tracker monitor configuration
Establish a directory for storing data files and log files
[root@tracker] # mkdir-m 755-p / opt/fastdfs
Modify tracker configuration file
[root@tracker ~] # vim / etc/fdfs/tracker.conf# modify the following configuration port=22122 / / tracker service default port 22122 to store the path of data and log in base_path=/opt/fastdfs / / tracker. The http service process must be created in advance to start the http service on the http.server_port=8080 / / tracker server, and ignore it.
Turn on the service and set to boot.
# enable service (command supports start | stop | restart) [root@tracker ~] # fdfs_trackerd / etc/fdfs/tracker.conf start [root@tracker ~] # netstat-atnp | grep 22122tcp 00 0.0.0.0restart 22122 0.0.0.0 LISTEN 43776/fdfs_trackerd# set boot [root@tracker ~] # add fdfs_trackerd on the last line of vim / etc/rc.local# / etc/fdfs/tracker.conf start [root@tracker ~] # systemctl stop firewalld [root@tracker ~] # setenforce 0 (4) storage server modification
Establish a directory for storing data files and log files
[root@storage] # mkdir-m 755-p / opt/fastdfs
Modify storage configuration file
[root@storage ~] # vim / etc/fdfs/storage.conf# modify the following configuration group_name=group1 / / default group name, and modify port=23000 / / storge default 23000 according to the actual situation. The storage port number of the same group must be the same as the root path store_path_count=1 / / of the base_path=/opt/fastdfs / / storage log file. The number of paths below is the same. The storage path provided by default is 1store_path0=/opt/fastdfs / / (which is stored with the log file by default) tracker_server=192.168.142.66:22122 / / your own tracker server IP (focus! ) the port of http.server_port=80 / / http access file defaults to 8888. The listening port configured in Maginx is consistent.
Turn on the service and set to boot.
# enable service (command supports start | stop | restart) [root@storage ~] # fdfs_storaged / etc/fdfs/storage.conf start [root@storage ~] # netstat-atnp | grep 23000tcp 00 0.0.0.0restart 23000 0.0.0.0 LISTEN 40430/fdfs_storaged# set boot self [root@storage ~] # add fdfs_storaged on the last line of vim / etc/rc.local# / etc/fdfs/storage.conf start [root@storage ~] # systemctl stop firewalld [root@storage ~] # setenforce 0
Check whether the association with the tracker monitoring side is successful
[root@storage] # fdfs_monitor / etc/fdfs/storage.confStorage 1: id = 192.168.142.77 ip_addr = 192.168.142.77 (storage) ACTIVE http domain =. Omit (5) install nginx service (storage:192.168.142.77)
Here, in order to reduce the number of virtual machines turned on, nginx is installed on the storage side.
Install nginx and its components
[root@storage ~] # tar zxf nginx-1.12.0.tar.gz-C / opt/# download fastdfs-nginx-module installation package [root@storage ~] # wget https://github.com/happyfish200/fastdfs-nginx-module/archive/V1.20.tar.gz[root@storage ~] # tar zxf V1.20.tar.gz-C / opt/
Compile & install
[root@storage ~] # cd / opt/nginx-1.12.0 [root@storage nginx-1.12.0] #. / configure\-- prefix=/usr/local/nginx\-- add-module=/opt/fastdfs-nginx-module-1.20/src/ fastdfs-nginx-module module [root@storage nginx-1.12.0] # make & & make install
Note:
Possible errors:
/ usr/include/fastdfs/fdfs_define.h:15:27: fatal error: common_define.h: No such file or directory
Solution:
Modify the fastdfs-nginx-module-1.20/src/config file, and then restart step 7
Ngx_module_incs= "/ usr/include/fastdfs / usr/include/fastcommon/"
CORE_INCS= "$CORE_INCS / usr/include/fastdfs / usr/include/fastcommon/"
Configure the fastdfs-nginx-module module
[root@storage nginx-1.12.0] # cd fastdfs-nginx-module-1.20/src [root@storage nginx-1.12.0] # cp mod_fastdfs.conf / etc/fdfs/ move its configuration file to the fdfs directory # modify the fastdfs-nginx-module module configuration file mod-fasts.conf [root@storage nginx-1.12.0] # cd / etc/fdfs [root@storage fdfs] # vim mod_fastdfs.conf# Check the configuration base_path=/opt/fastdfs / / store data files, The address of the tracker_server=192.168.142.66:22122 / / tracker side of the log path (key! ) url_have_group_name = whether true / / url contains the group name storage_server_port=23000 / / the same number of store_path_count=1 / / storage paths configured as storage, and the number of store_path needs to match the location of store_path0=/opt/fastdfs / / file storage
Modify nginx configuration file
[root@storage fdfs] # vim / usr/local/nginx/conf/nginx.conf# add location ~ / M00 {root / opt/fastdfs/data; ngx_fastdfs_module;} at the blank line
Copy the http.conf and mime.types in the fastdfs decompression directory
# failure to do this may cause an error [root@storage fdfs] # cd / opt/fastdfs-5.11/conf/ [root@storage conf] # cp mime.types http.conf / etc/fdfs/ (6) modify the client side (this experiment is the storage side)
Modify the configuration file
[root@storage ~] # vim / etc/fdfs/client.conf# check the following configuration base_path=/opt/fastdfs / / tracker server file path tracker_server=192.168.142.66:22122 / / tracker server IP address and port number http.tracker_server_port=8080 / / tracker server's http port number, which must correspond to the setting of tracker.
Upload test files
Command:
/ usr/bin/fdfs_upload_file
Example:
/ usr/bin/fdfs_upload_file / etc/fdfs/client.conf test.jpg
The effect is as follows
Download a file
Command:
/ usr/bin/fdfs_download_file [local_filename]
Example:
/ usr/bin/fdfs_download_file / etc/fdfs/client.conf group1/M00/00/00/wKiOTV354W2AIf7GAAAAEh4TEws726.jpg test2.jpg
Delete a file
Command:
/ usr/bin/fdfs_delete_file
Example:
Fdfs_delete_file / etc/fdfs/client.conf group1/M00/00/00/wKiOTV354W2AIf7GAAAAEh4TEws726.jpg
Thank you for reading.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.