单台服务器 fastdfsv5.08的安装,配置

在新的服务器上安装了FastDFS_v5.08,现将安装配置过程记录下,供大家参考,在访问量不大情况下,将tracker和storage都部署在同一台服务器上,后期根据业务需要进行扩展

软件列表

FastDFS_v5.08.tar.gz、fastdfs-nginx-module_v1.16.tar.gz、libfastcommon-master.zip、nginx-1.13.1.tar.gz

这些软件都是放在/usr/local下

1.安装gcc

安装FastDFS需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc:yum install gcc-c++

1.1安装libevent

yum -y install libevent

2.libfastcommon 安装

unzip libfastcommon-master.zip

cd libfastcommon-master

./make

./make install

3.安装FastDFS

1)tar -zxvf FastDFS_v5.08.tar.gz

cd FastDFS    

./make.sh

./make.sh install

cd /etc/fdfs

2)配置文件设置

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

vim tracker.conf


disabled=false
bind_addr=
port=22122
connect_timeout=30
network_timeout=60
base_path=/usr/local/fastdfs
max_connections=256
accept_threads=1
work_threads=4
store_lookup=2
store_group=group2
store_server=0
store_path=0
download_server=0
reserved_storage_space = 10%
log_level=info
run_by_group=
run_by_user=
allow_hosts=*
sync_log_buff_interval = 10
check_active_interval = 120
thread_stack_size = 64KB
storage_ip_changed_auto_adjust = true
storage_sync_file_max_delay = 86400
storage_sync_file_max_time = 300
use_trunk_file = false 
slot_min_size = 256
slot_max_size = 16MB
trunk_file_size = 64MB
trunk_create_file_advance = false
trunk_create_file_time_base = 02:00
trunk_create_file_interval = 86400
trunk_create_file_space_threshold = 20G
trunk_init_check_occupying = false
trunk_init_reload_from_binlog = false
trunk_compress_binlog_min_interval = 0
use_storage_id = false
storage_ids_filename = storage_ids.conf
id_type_in_filename = ip
store_slave_file_use_link = false
rotate_error_log = false
error_log_rotate_time=00:00
rotate_error_log_size = 0
log_file_keep_days = 0
use_connection_pool = false
connection_pool_max_idle_time = 3600
http.server_port=80
http.check_alive_interval=30
http.check_alive_type=tcp
http.check_alive_uri=/status.html

vim storage.conf

disabled=false
group_name=group1
bind_addr=
client_bind=true
port=23000
connect_timeout=30
network_timeout=60
heart_beat_interval=30
stat_report_interval=60
base_path=/usr/local/fastdfs
max_connections=256
buff_size = 256KB
accept_threads=1
work_threads=4
disk_rw_separated = true
disk_reader_threads = 1
disk_writer_threads = 1
sync_wait_msec=50
sync_interval=0
sync_start_time=00:00
sync_end_time=23:59
write_mark_file_freq=500
store_path_count=1

store_path0=/usr/local/fastdfs/storage
#store_path1=/home/yuqing/fastdfs2
subdir_count_per_path=256

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=47.XX.XX.206:22122
log_level=info
run_by_group=


run_by_user=


allow_hosts=*
file_distribute_path_mode=0
fsync_after_written_bytes=0
sync_log_buff_interval=10
sync_binlog_buff_interval=10


sync_stat_file_interval=300
thread_stack_size=512KB
upload_priority=10
if_alias_prefix=
check_file_duplicate=0
file_signature_method=hash
key_namespace=FastDFS
keep_alive=0
use_access_log = false
rotate_access_log = false


access_log_rotate_time=00:00


rotate_error_log = false


error_log_rotate_time=00:00


rotate_access_log_size = 0
rotate_error_log_size = 0
log_file_keep_days = 0
file_sync_skip_invalid_record=false
use_connection_pool = false
connection_pool_max_idle_time = 3600
http.domain_name=
http.server_port=80

 

启动tracker

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

启动 storage

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

4.测试图片上传

vim client.conf


connect_timeout=30


network_timeout=60


base_path=/usr/local/fastdfs

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=47.xx.xx.206:22122
log_level=info
use_connection_pool = false
connection_pool_max_idle_time = 3600
load_fdfs_parameters_from_tracker=false
use_storage_id = false
storage_ids_filename = storage_ids.conf
http.tracker_server_port=80

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/test.jpg 

