FastDFS 클 러 스 터 구축 및 사용(CentOS 7)

12770 단어 FastDFS
배치 하 다.
환경 준비
군집 구조
서버
IP
서비스(포트)
서버 1
192.168.2.130
tracker0(22122)
서버 2
192.168.2.150
tracker1(22122)
서버 3
192.168.2.124
storage0(23000)、nginx(8888)
서버 4
192.168.2.119
storage1(23000)、nginx(8888)
오픈 서버
네트워크 IP/도 메 인 이름
nginx(80/443)
필요 한 서류
문건
묘사 하 다.
다운로드 하 다.
libfastcommon_V1.0.43.tar.gz
FastdFS 에서 분 리 된 공용 함수 패키지
다운로드 하 다.
fastdfs_V6.06.tar.gz
FastDFS 본체
다운로드 하 다.
fastdfs-nginx-module_V1.22.tar.gz
FastDFS 와 nginx 의 관련 모듈,그룹 내 동기 화 지연 문제 해결
다운로드 하 다.
nginx-1.16.1.tar.gz
다운로드 하 다.
공식 문서
서버 1:Tracker 0
1.컴 파일 환경 설치
yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y

2.libfastcommon 설치
tar -zxvf libfastcommon_V1.0.43.tar.gz
cd libfastcommon-1.0.43/
./make.sh
./make.sh install
cd ..

3.FastDFS 설치
설치 하 다.
tar -zxvf fastdfs_V6.06.tar.gz
cd fastdfs-6.06/
./make.sh
./make.sh install
cd ..

배치 하 다.
tracker.conf
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
vim /etc/fdfs/tracker.conf
#         
port=22122 # tracker     (  22122,     )
base_path=/data/fastdfs #            
use_storage_id = true #   id   storage,    
storage_ids_filename = storage_ids.conf
id_type_in_filename = id


프로필 디 렉 터 리 가 모두 존재 하 는 지 확인 하 십시오.
mkdir -p /data/fastdfs

storage_ids.conf
cp /etc/fdfs/storage_ids.conf.sample /etc/fdfs/storage_ids.conf
vim /etc/fdfs/storage_ids.conf
#  storage ip    
100001   group1  172.18.0.2
100002   group1  172.18.0.3

시동 을 걸다
#   
fdfs_trackerd /etc/fdfs/tracker.conf start
#   
fdfs_trackerd /etc/fdfs/tracker.conf stop
#   
fdfs_trackerd /etc/fdfs/tracker.conf restart

서버 2:Tracker 1
배포 방식
서버 3:Storage 0+Nginx
1.컴 파일 환경 설치
yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y

2.libfastcommon 설치
tar -zxvf libfastcommon_V1.0.43.tar.gz
cd libfastcommon-1.0.43/
./make.sh
./make.sh install
cd ..

3.FastDFS 설치
설치 하 다.
tar -zxvf fastdfs_V6.06.tar.gz
cd fastdfs-6.06/
./make.sh
./make.sh install
cd ..

배치 하 다.
storage.conf
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
vim /etc/fdfs/storage.conf
#         
port=9000 # storage    (  23000,     )
base_path=/data/fastdfs #             
store_path0=/data/fastdfs/store_path0 #       ,       
tracker_server = 192.168.2.130:22122 # tracker   IP   
tracker_server = 192.168.2.150:22122 # tracker   IP   
http.server_port=8888 # http       (  8888,     , nginx     )

프로필 에 설 정 된 디 렉 터 리 가 모두 존재 하 는 지 확인 하 십시오.
mkdir -p /data/fastdfs
mkdir -p /data/fastdfs/store_path0

시동 을 걸다
#   
fdfs_storaged /etc/fdfs/storage.conf start
#   
fdfs_storaged /etc/fdfs/storage.conf stop
#   
fdfs_storaged /etc/fdfs/storage.conf restart
#      
fdfs_monitor /etc/fdfs/storage.conf list

4.Nginx 설치
설치 하 다.
tar -zxvf fastdfs-nginx-module_V1.22.tar.gz
tar -zxvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./configure --add-module=../fastdfs-nginx-module-1.22/src/
make
make install
cd ..

