Linux docker 下运行season/fastdfs
Linux docker 下运行 fastdfs 包括两个组建tracker1 运行trackerdocker run -d --name tracker --net=host docker.io/season/fastdfs:latest sh tracker.sh2 运行storagedocker run -d --name storage --net=host -e TRACKER_IP=*
Linux docker 下运行 fastdfs 包括两个组建 tracker
1 运行tracker
docker run -ti -d --name trakcer -v ~/tracker_data:/fastdfs/tracker/data --net=host season/fastdfs tracker
2 运行 storage
docker run -ti --name storage -v ~/storage_data:/fastdfs/storage/data -v ~/store_path:/fastdfs/store_path --net=host -e TRACKER_SERVER:192.168.1.2:22122 season/fastdfs storage
group1是组名,即storage的组
3 storage 中 更改 把 storage.conf 从 容器中复制出来 tracker_server 改成外网地址 在覆盖到容器中 。
[root@localhost ~]# docker cp storage:/fdfs_conf/storage.conf ~/
[root@localhost ~]# vi ~/storage.conf
[root@localhost ~]# docker cp ~/storage.conf storage:/fdfs_conf/
[root@localhost ~]# docker restart storage
进入查看tracker容器和storage容器的关联
[root@localhost ~]# docker exec -it storage /bin/bash
root@localhost ~:/# cd fdfs_conf
root@localhost ~:/fdfs_conf# fdfs_monitor storage.conf
[2020-07-22 14:10:05] DEBUG - base_path=/fastdfs/storage, 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
server_count=1, server_index=0
tracker server is *.*.*.*:22122
group count: 1
Group 1:
group name = group1
disk total space = 40187 MB
disk free space = 35078 MB
trunk free space = 0 MB
storage server count = 1
active server count = 1
storage server port = 23000
storage HTTP port = 8888
store path count = 1
subdir count per path = 256
current write server index = 0
current trunk file id = 0
Storage 1:
id = *.*.*.*
ip_addr = *.*.*.* ACTIVE
http domain =
version = 4.08
4 如果是外网环境或者阿里云服务器 需要开启23000端口 和22122端口 不然 java代码连接网络不通 会被拒绝
fastdfs 会报错 java.net.ConnectException Connection refused (Connection refused) 或者网络不通
[root@localhost ~]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1150/sshd
tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 17602/fdfs_storaged
tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 17530/fdfs_trackerd
[root@localhost ~]# firewall-cmd --list-ports
8888/tcp 22122/tcp 8801/tcp
[root@localhost ~]# firewall-cmd --zone=public --add-port=23000/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-ports
8888/tcp 22122/tcp 8801/tcp 23000/tcp
[root@localhost ~]#
5 nginx 模块访问 fdfs
https://github.com/happyfish100
yum install git
git clone https://github.com/happyfish100/fastdfs.git
git clone https://github.com/happyfish100/libfastcommon.git
git clone https://github.com/happyfish100/fastdfs-nginx-module.git
下图三个文件都需要下载 下载并且解压
解压nginx
tar -zxvf nginx-1.15.9.tar.gz
目录如下
4 至此准备工作已经OK,接下来就是重点了,如何配置fastdfs以及整合nginx
接着往下看:进入 /libfastcommon 文件夹
执行如下命令:
./make.sh
./make.sh install
接着进入 /fastdfs 文件夹
执行如下命令:
./make.sh
./make.sh install
然后下载并安装 安装nginx所需依赖:
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
进入nginx解压出来的目录
cd nginx-1.15.9
./configure --add-module=/home/soft/fastdfs-nginx-module/src
make&&make install
OK,一切顺利的话 你在/usr/local/ 目录下就可以看到nginx了。
然后将 /home/soft/fastdfs/conf 目录下的所有文件copy到 /etc/fdfs中
cp -r /home/soft//fastdfs/conf/* /etc/fdfs/
将 /home/soft/fastdfs-nginx-module/src 目录中的 mod_fastdfs.conf 复制到/etc/fdfs
/etc/fdfs目录中的所有文件是nginx 整合fastdfs-nginx-module所用到的配置文件
vi /etc/fdfs/storage.conf
修改其中内容为:
base_path=/root/store_path
store_path0=/root/store_path
tracker_server=192.168.1.102:22122
http.server_port=8888 //需要与nginx监听的端口一致
vi /etc/fdfs/tracker.conf
修改其中内容为:
base_path=/root/tracker_data
vi /etc/fdfs/mod_fastdfs.conf
修改其中内容为:
tracker_server=192.168.1.102:22122
store_path0=/root/store_path
url_have_group_name = true //请求路径是否携带组信息
接下来就剩下最后一步了,配置nginx
ngxinx 配置文件
vi /usr/local/nginx/conf/nginx.conf
server {
listen 8888;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
}
然后启动nginx:
cd /usr/local/nginx/sbin
./nginx
//重新加载
./nginx -s reload
//停止
./nginx -s stop
错误问题
出现问题 请查看nginx 下 logs 文件夹的错误日志
ERROR - file: /home/soft/fastdfs-nginx-module/src/common.c, line: 1094, file: ~/store_path/data/00/00/rBHNu18an_qATCFJAALI
g3DZxbQ982.jpg not exist
这个问题是 store_path0 的路劲配置不对 需要坚持
更多推荐
所有评论(0)