赞
踩
方案采用双tracker双storage的架构
IP | 部署内容 | 创建目录 |
---|---|---|
1.1.1.15 | tracker,storage | /data/fastdfs/tracker |
1.1.1.16 | tracker,storage | /data/fastdfs/storage /data/fastdfs/storage/data |
cd /usr/local/src
tar -zxf libfastcommon-1.0.47.tar.gz
cd libfastcommon-1.0.47
./make.sh
./make.sh install
cd /usr/local/src
tar -zxf fastdfs-6.07.tar.gz
cd fastdfs-6.07
./make.sh
./make.sh install
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf #tracker节点
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf #storage节点
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf #客户端文件,测试用
cp /usr/local/src/FastDFS/fastdfs-6.07/conf/http.conf /etc/fdfs/ #供nginx访问使用
cp /usr/local/src/FastDFS/fastdfs-6.07/conf/mime.types /etc/fdfs/ #供nginx访问使用
#修改tracker.conf文件 $ vim /etc/fdfs/tracker.conf port = 22122 base_path = /data/fastdfs/tracker max_connections = 10000 accept_threads = 100 work_threads = 8 #配置启动文件 $vim /usr/lib/systemd/system/fastdfs-tracker.service [Unit] Description=The FastDFS File server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start ExecStop=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop ExecRestart=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart [Install] WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable fastdfs-tracker.service
systemctl start fastdfs-tracker.service
netstat -apn|grep 22122
#修改如下配置 $ vim /etc/fdfs/storage.conf port = 23000 base_path = /data/fastdfs/storage store_path0 = /data/fastdfs/storage/data max_connections = 10000 accept_threads = 100 work_threads = 8 tracker_server=1.1.1.15:22122 tracker_server=1.1.1.16:22122 $ vim /usr/lib/systemd/system/fastdfs-storage.service [Unit] Description=The FastDFS File server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start ExecStop=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop ExecRestart=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart [Install] WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable fastdfs-storage.service
systemctl start fastdfs-storage.service
netstat -tulnp|grep 23000 #查看服务是否启动,端口是否打开
$ fdfs_monitor /etc/fdfs/storage.conf list [2022-11-22 15:15:12] DEBUG - base_path=/data/fastdfs/storage, connect_timeout=5, network_timeout=60, tracker_server_count=2, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=1, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0 server_count=2, server_index=1 tracker server is 1.1.1.16:22122 group count: 1 Group 1: group name = group1 disk total space = 8,902 MB disk free space = 7,132 MB trunk free space = 0 MB storage server count = 2 active server count = 2 storage server port = 23000 ...
#修改如下配置
$ vim /etc/fdfs/client.conf
base_path = /data/fastdfs
tracker_server = 1.1.1.15:22122
tracker_server = 1.1.1.16:22122
#测试上传文件,有返回存储地址表示成功
$ fdfs_upload_file /etc/fdfs/client.conf apr-1.5.2.tar.gz
group1/M00/00/00/AQEBEGN8eDaAMRwAAA-9vdbUCG4.tar.gz
yum -y install zlib zlib-devel openssl-devel cd /usr/local/src/FastDFS tar -zxf fastdfs-nginx-module-1.22.tar.gz cd fastdfs-nginx-module-1.22 #修改fastdfs-nginx-module-1.22/src/config文件,修改如下: ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/" CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/" cp -prf /usr/local/src/FastDFS/fastdfs-nginx-module-1.22 /etc/fdfs/ cd /usr/local/src tar -zxf nginx-1.22.0.tar.gz cd nginx-1.22.0 ./configure --prefix=/usr/local/nginx --user=webadm --group=webadm --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-stream --add-module=/etc/fdfs/fastdfs-nginx-module-1.22/src make && make install #修改mod_fastdfs.conf cp -p /etc/fdfs/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/ $ vim /etc/fdfs/mod_fastdfs.conf url_have_group_name=true base_path=/data/fastdfs store_path0=/data/fastdfs/storage/data tracker_server=1.1.1.15:22122 tracker_server=1.1.1.16:22122 #修改nginx配置文件 $ vim /usr/local/nginx/conf/nginx.conf ... include /usr/local/nginx/conf/conf.d/*.conf ... $ vim /usr/local/nginx/conf/conf.d/fdfs.conf upstream fdfs_group1 { server 1.1.1.15:8888 weight=1 max_fails=2 fail_timeout=30s; server 1.1.1.16:8888 weight=1 max_fails=2 fail_timeout=30s; } server { listen 80; server_name localhost 1.1.1.15; location /group1 { proxy_next_upstream http_502 http_504 error timeout invalid_header; proxy_pass http://fdfs_group1; } } server { listen 8888; ## 该端口为storage.conf中的http.server_port相同 server_name 1.1.1.15; location ~/group1 { root /data/fastdfs/storage/data; ngx_fastdfs_module; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
略。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。