Fastdfs脚本部署命令整理
1.tracker脚本 #执行 sh tracker
# 1iptables -Fmkdir -p /opt/fastdfs_trackermkdir -p /opt/fastdfs_storage_infomkdir -p /opt/fastdfs_storage_datamkdir -p /myself_settingsyum install -y gccyum install -y gcc-c++yum install -y perlyum install -y net-toolsyum install -y wgetln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.soln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.soln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.soln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.socd /myself_settings/wget http://192.168.130.150/fastdf/libfastcommonV1.0.7.tar.gztar -zxvf libfastcommonV1.0.7.tar.gzcd libfastcommon-1.0.7./make.sh./make.sh installcd /myself_settings/wget http://192.168.130.150/fastdf/FastDFS_v5.05.tar.gztar -zxvf FastDFS_v5.05.tar.gzcd FastDFS./make.sh./make.sh install# 2cp -p /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.confsed -i "s#base_path=/home/yuqing/fastdfs#base_path=/opt/fastdfs_tracker#g" /etc/fdfs/tracker.conf/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restartecho "/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart" >> /etc/rc.localchmod +x /etc/rc.d/rc.local
2.nginx代理配置
trachernginx.sh
yum install -y pcre pcre-develyum install -y zlib zlib-develyum install -y openssl openssl-develcd /myself_settingswget http://192.168.130.150/fastdf/nginx-1.7.8.tar.gzwget http://192.168.130.150/fastdf/fastdfs-nginx-module_v1.16.tar.gzwget http://192.168.130.150/fastdf/ngx_cache_purge-2.1.tar.gztar -zxvf nginx-1.7.8.tar.gztar -zxvf fastdfs-nginx-module_v1.16.tar.gztar -zxvf ngx_cache_purge-2.1.tar.gzsed -i '4cCORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"' /myself_settings/fastdfs-nginx-module/src/configcd /myself_settings/nginx-1.7.8mkdir /usr/local/nginx -p./configure --prefix=/usr/local/nginx --add-module=/myself_settings/fastdfs-nginx-module/src \--add-module=/myself_settings/ngx_cache_purge-2.1makemake installcp /myself_settings/FastDFS/conf/http.conf /etc/fdfs/cp /myself_settings/FastDFS/conf/mime.types /etc/fdfs/cp /etc/fdfs/client.conf.sample /etc/fdfs/client.confmkdir /opt/cache/nginx/proxy_cache -pcp /myself_settings/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/sed -i "s#base_path=/tmp#base_path=/opt/fastdfs_storage_info#g" /etc/fdfs/mod_fastdfs.confsed -i "s#tracker_server=tracker:22122#tracker_server=192.168.130.81:22122#g" /etc/fdfs/mod_fastdfs.confsed -i "s#url_have_group_name = false#url_have_group_name= true#g" /etc/fdfs/mod_fastdfs.confsed -i "s#store_path0=/home/yuqing/fastdfs#store_path0=/opt/fastdfs_storage_data#g" /etc/fdfs/mod_fastdfs.confsed -i "s#url_have_group_name = false#url_have_group_name= true#g" /etc/fdfs/mod_fastdfs.confsed -i '105a\http.need_find_content_type=true' /etc/fdfs/mod_fastdfs.confsed -i "s#group_count = 0#group_count= 1#g" /etc/fdfs/mod_fastdfs.confecho "[group1]" >> /etc/fdfs/mod_fastdfs.confecho "group_name=group1" >> /etc/fdfs/mod_fastdfs.confecho "storage_server_port=23000" >> /etc/fdfs/mod_fastdfs.confecho "store_path_count=1" >> /etc/fdfs/mod_fastdfs.confecho "store_path0=/opt/fastdfs_storage_data" >> /etc/fdfs/mod_fastdfs.conf
vi /usr/local/nginx/conf/nginx.conf
#user nobody;worker_processes 1;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '#access_log logs/access.log main;sendfile on;tcp_nopush on;keepalive_timeout 65;#gzip on;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 300m;proxy_redirect off;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 90;proxy_send_timeout 90;proxy_read_timeout 90;proxy_buffer_size 16k;proxy_buffers 4 64k;proxy_busy_buffers_size 128k;proxy_temp_file_write_size 128k;proxy_cache_path /opt/cache/nginx/proxy_cache levels=1:2keys_zone=http-cache:500m max_size=10g inactive=30d;proxy_temp_path /opt/cache/nginx/proxy_cache/tmp;upstream fdfs_group1 {server 192.168.130.83:8080 weight=1 max_fails=2 fail_timeout=30s;server 192.168.130.82:8080 weight=1 max_fails=2 fail_timeout=30s;}# upstream fdfs_group2 {#server 192.168.130.73:8080 weight=1 max_fails=2 fail_timeout=30s;#server 192.168.224.29:8080 weight=1 max_fails=2 fail_timeout=30s;# }server {listen 8080;server_name localhost;location /group1/M00 {proxy_next_upstream http_502 http_504 error timeout invalid_header;proxy_cache http-cache;proxy_cache_valid 200 304 12h;proxy_cache_key $uri$is_args$args;proxy_pass http://fdfs_group1;expires 30d;}# location /group2/M00 {# proxy_next_upstream http_502 http_504 error timeout invalid_header;# proxy_cache http-cache;# proxy_cache_valid 200 304 12h;# proxy_cache_key $uri$is_args$args;# proxy_pass http://fdfs_group2;# expires 30d;# }location ~/purge(/.*) {allow 127.0.0.1;allow 192.168.130.0/24;deny all;proxy_cache_purge http-cache $1$is_args$args;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}}
tail /usr/local/nginx/logs/error.log #查看是否有报错
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s reload
3.存储st.sh
# 1iptables -Fmkdir -p /opt/fastdfs_trackermkdir -p /opt/fastdfs_storage_infomkdir -p /opt/fastdfs_storage_datamkdir -p /myself_settingsyum install -y gccyum install -y gcc-c++yum install -y perlyum install -y net-toolsyum install -y wgetln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.soln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.soln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.soln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.socd /myself_settings/wget http://192.168.130.150/fastdf/libfastcommonV1.0.7.tar.gztar -zxvf libfastcommonV1.0.7.tar.gzcd libfastcommon-1.0.7./make.sh./make.sh installcd /myself_settings/wget http://192.168.130.150/fastdf/FastDFS_v5.05.tar.gztar -zxvf FastDFS_v5.05.tar.gzcd FastDFS./make.sh./make.sh install# 2cp -p /etc/fdfs/storage.conf.sample /etc/fdfs/storage.confsed -i "s#base_path=/home/yuqing/fastdfs#base_path=/opt/fastdfs_storage_info#g" /etc/fdfs/storage.confsed -i "s#store_path0=/home/yuqing/fastdfs#store_path0=/opt/fastdfs_storage_data#g" /etc/fdfs/storage.confsed -i "s#tracker_server=192.168.209.121:22122#tracker_server=192.168.130.81:22122#g" /etc/fdfs/storage.confsed -i "s#http.server_port=8888#http.server_port=8080#g" /etc/fdfs/storage.conf/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restartecho "/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart" >> /etc/rc.localchmod +x /etc/rc.d/rc.local
3.1
st.nginx配置
yum install -y pcre pcre-develyum install -y zlib zlib-develyum install -y openssl openssl-develcd /myself_settingswget http://192.168.130.150/fastdf/nginx-1.7.8.tar.gzwget http://192.168.130.150/fastdf/fastdfs-nginx-module_v1.16.tar.gztar -zxvf nginx-1.7.8.tar.gztar -zxvf fastdfs-nginx-module_v1.16.tar.gzsed -i '4cCORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"' /myself_settings/fastdfs-nginx-module/src/configcd /myself_settings/nginx-1.7.8mkdir /usr/local/nginx -p./configure --prefix=/usr/local/nginx --add-module=/myself_settings/fastdfs-nginx-module/srcmakemake installsed -i '36c listen 8080;' /usr/local/nginx/conf/nginx.confsed -i '40i\ }' /usr/local/nginx/conf/nginx.confsed -i '40i\ ngx_fastdfs_module;' /usr/local/nginx/conf/nginx.confsed -i '40i\ ngx_fastdfs_module;' /usr/local/nginx/conf/nginx.confsed -i '40i\ root /opt/fastdfs_storage_data/data;' /usr/local/nginx/conf/nginx.confsed -i '40i\location ~/group1/M00{' /usr/local/nginx/conf/nginx.confcp /myself_settings/FastDFS/conf/http.conf /etc/fdfs/cp /myself_settings/FastDFS/conf/mime.types /etc/fdfs/cp /myself_settings/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/sed -i "s#base_path=/tmp#base_path=/opt/fastdfs_storage_info#g" /etc/fdfs/mod_fastdfs.confsed -i "s#tracker_server=tracker:22122#tracker_server=192.168.130.81:22122#g" /etc/fdfs/mod_fastdfs.confsed -i "s#url_have_group_name = false#url_have_group_name= true#g" /etc/fdfs/mod_fastdfs.confsed -i "s#store_path0=/home/yuqing/fastdfs#store_path0=/opt/fastdfs_storage_data#g" /etc/fdfs/mod_fastdfs.confsed -i "s#url_have_group_name = false#url_have_group_name= true#g" /etc/fdfs/mod_fastdfs.confsed -i '105a\http.need_find_content_type=true' /etc/fdfs/mod_fastdfs.confsed -i "s#group_count = 0#group_count= 1#g" /etc/fdfs/mod_fastdfs.confecho "[group1]" >> /etc/fdfs/mod_fastdfs.confecho "group_name=group1" >> /etc/fdfs/mod_fastdfs.confecho "storage_server_port=23000" >> /etc/fdfs/mod_fastdfs.confecho "store_path_count=1" >> /etc/fdfs/mod_fastdfs.confecho "store_path0=/opt/fastdfs_storage_data" >> /etc/fdfs/mod_fastdfs.confln -s /opt/fastdfs_storage_data/data /opt/fastdfs_storage_data/data/M00/usr/local/nginx/sbin/nginx
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf #拷贝模板
connect_timeout=30network_timeout=60base_path=/opt/fastdfs_storage_info #路径信息需要修改tracker_server=192.168.130.81:22122 # track服务器ip地址需要修改#standard log level as syslog, case insensitive, value list:log_level=infouse_connection_pool = falseconnection_pool_max_idle_time = 3600load_fdfs_parameters_from_tracker=falseuse_storage_id = falsestorage_ids_filename = storage_ids.conf#HTTP settingshttp.tracker_server_port=8080 #注意修改成web的端口#use "#include" directive to include HTTP other settiongs##include http.conf
存储节点上传测试
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/a.jpg
返回的图片查看连接
http://192.168.130.83:8080/group1/M00/00/00/wKiCU124NcmAfNoWAAFYJyk7_sk048_big.jpg
高可用参考
https://www.cnblogs.com/sunnydou/p/49b92d511047f4f9da6cd727cfd415d5.html
满血拉二胡 残血到处浪

浙公网安备 33010602011771号