sudo chmod 777 /usr/local/fastdfs/storage/data/data/00/00
一:安装fastdfs依赖包
sudo chmod 777 /usr/local/src/
// 切换到/usr/local/src/目录
[root@localhost ~]# cd /usr/local/src/
// 下载libfastcommon-V1.0.38.tar.gz
[root@localhost src]# wget https://github.com/happyfish100/libfastcommon/archive/V1.0.38.tar.gz
// 解压缩libfastcommon-V1.0.38.tar.gz
[root@localhost src]# tar -zxvf V1.0.38.tar.gz
// 进入到解压目录中
[root@localhost src]# cd libfastcommon-1.0.38/
// 执行编译
[root@localhost libfastcommon-1.0.38]# ./make.sh
// 执行安装
[root@localhost libfastcommon-1.0.38]# sudo ./make.sh install
1.1 报错解决
//安装gcc
sudo apt-get install gcc
//安装make
sudo apt-get update
sudo apt-get install make
二:安装fastdfs
// 切换到/usr/local/src/目录
[root@localhost ~]# cd /usr/local/src/
// 下载fastdfs-5.11.tar.gz
[root@localhost src]# wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz
// 解压缩fastdfs-5.11.tar.gz
[root@localhost src]# tar -zxvf V5.11.tar.gz
// 进入到解压目录中
[root@localhost src]# cd fastdfs-5.11/
// 执行编译
[root@localhost fastdfs-5.11]# ./make.sh
// 执行安装
[root@localhost fastdfs-5.11]# sudo ./make.sh install
2.1// 复制配置样例
[root@localhost fastdfs-5.11]# sudo cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
// 创建tracker数据存放目录
[root@localhost fastdfs-5.11]# sudo mkdir -p /usr/local/fastdfs/tracker
// 修改/etc/fdfs/tracker.conf配置文件
[root@localhost fastdfs-5.11]# sudo vim /etc/fdfs/tracker.conf
// 修改内容:
base_path=/usr/local/fastdfs/tracker
三:修改tracker
// 复制客户端配置样例
[root@localhost fastdfs-5.11]# sudo cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
// 创建tracker数据存放目录
[root@localhost fastdfs-5.11]# sudo mkdir -p /usr/local/fastdfs/tracker
// 修改/etc/fdfs/client.conf配置文件
[root@localhost fastdfs-5.11]#sudo vim /etc/fdfs/client.conf
// 修改内容:
base_path=/usr/local/fastdfs/tracker
tracker_server=100.0.0.5:22122
四:配置存储服务器storage
// 复制配置样例
[root@localhost fastdfs-5.11]# sudo cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
// 创建storage数据存放目录
[root@localhost fastdfs-5.11]# sudo mkdir -p /usr/local/fastdfs/storage/data
// 修改/etc/fdfs/storage.conf配置文件
[root@localhost fastdfs-5.11]#sudo vim /etc/fdfs/storage.conf
// 修改内容:
base_path=/usr/local/fastdfs/storage
store_path0=/usr/local/fastdfs/storage/data
// 前面配置的tracker服务器监听的地址及端口号
tracker_server=100.0.0.5:22122
五:启动,停止tracker和storage
sudo fdfs_trackerd /etc/fdfs/tracker.conf start
sudo fdfs_trackerd /etc/fdfs/tracker.conf stop
sudo fdfs_storaged /etc/fdfs/storage.conf start
sudo fdfs_storaged /etc/fdfs/storage.conf stop
使用 ps aux | grep fdfs 查看是否启动成功。
六:错误:
6.1 tracker,storage启动失败
sudo cat /usr/local/fastdfs/tracker/logs/trackerd.log
解决:sudo vim /etc/fdfs/tracker.conf
thread_stack_size = 64KB 修改为 thread_stack_size = 128KB
sudo cat /data/fastdfs/storage/logs
问题待发现
6.2 process_ctrl.c, line: 288, “/opt/fastdfs/tracker“ can‘t be accessed, error info: No such file or dir
解决:mkdir -p /usr/local/fastdfs/tracker
七:测试上传
fdfs_upload_file /etc/fdfs/client.conf 要上传的文件
八:所有存储节点都启动之后,可以在任一存储节点上使用如下命令查看集群的状态信息:
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf
八 nginx安装
// 切换到/usr/local/src/目录
[root@localhost ~]# cd /usr/local/src/
// 下载nginx-1.16.1.tar.gz
[root@localhost src]# wget wget http://nginx.org/download/nginx-1.16.1.tar.gz
// 下载fastdfs-nginx-module-1.20.tar.gz
[root@localhost src]# wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz
// 解压缩nginx-1.16.1.tar.gz
[root@localhost src]# tar -zxvf nginx-1.16.1.tar.gz
// 解压缩fastdfs-nginx-module-1.20.tar.gz
[root@localhost src]# tar -zxvf V1.20.tar.gz
// 进入nginx解压目录
[root@localhost src]# cd nginx-1.16.1
// 预安装配置
./configure --prefix=/usr/local/nginx/ --add-module=/usr/local/src/fastdfs-nginx-module-1.20/src/
// 预编译
make
// 安装
make install
8.1 错误解决 make: *** No targets specified and no makefile found. Stop.
8.1.1 sudo apt-get install gcc(预处理、编译、连接、汇编)
8.1.2 sudo apt-get install zlib1g zlib1g-dev (对数据进行解压缩,用于通信)
8.1.3 sudo apt-get install libpcre3 libpcre3-dev(支持解析正则表达式)
8.1.4 OpenSSL的安装库和源代码需要分开安装
sudo apt-get install openssl
sudo apt-get install libssl-dev
再进行 ./configure --prefix=/usr/local/nginx/ --add-module=/usr/local/src/fastdfs-nginx-module-1.20/src/
make
8.2 报错 fatal error: common_define.h: No such file or directory
解决:修改 /usr.local/src/fastdfs-nginx-module-1.20/src/config
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
再进行 ./configure --prefix=/usr/local/nginx/ --add-module=/usr/local/src/fastdfs-nginx-module-1.20/src/
make
sudo make install
8.3 配置nginx
// 将fastdfs-nginx-module-1.20/src中的mod_fastdfs.conf拷贝到/etc/fdfs
[root@localhost logs]# cp /usr/local/src/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
// 修改 /etc/fdfs/mod_fastdfs.conf
vim /etc/fdfs/mod_fastdfs.conf
// 修改内容:
connect_timeout=10
tracker_server=100.0.0.5:22122 (云服务器用公网ip)
url_have_group_name=true
store_path0=/usr/local/fastdfs/storage/data
// 拷贝文件
[root@localhost nginx]# sudo cp /usr/local/src/fastdfs-5.11/conf/http.conf /etc/fdfs/http.conf
[root@localhost nginx]# sudo cp /usr/local/src/fastdfs-5.11/conf/mime.types /etc/fdfs/mime.types
// 修改 nginx.conf配置
[root@localhost nginx]# vim /usr/local/nginx/conf/nginx.conf
// 修改如下内容:
server {
listen 8098;
server_name localhost;
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
// 启动nginx
sudo /usr/local/nginx/sbin/nginx
查看:http://100.0.0.5:8098/group1/M00/00/00/ZAAABWNp22OATZarAAMLSrOjBN8530.png
http://100.0.0.5:8098/group1/M00/00/00/ZAAABWNp0bWAZCPWAAAAAAAAAAA841.txt