FastDFS 5.01+ nginx+ cache 集群安装配置手册

2026/1/13 11:56:35

group_name=group1

storage_server_port=23000 store_path_count=1 store_path0=/fdfs/storage

[group2]

group_name=group2

storage_server_port=23000 store_path_count=1 store_path0=/fdfs/storage

[group3]

group_name=group3

storage_server_port=23000 store_path_count=1 store_path0=/fdfs/storage

? 建立M00至存储目录的符号连接。 [root@storage1 nginx-1.4.7]# ln -s /fdfs/storage/data /fdfs/storage/data/M00 [root@storage1 nginx-1.4.7]# ll /fdfs/storage/data/M00 lrwxrwxrwx. 1 root root 19 3月 26 03:44 /fdfs/storage/data/M00 -> /fdfs/storage/data/ ? 至此,nginx以及FastDFS插件模块设置完成。

3. 运行

? 运行nginx之前,先要把防火墙中对应的端口打开(本例中为8080)。 [root@storage1nginx-1.4.7]# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT [root@storage1nginx-1.4.7]# /etc/init.d/iptables save iptables:将防火墙规则保存到 /etc/sysconfig/iptables:[确定] ? 启动nginx,确认启动是否成功。(查看是否对应端口8080是否开始监听) [root@storage1 nginx-1.4.7]# /usr/local/nginx/sbin/nginx ngx_http_fastdfs_set pid=40638 [root@storage1 nginx-1.4.7]# netstat -unltp | grep nginx tcp 0 0.0.0.0:8080 0.0.0.0:* LISTEN 40639/nginx 也可查看nginx的日志是否启动成功或是否有错误。

13 / 29

[root@storage1 nginx-1.4.7]# cat /usr/local/nginx/logs/error.log ngx_http_fastdfs_process_init pid=40640

[2014-03-26 03:47:17] INFO - local_host_ip_count: 2, 127.0.0.1 172.16.1.203

[2014-03-26 03:47:17] INFO - fastdfs apache / nginx module v1.15, response_mode=proxy, base_path=/tmp,

url_have_group_name=1,

group_count=3,

connect_timeout=2,

network_timeout=30, tracker_server_count=1, if_alias_prefix=, local_host_ip_count=2, need_find_content_type=1,

default_content_type=application/octet-stream,

anti_steal_token=0, token_ttl=0s, anti_steal_secret_key length=0, token_check_fail content_type=, token_check_fail buff length=0, load_fdfs_parameters_from_tracker=1, storage_sync_file_max_delay=86400s, use_storage_id=0, storage server id count=0, flv_support=1, flv_extension=flv

[2014-03-26 03:47:17] INFO - group 1. group_name=group1, storage_server_port=23000, path_count=1, store_path0=/fdfs/storage

[2014-03-26 03:47:17] INFO - group 2. group_name=group2, storage_server_port=23000, path_count=1, store_path0=/fdfs/storage

[2014-03-26 03:47:17] INFO - group 3. group_name=group3, storage_server_port=23000, path_count=1, store_path0=/fdfs/storage

在error.log中没有错误,既启动成功。可以打开浏览器,直接访问http://172.16.1.203:8080,查看是否弹出nginx欢迎页面。

之后依次在172.16.1.204~208上全部安装上nginx并确认运行正常。

? 设置开机自动启动。 [root@storage1 nginx-1.4.7]# vim /etc/rc.d/rc.local

将运行命令行添加进文件:/usr/local/nginx/sbin/nginx

(五) 在tracker上安装nginx

在tracker上安装的nginx主要为了提供http访问的反向代理、负载均衡以及缓存服务。

14 / 29

1. 安装

? 首先将代码包和插件复制到系统的/usr/local/src内(可选),然后使用tar命令解压

[root@trackeropt]# cp nginx-1.4.7.tar.gz /usr/local/src

[root@tracker opt]# cp ngx_cache_purge-2.1.tar.gz /usr/local/src [root@tracker opt]# cp pcre-8.34.tar.gz /usr/local/src [root@tracker opt]# cp zlib-1.2.8.tar.gz /usr/local/src [root@tracker opt]# cd /usr/local/src/ [root@tracker src]# tar zxf nginx-1.4.7.tar.gz

[root@tracker src]# tar zxf ngx_cache_purge-2.1.tar.gz [root@tracker src]# tar zxf pcre-8.34.tar.gz [root@tracker src]# tar zxf zlib-1.2.8.tar.gz [root@tracker src]# cd nginx-1.4.7 [root@tracker nginx-1.4.7]# ll 总用量 592

drwxr-xr-x. 6 1001 1001 4096 3月 26 02:34 auto -rw-r--r--. 1 1001 1001 225213 3月 18 21:17 CHANGES -rw-r--r--. 1 1001 1001 343040 3月 18 21:17 CHANGES.ru drwxr-xr-x. 2 1001 1001 4096 3月 26 02:34 conf -rwxr-xr-x. 1 1001 1001 2369 3月 18 21:17 configure drwxr-xr-x. 3 1001 1001 4096 3月 26 02:34 contrib drwxr-xr-x. 2 1001 1001 4096 3月 26 02:34 html -rw-r--r--. 1 1001 1001 1397 3月 18 21:17 LICENSE drwxr-xr-x. 2 1001 1001 4096 3月 26 02:34 man -rw-r--r--. 1 1001 1001 49 3月 18 21:17 README drwxr-xr-x. 8 1001 1001 4096 3月 26 02:34 src

? 运行./configure进行安装前的设置,主要设置安装路径、nginx cache purge插件模块目

录、pcre库目录、zlib库目录。

如果提示错误,可能缺少依赖的软件包,需先安装依赖包,再次运行./configure

yuminstall gd-devel

./configure --fix=/usr/local/nginx --with-http_image_filter_module --add-module=/home/storage/nginx/tracker_nginx/ngx_cache_purge-2.1/ --with-pcre=/home/storage/nginx/tracker_nginx/pcre-8.34/ --with-zlib=/home/storage/nginx/tracker_nginx/zlib-1.2.8/

15 / 29

? 运行make进行编译,确保编译成功。 [root@storage1 nginx-1.4.7]#make

? 运行make install进行安装。 [root@storage1 nginx-1.4.7]#make install ? 至此nginx以及nginx cache purge插件模块安装完成。

2. 配置

? 编辑/usr/local/nginx/conf配置文件目录下的nginx.conf,设置负载均衡以及缓存。 [root@storage1 nginx-1.4.7]# vim /usr/local/nginx/conf/nginx.conf worker_processes 4; #根据CPU核心数而定 events {

worker_connections 65535; #最大链接数 use epoll;#新版本的Linux可使用epoll加快处理性能 } http { #设置缓存参数

server_names_hash_bucket_size 128; client_header_buffer_size 32k;

large_client_header_buffers 4 32k; client_max_body_size 300m; sendfile on; tcp_nopush on; proxy_redirect off;

proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k;

#设置缓存存储路径、存储方式、分配内存大小、磁盘最大空间、缓存期限 proxy_cache_path

/var/cache/nginx/proxy_cache

levels=1:2

keys_zone=http-cache:500m max_size=10g inactive=30d;

16 / 29


FastDFS 5.01+ nginx+ cache 集群安装配置手册.doc 将本文的Word文档下载到电脑
搜索更多关于: FastDFS 5.01+ nginx+ cache 集群安 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219