CleverCode发现fastdfs是一个很好的开源的轻量级分布式文件系统。
本次安装资源包下载:http://download.csdn.net/download/clevercode/9607300。
1 安装fastdfs
安装之前确认先安装了《Linux中必备常用支持库的安装(CentOS-6.5)》:http://blog.csdn.net/clevercode/article/details/45438401。
# cd /usr/local/src/fastdfs
# tar xzf FastDFS_v4.06.tar.gz
# cd FastDFS
# vi make.sh
去掉注释
WITH_LINUX_SERVICE=1
# ./make.sh
# ./make.sh install
2 配置tracker
2.1 创建与配置tracker数据目录
# mkdir -p /data0/fastdfs/tracker
# vi /etc/fdfs/tracker.conf
base_path=/data0/fastdfs/tracker
2.2 启动tracker
# service fdfs_trackerd start
2.3 查看启动
# netstat -anp | grep 22122
3 配置storage
3.1 创建与配置storage目录
# mkdir -p /data0/fastdfs/storage/storage0
# vi /etc/fdfs/storage.conf
http.server_port=80
group_name=group1
base_path=/data0/fastdfs
store_path0=/data0/fastdfs/storage/storage0
tracker_server=192.168.101.130:22122
3.2 启动storage
# service fdfs_storaged start
3.3 查看启动
# netstat -anp | grep 23000
4 安装nginx
4.1 安装pcre-8.12.tar.gz
# cd /usr/local/src/nginx
# tar zxvf pcre-8.12.tar.gz
# cd pcre-8.12
# ./configure
# make && make install
4.2 解压fastdfs-nginx-module_v1.15.tar.gz
# cd /usr/local/src/nginx
# tar zxvf fastdfs-nginx-module_v1.15.tar.gz
4.3 安装nginx
# groupadd www #添加www组
# useradd -g www www -s /bin/false #创建nginx运行账户www并加入到www组,不允许www用户直接登录系统
创建安装目录与日志目录
a) 安装目录
# mkdir /usr/local/nginx
b) 日志目录
# mkdir /data0/logs/nginx
# chown www:www /data0/logs/nginx -R
# cd /usr/local/src/nginx
# tar zxvf nginx-1.5.0.tar.gz
# cd nginx-1.5.0
4) 配置。通常将软件安装在/usr/local/目录下。将fastdfs-nginx-module/src模块添加进来
# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --add-module=/usr/local/src/nginx/fastdfs-nginx-module/src
5)编译安装
# make && make install
6) 检查是否安装成功
# cd /usr/local/nginx/sbin
# ./nginx -t
4.4 配置mod_fastdfs.conf
# cp /usr/local/src/nginx/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
# vi /etc/fdfs/mod_fastdfs.conf
base_path=/data0/fastdfs
tracker_server=192.168.101.130:22122
group_name=group1
url_have_group_name = true
store_path0=/data0/fastdfs/storage/storage0
4.5 配置nginx.conf
# vi /usr/local/nginx/conf/nginx.conf
location /group1/M00 {
root /data0/fastdfs/storage/storage0/data;
ngx_fastdfs_module;
}
4.6 启动nginx
# service iptables stop
# cd /usr/local/nginx/sbin/
# ./nginx
5 测试
6.1 配置client.conf
# vi /etc/fdfs/client.conf
base_path=/tmp
tracker_server=192.168.101.130:22122
http.tracker_server_port=80
6.2 上传txt
/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload test.txt
6.3 上传图片
# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload clevercode.png