zoukankan      html  css  js  c++  java
  • 使用fastdfs搭建文件服务器


    一:安装tracker 1. 拷贝安装目录下各个.gz文件到/usr/local/src下,解压各个install lib,例如tar zxvf xxx.tar.gz 2. 先安装libfastcommon,(需要先安装 yum install gcc,gcc-c++,perl) cd libfastcommon ./make.sh ./make.sh install 3. 安装FastDFS cd FastDFS ./make.sh ./make.sh install 4. 修改tracker.conf和client.conf cd /etc/fdfs cp client.conf.sample client.conf cp tracker.conf.sample tracker.conf //创建目录 mkdir -p /opt/fdfs/tracker vi tracker.conf 修改项: base_path=/opt/fdfs/tracker vi client.conf 修改项: base_path=/opt/fdfs/tracker tracker_server=tracker的ip:22122 5. 拷贝命令到指定目录 cp /usr/bin/fdfs_trackerd /usr/local/bin cp /usr/bin/fdfs_monitor /usr/local/bin cp /usr/bin/fdfs_upload_file /usr/local/bin cp /usr/bin/fdfs_test /usr/local/bin 6. 连接目录 ln -s /usr/include/fastcommon /usr/local/include/fastcommon ln -s /usr/include/fastdfs /usr/local/include/fastdfs ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so 6:启动tracker fdfs_trackerd /etc/fdfs/tracker.conf start /usr/bin/restart.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf 7:查看启动状态 //查看是否对应端口22122是否开始监听 netstat -unltp | grep fdfs 查看日志:cat /opt/fdfs/tracker/logs/trackerd.log or tail -f /opt/fdfs/tracker/logs/trackerd.log 8:对应的storage启动完成后,可以查看链接状态 fdfs_monitor /etc/fdfs/client.conf fdfs_monitor /home/fastdfs/fastdfs-5.05/conf/client.conf 9:tracker上安装nginx 1):确保依赖安装 yum install –y openssl-devel pcre-devel zlib-devel yum install gd-devel 2) ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/media/disk1/nginx/logs/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-pcre=/usr/local/src/pcre-8.35 --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/media/disk1/nginx/logs/access.log --http-client-body-temp-path=/media/disk1/nginx/client --http-proxy-temp-path=/media/disk1/nginx/proxy --http-fastcgi-temp-path=/media/disk1/nginx/fcgi --with-http_stub_status_module --with-http_stub_status_module --with-poll_module --with-http_image_filter_module --with-http_realip_module --add-module=/usr/local/src/ngx_cache_purge-2.3 --with-cc-opt=-Wno-error 3)make 4)make install 10:设置启动文件和nginx配置文件 请参考安装目录下的tracker下的nginx和nginx.conf 创建缓存目录:mkdir /media/disk1/nginx/proxy_temp mkdir /media/disk1/nginx/proxy_cache 修改对应的ip后分别拷贝到/etc/init.d/、/etc/nginx/ cp /usr/sbin/nginx /etc/init.d/ cd /usr/sbin/ ./nginx 11: 查看启动进程 ps aux | grep nginx cat /media/disk1/nginx/logs/access.log cat /media/disk1/nginx/logs/error.log 如不清楚log位置可在nginx.conf 配置中查看。 如果提示错误,可能缺少依赖的软件包,需先安装依赖包,再次运行./configure nginx以及nginx cache purge插件模块安装完成,安装目录/usr/local/nginx 可以使用fdfs_monitor来删除。命令行如下: /usr/bin/fdfs_monitor
    <config_filename> delete <group_name> <storage_id> 例如: /usr/bin/fdfs_monitor /etc/fdfs/client.conf delete group1 192.168.0.100 注意:如果被删除的storage server的状态是ACTIVE,也就是该storage server还在线上服务的情况下,是无法删除掉的。 storage_id参数:如果使用默认的ip方式,填写storage server IP地址,否则使用对应的server id。 ------------------------------------------------------------------------------- 一:安装storage /**** !!若storage和tracker在同一台服务器上,1-3步跳过 */ 1. 拷贝安装目录下各个.gz文件到/usr/local/src下,解压各个install lib,例如tar zxvf xxx.tar.gz 2. 先安装libfastcommon,(需要先安装 yum install gcc,gcc-c++,perl) cd libfastcommon ./make.sh ./make.sh install 3. 安装FastDFS cd FastDFS ./make.sh ./make.sh install 4. 修改storage.conf cd /etc/fdfs cp storage.conf.sample storage.conf //创建目录 mkdir -p /opt/fdfs/storage mkdir -p /data/fdfs vi storage.conf 修改项: base_path=/opt/fdfs/storage group_name=group1 store_path0=/data/fdfs tracker_server=tracker服务器ip:22122 http.server_port=8080 5. 拷贝命令到指定目录 cp /usr/bin/fdfs_storaged /usr/local/bin cp /usr/bin/fdfs_monitor /usr/local/bin 6. 连接目录 ln -s /usr/include/fastcommon /usr/local/include/fastcommon ln -s /usr/include/fastdfs /usr/local/include/fastdfs ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so 6:启动storage fdfs_storaged /etc/fdfs/storage.conf start fdfs_storaged /home/fastdfs/fastdfs-5.05/conf/storage.conf 重启 /usr/bin/restart.sh /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf 7:查看启动状态 netstat -unltp | grep fdfs 查看log: cat /opt/fdfs/stroage/logs/storaged.log or tail -f /opt/fdfs/stroage/logs/storage.log 8: 监控storage状态 //查看storage状态 fdfs_monitor /etc/fdfs/storage.conf fdfs_monitor /home/fastdfs/fdfs_conf/storage.conf 二:storage上安装nginx 1:确保依赖安装 yum install –y openssl-devel pcre-devel zlib-devel 2:解压/usr/local/src下的相关压缩包 3:编译和安装nginx 创建用户和响应的目录和文件,请参考nginx的安装文档 cd /usr/local/src/nginx-1.8.0 ----整段运行------ ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/media/disk1/nginx/logs/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-pcre=/usr/local/src/pcre-8.35 --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/media/disk1/nginx/logs/access.log --http-client-body-temp-path=/media/disk1/nginx/client --http-proxy-temp-path=/media/disk1/nginx/proxy --http-fastcgi-temp-path=/media/disk1/nginx/fcgi --with-http_stub_status_module --with-poll_module --with-http_realip_module --add-module=/usr/local/src/ngx_cache_purge-2.3 --add-module=/usr/local/src/fastdfs-nginx-module/src --with-cc-opt=-Wno-error 安装: make make install 4: 配置mod_fastdfs.conf cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ 修改/etc/fdfs/mod_fastdfs.conf配置项 base_path=/data/fdfs tracker_server=tracker服务器io:22122#修改为tracker server信息 url_have_group_name= true #改为true store_path0=/data/fdfs #改为数据存储路径,和storage.conf一样 group_name=group1 group_count = 2 并且在文件末尾加上以下信息: [group1] group_name=group1 storage_server_port=23000 store_path_count=1 store_path0=/data/fdfs 5:ln -s /data/fdfs/data /data/fdfs/data/M00 ln -s /opt/file/fdfs/data /opt/file/fdfs/data/M01 6:拷贝http.conf和mime.type cp /usr/local/src/FastDFS/conf/http.conf /etc/fdfs/ cp /usr/local/src/FastDFS/conf/mime.types /etc/fdfs/ 7:设置启动文件和nginx配置文件 请参考安装目录下的storage下的nginx和nginx.conf location ~/group[1-3]/M00 { root /home/fastdfs/data; ngx_fastdfs_module; } 修改对应的ip后分别拷贝到/etc/init.d/、/etc/nginx/ cp /usr/sbin/nginx /etc/init.d/ 如果忘记copy 会报错:[emerg]: getpwnam(“nginx”) failed ,原因没有注册用户 chmod u+x nginx 8: 启动nginx cd /usr/sbin/ ./nginx #service nginx start 9: 查看启动进程 ps aux | grep nginx cat /media/disk1/nginx/logs/access.log cat /media/disk1/nginx/logs/error.log 如不清楚log位置可在nginx.conf 配置中查看。 安装tracker 和 storage之后,测试 上传文件: 上传: /usr/local/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/a.txt 测试: /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /usr/local/a.txt 返回路径 fdfs_upload_file /home/fastdfs/fastdfs-5.05/conf/client.conf /home/fastdfs_file/data/fdfs_trackerd.pid /home/fastdfs/fastdfs-5.05/conf/tracker.conf 然后在浏览器访问: http://10.74.11.118:8080/group1/M00/00/00/CkoLdlpYL1eAfvQXAAAAD14pc-g996.txt 至此安装测试部分结束. ------------------------------------------------------------------------------------- 安装过程常见问题解决办法: 读取不了的原因可能是防火墙没关,把防火墙关掉:service iptables stop stroage server保存路径:/data/fdfs storage 非active状态的解决办法: #从集群中删除 fdfs_monitor /etc/fdfs/client.conf delete group1 10.74.11.118
  • 相关阅读:
    LUA表的引用理解
    UNITY 打包安卓APK
    UNITY打包问题
    U3D 打包时找不到tag的问题
    break prefab instance的原理
    C#调用LUA函数
    LUA 利用#遍历表的问题
    U3D笔记11:47 2016/11/30-15:15 2016/12/19
    Unity3D 预设打包的注意事项
    回调 和 覆盖
  • 原文地址:https://www.cnblogs.com/lazyInsects/p/9486354.html
Copyright © 2011-2022 走看看