배치 하 다.
mod_fastdfs.conf
cp fastdfs-6.06/conf/http.conf /etc/fdfs/
cp fastdfs-6.06/conf/mime.types /etc/fdfs/
cp fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
#         
tracker_server = 192.168.2.130:22122 # tracker   IP   
tracker_server = 192.168.2.150:22122 # tracker   IP   
storage_server_port=23000
url_have_group_name=true
store_path0=/data/fastdfs/store_path0

nginx.config
vim /usr/local/nginx/conf/nginx.conf
#      
server {
    listen       8888;    ##     storage.conf  http.server_port  
    server_name  localhost;
    location ~/group1/ {
        ngx_fastdfs_module;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   html;
    }
}

시동 을 걸다
#   
/usr/local/nginx/sbin/nginx
#   
/usr/local/nginx/sbin/nginx -s stop
#   
/usr/local/nginx/sbin/nginx -s reload

서버 4:Storage1+Nginx
배포 방식
서버 1-4:클 라 이언 트(테스트 만 가능)
FastdFS 가 임의로 설 치 된 서버 에서 테스트 를 실행 할 수 있 습 니 다.
배치 하 다.
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
vim /etc/fdfs/client.conf
#         
base_path=/data/fastdfs_client #             
tracker_server = 192.168.2.130:22122 # tracker   IP   
tracker_server = 192.168.2.150:22122 # tracker   IP   
use_storage_id = true #   id   storage,    


프로필 에 있 는 디 렉 터 리 가 모두 존재 하 는 지 확인 하 십시오.
mkdir -p /data/fastdfs_client

시동 을 걸다
#     ,           :group1/M00/00/00/rBIAAV6ZN62AKxKOAA_ZI6CZBeI.tar.gz
fdfs_upload_file /etc/fdfs/client.conf /root/fastdfs/nginx-1.17.8.tar.gz

외부 접근 설정 Nginx
설정 참조
upstream fdfs_group01 {
        server 192.168.2.124:8888 weight=1 max_fails=2 fail_timeout=30s;
        server 192.168.2.119:8888 weight=1 max_fails=2 fail_timeout=30s;
    }

server {
   listen       80;
   server_name  localhost;
   
   location / {
       root   html;
       index  index.html index.htm;
   }

   location /files {
       proxy_next_upstream http_502 http_504 error timeout invalid_header;
       proxy_pass http://fdfs_group01/;
       expires 30d;
   }
}

브 라 우 저 에 접근 시도
http://127.0.0.1/files/group1/M00/00/00/rBIAAV6ZN62AKxKOAA_ZI6CZBeI.tar.gz
여 기 는 127.0.0.1 외부 네트워크 에서 접근 할 수 있 는 nginx 주소 로 바 꿔 야 합 니 다.
모든 것 이 정상 일 때 다운로드 상자 가 팝 업 됩 니 다.
token 도 난 방지 체인 오픈
열 린 후 파일 에 접근 하려 면 링크 가 남용 되 지 않도록 정기 적 으로 실 효 된 token 이 필요 합 니 다.
배치 하 다.
vim /etc/fdfs/http.conf
#          
# if use token to anti-steal
# default value is false (0)   
#    token  ,    false。
http.anti_steal.check_token=true
 
# token TTL (time to live), seconds
# default value is 600
# TTL,   token     ( )
http.anti_steal.token_ttl=3600
 
# secret key to generate anti-steal token
# this parameter must be set when http.anti_steal.check_token set to true
# the length of the secret key should not exceed 128 bytes
#   token   ,        ,        
http.anti_steal.secret_key=14789632
 
# return the content of the file when check token fail
# default value is empty (no file sepecified)
#     ,       ,        
http.anti_steal.token_check_fail=

시동 을 걸다
#   tracker
fdfs_trackerd /etc/fdfs/tracker.conf restart
#   storage
fdfs_storaged /etc/fdfs/storage.conf restart
#   nginx
./nginx -s reload

좋은 웹페이지 즐겨찾기