| 后一修订版 | 前一修订版 | ||
|
服务器技术:nginx:fastdfs安装与nginx反向代理配置 [2018/05/16 17:11] admin 创建 |
服务器技术:nginx:fastdfs安装与nginx反向代理配置 [2018/09/10 18:02] (当前版本) |
||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | <article><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;">nginx相关软件</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">nginx-1.10.1 <br/><a style="color: rgb(12, 137, 207);" href="http://nginx.org/en/download.html" target="_blank">http://nginx.org/en/download.html</a> <br/>nginx清除缓存模块 ngx_cache_purge-2.3 <br/><a style="color: rgb(12, 137, 207);" href="http://labs.frickle.com/nginx_ngx_cache_purge/" target="_blank">http://labs.frickle.com/nginx_ngx_cache_purge/</a> <br/>pcre-8.36 <br/><a style="color: rgb(12, 137, 207);" href="https://sourceforge.net/projects/pcre/files/pcre/8.36/" target="_blank">https://sourceforge.net/projects/pcre/files/pcre/8.36/</a> <br/>zlib库 <br/><a style="color: rgb(12, 137, 207);" href="http://zlib.net/zlib-1.2.8.tar.gz" target="_blank">http://zlib.net/zlib-1.2.8.tar.gz</a></p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>FastDFS相关软件</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">FastDFS_v5.08 <br/><a style="color: rgb(12, 137, 207);" href="https://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/stats/timeline" target="_blank">https://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/stats/timeline</a> <br/>或者<a style="color: rgb(12, 137, 207);" href="https://github.com/happyfish100/fastdfs" target="_blank">https://github.com/happyfish100/fastdfs</a> <br/>FastDFS Nginx Module 1.16 <br/><a style="color: rgb(12, 137, 207);" href="http://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/" target="_blank">http://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/</a> <br/>或者<a style="color: rgb(12, 137, 207);" href="https://github.com/happyfish100/fastdfs-nginx-module" target="_blank">https://github.com/happyfish100/fastdfs-nginx-module</a> <br/>libfastcommon <br/><a style="color: rgb(12, 137, 207);" href="https://github.com/happyfish100/libfastcommon" target="_blank">https://github.com/happyfish100/libfastcommon</a> <br/>其中github上的代码是最新的,sourceforge上不一定是最新的,当前FastDFS版本为5.08。 <br/><img title="" alt="网络拓扑图" src="https://img-blog.csdn.net/20160622100029775"/></p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>tracker的安装与配置</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">以下操作是在 tracker 10.10.10.80上操作。 <br/>通过rz工具或者FileZilla,把软件上传到Ubuntu的/usr/local/src目录下。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>安装libfastcommon</h3><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/usr/local/src# unzip libfastcommon-master.zip root@tracker:/usr/local/src# cd libfastcommon-masterroot@tracker:/usr/local/src/libfastcommon-master# lsHISTORY  INSTALL  libfastcommon.spec  make.sh  php-fastcommon  README  src | + | <article><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;">nginx相关软件</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">nginx-1.10.1 <br/><a style="color: rgb(12, 137, 207);" href="http://nginx.org/en/download.html" target="_blank">http://nginx.org/en/download.html</a> <br/>nginx清除缓存模块 ngx_cache_purge-2.3 <br/><a style="color: rgb(12, 137, 207);" href="http://labs.frickle.com/nginx_ngx_cache_purge/" target="_blank">http://labs.frickle.com/nginx_ngx_cache_purge/</a> <br/>pcre-8.36 <br/><a style="color: rgb(12, 137, 207);" href="https://sourceforge.net/projects/pcre/files/pcre/8.36/" target="_blank">https://sourceforge.net/projects/pcre/files/pcre/8.36/</a> <br/>zlib库 <br/><a style="color: rgb(12, 137, 207);" href="http://zlib.net/zlib-1.2.8.tar.gz" target="_blank">http://zlib.net/zlib-1.2.8.tar.gz</a></p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;">FastDFS相关软件</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">FastDFS_v5.08 <br/><a style="color: rgb(12, 137, 207);" href="https://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/stats/timeline" target="_blank">https://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/stats/timeline</a> <br/>或者<a style="color: rgb(12, 137, 207);" href="https://github.com/happyfish100/fastdfs" target="_blank">https://github.com/happyfish100/fastdfs</a> <br/>FastDFS Nginx Module 1.16 <br/><a style="color: rgb(12, 137, 207);" href="http://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/" target="_blank">http://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/</a> <br/>或者<a style="color: rgb(12, 137, 207);" href="https://github.com/happyfish100/fastdfs-nginx-module" target="_blank">https://github.com/happyfish100/fastdfs-nginx-module</a> <br/>libfastcommon <br/><a style="color: rgb(12, 137, 207);" href="https://github.com/happyfish100/libfastcommon" target="_blank">https://github.com/happyfish100/libfastcommon</a> <br/>其中github上的代码是最新的,sourceforge上不一定是最新的,当前FastDFS版本为5.08。 <br/><img src="/dokuwiki/ueditor/php/upload/image/20180517/1526534904479330.jpg" title="1526534904479330.jpg" alt="20160622100029775.jpg"/></p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;">tracker的安装与配置</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">以下操作是在 tracker 10.10.10.80上操作。 <br/>通过rz工具或者FileZilla,把软件上传到Ubuntu的/usr/local/src目录下。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">安装libfastcommon</h3><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/usr/local/src# unzip libfastcommon-master.zip root@tracker:/usr/local/src# cd libfastcommon-masterroot@tracker:/usr/local/src/libfastcommon-master# lsHISTORY  INSTALL  libfastcommon.spec  make.sh  php-fastcommon  README  src |
| - | root@tracker:/usr/local/src/libfastcommon-master# ./make.sh root@tracker:/usr/local/src/libfastcommon-master# ./make.sh install123456123456</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>安装FastDFS (FastDFS_v5.08.tar.gz)</h3><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/usr/local/src# tar zxvf FastDFS_v5.08.tar.gz root@tracker:/usr/local/src# cd FastDFSroot@tracker:/usr/local/src/FastDFS# ./make.shroot@tracker:/usr/local/src/FastDFS# ./make.sh install 12341234</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">到这里FastDFS在 tracker上安装完成,所有的可执行文件位于 /usr/bin 目录下,以fdfs开头的文件:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:~$ ll /usr/bin/fdfs_*-rwxr-xr-x 1 root root  379725 Jun 16 19:25 /usr/bin/fdfs_appender_test*-rwxr-xr-x 1 root root  375174 Jun 16 19:25 /usr/bin/fdfs_appender_test1*-rwxr-xr-x 1 root root  356800 Jun 16 19:25 /usr/bin/fdfs_append_file*-rwxr-xr-x 1 root root  356994 Jun 16 19:25 /usr/bin/fdfs_crc32*-rwxr-xr-x 1 root root  356827 Jun 16 19:25 /usr/bin/fdfs_delete_file*-rwxr-xr-x 1 root root  357754 Jun 16 19:25 /usr/bin/fdfs_download_file*-rwxr-xr-x 1 root root  357928 Jun 16 19:25 /usr/bin/fdfs_file_info*-rwxr-xr-x 1 root root  377621 Jun 16 19:25 /usr/bin/fdfs_monitor*-rwxr-xr-x 1 root root 1313605 Jun 16 19:25 /usr/bin/fdfs_storaged*-rwxr-xr-x 1 root root  389327 Jun 16 19:25 /usr/bin/fdfs_test*-rwxr-xr-x 1 root root  387896 Jun 16 19:25 /usr/bin/fdfs_test1*-rwxr-xr-x 1 root root  539675 Jun 16 19:25 /usr/bin/fdfs_trackerd*-rwxr-xr-x 1 root root  357728 Jun 16 19:25 /usr/bin/fdfs_upload_appender*-rwxr-xr-x 1 root root  363268 Jun 16 19:25 /usr/bin/fdfs_upload_file*123456789101112131415123456789101112131415</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">所有的配置文件在 /etc/fdfs/ 目录下:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:~$ ll /etc/fdfs/total 28drwxr-xr-x   2 root root 4096 Jun 16 19:33 ./drwxr-xr-x 117 root root 4096 Jun 16 19:44 ../-rwxr-xr-x   1 root root 1463 Jun 16 19:32 client.conf.sample-rwxr-xr-x   1 root root 7927 Jun 16 19:25 storage.conf.sample-rwxr-xr-x   1 root root 7202 Jun 16 19:33 tracker.conf.sample12345671234567</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>配置</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">①进入到 /etc/fdfs 目录下,将tracker.conf.sample重命名为tracker.conf。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/etc/fdfs# mv tracker.conf.sample tracker.conf11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">②创建数据文件和日志文件目录</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/etc/fdfs# mkdir -pv /data/fastdfs/trackermkdir: 已创建目录 "/data"mkdir: 已创建目录 "/data/fastdfs"mkdir: 已创建目录 "/data/fastdfs/tracker"12341234</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">③编辑 tracker.conf 文件,测试的时候只需要修改以下参数即可</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">disabled=false                        #启用配置文件port=22122                            #设置 tracker 的端口号base_path=/data/fastdfs/tracker       #设置 tracker 的数据文件和日志目录(需预先创建)http.server_port=8888                 #设置 http 端口号这个http.server_port=8888 指的是在tracker服务器上启动http服务进程,如:apache或者nginx 启动时所监听的端口1234512345</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>运行</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">直接使用 fdfs_trackerd 来启动tracker进程,然后使用netstat 查看端口是否起来。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/etc/fdfs# fdfs_trackerd /etc/fdfs/tracker.conf restartroot@tracker:/etc/fdfs# netstat -antp | grep trackerdtcp   0  0 0.0.0.0:22122   0.0.0.0:*   LISTEN   14520/fdfs_trackerd  | + | root@tracker:/usr/local/src/libfastcommon-master# ./make.sh root@tracker:/usr/local/src/libfastcommon-master# ./make.sh install123456123456</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">安装FastDFS (FastDFS_v5.08.tar.gz)</h3><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/usr/local/src# tar zxvf FastDFS_v5.08.tar.gz root@tracker:/usr/local/src# cd FastDFSroot@tracker:/usr/local/src/FastDFS# ./make.shroot@tracker:/usr/local/src/FastDFS# ./make.sh install 12341234</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">到这里FastDFS在 tracker上安装完成,所有的可执行文件位于 /usr/bin 目录下,以fdfs开头的文件:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:~$ ll /usr/bin/fdfs_*-rwxr-xr-x 1 root root  379725 Jun 16 19:25 /usr/bin/fdfs_appender_test*-rwxr-xr-x 1 root root  375174 Jun 16 19:25 /usr/bin/fdfs_appender_test1*-rwxr-xr-x 1 root root  356800 Jun 16 19:25 /usr/bin/fdfs_append_file*-rwxr-xr-x 1 root root  356994 Jun 16 19:25 /usr/bin/fdfs_crc32*-rwxr-xr-x 1 root root  356827 Jun 16 19:25 /usr/bin/fdfs_delete_file*-rwxr-xr-x 1 root root  357754 Jun 16 19:25 /usr/bin/fdfs_download_file*-rwxr-xr-x 1 root root  357928 Jun 16 19:25 /usr/bin/fdfs_file_info*-rwxr-xr-x 1 root root  377621 Jun 16 19:25 /usr/bin/fdfs_monitor*-rwxr-xr-x 1 root root 1313605 Jun 16 19:25 /usr/bin/fdfs_storaged*-rwxr-xr-x 1 root root  389327 Jun 16 19:25 /usr/bin/fdfs_test*-rwxr-xr-x 1 root root  387896 Jun 16 19:25 /usr/bin/fdfs_test1*-rwxr-xr-x 1 root root  539675 Jun 16 19:25 /usr/bin/fdfs_trackerd*-rwxr-xr-x 1 root root  357728 Jun 16 19:25 /usr/bin/fdfs_upload_appender*-rwxr-xr-x 1 root root  363268 Jun 16 19:25 /usr/bin/fdfs_upload_file*123456789101112131415123456789101112131415</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">所有的配置文件在 /etc/fdfs/ 目录下:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:~$ ll /etc/fdfs/total 28drwxr-xr-x   2 root root 4096 Jun 16 19:33 ./drwxr-xr-x 117 root root 4096 Jun 16 19:44 ../-rwxr-xr-x   1 root root 1463 Jun 16 19:32 client.conf.sample-rwxr-xr-x   1 root root 7927 Jun 16 19:25 storage.conf.sample-rwxr-xr-x   1 root root 7202 Jun 16 19:33 tracker.conf.sample12345671234567</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">配置</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">①进入到 /etc/fdfs 目录下,将tracker.conf.sample重命名为tracker.conf。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/etc/fdfs# mv tracker.conf.sample tracker.conf11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">②创建数据文件和日志文件目录</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/etc/fdfs# mkdir -pv /data/fastdfs/trackermkdir: 已创建目录 "/data"mkdir: 已创建目录 "/data/fastdfs"mkdir: 已创建目录 "/data/fastdfs/tracker"12341234</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">③编辑 tracker.conf 文件,测试的时候只需要修改以下参数即可</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">disabled=false                        #启用配置文件port=22122                            #设置 tracker 的端口号base_path=/data/fastdfs/tracker       #设置 tracker 的数据文件和日志目录(需预先创建)http.server_port=8888                 #设置 http 端口号这个http.server_port=8888 指的是在tracker服务器上启动http服务进程,如:apache或者nginx 启动时所监听的端口1234512345</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">运行</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">直接使用 fdfs_trackerd 来启动tracker进程,然后使用netstat 查看端口是否起来。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/etc/fdfs# fdfs_trackerd /etc/fdfs/tracker.conf restartroot@tracker:/etc/fdfs# netstat -antp | grep trackerdtcp   0  0 0.0.0.0:22122   0.0.0.0:*   LISTEN   14520/fdfs_trackerd  |
| root@tracker:/etc/fdfs# 12341234</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">也可以查看日志看服务是否正常运行:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:~# cat /data/fastdfs/tracker/logs/trackerd.log11</pre><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">[2016-06-28 11:55:55] INFO - FastDFS v5.08, base_path=/data/fastdfs/tracker, run_by_group=, run_by_user=, connect_timeout=30s, network_timeout=60s, port=22122, bind_addr=, max_connections=2048, accept_threads=1, work_threads=4, store_lookup=2, store_group=, store_server=0, store_path=0, reserved_storage_space=10.00%, download_server=0, allow_ip_count=-1, sync_log_buff_interval=10s, check_active_interval=120s, thread_stack_size=64 KB, storage_ip_changed_auto_adjust=1, storage_sync_file_max_delay=86400s, storage_sync_file_max_time=300s, use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file_size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_file_space_threshold=20 GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlog=0, trunk_compress_binlog_min_interval=0, use_storage_id=0, id_type_in_filename=ip, storage_id_count=0, rotate_error_log=0, error_log_rotate_time=00:00, rotate_error_log_size=0, log_file_keep_days=0, store_slave_file_use_link=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s | root@tracker:/etc/fdfs# 12341234</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">也可以查看日志看服务是否正常运行:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:~# cat /data/fastdfs/tracker/logs/trackerd.log11</pre><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">[2016-06-28 11:55:55] INFO - FastDFS v5.08, base_path=/data/fastdfs/tracker, run_by_group=, run_by_user=, connect_timeout=30s, network_timeout=60s, port=22122, bind_addr=, max_connections=2048, accept_threads=1, work_threads=4, store_lookup=2, store_group=, store_server=0, store_path=0, reserved_storage_space=10.00%, download_server=0, allow_ip_count=-1, sync_log_buff_interval=10s, check_active_interval=120s, thread_stack_size=64 KB, storage_ip_changed_auto_adjust=1, storage_sync_file_max_delay=86400s, storage_sync_file_max_time=300s, use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file_size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_file_space_threshold=20 GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlog=0, trunk_compress_binlog_min_interval=0, use_storage_id=0, id_type_in_filename=ip, storage_id_count=0, rotate_error_log=0, error_log_rotate_time=00:00, rotate_error_log_size=0, log_file_keep_days=0, store_slave_file_use_link=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s | ||
| [2016-06-28 11:56:01] INFO - file: tracker_relationship.c, line: 383, selecting leader... | [2016-06-28 11:56:01] INFO - file: tracker_relationship.c, line: 383, selecting leader... | ||
| - | [2016-06-28 11:56:02] INFO - file: tracker_relationship.c, line: 401, I am the new tracker leader 10.10.10.80:22122123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">⑤设置开机自动启动</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/etc# vi rc.local /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart1212</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">至此tracker上的安装与配置结束。</p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>storage的安装与配置</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">两台机器(10.10.10.81, 10.10.10.82)配置完全一样,以81为例。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>安装</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">利用上传 FastDFS_v5.08.tar.gz 和 libfastcommon-master.zip 至 storage服务器的/usr/local/src 目录下,解压安装 libfastcommon,这个和前面安装tracker一样。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">安装libfastcommon | + | [2016-06-28 11:56:02] INFO - file: tracker_relationship.c, line: 401, I am the new tracker leader 10.10.10.80:22122123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">⑤设置开机自动启动</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@tracker:/etc# vi rc.local /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart1212</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">至此tracker上的安装与配置结束。</p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;">storage的安装与配置</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">两台机器(10.10.10.81, 10.10.10.82)配置完全一样,以81为例。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">安装</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">利用上传 FastDFS_v5.08.tar.gz 和 libfastcommon-master.zip 至 storage服务器的/usr/local/src 目录下,解压安装 libfastcommon,这个和前面安装tracker一样。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">安装libfastcommon |
| root@storage1:/usr/local/src# unzip libfastcommon-master.zip root@storage1:/usr/local/src# cd libfastcommon-masterroot@storage1:/usr/local/src/libfastcommon-master# lsHISTORY  INSTALL  libfastcommon.spec  make.sh  php-fastcommon  README  src | root@storage1:/usr/local/src# unzip libfastcommon-master.zip root@storage1:/usr/local/src# cd libfastcommon-masterroot@storage1:/usr/local/src/libfastcommon-master# lsHISTORY  INSTALL  libfastcommon.spec  make.sh  php-fastcommon  README  src | ||
| root@storage1:/usr/local/src/libfastcommon-master# ./make.sh root@storage1:/usr/local/src/libfastcommon-master# ./make.sh install12345671234567</pre><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">安装FastDFSFastDFS_v5.08.tar.gz | root@storage1:/usr/local/src/libfastcommon-master# ./make.sh root@storage1:/usr/local/src/libfastcommon-master# ./make.sh install12345671234567</pre><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">安装FastDFSFastDFS_v5.08.tar.gz | ||
| - | root@storage1:/usr/local/src# tar zxvf FastDFS_v5.08.tar.gz root@storage1:/usr/local/src# cd FastDFSroot@storage1:/usr/local/src/FastDFS# ./make.shroot@storage1:/usr/local/src/FastDFS# ./make.sh install 123456123456</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>配置</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">进入到 /etc/fdfs 目录下,复制/usr/local/src/FastDFS/conf/* 下面的所有文件到当前目录下(/etc/fdfs):</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/etc/fdfs$ ll | + | root@storage1:/usr/local/src# tar zxvf FastDFS_v5.08.tar.gz root@storage1:/usr/local/src# cd FastDFSroot@storage1:/usr/local/src/FastDFS# ./make.shroot@storage1:/usr/local/src/FastDFS# ./make.sh install 123456123456</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">配置</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">进入到 /etc/fdfs 目录下,复制/usr/local/src/FastDFS/conf/* 下面的所有文件到当前目录下(/etc/fdfs):</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/etc/fdfs$ ll |
| total 96drwxr-xr-x  2 root root  4096 Jun 17 16:07 ./drwxr-xr-x 97 root root  4096 Jun 17 15:28 ../-rwxr-xr-x  1 root root 23981 Jun 16 20:06 anti-steal.jpg-rwxr-xr-x  1 root root  1461 Jun 16 20:06 client.conf-rwxr-xr-x  1 root root   858 Jun 16 20:06 http.conf-rwxr-xr-x  1 root root 31172 Jun 16 20:06 mime.types-rwxr-xr-x  1 root root  7910 Jun 17 09:40 storage.conf-rwxr-xr-x  1 root root   105 Jun 16 20:06 storage_ids.conf-rwxr-xr-x  1 root root  7202 May 20 10:45 tracker.conf12345678910111234567891011</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">编辑配置文件 storage.conf 测试的时候,只需修改以下内容即可</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/etc/fdfs$ vi storage.conf  | total 96drwxr-xr-x  2 root root  4096 Jun 17 16:07 ./drwxr-xr-x 97 root root  4096 Jun 17 15:28 ../-rwxr-xr-x  1 root root 23981 Jun 16 20:06 anti-steal.jpg-rwxr-xr-x  1 root root  1461 Jun 16 20:06 client.conf-rwxr-xr-x  1 root root   858 Jun 16 20:06 http.conf-rwxr-xr-x  1 root root 31172 Jun 16 20:06 mime.types-rwxr-xr-x  1 root root  7910 Jun 17 09:40 storage.conf-rwxr-xr-x  1 root root   105 Jun 16 20:06 storage_ids.conf-rwxr-xr-x  1 root root  7202 May 20 10:45 tracker.conf12345678910111234567891011</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">编辑配置文件 storage.conf 测试的时候,只需修改以下内容即可</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/etc/fdfs$ vi storage.conf  | ||
| - | disabled=false                        #启用配置文件group_name=group1                     #组名,根据实际情况修改port=23000                            #设置 storage 的端口号base_path=/data/fastdfs/storage       #设置 storage 的日志目录(需预先创建)store_path_count=1                    #存储路径个数,需要和 store_path 个数匹配store_path0=/data/fastdfs/storage     #存储路径tracker_server=10.10.10.81:22122     #tracker 服务器的 IP 地址和端口号http.server_port=8888                #设置storage上启动的http服务的端口号,如安装的nginx的端口号123456789123456789</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">[备注]:store_path_count如果有多个,那么需要设置多个存储路径,如:</p><blockquote style="margin: 0px 0px 1.1em; padding: 15px 20px; color: rgb(63, 63, 63); font-family: "microsoft yahei"; font-size: 15px;"><p style="line-height: 1.25; padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;">store_path_count=2 <br/>store_path0=/data/fastdfs/storage <br/>store_path1=/data/fastdfs/storage1</p></blockquote><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>运行</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">执行如下命令:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/etc/fdfs# fdfs_storaged /etc/fdfs/storage.conf restart11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">查看进程是否运行:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@dstorage1:/etc/fdfs# netstat -antp | grep storagetcp  0  0 0.0.0.0:23000   0.0.0.0:*   LISTEN      23426/fdfs_storaged1212</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">观察日志 /data/fastdfs/storage/logs/storaged.log 看运行情况</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">mkdir data path: FB ...mkdir data path: FC ...mkdir data path: FD ...mkdir data path: FE ...mkdir data path: FF ...data path: /data/fastdfs/storage/data, mkdir sub dir done. | + | disabled=false                        #启用配置文件group_name=group1                     #组名,根据实际情况修改port=23000                            #设置 storage 的端口号base_path=/data/fastdfs/storage       #设置 storage 的日志目录(需预先创建)store_path_count=1                    #存储路径个数,需要和 store_path 个数匹配store_path0=/data/fastdfs/storage     #存储路径tracker_server=10.10.10.81:22122     #tracker 服务器的 IP 地址和端口号http.server_port=8888                #设置storage上启动的http服务的端口号,如安装的nginx的端口号123456789123456789</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">[备注]:store_path_count如果有多个,那么需要设置多个存储路径,如:</p><blockquote style="margin: 0px 0px 1.1em; padding: 15px 20px; color: rgb(63, 63, 63); font-family: "microsoft yahei"; font-size: 15px;"><p style="line-height: 1.25; padding-top: 0px; padding-bottom: 0px; margin-top: 0px; margin-bottom: 0px;">store_path_count=2 <br/>store_path0=/data/fastdfs/storage <br/>store_path1=/data/fastdfs/storage1</p></blockquote><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">运行</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">执行如下命令:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/etc/fdfs# fdfs_storaged /etc/fdfs/storage.conf restart11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">查看进程是否运行:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@dstorage1:/etc/fdfs# netstat -antp | grep storagetcp  0  0 0.0.0.0:23000   0.0.0.0:*   LISTEN      23426/fdfs_storaged1212</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">观察日志 /data/fastdfs/storage/logs/storaged.log 看运行情况</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">mkdir data path: FB ...mkdir data path: FC ...mkdir data path: FD ...mkdir data path: FE ...mkdir data path: FF ...data path: /data/fastdfs/storage/data, mkdir sub dir done. |
| [2016-06-16 19:51:04] INFO - file: storage_param_getter.c, line: 191, use_storage_id=0, id_type_in_filename=ip, storage_ip_changed_auto_adjust=1, store_path=0, reserved_storage_space=10.00%, use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file_size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_file_space_threshold=20 GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlog=0, trunk_compress_binlog_min_interval=0, store_slave_file_use_link=0[2016-06-16 19:51:04] INFO - file: storage_func.c, line: 254, tracker_client_ip: 10.10.10.81, my_server_id_str: 10.10.10.81, g_server_id_in_filename: -771094006[2016-06-16 19:51:04] INFO - file: tracker_client_thread.c, line: 310, successfully connect to tracker server 10.10.10.80:22122, as a tracker client, my ip is 10.10.10.81[2016-06-16 19:51:34] INFO - file: tracker_client_thread.c, line: 1235, tracker server 10.10.10.80:22122, set tracker leader: 10.10.10.80:221221234567891012345678910</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">这里看到,创建了二级目录,成功连接到tracker。 <br/>可以使用 fdfs_monitor 来查看一下storage的状态,看是否已经成功注册到了tracker:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/# fdfs_monitor /etc/fdfs/storage.conf 或者: | [2016-06-16 19:51:04] INFO - file: storage_param_getter.c, line: 191, use_storage_id=0, id_type_in_filename=ip, storage_ip_changed_auto_adjust=1, store_path=0, reserved_storage_space=10.00%, use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file_size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_file_space_threshold=20 GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlog=0, trunk_compress_binlog_min_interval=0, store_slave_file_use_link=0[2016-06-16 19:51:04] INFO - file: storage_func.c, line: 254, tracker_client_ip: 10.10.10.81, my_server_id_str: 10.10.10.81, g_server_id_in_filename: -771094006[2016-06-16 19:51:04] INFO - file: tracker_client_thread.c, line: 310, successfully connect to tracker server 10.10.10.80:22122, as a tracker client, my ip is 10.10.10.81[2016-06-16 19:51:34] INFO - file: tracker_client_thread.c, line: 1235, tracker server 10.10.10.80:22122, set tracker leader: 10.10.10.80:221221234567891012345678910</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">这里看到,创建了二级目录,成功连接到tracker。 <br/>可以使用 fdfs_monitor 来查看一下storage的状态,看是否已经成功注册到了tracker:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/# fdfs_monitor /etc/fdfs/storage.conf 或者: | ||
| fdfs_monitor /etc/fdfs/client.conf(不过这个文件需要配置一下才行)123123</pre><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">[2016-06-28 14:32:41] DEBUG - base_path=/data/fastdfs/storage, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0server_count=1, server_index=0tracker server is 10.10.10.80:22122group count: 1Group 1: | fdfs_monitor /etc/fdfs/client.conf(不过这个文件需要配置一下才行)123123</pre><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">[2016-06-28 14:32:41] DEBUG - base_path=/data/fastdfs/storage, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0server_count=1, server_index=0tracker server is 10.10.10.80:22122group count: 1Group 1: | ||
| 行 24: | 行 24: | ||
|                 up time = 2016-06-17 15:41:37 |                 up time = 2016-06-17 15:41:37 | ||
|                 total storage = 19211 MB |                 total storage = 19211 MB | ||
| - |         。。。。。1234567891011121314151617181920212223242526272829303112345678910111213141516171819202122232425262728293031</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">看到这里显示“ACTIVE”,说明当前的storage节点已经注册到了Tracker上。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>设置开机启动</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">同Tracker中的配置,把如下命令加到/etc/rc.local中:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">到这里storage的安装配置也完成了。当第二台节点也加进来后,可以通过日志看到如下信息:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">[2016-06-17 15:41:46] INFO - file: storage_sync.c, line: 2698, successfully connect to storage server 10.10.10.82:2300011</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">【注】因为同一组的节点会进行数据同步,所以一个组内的所有storage节点会进行通信,那么这个地方就可以看出来,他们上线后会建立连接。 <br/>另外,从端口信息上也可以看出来:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/# netstat -antp | grep storagetcp        0      0 0.0.0.0:23000           0.0.0.0:*               LISTEN      23426/fdfs_storaged | + |         。。。。。1234567891011121314151617181920212223242526272829303112345678910111213141516171819202122232425262728293031</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">看到这里显示“ACTIVE”,说明当前的storage节点已经注册到了Tracker上。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">设置开机启动</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">同Tracker中的配置,把如下命令加到/etc/rc.local中:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">到这里storage的安装配置也完成了。当第二台节点也加进来后,可以通过日志看到如下信息:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">[2016-06-17 15:41:46] INFO - file: storage_sync.c, line: 2698, successfully connect to storage server 10.10.10.82:2300011</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">【注】因为同一组的节点会进行数据同步,所以一个组内的所有storage节点会进行通信,那么这个地方就可以看出来,他们上线后会建立连接。 <br/>另外,从端口信息上也可以看出来:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/# netstat -antp | grep storagetcp        0      0 0.0.0.0:23000           0.0.0.0:*               LISTEN      23426/fdfs_storaged |
| tcp        0      0 10.10.10.81:23000      10.10.10.82:33842      ESTABLISHED 23426/fdfs_storaged | tcp        0      0 10.10.10.81:23000      10.10.10.82:33842      ESTABLISHED 23426/fdfs_storaged | ||
| tcp        0      0 10.10.10.81:50824      10.10.10.82:23000      ESTABLISHED 23426/fdfs_storaged | tcp        0      0 10.10.10.81:50824      10.10.10.82:23000      ESTABLISHED 23426/fdfs_storaged | ||
| - | tcp        0      0 10.10.10.81:58116      10.10.10.80:22122      ESTABLISHED 23426/fdfs_storaged1234512345</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">storage1会与storage2建立连接,同时会与tracker建立连接。</p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>在storage上安装配置nginx</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">以下操作在storage1上完成。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>安装nginx</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">上传 fastdfs-nginx-module_v1.16.tar.gz nginx-1.10.0.tar.gz pcre-8.36.tar.gz zlib-1.2.8.tar.gz 到storage服务器上的/usr/local/src 目录下</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/usr/local/src/nginx-1.10.0# lsauto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src | + | tcp        0      0 10.10.10.81:58116      10.10.10.80:22122      ESTABLISHED 23426/fdfs_storaged1234512345</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">storage1会与storage2建立连接,同时会与tracker建立连接。</p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;">在storage上安装配置nginx</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">以下操作在storage1上完成。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">安装nginx</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">上传 fastdfs-nginx-module_v1.16.tar.gz nginx-1.10.0.tar.gz pcre-8.36.tar.gz zlib-1.2.8.tar.gz 到storage服务器上的/usr/local/src 目录下</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/usr/local/src/nginx-1.10.0# lsauto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src |
| - | root@storage1:/usr/local/src/nginx-1.10.0# ./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/fastdfs-nginx-module-master/src --with-pcre=/usr/local/src/pcre-8.36 --with-zlib=/usr/local/src/zlib-1.2.8123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">编译安装:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">make && make install 11</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>配置nginx</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">修改nginx配置文件 <br/>① 修改nginx的监听端口 <br/>将 server 段中的 listen 端口号改为 8888: <br/>② 在 server 段中添加fastdfs的配置: <br/>这里的group[1-3] 可以匹配 group1,group2,group3,当然group也可以是其他的名字,这里正则表达式只是用来过滤请求路径。 <br/>location ~ /group[1-3]/M00 { <br/>root /data/fastdfs/storage/data; <br/>ngx_fastdfs_module; <br/>} <br/>/data/fastdfs/storage/data 这个是指向真正存储文件的地方,该目录下有这些个二级目录</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@dtv-210:/data/fastdfs/storage/data# lltotal 1048drwxr-xr-x 259 root root 4096 Jun 27 15:42 ./ | + | root@storage1:/usr/local/src/nginx-1.10.0# ./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/fastdfs-nginx-module-master/src --with-pcre=/usr/local/src/pcre-8.36 --with-zlib=/usr/local/src/zlib-1.2.8123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">编译安装:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">make && make install 11</pre><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">配置nginx</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">修改nginx配置文件 <br/>① 修改nginx的监听端口 <br/>将 server 段中的 listen 端口号改为 8888: <br/>② 在 server 段中添加fastdfs的配置: <br/>这里的group[1-3] 可以匹配 group1,group2,group3,当然group也可以是其他的名字,这里正则表达式只是用来过滤请求路径。 <br/>location ~ /group[1-3]/M00 { <br/>root /data/fastdfs/storage/data; <br/>ngx_fastdfs_module; <br/>} <br/>/data/fastdfs/storage/data 这个是指向真正存储文件的地方,该目录下有这些个二级目录</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@dtv-210:/data/fastdfs/storage/data# lltotal 1048drwxr-xr-x 259 root root 4096 Jun 27 15:42 ./ |
| drwxr-xr-x   4 root root 4096 Jun 16 19:50 ../ | drwxr-xr-x   4 root root 4096 Jun 16 19:50 ../ | ||
| drwxr-xr-x 258 root root 4096 Jun 16 19:50 00/ | drwxr-xr-x 258 root root 4096 Jun 16 19:50 00/ | ||
| 行 46: | 行 46: | ||
| drwxr-xr-x 258 root root 4096 Jun 16 19:50 0E/ | drwxr-xr-x 258 root root 4096 Jun 16 19:50 0E/ | ||
| drwxr-xr-x 258 root root 4096 Jun 16 19:50 0F/ | drwxr-xr-x 258 root root 4096 Jun 16 19:50 0F/ | ||
| - | 。。。123456789101112131415161718192021123456789101112131415161718192021</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">③将 FastDFS 的 nginx 插件模块的配置文件拷贝到 FastDFS 配置文件目录:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/usr/local/src/fastdfs-nginx-module-master/src# cp mod_fastdfs.conf /etc/fdfs/11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">修改 fastdfs的nginx模块的配置文件 mod_fastdfs.conf</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">base_path=/data/fastdfs/storage      #保存日志目录tracker_server=10.10.10.80:22122     #tracker 服务器的 IP 地址以及端口号storage_server_port=23000            #storage服务器的端口号group_name=group1                    #当前服务器的group名url_have_group_name = true           #文件url中是否有group 名store_path_count=1                   #存储路径个数,需要和store_path 个数匹配store_path0=/data/fastdfs/storage    #存储路径group_count = 1                      #设置组的个数#然后在末尾添加分组信息,目前只有一个分组,就只写一个[group1]group_name=group1storage_server_port=23000store_path_count=1store_path0=/data/fastdfs/storage12345678910111213141234567891011121314</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">④建立 M00 至存储目录的符号连接</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1# ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/M00root@storage1# ll /data/fastdfs/storage/data/M00lrwxrwxrwx 1 root root 26 Jun 16 19:53 /data/fastdfs/storage/data/M00 -> /data/fastdfs/storage/data/123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">到这里,nginx和FastDFS 插件模块就配置完成了。 <br/>⑤启动nginx <br/>执行/usr/local/nginx/sbin/nginx <br/>把上述语句加入/etc/rc.local即可开机自启动。 <br/>可以通过netstat -unltp | grep nginx查看nginx是否起来,如果有错误,可以查看日志:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/usr/local/nginx/logs# cat error.log 11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">也可以访问<a style="color: rgb(12, 137, 207);" href="http://10.10.10.80:8888/" target="_blank">http://10.10.10.80:8888</a>查看nginx是否工作,看到如下界面说明nginx启动OK。 <br/><img title="" alt="nginx" src="https://img-blog.csdn.net/20160628155849736"/> <br/>其他storage节点依照上述步骤安装与配置即可。</p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>安装nginx反向代理及缓存服务器</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">在机器10.10.10.79上安装。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>安装nginx</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">将所需的软件包上传至服务器/usr/local/src下</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server:/usr/local/src# tar zxvf nginx-1.10.0.tar.gz root@server:/usr/local/src# tar zxvf ngx_cache_purge-2.3.tar.gz root@server:/usr/local/src# tar zxvf pcre-8.36.tar.gz root@server:/usr/local/src# tar zxvf zlib-1.2.8.tar.gz root@server:/usr/local/src# cd nginx-1.10.0root@server:/usr/local/src/nginx-1.10.0#./configure  --prefix=/usr/local/nginx  --add-module=/usr/local/src/ngx_cache_purge-2.3  --with-pcre=/usr/local/src/pcre-8.36/  --with-zlib=/usr/local/src/zlib-1.2.8root@server:/usr/local/src/nginx-1.10.0#make && make install12345671234567</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">nginx 以及 nginx cache purge 插件模块安装完毕。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>配置nginx</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">①创建nginx的缓存目录</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# mkdir -pv /var/cache/nginx/proxy_cache/tmp11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">②增加系统打开文件数的限制,手写到rc.local</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# ulimit -SHn 102400root@server# echo "ulimit -SHn 102400" >> /etc/rc.local1212</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">③编辑 vim /usr/local/nginx/conf/nginx.conf 文件修改以下内容:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">user  nobody;worker_processes  4;error_log  logs/error.log  info;pid        logs/nginx.pid;events {    worker_connections  65535;    use epoll; | + | 。。。123456789101112131415161718192021123456789101112131415161718192021</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">③将 FastDFS 的 nginx 插件模块的配置文件拷贝到 FastDFS 配置文件目录:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/usr/local/src/fastdfs-nginx-module-master/src# cp mod_fastdfs.conf /etc/fdfs/11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">修改 fastdfs的nginx模块的配置文件 mod_fastdfs.conf</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">base_path=/data/fastdfs/storage      #保存日志目录tracker_server=10.10.10.80:22122     #tracker 服务器的 IP 地址以及端口号storage_server_port=23000            #storage服务器的端口号group_name=group1                    #当前服务器的group名url_have_group_name = true           #文件url中是否有group 名store_path_count=1                   #存储路径个数,需要和store_path 个数匹配store_path0=/data/fastdfs/storage    #存储路径group_count = 1                      #设置组的个数#然后在末尾添加分组信息,目前只有一个分组,就只写一个[group1]group_name=group1storage_server_port=23000store_path_count=1store_path0=/data/fastdfs/storage12345678910111213141234567891011121314</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">④建立 M00 至存储目录的符号连接</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1# ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/M00root@storage1# ll /data/fastdfs/storage/data/M00lrwxrwxrwx 1 root root 26 Jun 16 19:53 /data/fastdfs/storage/data/M00 -> /data/fastdfs/storage/data/123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">到这里,nginx和FastDFS 插件模块就配置完成了。 <br/>⑤启动nginx <br/>执行/usr/local/nginx/sbin/nginx <br/>把上述语句加入/etc/rc.local即可开机自启动。 <br/>可以通过netstat -unltp | grep nginx查看nginx是否起来,如果有错误,可以查看日志:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@storage1:/usr/local/nginx/logs# cat error.log 11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">也可以访问<a style="color: rgb(12, 137, 207);" href="http://10.10.10.80:8888/" target="_blank">http://10.10.10.80:8888</a>查看nginx是否工作,看到如下界面说明nginx启动OK。 <br/><img src="/dokuwiki/ueditor/php/upload/image/20180517/1526534917556209.png" title="1526534917556209.png" alt="20160628155849736.png"/> <br/>其他storage节点依照上述步骤安装与配置即可。</p><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;">安装nginx反向代理及缓存服务器</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">在机器10.10.10.79上安装。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">安装nginx</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">将所需的软件包上传至服务器/usr/local/src下</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server:/usr/local/src# tar zxvf nginx-1.10.0.tar.gz root@server:/usr/local/src# tar zxvf ngx_cache_purge-2.3.tar.gz root@server:/usr/local/src# tar zxvf pcre-8.36.tar.gz root@server:/usr/local/src# tar zxvf zlib-1.2.8.tar.gz root@server:/usr/local/src# cd nginx-1.10.0root@server:/usr/local/src/nginx-1.10.0#./configure  --prefix=/usr/local/nginx  --add-module=/usr/local/src/ngx_cache_purge-2.3  --with-pcre=/usr/local/src/pcre-8.36/  --with-zlib=/usr/local/src/zlib-1.2.8root@server:/usr/local/src/nginx-1.10.0#make && make install12345671234567</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">nginx 以及 nginx cache purge 插件模块安装完毕。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">配置nginx</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">①创建nginx的缓存目录</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# mkdir -pv /var/cache/nginx/proxy_cache/tmp11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">②增加系统打开文件数的限制,手写到rc.local</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# ulimit -SHn 102400root@server# echo "ulimit -SHn 102400" >> /etc/rc.local1212</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">③编辑 vim /usr/local/nginx/conf/nginx.conf 文件修改以下内容:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">user  nobody;worker_processes  4;error_log  logs/error.log  info;pid        logs/nginx.pid;events {    worker_connections  65535;    use epoll; |
| }http {    include       mime.types;    default_type  application/octet-stream;    sendfile        on;    tcp_nopush     on;    keepalive_timeout  65;    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;    #设置缓存存储路径、存储方式、分配内存大小、磁盘最大空间、缓存期限 | }http {    include       mime.types;    default_type  application/octet-stream;    sendfile        on;    tcp_nopush     on;    keepalive_timeout  65;    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  /var/cache/nginx/proxy_cache  levels=1:2 |     proxy_cache_path  /var/cache/nginx/proxy_cache  levels=1:2 | ||
| 行 60: | 行 60: | ||
|     } |     } | ||
| }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">接下来,可以使用 /usr/local/nginx/sbin/nginx -t 来测试配置文件语法的正确性。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server:/usr/local/nginx# ./sbin/nginx -tngx_http_fastdfs_set pid=5895nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful | }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">接下来,可以使用 /usr/local/nginx/sbin/nginx -t 来测试配置文件语法的正确性。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server:/usr/local/nginx# ./sbin/nginx -tngx_http_fastdfs_set pid=5895nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful | ||
| - | root@server:/usr/local/nginx# 1234512345</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">④启动nginx并加入到开机启动</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">/usr/local/nginx/sbin/nginx11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">把/usr/local/nginx/sbin/nginx加入/etc/rc.local即可。 <br/>同样可以查看端口看是否正常启动:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">netstat -unltp | grep nginx11</pre><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>测试上传文件</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">以下操作在tracker服务器(10.10.10.80)上进行 <br/>①创建client 使用的日志目录</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# mkdir -pv /data/fastdfs/client11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">②修改客户端的配置文件/etc/fdfs/client.conf</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">base_path=/data/fastdfs/client #日志存放路径tracker_server=10.10.10.80:22122 #tracker 服务器 IP 地址和端口号http.tracker_server_port=8888123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">③上传一个图片</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# fdfs_upload_file /etc/fdfs/client.conf 1.jpggroup1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg | + | root@server:/usr/local/nginx# 1234512345</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">④启动nginx并加入到开机启动</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">/usr/local/nginx/sbin/nginx11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">把/usr/local/nginx/sbin/nginx加入/etc/rc.local即可。 <br/>同样可以查看端口看是否正常启动:</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">netstat -unltp | grep nginx11</pre><h2 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 2.13em; font-weight: 100;">测试上传文件</h2><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">以下操作在tracker服务器(10.10.10.80)上进行 <br/>①创建client 使用的日志目录</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# mkdir -pv /data/fastdfs/client11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">②修改客户端的配置文件/etc/fdfs/client.conf</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">base_path=/data/fastdfs/client #日志存放路径tracker_server=10.10.10.80:22122 #tracker 服务器 IP 地址和端口号http.tracker_server_port=8888123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">③上传一个图片</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# fdfs_upload_file /etc/fdfs/client.conf 1.jpggroup1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg |
| root@server#123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">得到了如下的地址: <br/>group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg <br/>还可以通过fdfs_file_info 来查看上传文件的信息</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# fdfs_file_info /etc/fdfs/client.conf 11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">通过浏览器访问: <br/>④使用浏览器访问一下该地址: <br/><a style="color: rgb(12, 137, 207);" href="http://10.10.10.79/group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg" target="_blank">http://10.10.10.79/group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg</a> <br/>即可成功访问到图片。 <br/>⑤查看nginx的缓存目录,可以查看缓存的内容。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# ll -R /var/cache/nginx/proxy_cache/ 11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">⑥清除缓存 <br/>如果清除该图片的缓存,可以在文件 URL 之前加上 purge 即可,如下图 <br/><a style="color: rgb(12, 137, 207);" href="http://10.10.10.79/purge/group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg" target="_blank">http://10.10.10.79/purge/group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg</a> <br/>清除之后,当storage中文件被删除后,将无法再请求到文件。 <br/>⑦配置浏览器端查看是否命中缓存 <br/>使用Chrome浏览器的开发工具,查看响应的头部信息来查看是否命中缓存,要启用此功能,修改nginx的主配置文件如下: <br/>在location /group1/M00 段增加这2个行</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">add_header  X-Via  $server_addr; | root@server#123123</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">得到了如下的地址: <br/>group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg <br/>还可以通过fdfs_file_info 来查看上传文件的信息</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# fdfs_file_info /etc/fdfs/client.conf 11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">通过浏览器访问: <br/>④使用浏览器访问一下该地址: <br/><a style="color: rgb(12, 137, 207);" href="http://10.10.10.79/group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg" target="_blank">http://10.10.10.79/group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg</a> <br/>即可成功访问到图片。 <br/>⑤查看nginx的缓存目录,可以查看缓存的内容。</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">root@server# ll -R /var/cache/nginx/proxy_cache/ 11</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">⑥清除缓存 <br/>如果清除该图片的缓存,可以在文件 URL 之前加上 purge 即可,如下图 <br/><a style="color: rgb(12, 137, 207);" href="http://10.10.10.79/purge/group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg" target="_blank">http://10.10.10.79/purge/group1/M00/00/00/CgoKeFRQqaaASddNAxEgRsu1UiU345.jpg</a> <br/>清除之后,当storage中文件被删除后,将无法再请求到文件。 <br/>⑦配置浏览器端查看是否命中缓存 <br/>使用Chrome浏览器的开发工具,查看响应的头部信息来查看是否命中缓存,要启用此功能,修改nginx的主配置文件如下: <br/>在location /group1/M00 段增加这2个行</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">add_header  X-Via  $server_addr; | ||
| add_header  X-Cache-Status $upstream_cache_status;1212</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">最终效果</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">location /group1/M00 { | add_header  X-Cache-Status $upstream_cache_status;1212</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">最终效果</p><pre class="prettyprint" style="padding: 5px 5px 5px 60px; border-radius: 0px; border: 0px solid rgb(136, 136, 136); border-image: none; color: rgb(51, 51, 51); line-height: 1.45; font-family: "Source Code Pro", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1.1em; white-space: nowrap; position: relative; -ms-word-break: break-all; -ms-overflow-x: auto; -ms-overflow-y: hidden; -ms-word-wrap: break-word; box-sizing: border-box; background-color: rgba(128, 128, 128, 0.047058);">location /group1/M00 { | ||
| 行 71: | 行 71: | ||
|     add_header  X-Via  $server_addr; |     add_header  X-Via  $server_addr; | ||
|     add_header  X-Cache-Status $upstream_cache_status; |     add_header  X-Cache-Status $upstream_cache_status; | ||
| - | }1234567891012345678910</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">重启nginx,清除缓存再次访问即可查看响应头命中信息。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;"><a style="color: rgb(12, 137, 207);" target="_blank"></a>附录</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">需要再多写一点, FastDFS这样部署就已经可以正常运行了,但是有一个问题,就是FastDFS本身不支持对上传的文件去重。也就是说,同一个文件,我们反复上传,那么会在Storage中保存多份,这显然是不合理的。解决办法,需要的请参考我另一篇文章: <br/>《FastDHT配合FastDFS进行文件上传去重》 <br/><a style="color: rgb(12, 137, 207);" href="http://blog.csdn.net/ForeverSunshine/article/details/51226061" target="_blank">http://blog.csdn.net/ForeverSunshine/article/details/51226061</a></p> | + | }1234567891012345678910</pre><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">重启nginx,清除缓存再次访问即可查看响应头命中信息。</p><h3 style="margin: 0.8em 0px; padding: 0px; color: rgb(63, 63, 63); line-height: 1.3em; font-family: "microsoft yahei"; font-size: 1.73em; font-weight: 100;">附录</h3><p style="color: rgb(63, 63, 63); padding-top: 0px; padding-bottom: 0px; font-family: "microsoft yahei"; font-size: 15px; margin-top: 0px; margin-bottom: 1.1em;">需要再多写一点, FastDFS这样部署就已经可以正常运行了,但是有一个问题,就是FastDFS本身不支持对上传的文件去重。也就是说,同一个文件,我们反复上传,那么会在Storage中保存多份,这显然是不合理的。解决办法,需要的请参考我另一篇文章: <br/>《FastDHT配合FastDFS进行文件上传去重》 <br/><a style="color: rgb(12, 137, 207);" href="http://blog.csdn.net/ForeverSunshine/article/details/51226061" target="_blank">http://blog.csdn.net/ForeverSunshine/article/details/51226061</a></p> |
| - |     </article><p> | + |     </article><p><br/></p><p><br/></p><p> </p> |
| - | + | ||
| - | </p><p> | + | |
| - | </p><p> </p> | + | |