linux安装FastDFS

先做一件事,修改hosts,将文件服务器的ip与域名映射(单机TrackerServer环境),因为后面很多配置里面都需要去配置服务器地址,ip变了,就只需要修改hosts即可

参考文章

1.修改Host

# vim /etc/hosts

增加如下一行,这是我的IP
192.168.51.128 file.fastdfs.com

2.下载安装libfastcommon

ibfastcommon是从 FastDFS 和 FastDHT 中提取出来的公共 C 函数库,基础环境,安装即可

#下载libfastcommon
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
#解压
 tar -zxvf V1.0.7.tar.gz
 cd libfastcommon-1.0.7
#编译、安装
 ./make.sh
 ./make.sh install
#libfastcommon.so 安装到了/usr/lib64/libfastcommon.so,但是FastDFS主程序设置的lib目录是/usr/local/lib,所以需要创建软链接。
ln -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.so ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so 

3.下载安装FastDFS

#下载FastDFS
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz

#解压
 tar -zxvf V5.05.tar.gz
 cd fastdfs-5.05

#编译、安装
./make.sh
./make.sh install

#默认安装方式安装后的相应文件与目录
#服务脚本:
/etc/init.d/fdfs_storaged
/etc/init.d/fdfs_tracker
#配置文件(这三个是作者给的样例配置文件) :
/etc/fdfs/client.conf.sample
/etc/fdfs/storage.conf.sample
/etc/fdfs/tracker.conf.sample

# FastDFS 服务脚本设置的 bin 目录是 /usr/local/bin, 但实际命令安装在 /usr/bin/ 下。ln -s /usr/bin/fdfs_trackerd   /usr/local/ln -s /usr/bin/fdfs_storaged   /usr/local/binln -s /usr/bin/stop.sh         /usr/local/binln -s /usr/bin/restart.sh      /usr/local/bin

 4.配置FastDFS跟踪器(Tracker)

#进入 /etc/fdfs,复制 FastDFS 跟踪器样例配置文件 tracker.conf.sample,并重命名为 tracker.conf。
cd /etc/fdfs
cp tracker.conf.sample tracker.conf
vim tracker.conf

#编辑tracker.conf ,标红的需要修改下,其它的默认即可。
# 配置文件是否不生效,false 为生效
disabled=false
# 提供服务的端口
port=22122
# Tracker 数据和日志目录地址(根目录必须存在,子目录会自动创建)
base_path=/fastdfs/tracker
# HTTP 服务端口
http.server_port=80

# 创建tracker基础数据目录,即base_path对应的目录
mkdir -p /fastdfs/tracker

#启动Tracker
/etc/init.d/fdfs_trackerd start

#查看 FastDFS Tracker 是否已成功启动 ,22122端口正在被监听,则算是Tracker服务安装成功。

netstat -unltp|grep fdfs

5.配置FastDFS存储(Storage)

#进入 /etc/fdfs 目录,复制 FastDFS 存储器样例配置文件 storage.conf.sample,并重命名为 storage.conf
cd /etc/fdfs
cp storage.conf.sample storage.conf
vim storage.conf

#编辑storage.conf
# 配置文件是否不生效,false 为生效
disabled=false 

# 指定此 storage server 所在 组(卷)
group_name=group1

# storage server 服务端口
port=23000

# 心跳间隔时间,单位为秒 (这里是指主动向 tracker server 发送心跳)
heart_beat_interval=30

# Storage 数据和日志目录地址(根目录必须存在,子目录会自动生成)
base_path=/fastdfs/storage

# 存放文件时 storage server 支持多个路径。这里配置存放文件的基路径数目,通常只配一个目录。
store_path_count=1

# 逐一配置 store_path_count 个路径,索引号基于 0。
# 如果不配置 store_path0,那它就和 base_path 对应的路径一样。
store_path0=/fastdfs/storage

# FastDFS 存储文件时,采用了两级目录。这里配置存放文件的目录个数。
# 如果本参数只为 N(如: 256),那么 storage server 在初次运行时,会在 store_path 下自动创建 N * N 个存放文件的子目录。
subdir_count_per_path=256

# tracker_server 的列表 ,会主动连接 tracker_server
# 有多个 tracker server 时,每个 tracker server 写一行
tracker_server=file.ljzsg.com:22122

# 允许系统同步的时间段 (默认是全天) 。一般用于避免高峰同步产生一些问题而设定。
sync_start_time=00:00
sync_end_time=23:59
# 访问端口
http.server_port=80

# 创建Storage基础数据目录,对应base_path目录
 mkdir -p  /fastdfs/storage
这是配置的store_path0路径
# 创建Storage基础数据目录,对应base_path目录
 mkdir -p  /fastdfs/storage
#可以用这种方式启动/etc/init.d/fdfs_storaged start

