1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - centos - 正文

君子好学,自强不息!

 原文:http://blog.csdn.net/wlwlwlwl015/article/details/52619851

 

 

项目中用到文件服务器,有朋友推荐用fastdfs,所以就了解学习了一番,感觉确实颇为强大,在此再次感谢淘宝资深架构师余庆大神开源了如此优秀的轻量级分布式文件系统,本篇blog就记录一下fastdfs的最新版本5.0.8在centos7中的安装与配置。

简介

首先简单了解一下基础概念,FastDFS是一个开源的轻量级分布式文件系统,由跟踪服务器(tracker server)、存储服务器(storage server)和客户端(client)三个部分组成,主要解决了海量数据存储问题,特别适合以中小文件(建议范围:4KB < file_size <500MB)为载体的在线服务。FastDFS的系统结构图如下: 
分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

如上图,FastDFS的两个核心概念分别是:

  1. Tracker(跟踪器)
  2. Storage(存储节点)

Tracker主要做调度工作,相当于mvc中的controller的角色,在访问上起负载均衡的作用。跟踪器和存储节点都可以由一台或多台服务器构成,跟踪器和存储节点中的服务器均可以随时增加或下线而不会影响线上服务,其中跟踪器中的所有服务器都是对等的,可以根据服务器的压力情况随时增加或减少。Tracker负责管理所有的Storage和group,每个storage在启动后会连接Tracker,告知自己所属的group等信息,并保持周期性的心跳,tracker根据storage的心跳信息,建立group==>[storage server list]的映射表,Tracker需要管理的元信息很少,会全部存储在内存中;另外tracker上的元信息都是由storage汇报的信息生成的,本身不需要持久化任何数据,这样使得tracker非常容易扩展,直接增加tracker机器即可扩展为tracker cluster来服务,cluster里每个tracker之间是完全对等的,所有的tracker都接受stroage的心跳信息,生成元数据信息来提供读写服务。

Storage采用了分卷[Volume](或分组[group])的组织方式,存储系统由一个或多个组组成,组与组之间的文件是相互独立的,所有组的文件容量累加就是整个存储系统中的文件容量。一个卷[Volume](组[group])可以由一台或多台存储服务器组成,一个组中的存储服务器中的文件都是相同的,组中的多台存储服务器起到了冗余备份和负载均衡的作用,数据互为备份,存储空间以group内容量最小的storage为准,所以建议group内的多个storage尽量配置相同,以免造成存储空间的浪费。更多原理性的内容可以参考这篇blog,介绍的很详细:分布式文件系统FastDFS设计原理 
接下来就具体看一下FastDFS的整个下载安装过程~

 

下载:https://github.com/happyfish100/fastdfs/releases

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

如上图,由于FastDFS是纯C语言实现,只支持Linux、FreeBSD等UNIX系统,所以我们直接下载tar.gz的压缩包,同时FastDFS 5.0.5同以前版本相比将公共的一些函数等单独封装成了libfastcommon包,所以在安装FastDFS之前我们还必须安装libfastcommon,在余大的GitHub首页可以看到: 

https://github.com/happyfish100/

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

下载完成后将下面这两个文件上传至CentOS服务器,然后就可以开始解压安装了: 

 分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

安装

libfastcommon

首先第一步是安装libfastcommon,我这里将libfastcommon上传到的/usr/local目录下,直接解压:

unzip libfastcommon-master.zip

 

解压成功后进入目录看一下压缩包的文件: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

解压完成后就可以进行编译安装了,分别执行./make.sh./make.sh install,由于是新安装的系统有可能会提示找不到gcc命令: 
分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

如上图,所以我们先要安装gcc编译器:

yum -y install gcc-c++

 

看到如下信息说明gcc已经安装成功: 
分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

此时再次执行./make.sh命令进行编译,没有error信息的话就说明编译成功了,最后再执行./make.sh install进行安装,看到类似如下提示信息就说明libfastcommon已安装成功

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

至此libfastcommon就已经安装成功了,但注意一下上图中红色框标注的内容,libfastcommon.so 默认安装到了/usr/lib64/libfastcommon.so,但是FastDFS主程序设置的lib目录是/usr/local/lib,所以此处需要重新设置软链接(类似于Windows的快捷方式):

ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so

设置完毕后就可以开始安装fastdfs了。

 

FastDFS

第一步依然是解压:

tar -zxvf fastdfs-5.08.tar.gz

 

解压完成后进入目录fastdfs-5.08,依次执行./make.sh和./make.sh install:

./make.sh
./make.sh install

没有报错就说明安装成功了,在log中我们可以发现安装路径: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

没错,正是安装到了/etc/fdfs中,我们看一下该目录下的文件: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

如上图,安装成功后就会生成如上的3个.sample文件(示例配置文件),我们再分别拷贝出3个后面用的正式的配置文件:

cp client.conf.sample client.conf
cp storage.conf.sample storage.conf
cp tracker.conf.sample tracker.conf

 

 之后再查看一下/etc/fdfs的文件目录: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

至此FastDFS已经安装完毕,接下来的工作就是依次配置Tracker和Storage了。

Tracker

在配置Tracker之前,首先需要创建Tracker服务器的文件路径,即用于存储Tracker的数据文件和日志文件等,我这里选择在/opt目录下创建一个fastdfs_tracker目录用于存放Tracker服务器的相关文件:

 

