安装Storage Server -192.168.127.12
配置及启动存储服务(Storage Server)
引用上例中安装libevent 和 fastdfs步骤
修改storage.conf配置
vim /usr/local/fastdfs/conf/storage.conf
# the name of the group this storage server belongs to
group_name=group1
# the name of the group this storage server belongs to
# the storage server port #the storage server port
port=23000
# the base path to store data and log files #日志目录
base_path=/home/yuqing/fastdfs -> /home/fastdfs/storage
# store_path#, based 0, if store_path0 not exists, it's value is base_path #data数据存储目录
# the paths must be exist
store_path0=/home/fastdfs/storage
# tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
tracker_server=192.168.209.121:22122 ->192.168.127.11:22122
#unix group name to run this program,
#not set (empty) means run by the group of current user
run_by_group= -> fastdfs #这儿一定填写执行的用户名,不然会启动报错,测试环境填写的 root
#unix username to run this program,
#not set (empty) means run by current user
run_by_user= -> fastdfs #这儿一定填写执行的用户名,不然会启动报错,测试环境填写的 root
编辑fdfs_storaged启动脚本
vim /etc/init.d/fdfs_storaged
# 使用 Vi 命令替换
%s/usr\/local/usr\/local\/fastdfs/g
%s/etc\/fdfs/usr\/local\/fastdfs\/conf/g
#增加x权限
chmod a+x /etc/init.d/fdfs_storaged
#启动storage
/etc/init.d/fdfs_storaged start
service fdfs_storaged restart
#接下来会出现很多mkdir data path,这是系统在创建数据目录
data path: /home/fastdfs/storage/data, mkdir sub dir...
mkdir data path: 00 ...
mkdir data path: 01 ...
mkdir data path: 02 ...
mkdir data path: 03 ...
.......................
data path: /home/fastdfs/storage/data, mkdir sub dir done.
# base_path 附目录说明:
storage server目录及文件结构:
${base_path}
|__data
| |__storage_stat.dat:本地存储信息
| |__sync
| |__ binlog.000
| |__ binlog.index
|__logs
|__storaged.log:storage server日志文件
#启动成功,加入开机启动
vim /etc/rc.d/rc.local
service fdfs_storaged restart
Storage安装fastdfs-nginx-module模块,通过url访问
#创建相关用户和目录创建www用户和组
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
#创建nginx日志目录
mkdir -p /home/www/logs
chmod a+w /home/www/logs
chown -R www:www /home/www/logs
#安装nginx必需的库:gcc zlib-devel openssl-devel pcre
yum -y install gcc gcc-c++ zlib-devel openssl-devel;
#手动安装pcre库,为了使nginx支持HTTP Rewrite 模块
tar -zxvf pcre-8.20.tar.gz
cd pcre-8.20/
./configure
make && make install
#安装基本nginx
tar -zxvf nginx-1.1.19.tar.gz
cd nginx-1.1.19/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module
make && make install
#--with-http_stub_status_module 用来监控nginx的当前状态
安装fastdfs-nginx-module插件
#worksrc;
wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz;
tar -zxvf fastdfs-nginx-module_v1.15.tar.gz;
#修改插件配置文件
vim /usr/local/src/fastdfs-nginx-module/src/config
ngx_addon_name=ngx_http_fastdfs_module
HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
CORE_INCS="$CORE_INCS /usr/local/fastdfs/include/fastdfs /usr/local/fastdfs/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/local/fastdfs/lib -lfastcommon -lfdfsclient"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/usr/local/fastdfs/conf/mod_fastdfs.conf\"'"
#复制mod_fastdfs.conf到/usr/local/fastdfs/conf/目录下
cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /usr/local/fastdfs/conf/
上面编译时使用的动态链接库( 这块可以省略)
#将/usr/local/fastdfs/lib 加入系统文件/etc/ld.so.conf中
vim /etc/ld.so.conf
/usr/local/fastdfs/lib
#更新库文件缓存ld.so.cache
/sbin/ldconfig