#查看 Storage 是否成功启动,23000 端口正在被监听,就算 Storage 启动成功。

netstat -unltp|grep fdfs

 #查看Storage和Tracker是否在通信:

/usr/bin/fdfs_monitor /etc/fdfs/storage.conf

6.文件上传测试

#修改 Tracker 服务器中的客户端配置文件
cd /etc/fdfs
cp client.conf.sample client.conf
vim client.conf

#修改如下配置即可,其它默认。
base_path=/fastdfs/client
#Tracker端口
tracker_server=file.fastdfs.com:22122

#上传测试/usr/bin/fdfs_upload_file /etc/fdfs/client.conf namei.jpeg

7.安装Nginx

上面将文件上传成功了,但我们无法下载。因此安装Nginx作为服务器以支持Http方式访问文件。同时,后面安装FastDFS的Nginx模块也需要Nginx环境。

Nginx只需要安装到StorageServer所在的服务器即可,用于访问文件。我这里由于是单机,TrackerServer和StorageServer在一台服务器上。

7.1安装nginx所需环境

#gcc安装
yum install gcc-c++

#PCRE pcre-devel 安装
yum install -y pcre pcre-devel

# zlib 安装
yum install -y zlib zlib-devel

#OpenSSL 安装
yum install -y openssl openssl-devel

7.2安装Nginx

#下载nginx
wget -c https://nginx.org/download/nginx-1.12.1.tar.gz

#解压
tar -zxvf nginx-1.12.1.tar.gz
cd nginx-1.12.1

#使用默认配置
./configure

#编译、安装
make
make install

#启动nginx
cd /usr/local/nginx/sbin/
./nginx 

#设置开机启动
vim /etc/rc.local
/usr/local/nginx/sbin/nginx

# 设置执行权限
chmod 755 rc.local

8.FastDFS配置Nginx模块

fastdfs-nginx-module 模块说明

FastDFS 通过 Tracker 服务器,将文件放在 Storage 服务器存储, 但是同组存储服务器之间需要进行文件复制, 有同步延迟的问题。

假设 Tracker 服务器将文件上传到了 192.168.51.128,上传成功后文件 ID已经返回给客户端。

此时 FastDFS 存储集群机制会将这个文件同步到同组存储 192.168.51.129,在文件还没有复制完成的情况下,客户端如果用这个文件 ID 在 192.168.51.129 上取文件,就会出现文件无法访问的错误。

而 fastdfs-nginx-module 可以重定向文件链接到源服务器取文件,避免客户端由于复制延迟导致的文件无法访问错误

#下载 fastdfs-nginx-module、解压
#这里为啥这么长一串呢,因为最新版的master与当前nginx有些版本问题。
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip
#解压
unzip 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip
#重命名
mv fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1  fastdfs-nginx-module-master

#进入解压包目录
cd /softpackages/nginx-1.12.1/

#添加模块
./configure --add-module=../fastdfs-nginx-module-master/src

#重新编译、安装
make && make install

#查看Nginx的模块
/usr/local/nginx/sbin/nginx -V

#复制 fastdfs-nginx-module 源码中的配置文件到/etc/fdfs 目录, 并修改
cd /softpackages/fastdfs-nginx-module-master/src
cp mod_fastdfs.conf /etc/fdfs/

修改如下配置,其他默认
# 连接超时时间
connect_timeout=10

# Tracker Server
tracker_server=file.ljzsg.com:22122

# StorageServer 默认端口
storage_server_port=23000

# 如果文件ID的uri中包含/group**,则要设置为true
url_have_group_name = true

# Storage 配置的store_path0路径,必须和storage.conf中的一致
store_path0=/fastdfs/storage

#复制 FastDFS 的部分配置文件到/etc/fdfs 目录

cd /softpackages/fastdfs-5.05/conf/
cp anti-steal.jpg http.conf mime.types /etc/fdfs/

9.配置iNginx ,修改nginx.conf

vim /usr/local/nginx/conf/nginx.conf

#修改配置,其它的默认
#在80端口下添加fastdfs-nginx模块

location ~/group([0-9])/M00 {
    ngx_fastdfs_module;
}
注意:
  listen 80 端口值是要与 /etc/fdfs/storage.conf 中的 http.server_port=80 (前面改成80了)相对应。如果改成其它端口,则需要统一,同时在防火墙中打开该端口。

  location 的配置,如果有多个group则配置location ~/group([0-9])/M00 ,没有则不用配group。

#在/ljzsg/fastdfs/file 文件存储目录下创建软连接,将其链接到实际存放数据的目录,这一步可以省略ln -s /fastdfs/file/data/ /fastdfs/file/data/M00 

#启动nginx/usr/local/nginx/sbin/nginx

#在地址栏中访问成功http://file.fastdfs.com/group1/M00/00/00/wKgz6lnduTeAMdrcAAEoRmXZPp870.jpeg
 
 