mkdir /opt/fastdfs_tracker

 

接下来就要重新编辑上一步准备好的/etc/fdfs目录下的tracker.conf配置文件,打开文件后依次做以下修改:

  1. disabled=false #启用配置文件(默认启用)
  2. port=22122 #设置tracker的端口号,通常采用22122这个默认端口
  3. base_path=/opt/fastdfs_tracker #设置tracker的数据文件和日志目录
  4. http.server_port=6666 #设置http端口号,默认为8080

配置完成后就可以启动Tracker服务器了,但首先依然要为启动脚本创建软引用,因为fdfs_trackerd等命令在/usr/local/bin中并没有,而是在/usr/bin路径下:

ln -s /usr/bin/fdfs_trackerd /usr/local/bin
ln -s /usr/bin/stop.sh /usr/local/bin
ln -s /usr/bin/restart.sh /usr/local/bin

最后通过命令启动Tracker服务器:

service fdfs_trackerd start

命令执行后可以看到以下提示: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 如果启动命令执行成功,那么同时在刚才创建的tracker文件目录/opt/fastdfs_tracker中就可以看到启动后新生成的data和logs目录,tracker服务的端口也应当被正常监听,最后再通过netstat命令查看一下端口监听情况:

 

netstat -unltp|grep fdfs

 

可以看到tracker服务运行的22122端口正常被监听: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 确认tracker正常启动后可以将tracker设置为开机启动,打开/etc/rc.d/rc.local并在其中加入以下配置:

service fdfs_trackerd start

 

如果重启后发现未能自动启动则通过命令ll /etc/rc.d/rc.local检查一下rc.local是否具备可执行权限,若是无可执行权限则通过chmod +x /etc/rc.d/rc.local进行授权,如下图: 
分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

Tracker至此就配置好了,接下来就可以配置FastDFS的另一核心——Storage。

 

Storage

同理,步骤基本与配置Tracker一致,首先是创建Storage服务器的文件目录,需要注意的是同Tracker相比我多建了一个目录,因为Storage还需要一个文件存储路径,用于存放接收的文件:

mkdir /opt/fastdfs_storage
mkdir /opt/fastdfs_storage_data

 

接下来修改/etc/fdfs目录下的storage.conf配置文件,

vi /etc/fdfs/storage.conf

 

打开文件后依次做以下修改:

  1. disabled=false #启用配置文件(默认启用)
  2. group_name=group1 #组名,根据实际情况修改
  3. port=23000 #设置storage的端口号,默认是23000,同一个组的storage端口号必须一致
  4. base_path=/opt/fastdfs_storage #设置storage数据文件和日志目录
  5. store_path_count=1 #存储路径个数,需要和store_path个数匹配
  6. store_path0=/opt/fastdfs_storage_data #实际文件存储路径
  7. tracker_server=192.168.111.11:22122 #tracker 服务器的 IP地址和端口号,如果是单机搭建,IP不要写127.0.0.1,否则启动不成功(此处的ip是我的CentOS虚拟机ip)
  8. http.server_port=8888 #设置 http 端口号

配置完成后同样要为Storage服务器的启动脚本设置软引用:

ln -s /usr/bin/fdfs_storaged /usr/local/bin

接下来就可以启动Storage服务了:

service fdfs_storaged start

命令执行后可以看到以下提示: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

同理,如果启动成功,/opt/fastdfs_storage中就可以看到启动后新生成的data和logs目录,端口23000也应被正常监听,还有一点就是文件存储路径下会生成多级存储目录,那么接下来看看是否启动成功了: 

 netstat -unltp|grep fdfs

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

(如果storage的23000端口并未被监听,那么我们只能去日志文件中找原因了,进入/opt/fastdfs_storage/logs目录下并打开storaged.log文件)

 

如上图,可以看到此时已经正常监听tracker的22122端口和storage的23000端口,至此storage服务器就已经配置完成,确定了storage服务器启动成功后,还有一项工作就是看看storage服务器是否已经登记到 tracker服务器(也可以理解为tracker与storage是否整合成功),运行以下命令:

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

 

[root@localhost sync]# /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
[2017-01-12 17:27:11] DEBUG – base_path=/opt/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: 0

server_count=1, server_index=0

tracker server is 192.168.1.238:22122

group count: 1

Group 1:
group name = group1
disk total space = 17781 MB
disk free space = 3869 MB
trunk free space = 0 MB
storage server count = 1
active server count = 1
storage server port = 23000
storage HTTP port = 8888
store path count = 1
subdir count per path = 256
current write server index = 0
current trunk file id = 0

