1、安装gcc等工具
yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
2、安装libevent
yum -y install libevent
3、安装libfastcommon-master
下载 https://github.com/happyfish100/libfastcommon
下载完成后,将libfastcommon_master.zip上传至服务器。
a.解压tar包:unzip ./libfastcommon_master.zip
b.编译:./make.sh
c.安装:./make.sh install
4、安装 FastDFS
a.解压FastDFS_v5.08.tar.gz
tar -zxvf FastDFS_v5.08.tar.gz
b.执行 ./make.sh
c.执行 ./make.sh install
d.将FastDFS/conf下的文件拷贝至 /etc/fdfs下
cp ./conf/* /etc/fdfs/
5、配置和启动tracker
进入/etc/fdfs目录,查看目录下的文件
修改/tracker.conf
base_path=/home/yuqing/fastdfs 改为: base_path=/home/fastdfs
http.server_port 改为: 80
创建/home/fastdfs
mkdir /home/fastdfs
启动tracker
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
若出现以下错误
/usr/bin/fdfs_trackerd: symbol lookup error: /usr/bin/fdfs_trackerd: undefined symbol: g_current_time
处理方式:
ldd /usr/bin/fdfs_trackerd
ll /usr/local/lib/libfastcommon.so
ll /usr/lib/libfastcommon.so
rm -rf /usr/local/lib/libfastcommon.so.1
ldd /usr/bin/fdfs_trackerd
6、修改和启动storage
group_name=group1 #配置组名
base_path=/home/yuqing/fastdfs 改为: base_path=/home/fastdfs
#store存放文件的位置(store_path)
store_path0=/home/yuqing/fastdfs 改为: store_path0=/home/fdfs_storage
#如果有多个挂载磁盘则定义多个store_path,如下
#store_path1=.....
#store_path2=......
#配置tracker服务器:IP
tracker_server=192.168.234.199:22122
#如果有多个则配置多个tracker
#tracker_server=192.168.101.4:22122
#配置http端口
http.server_port=88
启动storage
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
7、测试
修改client.conf
base_path=/home/yuqing/fastdfs 改为: base_path=/home/fastdfs
tracker_server=192.168.234.199:22122
上传1.jpg 到/opt目录
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /opt/1.jpg