10  .netCore 客户端访问

请期待。。

原文地址:https://www.cnblogs.com/xuehaiyiye/p/9108393.html

时间: 2024-07-29 12:11:19

linux安装FastDFS的相关文章

Linux 安装FastDFS<准备>(使用Mac远程访问)

阅读本文需要一定的Linux基础 一 FastDFS简介 fastdfs是用c语言编写的一款开源分布式文件系统, fastdfs为互联网量身定制, 充分考虑了冗余备份, 负载均衡, 线性扩容等机制, 并注重高可用, 高性能等指标, 使用fastdfs很容易搭建一套高性能的文件服务器集群提供文件上传|下载等服务. 二 FastDFS架构 fastdfs架构包括tracker server和storage server, 客户端请求tracker server进行文件上传|下载, 通过tracker

Linux 安装FastDFS<单机版>(使用Mac远程访问)

阅读本文需要先阅读安装FastDFS<准备> 一 编译环境 yum install gcc-c++ yum -y install libevent yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum install -y openssl openssl-devel 二 安装libfastcommon 新建目录 mkdir /usr/local/libfastcommon 解压 cd libfastcommon压缩包

linux上安装fastdfs文件系统

为什么选择Nginx Nginx 是一个很牛的高性能Web和反向代理服务器, 它具有有很多非常优越的特性: 在高连接并发的情况下,Nginx是Apache服务器不错的替代品:Nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一. 能够支持高达 50,000 个并发连接数的响应, 感谢Nginx为我们选择了 epoll and kqueue 作为开发模型. Nginx作为负载均衡服务器:Nginx 既可以在内部直接支持 Rails 和 PHP 程序对外进行服务, 也可以支持作为 HTTP

在 OSX 10.9.4 上编译安装 FastDFS 及其 PHP 扩展

经我测试,在OSX 10.9.4上安装FastDFS V5.01的话会很悲剧,一开始就无法安装,会遇到这帖子中的问题:http://www.oschina.net/question/252582_162768 而我还死活解决不了,貌OSX上就没有ldconfig这个东东,反正我也不懂Linux和UNIX这类的系统. 于是只好退而求其次,安个老版本来用,毕竟我只是为了装FastDFS的PHP扩展,以便在Mac上开发PHP项目,而真正的FastDFS模拟服务器环境是在另一台联想Win7上的虚拟机中的

安装FastDFS+Nginx

安装FastDFS FastDFS开发者的GitHub地址为:https://github.com/happyfish100 打开上述链接,我们点击fastdfs–>release,发现最新版的FastDFS为2017年上传的V5.11,接下来我们来安装最新版的FastDFS. 在安装前,我们新建一个目录,用来存储所有下载文件:mkdir /download,进入download目录完成接下来操作:cd /download 1. 下载安装 libfastcommon libfastcommon是

&lt;转&gt;Centos7 上安装 FastDFS

文章转自:https://www.cnblogs.com/yufeng218/p/8111961.html 1.安装gcc(编译时需要) FastDFS是C语言开发,安装FastDFS需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc yum install -y gcc gcc-c++ 2.安装libevent(运行时需求) 若安装了桌面图形界面,就不需要安装:FastDFS依赖libevent库: yum -y install libevent 3. 安装

CentOS单机安装FastDFS&amp;整合Nginx

单机安装 一 准备工作 准备linux服务器或虚拟机,这里是虚拟机,操作系统CentOS 6.4 Tracker 和 Storage 安装在一台机器上 FastDFS 5.08版本 1,准备软件 软件下载:http://sourceforge.net/projects/fastdfs/files/               文中用到的 https://pan.baidu.com/s/1IeZqzt6Gc5Yc34RMwew3nQ     提取码:7dvf  2,安装gcc FastDFS是C语

mac下安装fastdfs 完全版

一.下载安装包和依赖 4件套都在里面 附上链接:链接:https://pan.baidu.com/s/1bqsRQPBim4rd25k0o3wxUQ 密码:qzai 二.解除mac安全限制,mac默认不允许操作系统目录 重启电脑 按住command+r 打开终端,输入csrutil disable 禁用安全限制 如果想要恢复 csrutil enable 启用 重启三.安装 1.安装依赖 libevent pcre openssl  (1)安装libevent和openssl libevent是

linux安装(Ubuntu)——(二)

centos的安装参考: http://www.runoob.com/linux/linux-install.html Linux 安装(Ubuntu) 虚拟机:虚拟机(Virtual Machine),在计算机科学中的体系结构里,是指一种特殊的软件,他可以在计算机平台和终端用户之间建立一种环境,而终端用户则是基于这个软件所建立的环境来操作软件.在计算机科学中,虚拟机是指可以像真实机器一样运行程序的计算机的软件实现. 一.    安装Vmware 虚拟机 第一步:执行VMware-worksta