Storage 1:
id = 192.168.1.238
ip_addr = 192.168.1.238 ACTIVE
http domain =
version = 5.08
join time = 2017-01-12 17:16:49
up time = 2017-01-12 17:16:49
total storage = 17781 MB
free storage = 3869 MB
upload priority = 10
store_path_count = 1
subdir_count_per_path = 256
storage_port = 23000
storage_http_port = 8888
current_write_path = 0
source storage id =
if_trunk_server = 0
connection.alloc_count = 256
connection.current_count = 0
connection.max_count = 0
total_upload_count = 0
success_upload_count = 0
total_append_count = 0
success_append_count = 0
total_modify_count = 0
success_modify_count = 0
total_truncate_count = 0
success_truncate_count = 0
total_set_meta_count = 0
success_set_meta_count = 0
total_delete_count = 0
success_delete_count = 0
total_download_count = 0
success_download_count = 0
total_get_meta_count = 0
success_get_meta_count = 0
total_create_link_count = 0
success_create_link_count = 0
total_delete_link_count = 0
success_delete_link_count = 0
total_upload_bytes = 0
success_upload_bytes = 0
total_append_bytes = 0
success_append_bytes = 0
total_modify_bytes = 0
success_modify_bytes = 0
stotal_download_bytes = 0
success_download_bytes = 0
total_sync_in_bytes = 0
success_sync_in_bytes = 0
total_sync_out_bytes = 0
success_sync_out_bytes = 0
total_file_open_count = 0
success_file_open_count = 0
total_file_read_count = 0
success_file_read_count = 0
total_file_write_count = 0
success_file_write_count = 0
last_heart_beat_time = 2017-01-12 17:26:44
last_source_update = 1970-01-01 08:00:00
last_sync_update = 1970-01-01 08:00:00
last_synced_timestamp = 1970-01-01 08:00:00

如上所示,看到192.168.1.238 ACTIVE 字样即可说明storage服务器已经成功登记到了tracker服务器,同理别忘了添加开机启动,打开/etc/rc.d/rc.local

 vi /etc/rc.d/rc.local

并将如下配置追加到文件中:

service fdfs_storaged start

 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

至此我们就已经完成了fastdfs的全部配置,此时也就可以用客户端工具进行文件上传下载的测试了。

 

初步测试

测试时需要设置客户端的配置文件,编辑/etc/fdfs目录下的client.conf 文件,打开文件后

vi /etc/fdfs/client.conf

依次做以下修改:

配置时不要加注释,我加了之后upload时报错

  1. base_path=/opt/fastdfs_tracker #tracker服务器文件路径
  2. tracker_server=192.168.1.238:22122 #tracker服务器IP地址和端口号
  3. http.tracker_server_port=6666 # tracker 服务器的 http 端口号,必须和tracker的设置对应起来

配置完成后就可以模拟文件上传了,先给/opt目录下放一张图片: 

 1.jpg

 分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

然后通过执行客户端上传命令尝试上传:

 

/usr/bin/fdfs_upload_file  /etc/fdfs/client.conf  /opt/1.jpg

 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

上传后返回的文件存储地址:

 group1/M00/00/00/wKgB7lh3UeGAZYJvAACFao7PICk390.jpg

 

同时在之前配置的storage服务器的实际文件存储路径中也可以根据返回的路径找到实际文件: 

 查看文件保存位置:/opt/fastdfs_storage_data/data/00/00

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

 

 接下来尝试用浏览器发送HTTP请求访问一下文件: 

 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

此时发现并不能访问,因为FastDFS目前已不支持http协议,我们在FastDFS 4.0.5的版本更新日志中可以看到这样一条信息: 
分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

如上图,4.0.5版本开始移除了自带的HTTP支持(因为之前自带的HTTP服务较为简单,无法提供负载均衡等高性能服务),所以余大提供了nginx上使用FastDFS的模块fastdfs-nginx-module,下载地址如下:https://github.com/happyfish100/fastdfs-nginx-module,这样做最大的好处就是提供了HTTP服务并且解决了group中storage服务器的同步延迟问题,接下来就具体记录一下fastdfs-nginx-module的安装配置过程。

fastdfs-nginx-module

在余大的GitHub上下载好fastdfs-nginx-module上传到我们的CentOS中就可以开始安装了

首先是为storage服务器安装nginx,首先将nginx和fastdfs-nginx-module的安装包上传至CentOS: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

tar -zxvf nginx-1.11.8.tar.gz
unzip fastdfs-nginx-module-master.zip

 

安装fastdfs-nginx-module

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

解压成功后就可以编译安装nginx了,进入nginx目录并输入以下命令进行配置:

./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module-master/src

 执行后我的报错了:

 分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

报错信息提示要requires the PCRE library,那就安装PCRE 。

下载地址:https://sourceforge.net/projects/pcre/files/pcre/

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 点击后再点下面的

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

下载后上传到/usr/local后

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

tar -zxvf pcre-8.39.tar.gz
 cd pcre-8.39
./configure  
 

 接着又报下面的错误:

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether makesets $(MAKE)... yes
checking whether makesupports nested variables... yes
checking whether makesupports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for int64_t... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1966080
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether ln -s works... yes
checking whether the -Werror option is usable... yes
checking for simple visibility declarations... yes
checking for ANSI C header files... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking windows.h usability... no
checking windows.h presence... no
checking for windows.h... no
configure: error: You need a C++ compiler for C++ support.

那就安装C++

yum install -y gcc gcc-c++

 安装好后再次执行编译

 cd pcre-8.39
./configure  

 

 

执行后的结果:

[root@localhost pcre-8.39]# ./configure  
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether makesets $(MAKE)... yes
checking whether makesupports nested variables... yes
checking whether makesupports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for int64_t... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1966080
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether ln -s works... yes
checking whether the -Werror option is usable... yes
checking for simple visibility declarations... yes
checking for ANSI C header files... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking windows.h usability... no
checking windows.h presence... no
checking for windows.h... no
checking for alias support in the linker... no
checking for alias support in the linker... no
checking string usability... yes
checking string presence... yes
checking for string... yes
checking bits/type_traits.h usability... no
checking bits/type_traits.h presence... no
checking for bits/type_traits.h... no
checking type_traits.h usability... no
checking type_traits.h presence... no
checking for type_traits.h... no
checking for strtoq... yes
checking for long long... yes
checking for unsigned long long... yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for bcopy... yes
checking for memmove... yes
checking for strerror... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for gzopen in -lz... yes
checking bzlib.h usability... no
checking bzlib.h presence... no
checking for bzlib.h... no
checking for libbz2... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libpcre.pc
config.status: creating libpcre16.pc
config.status: creating libpcre32.pc
config.status: creating libpcreposix.pc
config.status: creating libpcrecpp.pc
config.status: creating pcre-config
config.status: creating pcre.h
config.status: creating pcre_stringpiece.h
config.status: creating pcrecpparg.h
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing script-chmod commands
config.status: executing delete-old-chartables commands

pcre-8.39 configuration summary:

    Install prefix .................. : /usr/local
    C preprocessor .................. : gcc -E
    C compiler ...................... : gcc
    C++ preprocessor ................ : g++ -E
    C++ compiler .................... : g++
    Linker .......................... : /usr/bin/ld -m elf_x86_64
    C preprocessor flags ............ : 
    C compiler flags ................ : -g -O2 -fvisibility=hidden
    C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
    Linker flags .................... : 
    Extra libraries ................. : 

    Build 8 bit pcre library ........ : yes
    Build 16 bit pcre library ....... : no
    Build 32 bit pcre library ....... : no
    Build C++ library ............... : yes
    Enable JIT compiling support .... : no
    Enable UTF-8/16/32 support ...... : no
    Unicode properties .............. : no
    Newline char/sequence ........... : lf
    \R matches only ANYCRLF ......... : no
    EBCDIC coding ................... : no
    EBCDIC code for NL .............. : n/a
    Rebuild char tables ............. : no
    Use stack recursion ............. : yes
    POSIX mem threshold ............. : 10
    Internal link size .............. : 2
    Nested parentheses limit ........ : 250
    Match limit ..................... : 10000000
    Match limit recursion ........... : MATCH_LIMIT
    Build shared libs ............... : yes
    Build static libs ............... : yes
    Use JIT in pcregrep ............. : no
    Buffer size for pcregrep ........ : 20480
    Link pcregrep with libz ......... : no
    Link pcregrep with libbz2 ....... : no
    Link pcretest with libedit ...... : no
    Link pcretest with libreadline .. : no
    Valgrind support ................ : no
    Code coverage ................... : no

[root@localhost pcre-8.39]# 

 

 执行成功后再make

make

下面是make后的结果:

[root@localhost pcre-8.39]# make
rm -f pcre_chartables.c
ln -s ./pcre_chartables.c.dist pcre_chartables.c
make all-am
make[1]: Entering directory `/usr/local/pcre-8.39'
  CC       libpcre_la-pcre_byte_order.lo
  CC       libpcre_la-pcre_compile.lo
  CC       libpcre_la-pcre_config.lo
  CC       libpcre_la-pcre_dfa_exec.lo
  CC       libpcre_la-pcre_exec.lo
  CC       libpcre_la-pcre_fullinfo.lo
  CC       libpcre_la-pcre_get.lo
  CC       libpcre_la-pcre_globals.lo
  CC       libpcre_la-pcre_jit_compile.lo
  CC       libpcre_la-pcre_maketables.lo
  CC       libpcre_la-pcre_newline.lo
  CC       libpcre_la-pcre_ord2utf8.lo
  CC       libpcre_la-pcre_refcount.lo
  CC       libpcre_la-pcre_string_utils.lo
  CC       libpcre_la-pcre_study.lo
  CC       libpcre_la-pcre_tables.lo
  CC       libpcre_la-pcre_ucd.lo
  CC       libpcre_la-pcre_valid_utf8.lo
  CC       libpcre_la-pcre_version.lo
  CC       libpcre_la-pcre_xclass.lo
  CC       libpcre_la-pcre_chartables.lo
  CCLD     libpcre.la
  CC       libpcreposix_la-pcreposix.lo
  CCLD     libpcreposix.la
  CXX      libpcrecpp_la-pcrecpp.lo
  CXX      libpcrecpp_la-pcre_scanner.lo
  CXX      libpcrecpp_la-pcre_stringpiece.lo
  CXXLD    libpcrecpp.la
  CC       pcretest-pcretest.o
  CC       pcretest-pcre_printint.o
  CCLD     pcretest
  CC       pcregrep-pcregrep.o
  CCLD     pcregrep
  CXX      pcrecpp_unittest-pcrecpp_unittest.o
  CXXLD    pcrecpp_unittest
  CXX      pcre_scanner_unittest-pcre_scanner_unittest.o
  CXXLD    pcre_scanner_unittest
  CXX      pcre_stringpiece_unittest-pcre_stringpiece_unittest.o
  CXXLD    pcre_stringpiece_unittest
make[1]: Leaving directory `/usr/local/pcre-8.39'
[root@localhost pcre-8.39]# 

 

编译完后可以执行makecheck进行测试(这一步非必须)

