<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>运达&#039;s  blog &#187; 分布式存储</title>
	<atom:link href="https://www.yunda51.com/?feed=rss2&#038;tag=%E5%88%86%E5%B8%83%E5%BC%8F%E5%AD%98%E5%82%A8" rel="self" type="application/rss+xml" />
	<link>https://www.yunda51.com</link>
	<description>运达的博客</description>
	<lastBuildDate>Wed, 12 Nov 2025 07:58:26 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.19</generator>
	<item>
		<title>FastDFS安装部署</title>
		<link>https://www.yunda51.com/?p=1786</link>
		<comments>https://www.yunda51.com/?p=1786#comments</comments>
		<pubDate>Wed, 09 Aug 2017 10:05:44 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[FastDFS]]></category>
		<category><![CDATA[分布式存储]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1786</guid>
		<description><![CDATA[FastDFS原理：FastDFS是一个开源的轻量级分布式文件系统，它对文件进行管理，功能包括：文件存储、文件<a href="https://www.yunda51.com/?p=1786" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p><strong>FastDFS原理：</strong>FastDFS是一个开源的轻量级分布式文件系统，它对文件进行管理，功能包括：文件存储、文件同步、文件访问（文件上传、文件下载）等，解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务，如相册网站、视频网站等等。<br />
FastDFS为互联网量身定制，充分考虑了冗余备份、负载均衡、线性扩容等机制，并注重高可用、高性能等指标，使用FastDFS很容易搭建一套高性能的文件服务器集群提供文件上传、下载等服务。<br />
FastDFS服务端有两个角色：跟踪器（tracker）和存储节点（storage）。跟踪器主要做调度工作，在访问上起负载均衡的作用。<br />
需要说明的是，client为使用FastDFS服务的调用方，client也应该是一台服务器，它对tracker和storage的调用均为服务器间的调用。<br />
<a href="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175430.png"><img class="alignnone size-full wp-image-1787" src="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175430.png" alt="20170809175430" width="691" height="573" /></a><br />
1.1安装依赖应用：</p>
<pre class="wp-code-highlight prettyprint">yum install vim wget zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel 
libevent libevent-devel perl net-tools unzip -y
</pre>
<p>1.2上传libfastcommon-master.zip至/usr/local/路径下面<br />
解压：(##如果没有安装解压工具，可以直接yum install unzip zip –y)<br />
unzip libfastcommon-master.zip<br />
进入到目录查看压缩包的内容：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175446.png"><img class="alignnone size-full wp-image-1788" src="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175446.png" alt="20170809175446" width="693" height="56" /></a></p>
<p>1.3安装libfastcommon-master<br />
解压完成后进行编译安装。由于文件没有make.sh脚本，所以编译安装执行命令：##在当前路径下直接执行如下命令：</p>
<pre class="wp-code-highlight prettyprint">./make.sh
./make.sh install
</pre>
<p>当./make.sh install编译后看见如下信息，表示变异完成。<br />
<a href="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175500.png"><img class="alignnone size-full wp-image-1789" src="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175500.png" alt="20170809175500" width="693" height="233" /></a><br />
至此，libfastcommon就已经安装成功了，这里需要留一下红色方框中标志的两个路径，其中libfastcommon.so是默认安装到/usr/lib64/libfastcommon.so，但是FastDFS主程序设置的lib目录是/usr/local/lib，所以此处需要重新设置软连接。</p>
<pre class="wp-code-highlight prettyprint">ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
</pre>
<p>设置完后开始安装fastdfs。</p>
<p>1.4安装fastdfs<br />
1.4.1解压安装包</p>
<pre class="wp-code-highlight prettyprint">
tar -zxvf fastdfs-5.05.tar.gz
</pre>
<p>1.4.2进入到目录下进行编译</p>
<pre class="wp-code-highlight prettyprint">cd fastdfs-5.05
./make.sh
./make.sh install
</pre>
<p><a href="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175510.png"><img class="alignnone size-full wp-image-1790" src="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175510.png" alt="20170809175510" width="693" height="165" /></a><br />
编译后 可以看见系统创建了标记的路径，进入查看，编译后的文件安装在了该路径下面。<br />
<a href="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175519.png"><img src="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175519.png" alt="20170809175519" width="693" height="44" class="alignnone size-full wp-image-1791" /></a><br />
将/etc/fdfs/路径下生成的三个文件拷贝生成正式的配置文件。</p>
<pre class="wp-code-highlight prettyprint">
cd /etc/fdfs/
cp client.conf.sample client.conf
cp storage.conf.sample storage.conf
cp tracker.conf.sample tracker.conf
</pre>
<p>再次查看：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175537.png"><img src="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175537.png" alt="20170809175537" width="693" height="135" class="alignnone size-full wp-image-1792" /></a></p>
<p>1.5配置，启动Tracker<br />
Tracker在配置他之前，首先需要创建Tracker服务器的文件路径，即用于存储Tracker的数据文件和日志文件等。在此，我将在/opt/目录下面创建一个    fastdfs_tracker目录，用于存放Tracker服务器的相关文件：<br />
mkdir /opt/fastdfs_tracker<br />
1.5.1更改配置文件<br />
重新编辑上一步准备好的/etc/fdfs目录下的tracker.conf配置文件，打开文件后依次做以下修改：</p>
<pre class="wp-code-highlight prettyprint">
[root@localhost fdfs]# vim tracker.conf
1、disabled=false #启用配置文件（默认启用）
2、port=22122 #设置tracker的端口号，通常采用22122这个默认端口
3、base_path=/opt/fastdfs_tracker #设置tracker的数据文件和日志目录
4、http.server_port=6666 #设置http端口号，默认为8080
</pre>
<p>1.5.2配置启动路径：</p>
<pre class="wp-code-highlight prettyprint">
ln -s /usr/bin/fdfs_trackerd /usr/local/bin
ln -s /usr/bin/stop.sh /usr/local/bin
ln -s /usr/bin/restart.sh /usr/local/bin
</pre>
<p>最后通过命令启动Tracker服务器：</p>
<pre class="wp-code-highlight prettyprint">
service fdfs_trackerd start
</pre>
<p>命令执行后可以看到以下提示：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175547.png"><img src="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175547.png" alt="20170809175547" width="693" height="65" class="alignnone size-full wp-image-1793" /></a><br />
查看端口是否被监听：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175558.png"><img src="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175558.png" alt="20170809175558" width="693" height="53" class="alignnone size-full wp-image-1794" /></a></p>
<p>将启动命令加入到开机自启动。<br />
echo “service fdfs_trackerd start”  >>/etc/rc.d/rc.local</p>
<p>1.6配置，启动Storage<br />
与Tracker做相似的修改<br />
1.6.1创建存储目录<br />
同理，步骤基本与配置Tracker一致，首先是创建Storage服务器的文件目录，需要注意的是同Tracker相比我多建了一个目录，因为Storage还需要一个文件存储路径，用于存放接收的文件：：</p>
<pre class="wp-code-highlight prettyprint">
mkdir /opt/ fastdfs_storage
mkdir /opt/fastdfs_storage_data
</pre>
<p>1.6.2修改编辑配置文件<br />
接下来修改/etc/fdfs目录下的storage.conf配置文件，打开文件后依次做以下修改：</p>
<pre class="wp-code-highlight prettyprint">
[root@localhost fdfs]# vim storage.conf
disabled=false #启用配置文件（默认启用）
group_name=group1 #组名，根据实际情况修改
port=23000 #设置storage的端口号，默认是23000，同一个组的storage端口号必须一致
base_path=/opt/fastdfs_storage #设置storage数据文件和日志目录
store_path_count=1 #存储路径个数，需要和store_path个数匹配
store_path0=/opt/fastdfs_storage_data #实际文件存储路径
tracker_server=192.168.199.33:22122   #tracker 服务器的 IP地址和端口号，如果是单机搭建，IP不要写127.0.0.1，否则启动不成功（此处的ip是为CentOS虚拟机ip），此处只装有一个server端  如果有两个，可在下面一行安装该模式，修改ip做添加。
http.server_port=8888 #设置 http 端口号
</pre>
<p>1.6.3配置启动路径<br />
配置完成后同样要为Storage服务器的启动脚本设置软引用：</p>
<pre class="wp-code-highlight prettyprint">
ln -s /usr/bin/fdfs_storaged /usr/local/bin
</pre>
<p>接下来启动Storage服务：（##并加入到开机自启动项）</p>
<pre class="wp-code-highlight prettyprint">
service fdfs_storaged start
</pre>
<p><a href="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175614.png"><img src="http://www.yunda51.com/wp-content/uploads/2017/08/20170809175614.png" alt="20170809175614" width="693" height="57" class="alignnone size-full wp-image-1795" /></a><br />
见到如图所示的结果表示启动成功。</p>
<p>1.7修改启动脚本：</p>
<pre class="wp-code-highlight prettyprint">
cd /etc/fdfs/
ls -l /etc/init.d/fdfs*
whereis fdfs_trackerd
fdfs_trackerd: /usr/bin/fdfs_trackerd
sed -i &#039;s#/usr/local/bin#/usr/bin#g&#039;  /etc/init.d/fdfs_storaged
sed -i &#039;s#/usr/local/bin#/usr/bin#g&#039;  /etc/init.d/fdfs_trackerd
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1786</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
