码迷,mamicode.com
首页 > 其他好文 > 详细

搭建fastdfs

时间:2019-10-16 23:40:45      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:storage   结果   bind   创建目录   master   ddr   ima   client   --   

group1的ip 192.168.124.10
group2的ip 192.168.124.51
1.yum -y install pcre pcre- gcc-c++ gcc* zlib zlib-devel openssl openssl-devel gc-devel gd gd-devel git
2.安装libfastcommon
cd /usr/local/src
git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon
./make.sh && ./make.sh install
3.建立软连接
ln -s /usr/lib64/libfastcommon.so /usr/lib/
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/
ln -s /usr/lib64/libfastcommon.so /usr/local/lib64/
ln -s /usr/lib64/libfdfsclient.so /usr/lib/
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/
ln -s /usr/lib64/libfdfsclient.so /usr/locla/lib64/
4.安装fastdfs
cd /usr/local/src
git clone https://github.com/happyfish100/fastdfs.git
cd fastdfs //进入到fastdfs-master目录
./make.sh && ./make.sh install

cp -r /usr/local/src/fastdfs/conf/* /etc/fdfs/
cd /etc/fdfs/
group1的配置
1.vim /etc/fdfs/tracker.conf
bind_addr=192.168.124.10
port=22122
base_path=/data/server/fastdfs
store_lookup=0
store_group=group1
store_server=0
use_storage_id = true
id_type_in_filename = id
2.vim /etc/fdfs/storage_ids.conf
100001 group1 192.168.124.10
100002 group2 192.168.124.51
3.vim /etc/fdfs/client.conf
base_path=/data/server/fastdfs_cli
tracker_server=192.168.124.10:22122
use_storage_id = true
4.vim /etc/fdfs/storage.conf
group_name=group1
bind_addr=192.168.124.10
port=23000
base_path=/data/server/fastdfs_sto
store_path0=/data/server/fastdfs_sto
tracker_server=192.168.124.10:22122
5.mkdir /data/server/fastdfs_cli
mkdir /data/server/fastdfs_sto
mkdir /data/server/fastdfs
6.fdfs_trackerd /etc/fdfs/tracker.conf
fdfs_storaged /etc/fdfs/storage.conf
group2的配置
1.vim /etc/fdfs/storage_ids.conf
100001 group1 192.168.124.10
100002 group2 192.168.124.51
2.vim /etc/fdfs/storage.conf
group_name=group2
bind_addr=192.168.43.15
port=23000
base_path=/data/server/fastdfs_sto
store_path0=/data/server/fastdfs_sto
tracker_server=192.168.124.51:22122
3.创建目录mkdir /data/server/fastdfs_sto
4.启动fdfs_storaged /etc/fdfs/storage.conf

安装nginx
1.cd /usr/local/src
wget https://raw.githubusercontent.com/ww1230258u/server/master/fastdfs-nginx-module_v1.16.tar.gz
tar zxvf fastdfs-nginx-module_v1.16.tar.gz
vim /usr/local/src/fastdfs-nginx-module/src/config

CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/" //修改这条语句,去掉/local
2.cd /usr/local/src
wget https://raw.githubusercontent.com/ww1230258u/server/master/nginx-1.14.2.tar.gz
tar zxf nginx-1.14.2.tar.gz
cd nginx-1.14.2
编译
./configure --prefix=/data/server/nginx --add-module=/usr/local/src/fastdfs-nginx-module/src --with-http_gunzip_module --with-pcre --with-http_image_filter_module --with-http_stub_status_module

make && make install
nginx配置
group1
vim /data/server/nginx/conf/nginx.conf //在server的函数下编录以后语句
location ~ /group1/M00/(\w+)/(\w+)/(.+)_(\d+)x(\d+).(png|jpg|gif) {
root "/data/server/nginx/html/";
ngx_fastdfs_module;
set $iw "$4";
set $ih "$5";
image_filter resize $iw $ih;
image_filter_buffer 2M;
try_files /group1/M00/$1/$2/$3.$6 /404.html;
}
location /group1/M00 {
root "/data/server/nginx/html/";
ngx_fastdfs_module;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
group2
location ~
/group2/M00/(\w+)/(\w+)/(.+)_(\d+)x(\d+).(png|jpg|gif) {
root "/data/server/nginx/html/";
ngx_fastdfs_module;
set $iw "$4";
set $ih "$5";
image_filter resize $iw $ih;
image_filter_buffer 2M;
try_files /group2/M00/$1/$2/$3.$6 /404.html;
}
location /group2/M00 {
root "/data/server/nginx/html/";
ngx_fastdfs_module;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}

/data/server/nginx/sbin/nginx //启动nginx服务

四、配置mod_fastdfs.conf文件
mkdir /data/server/nginx/html/group1/
ln -s /data/server/fastdfs_storage/data /data/server/nginx/html/group1/M00
//注意:“/data/server/fastdfs_storage/data”后面不加“/”

cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
//配置group1

use_storage_id = true
tracker_server=192.168.124.10:22122
url_have_group_name = true
group_name=group1
store_path0=/data/server/fastdfs_sto
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/data/server/fastdfs_sto

//配置group2
vim /etc/fdfs/mod_fastdfs.conf

use_storage_id = true
tracker_server=192.168.124.10:22122
url_have_group_name = true
group_name=group2
store_path0=/data/server/fastdfs_sto
[group2]
group_name=group2
storage_server_port=23000
store_path_count=2
store_path0=/data/server/fastdfs_sto

【安装后结果】
测试图片是否上传

fdfs_upload_file /etc/fdfs/client.conf /etc/fdfs/anti-steal.jpg
group1/M00/00/00/oYYBAFwvZOyALm1UAABdreSfEnY259.jpg

测试图片是否能缩进
192.168.124.10/group1/M00/00/00/oYYBAFwvZOyALm1UAABdreSfEnY259_100x50.jpg

ps:没标注group1和group2的两机都要做

搭建fastdfs

标签:storage   结果   bind   创建目录   master   ddr   ima   client   --   

原文地址:https://blog.51cto.com/14375805/2442978

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!