标签:
先说环境:
win7旗舰版,配CRT连接虚拟机,虚拟机用的vmware Player,安装的CentOS6.4版本。
1.添加用户
useradd fastdfs
这步可以不做,后面的操作用root账号。
2.创建数据存储目录
mkdir -p /export/fastdfs/{strage,tracker} [root@localhost src]# ll /export/fastdfs
3.安装libevent
#卸载自带的libevent yum remove libevent* wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz tar -zxvf libevent-2.0.19-stable.tar.gz cd libevent-2.0.19-stable ./configure --prefix=/usr/local/libevent make && make install echo "/usr/local/libevent/lib/ " >> /etc/ld.so.conf #加入动态链接库 ldconfig #如果在make install 的时候报错: error: openssl/ssl.h: No such file or directory #执行下列命令即可 yum install openssl-devel
4.安装libfastcommon 在FastdfsV5.0X,貌似这个玩意还有版本需求(libfastcommon_v1.05及以下版本不支持FastDFS_v5.04)
wget https://github.com/happyfish100/libfastcommon/archive/master.zip unzip master.zip cd libfastcommon-master/ ./make.sh ./make.sh install
5.安装fastdfs (这段主要是路径替换,可以放在gedit里面做,方便)
#我下载的版本是fastdfs-5.05.tar.gz,也可以通过下面命令下载,通过CRT上传以后,进行解压安装,上传要安装rz。
tar zxf FastDFS_v5.05.tar.gz
cd FastDFS
#修改make.sh,将默认安装位置/etc/fdfs 修改为/usr/local/fastdfs 下面的替换可以在 gedit里面做,
%s/\/etc\/fdfs/\/usr\/local\/fastdfs\/conf/g #修改prefix为/usr/local/fastdfs sed -i ‘s:TARGET_PREFIX=.*:TARGET_PREFIX=/usr/local/fastdfs:g‘ make.sh #将TARGET_CONF_PATH=/etc/fdfs 修改为 /usr/local/fastdfs/conf sed -i ‘s:TARGET_CONF_PATH=.*:TARGET_CONF_PATH=/usr/local/fastdfs/conf:g‘ make.sh ./make.sh #或许有人看到别的教程有C_INCLUDE_PATH这么一个参数,是因为他们做的软连接到/usr/lib64下,而我是直接加的动态链接库 ./make.sh install #修改fastdfs的启动文件 vim /etc/init.d/fdfs_trackerd %s/usr\/local/usr\/local\/fastdfs/g %s/etc\/fdfs/usr\/local\/fastdfs\/conf/g vim /etc/init.d/fdfs_storaged %s/usr\/local/usr\/local\/fastdfs/g %s/etc\/fdfs/usr\/local\/fastdfs\/conf/g
6. tracker服务器配置,tracker.conf文件如果没有,可以把tracker.conf.simple文件直接改名字过来用。
1.tracker配置 修改以下地方,其他用默认值
#数据和日志的存放路径
base_path=/export/fastdfs/tracker/
2.启动服务
/etc/init.d/fdfs_trackerd start
3.查看启动状态
[root@localhost conf]# netstat -ant |grep 22122 Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN
4.storage配置文件 修改以下3个地方,其他用默认值。storage.conf文件如果没有,可以把storage.conf.simple文件直接改名字过来用。
# the base path to store data and log files base_path=/export/fastdfs/storage
# store_path#, based 0, if store_path0 not exists, it‘s value is base_path # the paths must be exist store_path0=/export/fastdfs/storage
func:tracker_server 的列表 要写端口号 tracker_server=192.168.116.134:22122
5.启动storage
/etc/init.d/fdfs_storaged start
6.查看状态
[root@localhost data]# netstat -ant |grep 23000 Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN
7.client.conf 文件修改
# the base path to store log files
base_path=/export/fastdfs/log
# 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.116.134:22122
8.测试上传
在根目录下执行
/usr/local/fastfds/bin/fdfs_test /usr/local/fastfds/conf/client.conf upload a.html
测试完成后应该能看到文件路径信息。
成功!
参考http://www.99ya.net/376.html。
标签:
原文地址:http://www.cnblogs.com/brantshi/p/4441000.html