/usr/bin/fdfs_test: Symbol `g_log_context' has different size in shared object, consider re-linking
This is FastDFS client test program v5.08

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/ 
for more detail.

[2017-06-20 21:37:04] DEBUG - base_path=/home/fastdfs, 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

tracker_query_storage_store_list_without_group: 
        server 1. group_name=, ip_addr=47.XX.XX.206, port=23000

group_name=group1, ip_addr=47.XX.XX.206, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/rBoSSFlJJQCAFGJgAAVmPvrilNY026.jpg
source ip address: 172.26.18.72
file timestamp=2017-06-20 21:37:04
file size=353854
file crc32=4209153238
example file url: http://47.XX.XX.206/group1/M00/00/00/rBoSSFlJJQCAFGJgAAVmPvrilNY026.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/rBoSSFlJJQCAFGJgAAVmPvrilNY026_big.jpg
source ip address: 172.26.18.72
file timestamp=2017-06-20 21:37:04
file size=353854
file crc32=4209153238
example file url: http://47.XX.XX.206/group1/M00/00/00/rBoSSFlJJQCAFGJgAAVmPvrilNY026_big.jpg

如上面所示,说明部署的问没有问题。但是在这个地址

http://47.XX.XX.206/group1/M00/00/00/rBoSSFlJJQCAFGJgAAVmPvrilNY026_big.jpg 并不能直接在浏览器直接访问。(会报错404)需要nginx模块

5.安装nginx和nginx-module

5.1安装nginx环境

PCRE

         PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。

yum install -y pcre pcre-devel

注:pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库。

zlib

         zlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip,所以需要在linux上安装zlib库。

yum install -y zlib zlib-devel

openssl

         OpenSSL 是一个强大的安全tao接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。

         nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。

yum install -y openssl openssl-devel

准备nginx和nginx-module安装

tar -zxvf nginx-1.13.1.tar.gz

tar -zxvf fastdfs-nginx-module_v1.16.tar.gz

mkdir nginx

修改nginx-module配置文件

cd fastdfs-nginx-module/src

vim conf

CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"

删除"local"改为

CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

vim mod_fastdfs.conf 

url_have_group_name=false 改为true

store_path0=/home/fastdfs

cp mod_fastdfs.conf /etc/fdfs/

安装nginx

cd nginx-1.13.1

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

make

make.install

5.2修改配置文件

vim /usr/local/nginx/conf/nginx.conf


user  root;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;

        server_name  47.XX.XX.206;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {

        root html;

        index index.html index.htm;

        }

        location ~/group[0-9]/M00 {
                ngx_fastdfs_module;
        }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
       
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

 
    }

 

}

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

 vim /etc/fdfs/mod_fastdfs.conf


connect_timeout=2


network_timeout=30
base_path=/usr/local/logs/fastdfs-nginx-module/data-and-log
load_fdfs_parameters_from_tracker=true


storage_sync_file_max_delay = 86400
use_storage_id = false
storage_ids_filename = storage_ids.conf

tracker_server=47.xx.xx.206:22122
storage_server_port=23000
group_name=group1
url_have_group_name = true
store_path_count=1
store_path0=/usr/local/fastdfs/storage
#store_path1=/home/yuqing/fastdfs1
log_level=info


log_filename=


response_mode=proxy
if_alias_prefix=
flv_support = true
flv_extension = flv
group_count = 0

 

5.3检查nginx配置文件是否正确

/usr/local/nginx/sbin/nginx -t

5.4启动nginx

/usr/local/nginx/sbin/nginx

/usr/local/nginx/sbin/nginx/ -s reload 重新加载配置文件

/usr/local/nginx/sbin/nginx/ -s reopen 重新启动nginx

/usr/local/nginx/sbin/nginx/ -s stop 停止nginx

 

Nginx启动错误:error while loading shared libraries: libpcre.so.1

解决办法:

1、首先确认已经安装好pcre 软件(nginx 依赖该软件)

2、创建软连接

对于/lib/* 32位系统来说:


#查看lib库
    
#ls /lib/ |grep pcre
    
libpcre.so.0
    
libpcre.so.0.0.1
    
#添加软连接 
# ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1
 

ps: 也有可能 pcre lib文件在目录:/usr/local/lib/

对于/lib64/* 64位系统来说:

#查看lib库

#ls /lib64/ |grep pcre

libpcre.so.0

libpcre.so.0.0.1
# ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1

ps: 也有可能 pcre lib文件在目录:/usr/local/lib64/。

转载于:https://my.oschina.net/u/2270256/blog/994018

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值