安装fastDFS文件

来源:互联网 发布:古典风格网站源码 编辑:程序博客网 时间:2024/06/05 18:04

安装fastDFS文件服务器


tracker storage都在同一台服务器上。

首先,下载一下所有必需文件,然后上传至目标服务器。


nginx-1.6.0.tar.gz

FastDFS_v5.01.tar.gz

libevent-2.0.21-stable.tar.gz

fastdfs-nginx-module_v1.16.tar.gz


上传命令:  

scp -P 端口  Downloads/目标文件 jishi@10.10.xx.xx:hbase-1.3.1-bin.tar.gz


依次 tar -zxvf xxx.tar.gz 

参数说明:

z:是否同时具有gzip的属性,是否需要使用gzip压缩 

v :显示详细信息

f:  使用压缩包的名字,必需放后面..


libevent安装:


tar  -zxvf libevent-2.0.21-stable.tar.gz
cd  libevent-2.0.21-stable
mkdir -p /usr/local/libevnet
./configure --prefix=/usr/local/libevent
make && make install
#libevent创建软链接到/lib库下

ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

FastDFS安装


进入解压后的FastDFS文件夹

cd /usr/local/FastDFS/

vim make.sh
#WITH_LINUX_SERVICE=1  /取消此行的注释

make 

make install

配置文件:



 

其中fdfs_restart.shfdfs_stop.sh以前叫restart.shstop.sh,为了避免混淆,重命名了。




首先配置tracker.conf

disabled=false            #启用配置文件port=22122                #设置tracker的端口号base_path=/usr/local/FastDFS/tracker   #设置tracker的数据文件和日志目录(需预先创建)http.server_port=9090     #设置http端口号

配置好之后,启动tracker:

cd /usr/local/bin

[root@centos7-tmp bin]# ./fdfs_trackerd /etc/fdfs/tracker.conf 

查看状态:


看到storage是因为已经安装了storage后查到的。

查看日志:




然后配置storage.conf


vim /etc/fdfs/storage.conf

disabled=false
# the name of the group this storage server belongs to
group_name=group1
# the storage server port
port=23000
# the base path to store data and log files
base_path=/usr/local/FastDFS/storage
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/usr/local/FastDFS/storage
# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=10.10.20.207:22122
# the port of the web server on this storage server
http.server_port=9090

之后启动:

cd /usr/local/bin

[root@centos7-tmp bin]# ./fdfs_storaged /etc/fdfs/storage.conf restart

然后会创建目录

之后再按trakcer的方式,查看进程,查看log,没有报错就好了。

./fdfs_monitor /etc/fdfs/storage.conf

查看storage是否已经登记到tracker

至此,tracker和storage已经安装完毕


storage节点安装nginx和fastdfs-nginx-module模块:

“在storage上安装的nginx主要为了提供http的访问服务,同时解决group中storage服务器的同步延迟问题。”

要求必须先安装zlib和pcre包。

yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

解压fastdfs-nginx-module,解压后的路径:/usr/local/fastdfs-nginx-module

解压nginx,configuration命令,把fastdfs-nginx-module加上

./configure --user=csrr --group=jishi --prefix=/usr/local/nginx-1.11.13 --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-pcre --with-pcre-jit --add-module=/usr/local/fastdfs-nginx-module/src 


然后make&&make install


安装完之后,将插件的配置fastdfs-nginx-module文件拷贝到FastDFS配置文件目录下:

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

编辑这个文件

vim /etc/fdfs/mod_fastdfs.conf



# the base path to store log files
base_path=/usr/local/FastDFS/storage
# FastDFS tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=10.10.20.207:22122
# the port of the local storage server
# the default value is 23000
storage_server_port=23000
# the group name of the local storage server
group_name=group1


# if the url / uri including the group name
# set to false when uri like /M00/00/00/xxx
# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
# default value is false
url_have_group_name=true    #设置为true。。。不然之后ngxin访问文件的时候会报错,400
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/usr/local/FastDFS/storage
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/usr/local/FastDFS/storage


[group2]
group_name=group2
storage_server_port=23000
store_path_count=1
store_path0=/usr/local/FastDFS/storage


建立软连接:

ln -s /usr/local/FastDFS/storage/data/ /usr/local/FastDFS/storage/data/M00


nginx.conf配置:



上传文件进行测试:

[jishi@centos7-tmp ~]$ cd /usr/local/bin/

[jishi@centos7-tmp bin]$ sudo -s

[root@centos7-tmp bin]# ./fdfs_upload_file /etc/fdfs/client.conf /home/jishi/wendy.jpg 

group1/M00/00/00/CgoUz1lTaF-AMyMMAAGxlGN_EAs711.jpg

进入目标路径查看:



然后通过地址访问:




DONE...

//todo 权限

参考:http://www.cnblogs.com/radio/p/3799922.html

http://www.linuxdiyf.com/linux/10581.html

原创粉丝点击