[root@localhost pcre-8.39]# makecheck
make check-am
make[1]: Entering directory `/usr/local/pcre-8.39'
make 
make[2]: Entering directory `/usr/local/pcre-8.39'
make all-am
make[3]: Entering directory `/usr/local/pcre-8.39'
make[3]: Leaving directory `/usr/local/pcre-8.39'
make[2]: Leaving directory `/usr/local/pcre-8.39'
make check-TESTS
make[2]: Entering directory `/usr/local/pcre-8.39'
make[3]: Entering directory `/usr/local/pcre-8.39'
PASS: pcrecpp_unittest
PASS: pcre_scanner_unittest
PASS: pcre_stringpiece_unittest
PASS: RunTest
PASS: RunGrepTest
============================================================================
Testsuite summary for PCRE 8.39
============================================================================
# TOTAL: 5
# PASS:  5
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
make[3]: Leaving directory `/usr/local/pcre-8.39'
make[2]: Leaving directory `/usr/local/pcre-8.39'
make[1]: Leaving directory `/usr/local/pcre-8.39'
[root@localhost pcre-8.39]# 

 

 执行makeinstall操作:

 makeinstall

makeinstall结束后pcre编译安装流程就结束了。

 下面贴出makeinstall后执行的结果:

[root@localhost pcre-8.39]# makeinstall
make install-am
make[1]: Entering directory `/usr/local/pcre-8.39'
make[2]: Entering directory `/usr/local/pcre-8.39'
 /bin/mkdir -p '/usr/local/lib'
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libpcre.la libpcreposix.la libpcrecpp.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libpcre.so.1.2.7 /usr/local/lib/libpcre.so.1.2.7
libtool: install: (cd /usr/local/lib && { ln -s -f libpcre.so.1.2.7 libpcre.so.1 || { rm -f libpcre.so.1 && ln -s libpcre.so.1.2.7 libpcre.so.1; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libpcre.so.1.2.7 libpcre.so || { rm -f libpcre.so && ln -s libpcre.so.1.2.7 libpcre.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcre.lai /usr/local/lib/libpcre.la
libtool: warning: relinking 'libpcreposix.la'
libtool: install: (cd /usr/local/pcre-8.39; /bin/sh "/usr/local/pcre-8.39/libtool"  --silent --tag CC --mode=relink gcc -fvisibility=hidden -g -O2 -version-info 0:4:0 -o libpcreposix.la -rpath /usr/local/lib libpcreposix_la-pcreposix.lo libpcre.la )
libtool: install: /usr/bin/install -c .libs/libpcreposix.so.0.0.4T /usr/local/lib/libpcreposix.so.0.0.4
libtool: install: (cd /usr/local/lib && { ln -s -f libpcreposix.so.0.0.4 libpcreposix.so.0 || { rm -f libpcreposix.so.0 && ln -s libpcreposix.so.0.0.4 libpcreposix.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libpcreposix.so.0.0.4 libpcreposix.so || { rm -f libpcreposix.so && ln -s libpcreposix.so.0.0.4 libpcreposix.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcreposix.lai /usr/local/lib/libpcreposix.la
libtool: warning: relinking 'libpcrecpp.la'
libtool: install: (cd /usr/local/pcre-8.39; /bin/sh "/usr/local/pcre-8.39/libtool"  --silent --tag CXX --mode=relink g++ -fvisibility=hidden -fvisibility-inlines-hidden -O2 -version-info 0:1:0 -o libpcrecpp.la -rpath /usr/local/lib libpcrecpp_la-pcrecpp.lo libpcrecpp_la-pcre_scanner.lo libpcrecpp_la-pcre_stringpiece.lo libpcre.la )
libtool: install: /usr/bin/install -c .libs/libpcrecpp.so.0.0.1T /usr/local/lib/libpcrecpp.so.0.0.1
libtool: install: (cd /usr/local/lib && { ln -s -f libpcrecpp.so.0.0.1 libpcrecpp.so.0 || { rm -f libpcrecpp.so.0 && ln -s libpcrecpp.so.0.0.1 libpcrecpp.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libpcrecpp.so.0.0.1 libpcrecpp.so || { rm -f libpcrecpp.so && ln -s libpcrecpp.so.0.0.1 libpcrecpp.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcrecpp.lai /usr/local/lib/libpcrecpp.la
libtool: install: /usr/bin/install -c .libs/libpcre.a /usr/local/lib/libpcre.a
libtool: install: chmod 644 /usr/local/lib/libpcre.a
libtool: install: ranlib /usr/local/lib/libpcre.a
libtool: install: /usr/bin/install -c .libs/libpcreposix.a /usr/local/lib/libpcreposix.a
libtool: install: chmod 644 /usr/local/lib/libpcreposix.a
libtool: install: ranlib /usr/local/lib/libpcreposix.a
libtool: install: /usr/bin/install -c .libs/libpcrecpp.a /usr/local/lib/libpcrecpp.a
libtool: install: chmod 644 /usr/local/lib/libpcrecpp.a
libtool: install: ranlib /usr/local/lib/libpcrecpp.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.8.0_60/bin:/usr/java/maven-3.2.3/bin:/usr/local/mysql/bin:/root/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/usr/local/bin'
  /bin/sh ./libtool   --mode=install /usr/bin/install -c pcretest pcregrep '/usr/local/bin'
libtool: install: /usr/bin/install -c .libs/pcretest /usr/local/bin/pcretest
libtool: install: /usr/bin/install -c .libs/pcregrep /usr/local/bin/pcregrep
 /bin/mkdir -p '/usr/local/bin'
 /usr/bin/install -c pcre-config '/usr/local/bin'
 /bin/mkdir -p '/usr/local/share/doc/pcre'
 /usr/bin/install -c -m 644 doc/pcre.txt doc/pcre-config.txt doc/pcregrep.txt doc/pcretest.txt AUTHORS COPYING ChangeLog LICENCE NEWS README '/usr/local/share/doc/pcre'
 /bin/mkdir -p '/usr/local/share/doc/pcre/html'
 /usr/bin/install -c -m 644 doc/html/NON-AUTOTOOLS-BUILD.txt doc/html/README.txt doc/html/index.html doc/html/pcre-config.html doc/html/pcre.html doc/html/pcre16.html doc/html/pcre32.html doc/html/pcre_assign_jit_stack.html doc/html/pcre_compile.html doc/html/pcre_compile2.html doc/html/pcre_config.html doc/html/pcre_copy_named_substring.html doc/html/pcre_copy_substring.html doc/html/pcre_dfa_exec.html doc/html/pcre_exec.html doc/html/pcre_free_study.html doc/html/pcre_free_substring.html doc/html/pcre_free_substring_list.html doc/html/pcre_fullinfo.html doc/html/pcre_get_named_substring.html doc/html/pcre_get_stringnumber.html doc/html/pcre_get_stringtable_entries.html doc/html/pcre_get_substring.html doc/html/pcre_get_substring_list.html doc/html/pcre_jit_exec.html doc/html/pcre_jit_stack_alloc.html doc/html/pcre_jit_stack_free.html doc/html/pcre_maketables.html doc/html/pcre_pattern_to_host_byte_order.html doc/html/pcre_refcount.html doc/html/pcre_study.html doc/html/pcre_utf16_to_host_byte_order.html doc/html/pcre_utf32_to_host_byte_order.html doc/html/pcre_version.html doc/html/pcreapi.html doc/html/pcrebuild.html doc/html/pcrecallout.html doc/html/pcrecompat.html doc/html/pcredemo.html doc/html/pcregrep.html '/usr/local/share/doc/pcre/html'
 /usr/bin/install -c -m 644 doc/html/pcrejit.html doc/html/pcrelimits.html doc/html/pcrematching.html doc/html/pcrepartial.html doc/html/pcrepattern.html doc/html/pcreperform.html doc/html/pcreposix.html doc/html/pcreprecompile.html doc/html/pcresample.html doc/html/pcrestack.html doc/html/pcresyntax.html doc/html/pcretest.html doc/html/pcreunicode.html '/usr/local/share/doc/pcre/html'
 /bin/mkdir -p '/usr/local/share/doc/pcre/html'
 /usr/bin/install -c -m 644 doc/html/pcrecpp.html '/usr/local/share/doc/pcre/html'
 /bin/mkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 pcreposix.h pcrecpp.h pcre_scanner.h '/usr/local/include'
 /bin/mkdir -p '/usr/local/share/man/man1'
 /usr/bin/install -c -m 644 doc/pcre-config.1 doc/pcregrep.1 doc/pcretest.1 '/usr/local/share/man/man1'
 /bin/mkdir -p '/usr/local/share/man/man3'
 /usr/bin/install -c -m 644 doc/pcre.3 doc/pcre16.3 doc/pcre32.3 doc/pcre_assign_jit_stack.3 doc/pcre_compile.3 doc/pcre_compile2.3 doc/pcre_config.3 doc/pcre_copy_named_substring.3 doc/pcre_copy_substring.3 doc/pcre_dfa_exec.3 doc/pcre_exec.3 doc/pcre_free_study.3 doc/pcre_free_substring.3 doc/pcre_free_substring_list.3 doc/pcre_fullinfo.3 doc/pcre_get_named_substring.3 doc/pcre_get_stringnumber.3 doc/pcre_get_stringtable_entries.3 doc/pcre_get_substring.3 doc/pcre_get_substring_list.3 doc/pcre_jit_exec.3 doc/pcre_jit_stack_alloc.3 doc/pcre_jit_stack_free.3 doc/pcre_maketables.3 doc/pcre_pattern_to_host_byte_order.3 doc/pcre_refcount.3 doc/pcre_study.3 doc/pcre_utf16_to_host_byte_order.3 doc/pcre_utf32_to_host_byte_order.3 doc/pcre_version.3 doc/pcreapi.3 doc/pcrebuild.3 doc/pcrecallout.3 doc/pcrecompat.3 doc/pcredemo.3 doc/pcrejit.3 doc/pcrelimits.3 doc/pcrematching.3 doc/pcrepartial.3 doc/pcrepattern.3 '/usr/local/share/man/man3'
 /usr/bin/install -c -m 644 doc/pcreperform.3 doc/pcreposix.3 doc/pcreprecompile.3 doc/pcresample.3 doc/pcrestack.3 doc/pcresyntax.3 doc/pcreunicode.3 doc/pcrecpp.3 '/usr/local/share/man/man3'
 /bin/mkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 pcre.h pcrecpparg.h pcre_stringpiece.h '/usr/local/include'
 /bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 libpcre.pc libpcreposix.pc libpcrecpp.pc '/usr/local/lib/pkgconfig'
make install-data-hook
make[3]: Entering directory `/usr/local/pcre-8.39'
ln -sf pcre_assign_jit_stack.3         /usr/local/share/man/man3/pcre16_assign_jit_stack.3
ln -sf pcre_compile.3             /usr/local/share/man/man3/pcre16_compile.3
ln -sf pcre_compile2.3             /usr/local/share/man/man3/pcre16_compile2.3
ln -sf pcre_config.3             /usr/local/share/man/man3/pcre16_config.3
ln -sf pcre_copy_named_substring.3     /usr/local/share/man/man3/pcre16_copy_named_substring.3
ln -sf pcre_copy_substring.3         /usr/local/share/man/man3/pcre16_copy_substring.3
ln -sf pcre_dfa_exec.3             /usr/local/share/man/man3/pcre16_dfa_exec.3
ln -sf pcre_exec.3             /usr/local/share/man/man3/pcre16_exec.3
ln -sf pcre_free_study.3         /usr/local/share/man/man3/pcre16_free_study.3
ln -sf pcre_free_substring.3         /usr/local/share/man/man3/pcre16_free_substring.3
ln -sf pcre_free_substring_list.3     /usr/local/share/man/man3/pcre16_free_substring_list.3
ln -sf pcre_fullinfo.3             /usr/local/share/man/man3/pcre16_fullinfo.3
ln -sf pcre_get_named_substring.3     /usr/local/share/man/man3/pcre16_get_named_substring.3
ln -sf pcre_get_stringnumber.3         /usr/local/share/man/man3/pcre16_get_stringnumber.3
ln -sf pcre_get_stringtable_entries.3     /usr/local/share/man/man3/pcre16_get_stringtable_entries.3
ln -sf pcre_get_substring.3         /usr/local/share/man/man3/pcre16_get_substring.3
ln -sf pcre_get_substring_list.3     /usr/local/share/man/man3/pcre16_get_substring_list.3
ln -sf pcre_jit_exec.3             /usr/local/share/man/man3/pcre16_jit_exec.3
ln -sf pcre_jit_stack_alloc.3         /usr/local/share/man/man3/pcre16_jit_stack_alloc.3
ln -sf pcre_jit_stack_free.3         /usr/local/share/man/man3/pcre16_jit_stack_free.3
ln -sf pcre_maketables.3         /usr/local/share/man/man3/pcre16_maketables.3
ln -sf pcre_pattern_to_host_byte_order.3 /usr/local/share/man/man3/pcre16_pattern_to_host_byte_order.3
ln -sf pcre_refcount.3             /usr/local/share/man/man3/pcre16_refcount.3
ln -sf pcre_study.3             /usr/local/share/man/man3/pcre16_study.3
ln -sf pcre_utf16_to_host_byte_order.3     /usr/local/share/man/man3/pcre16_utf16_to_host_byte_order.3
ln -sf pcre_version.3             /usr/local/share/man/man3/pcre16_version.3
ln -sf pcre_assign_jit_stack.3         /usr/local/share/man/man3/pcre32_assign_jit_stack.3
ln -sf pcre_compile.3             /usr/local/share/man/man3/pcre32_compile.3
ln -sf pcre_compile2.3             /usr/local/share/man/man3/pcre32_compile2.3
ln -sf pcre_config.3             /usr/local/share/man/man3/pcre32_config.3
ln -sf pcre_copy_named_substring.3     /usr/local/share/man/man3/pcre32_copy_named_substring.3
ln -sf pcre_copy_substring.3         /usr/local/share/man/man3/pcre32_copy_substring.3
ln -sf pcre_dfa_exec.3             /usr/local/share/man/man3/pcre32_dfa_exec.3
ln -sf pcre_exec.3             /usr/local/share/man/man3/pcre32_exec.3
ln -sf pcre_free_study.3         /usr/local/share/man/man3/pcre32_free_study.3
ln -sf pcre_free_substring.3         /usr/local/share/man/man3/pcre32_free_substring.3
ln -sf pcre_free_substring_list.3     /usr/local/share/man/man3/pcre32_free_substring_list.3
ln -sf pcre_fullinfo.3             /usr/local/share/man/man3/pcre32_fullinfo.3
ln -sf pcre_get_named_substring.3     /usr/local/share/man/man3/pcre32_get_named_substring.3
ln -sf pcre_get_stringnumber.3         /usr/local/share/man/man3/pcre32_get_stringnumber.3
ln -sf pcre_get_stringtable_entries.3     /usr/local/share/man/man3/pcre32_get_stringtable_entries.3
ln -sf pcre_get_substring.3         /usr/local/share/man/man3/pcre32_get_substring.3
ln -sf pcre_get_substring_list.3     /usr/local/share/man/man3/pcre32_get_substring_list.3
ln -sf pcre_jit_exec.3             /usr/local/share/man/man3/pcre32_jit_exec.3
ln -sf pcre_jit_stack_alloc.3         /usr/local/share/man/man3/pcre32_jit_stack_alloc.3
ln -sf pcre_jit_stack_free.3         /usr/local/share/man/man3/pcre32_jit_stack_free.3
ln -sf pcre_maketables.3         /usr/local/share/man/man3/pcre32_maketables.3
ln -sf pcre_pattern_to_host_byte_order.3 /usr/local/share/man/man3/pcre32_pattern_to_host_byte_order.3
ln -sf pcre_refcount.3             /usr/local/share/man/man3/pcre32_refcount.3
ln -sf pcre_study.3             /usr/local/share/man/man3/pcre32_study.3
ln -sf pcre_utf32_to_host_byte_order.3     /usr/local/share/man/man3/pcre32_utf32_to_host_byte_order.3
ln -sf pcre_version.3             /usr/local/share/man/man3/pcre32_version.3
make[3]: Leaving directory `/usr/local/pcre-8.39'
make[2]: Leaving directory `/usr/local/pcre-8.39'
make[1]: Leaving directory `/usr/local/pcre-8.39'
[root@localhost pcre-8.39]# 

 

此时再回到nginx目录下执行

./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module-master/src

执行结果如下:

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

紧接着就可以进行编译安装了,依次执行以下命令:

 

make
makeinstall

 

 安装完成后,我们在我们指定的目录/usr/local/nginx中就可以看到nginx的安装目录了: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

接下来要修改一下nginx的配置文件,进入conf目录并打开nginx.conf文件加入以下配置:

 

listen       9999;

location ~/group1/M00 {
      root /opt/fastdfs_storage_data/data;
      ngx_fastdfs_module;
}

 下面是我加的位置:

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

然后进入FastDFS的安装目录/usr/local/fastdfs-5.08目录下的conf目录,将http.confmime.types拷贝到/etc/fdfs目录下:

cd /usr/local/fastdfs-5.08
cp -r /usr/local/fastdfs-5.08/conf/http.conf /etc/fdfs/
cp -r /usr/local/fastdfs-5.08/conf/mime.types /etc/fdfs/

接下来还需要把fastdfs-nginx-module安装目录中src目录下的mod_fastdfs.conf也拷贝到/etc/fdfs目录下:

cp -r /usr/local/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/

看一下/etc/fdfs目录下当前所有的配置文件: 

 分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

没什么问题,接下来就需要编辑刚拷贝的这个mod_fastdfs.conf文件了,打开mod_fastdfs.conf并按顺序依次编译以下内容:

  1. base_path=/opt/fastdfs_storage #保存日志目录
  2. tracker_server=192.168.1.238:22122 #tracker服务器的IP地址以及端口号
  3. storage_server_port=23000 #storage服务器的端口号
  4. url_have_group_name = true #文件 url 中是否有 group 名
  5. store_path0=/opt/fastdfs_storage_data # 存储路径
  6. group_count = 3 #设置组的个数,事实上这次只使用了group1

设置了group_count = 3,接下来就需要在文件尾部追加这3个group setting:

[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/opt/fastdfs_storage_data

[group2]
group_name=group2
storage_server_port=23000
store_path_count=1
store_path0=/opt/fastdfs_storage_data

[group3]
group_name=group3
storage_server_port=23000
store_path_count=1
store_path0=/opt/fastdfs_storage_data

 

 接下来还需要建立 M00 至存储目录的符号连接:

ln  -s  /opt/fastdfs_storage_data/data  /opt/fastdfs_storage_data/data/M00

最后启动nginx:

 

/usr/local/nginx/sbin/nginx

我启动时报下面的错误

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

如果报上面的错就执行下面的代码:可访问http://www.cnblogs.com/shihaiming/p/6281955.html,看看详细情况

ln -s /usr/local/lib/libpcre.so.1 /lib64

 

 

显示如下信息说明nginx已启动成功: 

 分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

通过浏览器也可以看到nginx的主页: 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

storage服务器的nginx就已经安装完毕,接下来看一下tracker服务器的nginx安装。

 

 

 

tracker nginx

同理,再装一个nginx,目录命名为nginx2,安装路径依旧放在/usr/local下,由于和之前一样,此处就不再做详细解释:

 

mkdir nginx2
cd nginx-1.11.8/
./configure --prefix=/usr/local/nginx2 --add-module=/usr/local/fastdfs-nginx-module-master/src
make
makeinstall

 

接下来依然是修改nginx2的配置文件,进入conf目录并打开nginx.conf文件加入以下配置,storage的nginx无需修改listen端口,即默认的80端口,并将upstream指向tracker的nginx地址:

upstream fdfs_group1 {
     server 127.0.0.1:9999;
}

location /group1/M00 {
     proxy_pass http://fdfs_group1;
}

 下图是我加的位置:

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

接下来启动nginx2:

/usr/local/nginx2/sbin/nginx

此时访问nginx2的主页,由于没有修改端口,直接访问ip地址即可: 

 分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

最后一步就是需要修改/etc/fdfs目录下的client.conf文件,打开该文件并加入以下配置:

vi /etc/fdfs/client.conf
base_path=/data/fastdfs_storage  #日志存放路径
tracker_server=192.168.1.238:22122  #tracker 服务器 IP 地址和端口号
http.tracker_server_port=6666  # tracker 服务器的 http 端口号,必须和tracker的设置对应起来

至此关于fastdfs就已经全部配置完毕了,再次测试看看是否能正常上传文件并通过http访问文件。

两个nginx都可以访问了

http://192.168.1.238/group1/M00/00/00/wKgB7lh3UeGAZYJvAACFao7PICk390.jpg

http://192.168.1.238:9999/group1/M00/00/00/wKgB7lh3UeGAZYJvAACFao7PICk390.jpg

 

分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

文件保存位置:

cd /opt/fastdfs_storage_data/data/00/00

 

 分布式文件系统 FastDFS 5.0.8 & Linux CentOS 6.7 安装配置

 

 

一切正常~ 至此关于FastDFS在CentOS 6下的部署测试就已经全部完成了。

 

本文来源:1818IP

本文地址:https://www.1818ip.com/post/32759.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。