环境: Centos x86_64 0.205 和 0.206 都为tracker 和 storage
192.168.0.205 storage tracker
192.168.0.206 storage tracker
0.205 和 0.206 安装配置类似, 下面以一台为例
1, 安装依赖包,添加fastDFS运行用户
yum install -y zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip useradd -s /sbin/nologin fastdfs
2,创建数据存储目录
mkdir -p /export/fastdfs/{storage,tracker} [[email protected] src]# ll /export/fastdfs total 0 drwxr-xr-x 2 root root 6 Dec 10 15:18 storage #Storage目录保存运行日志及其data数据 drwxr-xr-x 2 root root 6 Dec 10 15:17 tracker #tracker目录保存运行日志
3,安装libfastcommon
下载最新版本: libfastcommon wget https://github.com/happyfish100/libfastcommon/archive/master.zip unzip master.zip cd libfastcommon-master/ ./make.sh ./make.sh install
4, 安装Fastdfs
wget http://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/FastDFS%20Server%20with%20PHP%20Extension%20Source%20Code%20V5.05/FastDFS_v5.05.tar.gz/download tar zxf FastDFS_v5.05.tar.gz && cd FastDFS ./make.sh ./make.sh install \cp pa conf/*.conf /etc/fdfs/ cd /etc/fdfs/ rm -rf *.sample chown -R fastdfs: /export/fastdfs
5, 配置tracker 和 storage 配置文件, 对应修改
vi storage.conf group_name=group1 base_path=/export/fastdfs/storage store_path0=/export/fastdfs/storage tracker_server=192.168.0.205:22122 tracker_server=192.168.0.206:22122 http.server_port=80 vi tracker.conf base_path=/export/fastdfs/tracker vi mod_fastdfs.conf group_name=group1 base_path=/export/fastdfs/storage store_path0=/export/fastdfs/storage tracker_server=192.168.0.205:22122 tracker_server=192.168.0.206:22122 url_have_group_name = true #是true 不是ture vi client.conf tracker_server=192.168.0.205:22122 tracker_server=192.168.0.206:22122
6,安装nginx和fastdfs-nginx-module模块
wget http://nginx.org/download/nginx-1.8.0.tar.gz http://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz/download tar zxf fastdfs-nginx-module_v1.16.tar.gz && tar zxf nginx-1.8.0.tar.gz #修改模块中对应的路径,要不然模块不能正确安装加载 cd fastdfs-nginx-module/src vi conf #更改如下, 去掉local,并指定lib64(64系统) CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/" CORE_LIBS="$CORE_LIBS -L/usr/lib64 -lfastcommon -lfdfsclient" ulimit -SHn 102400 useradd -s /sbin/nologin www cd nginx-1.8.0 /configure --user=www --group=www --add-module=../fastdfs-nginx-module/src/ --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module make make install
7, 配置nginx
server { listen 80; server_name 192.168.0.205; root /webdata/fastdfs.com; index index.html index.htm; location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.html last; } location /group1/M00 { root /export/fastdfs/storage/data/; ngx_fastdfs_module; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js)$ { # fastcgi_cache cache_one; #nginx.conf 开启cache才行,要不然启动报错 fastcgi_cache_valid 200 10m; fastcgi_cache_valid 304 3m; fastcgi_cache_valid 301 302 1h; fastcgi_cache_valid any 1m; fastcgi_cache_min_uses 1; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_cache_key $host$request_uri; access_log off; } } access_log off; }
8, 206 的配置一样, nginx对应的ip为206, 启动nginx和fastdfs
[[email protected] vhost]# /etc/init.d/fdfs_storaged start Starting FastDFS storage server: [[email protected] vhost]# /etc/init.d/fdfs_trackerd start Starting FastDFS tracker server: [[email protected] vhost]# [[email protected] vhost]# /etc/init.d/nginx -t ngx_http_fastdfs_set pid=8985 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [[email protected] vhost]# /etc/init.d/nginx -s reload ngx_http_fastdfs_set pid=8986 [email protected] vhost]# netstat -npl |grep -E "nginx|fdfs" tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 8972/fdfs_trackerd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7561/nginx tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 8679/fdfs_storaged
9,测试
[[email protected] ~]# fdfs_test /etc/fdfs/client.conf upload test.html This is FastDFS client test program v5.05 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. [2015-06-14 02:46:06] DEBUG - base_path=/tmp, 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=192.168.0.205, port=23000 server 2. group_name=, ip_addr=192.168.0.206, port=23000 group_name=group1, ip_addr=192.168.0.206, port=23000 storage_upload_by_filename group_name=group1, remote_filename=M00/00/00/wKgAzlV8em6Af8qBAAAADxtaRO466.html source ip address: 192.168.0.206 file timestamp=2015-06-14 02:46:06 file size=15 file crc32=458900718 example file url: http://192.168.0.206/group1/M00/00/00/wKgAzlV8em6Af8qBAAAADxtaRO466.html storage_upload_slave_by_filename group_name=group1, remote_filename=M00/00/00/wKgAzlV8em6Af8qBAAAADxtaRO466_big.html source ip address: 192.168.0.206 file timestamp=2015-06-14 02:46:06 file size=15 file crc32=458900718 example file url: http://192.168.0.206/group1/M00/00/00/wKgAzlV8em6Af8qBAAAADxtaRO466_big.html
时间: 2024-10-11 23:18:41