libfastcommon:FastDFS分离出的一些公用函数包
FastDFS:FastFDS本体
fastdfs-nginx-module:FastFDS和nignx的关联模块
nginx:发布访问服务
二、安装
0.将安装包上传至/home/software/fastdfs
1.安装基础环境
yum install -y gcc gcc-c++
yum -y install libevent
2.安装libfastcommon函数库
腔明锋解压: tar -zxvf libfastcommon-1.0.42.tar.gz
进入到libfastcommon文件夹:./make.sh
./make.sh install
3.安装fastdfs主程序文件
解压:tar -zxvf fastdfs-6.04.tar.gz
进入fastdfs目录:./make.sh
./make.sh install
4.确保文件夹存在
/usr/bin:包含了可执行文件
/etc/fdfs:包含了配置文件
5.拷贝配置文件 cp /home/software/FastDFS/fastdfs-6.04/conf/* /etc/fdfs/
三、配置tracker
1.配置tracker配置文件
cd /etc/fdfs
vim tracker.conf
2.修改基础路径
base_path=/usr/local/fastdfs/tracker
mkdir /usr/local/fastdfs/tracker
3.启动tracker服务
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
4.查看进程 ps -ef|grep tracker
5.停止tracker
/usr/bin/stop.sh /etc/fdfs/tracker.conf
四、配置storage
1.配置storage配置文件
cd /etc/fdfs
vim storage.conf
#修改组名
group_name=imooc
# 修改storage的工作空间
base_path=/usr/local/fastdfs/storage
伍晌 # 修改storage的存储空间
store_path0=/usr/local/fastdfs/storage
# 修改tracker的地址和端口号,用于心跳
tracker_server=192.168.1.153:22122
# 后续结合nginx的一个对外服务端口号
http.server_port=8888
2.创建目录 mkdir /usr/local/fastdfs/storage -p
3.启动storage(前提:必须先启动tracker) /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
4.查看进程: ps -ef|grep storage
五、测试图片上传
0.创建/usr/local/fastdfs/client后,配置/etc/fdfs/client.conf
base_path=/usr/local/fastdfs/client
tracker_server=192.168.1.153:22122
1.上传测试图片至/home/logo.png
2.确保先启动tracker,再启动storage
/槐游usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/logo.png
六、配置Nginx FastDFS实现文件服务器(按步骤来配置)
fastdfs安装好以后是无法通过http访问的,这个时候就需要借助nginx,所以需要安装fastdfs第三方模块到nginx中,就能使用了。
注:nginx需要和storage在同一个节点
1.安装nginx插件
解压nginx的fastdfs压缩包:tar -zxvf fastdfs-nginx-module-1.22.tar.gz
复制配置文件:cp mod_fastdfs.conf /etc/fdfs
修改/fastdfs-nginx-modules/src/config文件,主要是修改路径,把local删除,因为fastdfs安装的时候我们没有修改路径
2.安装nginx,详情参考https://www.jianshu.com/p/65b48c4a6606
其中配置模块,增加fastdfs插件
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi --add-module=/home/software/fastdfs/fastdfs-nginx-module-1.22/src
修改nginx.conf,添加如下虚拟机
3.修改mod_fastdfs.conf配置文件
创建文件夹: mkdir /usr/local/fastdfs/tmp
4.启动nginx
5.访问 Ip+代理转发端口+storage存储组名
http://192.168.31.221:8888/imooc/M00/00/00/wKgf3V-eChSAdlnFAALdsLCF3uA337.JPG
在Linux系统中进行FastDFS软件的安装配置,方法的过程中是很复杂的,所以如果不是专业的电脑高手可能是没有办法整理出来,所以为了方便网友们更好的了解这个软件的安装,一下就是详细的过程,大家一起来看看吧!\x0d\x0a第一步:安装FastDFS\x0d\x0a1.解压FastDFS_v4.07.tar.gz==>FastDFS\x0d\x0a2.cdFastDFS==>vimmake.sh\x0d\x0a修改以下内容\x0d\x0aTARGET_PREFIX=/usr/local/察坦让fdfs\x0d\x0aTARGET_CONF_PATH=/usr/local/fdfs/conf\x0d\x0amkdir-p/usr/local/fdfs\x0d\x0amkdir-p/usr/local/fdfs/conf\x0d\x0a修改\x0d\x0aif["$uname"="Linux"]then\x0d\x0aif["$WITH_LINUX_SERVICE"="1"]then\x0d\x0aif[!-d$TARGET_CONF_PATH]then\x0d\x0amkdir-p$TARGET_CONF_PATH\x0d\x0acp-fconf/tracker.conf$TARGET_CONF_PATH\x0d\x0acp-fconf/storage.conf$TARGET_CONF_PATH\x0d\x0acp-fconf/client.conf$TARGET_CONF_PATH\x0d\x0acp-fconf/http.conf$TARGET_CONF_PATH\x0d\x0acp-fconf/mime.types$TARGET_CONF_PATH\x0d\x0afi\x0d\x0acp-finit.d/fdfs_trackerd/etc/rc.d/init.d/\x0d\x0acp-finit.d/fdfs_storaged/etc/rc.d/init.d/\x0d\x0a/sbin/chkconfig--addfdfs_trackerd\x0d\x0a/sbin/chkconfig--addfdfs_storaged\x0d\x0afi\x0d\x0afi\x0d\x0a第二步:安装libevent-2.0.19-stable.tar.gz\x0d\x0a1.解压libevent-2.0.19-stable.tar.gz==>libevent-2.0.19-stable\x0d\x0a2.进入libevent-2.0.19-stable安装\x0d\x0a./configure--prefix=/usr/local/libevent\x0d\x0amake\x0d\x0amakeinstall\x0d\x0a3.添加软连接\x0d\x0aln-s/usr/local/libevent/lib/libevent-2.0.so.5/usr/lib/libevent-2.0.so.5\x0d\x0aln-s/usr/local/libevent/lib/libevent-2.0.so.5/usr/lib64/libevent-2.0.so.5\x0d\x0aln-s/usr/local/libevent/lib/libevent-2.0.so.5/lib64/libevent-2.0.so.5\x0d\x0aln-s/usr/local/败局libevent/lib/libevent-2.0.so.5/lib/libevent-2.0.so.5\x0d\x0aln-s/usr/local/libevent/lib/libevent-2.0.so.5/usr/local/lib64/libevent-2.0.so.5\x0d\x0aln-s/usr/local/libevent/lib/libevent-2.0.so.5/usr/local/lib/libevent-2.0.so.5\x0d\x0a第三步:安装FastDFS\x0d\x0a./make.shC_INCLUDE_PATH=/usr/local/libevent/includeLIBRARY_PATH=/usr/local/libevent/lib\x0d\x0a./信碧make.shinstall\x0d\x0a第四步:如果/usr/local/fastdfs/conf没有fdfs_trackerd和fdfs_storaged这两个文件,就从/FastDFS/tracker和FastDFS/storage/目录下复制过去\x0d\x0a第五步:修改配置\x0d\x0amkdir-p/home/softinstall/data/tracker\x0d\x0a1.修改tracker.conf\x0d\x0abase_path=/home/softinstall/data/tracker\x0d\x0abind_addr=192.168.9.169\x0d\x0a1.1修改storage_ids.conf\x0d\x0a100001group1192.168.9.169\x0d\x0a2.启动tracker\x0d\x0a./fdfs_trackerd../conf/tracker.conf\x0d\x0a查看22122端口是否启动起来\x0d\x0a第六步:配置storage\x0d\x0amkdir-p/home/softinstall/data/store\x0d\x0amkdir-p/home/softinstall/data/store/store0\x0d\x0amkdir-p/home/softinstall/data/store/store1\x0d\x0amkdir-p/home/softinstall/data/store/store2\x0d\x0a1.修改storage.conf\x0d\x0abase_path=/home/softinstall/data/store\x0d\x0astore_path_count=3\x0d\x0astore_path0=/home/softinstall/data/store/store0\x0d\x0astore_path1=/home/softinstall/data/store/store1\x0d\x0astore_path2=/home/softinstall/data/store/store2\x0d\x0atracker_server=192.168.9.169:22122\x0d\x0a#限6*6=36个目录默认256*256\x0d\x0asubdir_count_per_path=6\x0d\x0a2.启动storage\x0d\x0a./fdfs_storaged../conf/storage.conf\x0d\x0a查看23000端口是否启动\x0d\x0a第七步:安装nginx+fastdfs模块\x0d\x0a1.安装pcre-8.32\x0d\x0a进入pcre-8.32\x0d\x0a./configure\x0d\x0amake\x0d\x0amakeinstall\x0d\x0a安装如果有问题缺省某些包,可以执行:\x0d\x0ayumgroupinstall"DevelopmentTools"\x0d\x0a第八步:解压fastdfs-nginx-module_v1.15.tar.gz和nginx-1.4.2.tar.gz\x0d\x0a1.进入fastdfs-nginx-module_v1.15/src\x0d\x0avimfastdfs-nginx-module_v1.15/src/config\x0d\x0a修改成以下内容\x0d\x0angx_addon_name=ngx_http_fastdfs_module\x0d\x0aHTTP_MODULES="$HTTP_MODULESngx_http_fastdfs_module"\x0d\x0aNGX_ADDON_SRCS="$NGX_ADDON_SRCS$ngx_addon_dir/ngx_http_fastdfs_module.c"\x0d\x0aCORE_INCS="$CORE_INCS/usr/local/fdfs/include/fastdfs/usr/local/fdfs/include/fastcommon/"\x0d\x0aCORE_LIBS="$CORE_LIBS-L/usr/local/fdfs/lib-lfastcommon-lfdfsclient"\x0d\x0aCFLAGS="$CFLAGS-D_FILE_OFFSET_BITS=64-DFDFS_OUTPUT_CHUNK_SIZE='256*1024'-DFDFS_MOD_CONF_FILENAME='\"/usr/local/fdfs/conf/mod_fastdfs.conf\"'"\x0d\x0a2.安装\x0d\x0a进入nginx-1.4.2目录\x0d\x0a./configure--prefix=/home/softinstall/nginx/nginx-fastdfs-install--with-pcre=/home/softinstall/nginx/pcre-8.32--add-module=/home/softinstall/nginx/fastdfs-nginx-module/src\x0d\x0a安装中如果有问题\x0d\x0a可以执行安装以下包:yum-yinstallgccgcc-c++zlib-developenssl-devel\x0d\x0a3.配置nginx.conf\x0d\x0a进入nginx-fastdfs-install/conf\x0d\x0avimnginx.conf配置以下内容\x0d\x0alocation/M00{\x0d\x0aroot/home/softinstall/data/store/store0/data\x0d\x0angx_fastdfs_module\x0d\x0a}\x0d\x0alocation/M01{\x0d\x0aroot/home/softinstall/data/store/store1/data\x0d\x0angx_fastdfs_module\x0d\x0a}\x0d\x0alocation/M02{\x0d\x0aroot/home/softinstall/data/store/store2/data\x0d\x0angx_fastdfs_module\x0d\x0a}\x0d\x0a4.配置mod_fastdfs.conf\x0d\x0amkdir-p/home/softinstall/data/nginx_mod\x0d\x0a进入/usr/local/fdfs/conf目录\x0d\x0avimmod_fastdfs.conf\x0d\x0abase_path=/home/softinstall/data/nginx_mod\x0d\x0atracker_server=192.168.9.169:22122\x0d\x0astore_path_count=3\x0d\x0astore_path0=/home/softinstall/data/store/store0\x0d\x0astore_path1=/home/softinstall/data/store/store1\x0d\x0astore_path2=/home/softinstall/data/store/store2\x0d\x0a5.启动nginx\x0d\x0a进入/home/softinstall/nginx/nginx-fastdfs-install/sbin\x0d\x0a./nginx\x0d\x0a如果启动找不到\x0d\x0aerrorwhileloadingsharedlibraries:libfdfsclient.so:cannotopensharedobjectfile:Nosuchfileordirectory\x0d\x0aerrorwhileloadingsharedlibraries:libfastcommon.so:cannotopensharedobjectfile:Nosuchfileordirectory\x0d\x0a请使用以下软连接\x0d\x0aln-s/usr/local/fdfs/lib/libfastcommon.so/usr/lib/libfastcommon.so\x0d\x0aln-s/usr/local/fdfs/lib/libfastcommon.so/usr/lib64/libfastcommon.so\x0d\x0aln-s/usr/local/fdfs/lib/libfdfsclient.so/usr/lib64/libfdfsclient.so\x0d\x0aln-s/usr/local/fdfs/lib/libfdfsclient.so/usr/lib/libfdfsclient.so\x0d\x0a==========================fastDHT================================\x0d\x0a【第一步:】安装BerkleyDB\x0d\x0a【1.】tar-zxvfdb-4.7.25.tar.gz\x0d\x0a进入db-4.7.25/build_unix\x0d\x0a../dist/configure--prefix=/usr\x0d\x0a【第二步:】安装FastDHT\x0d\x0amkdir-p/usr/local/fdht\x0d\x0amkdir-p/usr/local/fdht/conf\x0d\x0a1.tar-zxvfFastDHT_v1.23.tar.gz\x0d\x0a进入FastDHT_v1.23\x0d\x0avimmake.sh\x0d\x0a修改\x0d\x0aTARGET_PREFIX=/usr/local/fdht\x0d\x0aTARGET_CONF_PATH=/usr/local/fdht/conf\x0d\x0aif["$1"="install"]then\x0d\x0acd..\x0d\x0acp-frestart.sh$TARGET_PREFIX/bin\x0d\x0acp-fstop.sh$TARGET_PREFIX/bin\x0d\x0aif["$uname"="Linux"]then\x0d\x0aif["$WITH_LINUX_SERVICE"="1"]then\x0d\x0aif[!-d$TARGET_CONF_PATH]then\x0d\x0amkdir-p$TARGET_CONF_PATH\x0d\x0acp-fconf/fdhtd.conf$TARGET_CONF_PATH\x0d\x0acp-fconf/fdht_servers.conf$TARGET_CONF_PATH\x0d\x0acp-fconf/fdht_client.conf$TARGET_CONF_PATH\x0d\x0afi\x0d\x0acp-finit.d/fdhtd/etc/rc.d/init.d/\x0d\x0a/sbin/chkconfig--addfdhtd\x0d\x0afi\x0d\x0afi\x0d\x0afi\x0d\x0a【2.】安装\x0d\x0a./make.sh\x0d\x0a------------------------------------------------------------------------------\x0d\x0a如果出现global.h:18:19:error:event.h:Nosuchfileordirectory\x0d\x0a进入/home/softinstall/fastdfs/libevent-2.0.19-stable然后执行\x0d\x0a./configure--prefix=/usr\x0d\x0amake\x0d\x0amakeinstall\x0d\x0a---------------------------------------------------------------------------------\x0d\x0a./make.shinstall\x0d\x0a【3.】配置fdht\x0d\x0a【3.1】vim/usr/local/fdht/conf/fdhtd.conf\x0d\x0aport=11411\x0d\x0abash_path=/home/softinstall/data/fastdht\x0d\x0acache_size=32MB\x0d\x0astore_sub_keys=true\x0d\x0ause_storage_id=true\x0d\x0a#include/usr/local/fdht/conf/fdht_servers.conf(本行前有#表示打开,如果想关闭此选项,则应该为##开头)\x0d\x0a【3.2】vim/usr/local/fdht/conf/fdht_server.conf\x0d\x0agroup_count=1\x0d\x0agroup0=192.168.9.165:11411\x0d\x0a【3.3】vim/usr/local/fdht/conf/fdht_client.conf\x0d\x0akeep_alive=1(本选项关联storaged.conf文件)\x0d\x0abase_path=/home/softinstall/data/fastdht\x0d\x0a#include/usr/local/fdht/conf/fdht_servers.conf\x0d\x0a【3.4】配置FastDFS的storaged.conf文件\x0d\x0avistoraged.conf(默认位置:/usr/local/fdfs/conf/storaged.conf)\x0d\x0acheck_file_duplicate=1\x0d\x0a本配置项解释:是否检测上传文件已经存在。如果已经存在,则不存在文件内容,建立一个索引链接以节省磁盘空间\x0d\x0akey_namespace=FastDFS\x0d\x0a本配置项解释:当上个参数设定为1时,在FastDHT中的命名空间\x0d\x0akeep_alive=1\x0d\x0a本配置项解释:长连接配置选项,如果为0则为短连接1为长连接\x0d\x0a#include/usr/local/fdht/conf/fdht_servers.conf\x0d\x0a本配置项解释:可以通过#includefilename方式来加载FastDHTservers的配置\x0d\x0a【3.5】\x0d\x0a===========================总体启动流程======================================\x0d\x0a\x0d\x0a启动tracker/usr/local/fdfs/bin/fdfs_trackerd/usr/local/fdfs/conf/tracker.conf\x0d\x0a停止tracker/usr/local/fdfs/bin/stop.sh/usr/local/fdfs/conf/tracker.conf\x0d\x0a启动storage/usr/local/fdfs/bin/fdfs_storaged/usr/local/fdfs/conf/storage.conf\x0d\x0a停止storage/usr/local/fdfs/bin/stop.sh/usr/local/fdfs/conf/storage.conf\x0d\x0a\x0d\x0a启动nginx/go-fastdfs 最简单、可靠、高效的分布式文件系统
官方文档
docker go-fastdfs安装
修改容器里面的fastdfs配置有2种方法
如果想通过curl访问fastdfs的话,需要在cfg.json里面樱携你添加白名单。使用localhost或127.0.0.1是不行的
添加172.17.0.1,这是docker的默认地址。
示例
这个api可以查看fastdfs的文件存储信息。
/搭碰group1/stat的group1是分组的名称,因为默认配置是分组存储的,如果不想分组,就修改cfg.json的配置
不分组的话,api命令不需要groupx
修改完配置后,需要reload fastdfs
这里的restart只会重启容器里面的fastdfs进程
api的方法修改配置不是很友善,不建议使用。因为只修改单个配置项的话,其他的值脊枝伏会变空
api接口: /reload
/reload接口可以获取cfg配置信息、修改配置、reload配置
更多的API: go-fastdfs Api文档
浏览器输入: http://127.0.0.1:8080, 可以打开go-fastdfs的上传文件页面
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)