linux 运维:安装+部署+配置
安装:编译安装
部署:涉及到权限问题
配置:见招拆招
运行环境:
Ubuntu 16.04
参考文献https://www.cnblogs.com/chiangchou/p/fastdfs.html
1.下载安装libfastcommon:(/usr/local/)
下载
sudo wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
解压
sudo tar -xzvf V1.0.7.tar.gz
编译安装
cd libfastcommon-1.0.7/
sudo ./make.sh
sudo sh ./make.sh install
创建软链接
libfastcommon.so 安装到了/usr/lib64/libfastcommon.so,但是FastDFS主程序设置的lib目录是/usr/local/lib,所以需要创建软链接
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
2.下载安装FastDFS(/usr/local/)
下载FastDFS
sudo wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
解压编译安装
sudo tar -xzvf V5.05.tar.gz
cd fastdfs-5.05/
sudo ./make.sh
sudo sh ./make.sh install
安装之后提示一下信息:(其实就是一个脚本的内容了,要学会去看里面的信息)
mkdir -p /usr/bin
mkdir -p /etc/fdfs
cp -f fdfs_trackerd /usr/bin
if [ ! -f /etc/fdfs/tracker.conf.sample ]; then cp -f ../conf/tracker.conf /etc/fdfs/tracker.conf.sample; fi
mkdir -p /usr/bin
mkdir -p /etc/fdfs
cp -f fdfs_storaged /usr/bin
if [ ! -f /etc/fdfs/storage.conf.sample ]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf.sample; fi
mkdir -p /usr/bin
mkdir -p /etc/fdfs
mkdir -p /usr/lib64
cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender /usr/bin
if [ 0 -eq 1 ]; then cp -f libfdfsclient.a /usr/lib64; fi
if [ 1 -eq 1 ]; then cp -f libfdfsclient.so /usr/lib64; fi
mkdir -p /usr/include/fastdfs
cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs
if [ ! -f /etc/fdfs/client.conf.sample ]; then cp -f ../conf/client.conf /etc/fdfs/client.conf.sample; fi
要注意其中的fdfs_trackerd fdfs_storaged两个可执行文件的路径!!
默认安装方式安装后的相应文件与目录
1)服务脚本:
/etc/init.d/fdfs_storaged
/etc/init.d/fdfs_tracker
2)配置文件(这三个是作者给的样例配置文件) :
/etc/fdfs/client.conf.sample
/etc/fdfs/storage.conf.sample
/etc/fdfs/tracker.conf.sample
3) 命令工具在 /usr/bin/ 目录下:
fdfs_appender_test
fdfs_appender_test1
fdfs_append_file
fdfs_crc32
fdfs_delete_file
fdfs_download_file
fdfs_file_info
fdfs_monitor
fdfs_storaged
fdfs_test
fdfs_test1
fdfs_trackerd
fdfs_upload_appender
fdfs_upload_file
stop.sh
restart.sh
3.运行脚本fdfs_storaged并修改脚本
root@dss-ThinkPad-T430s:/etc/init.d# ./fdfs_storaged start
./fdfs_storaged: 行 13: /etc/init.d/functions: 没有那个文件或目录
file /usr/local/bin/fdfs_storaged does not exist!
报错了!说没有functions这个文件,从网上查找也没查找到这个文件,于是就从同学那里拷贝了一份到/etc/init.d/目录下:
再次运行:
root@dss-ThinkPad-T430s:/etc/init.d# ./fdfs_storaged start
Starting FastDFS storage server:
root@dss-ThinkPad-T430s:/etc/init.d# [2018-07-05 18:13:42] ERROR - file: process_ctrl.c, line: 189, "/home/yuqing/fastdfs" can't be accessed, error info: No such file or directory
网上查到相同的错误,很多文档是直接创建/home/yuqing/fastdfs这个路径和文件,很显然这个"yuqing"这个东西是不存在的,要修改配置文件改变它就好(存在的问题就是不知道是哪个配置文件里面的)。
可参考:https://blog.csdn.net/xuekunyansukun/article/details/54311955
解决方案:修改vim /etc/fdfs/tracker.conf
vim /etc/fdfs/tracker.conf
把里面的"yuqing"改为自己的home下面的名字即可!
root@dss-ThinkPad-T430s:/etc/init.d# [2018-07-05 19:56:39] ERROR - file: process_ctrl.c, line: 189, "/home/yuqing/fastdfs" can't be accessed, error info: No such file or directory
还是这样的问题,考虑还有其他的配置文件没有改!尝试!
找到,在/usr/local/fastdfs-5.05/conf/storage.conf,里面有"yuqing"的东西就全部改掉!
再次启动:
root@dss-ThinkPad-T430s:/etc/init.d# ./fdfs_storaged start
Starting FastDFS storage server:
root@dss-ThinkPad-T430s:/etc/init.d# ps -ef | grep fdfs_storaged
root 3483 1049 0 20:05 pts/4 00:00:00 /usr/local/bin/fdfs_storaged /usr/local/fastdfs-5.05/conf/storage.conf
root 3499 30388 0 20:06 pts/4 00:00:00 grep --color=auto fdfs_storaged
BINGO!!这样就启动成功了!
4.配置FastDFS跟踪器(Tracker)
注:在参考的这篇文献https://www.cnblogs.com/chiangchou/p/fastdfs.html中,作者直接把东西改了,然后启动之,他所遇到的错并没有告诉大家,如果我就照着做的话,我不知道里面哪里存在的问题,所以最好还是自己来解决问题,以便增强自己处理问题的能力!!好,废话多了点,接着撸!
- 启动Tracker
root@dss-ThinkPad-T430s:/etc/init.d# ./fdfs_trackerd start
[2018-07-05 20:25:49] ERROR - file: shared_func.c, line: 960, open file /etc/init.d/start fail, errno: 2, error info: No such file or directory
[2018-07-05 20:25:49] ERROR - file: process_ctrl.c, line: 167, load conf file "start" fail, ret code: 2
- 修改stop.sh restart.sh stop.sh 这些文件的路径/usr/bin/
- 创建目录:
mkdir /home/dss/trackerd - 修改fdfs_trackerd的配置文件
Tracker 数据和日志目录地址(根目录必须存在,子目录会自动创建)
base_path=/home/dss/trackerd
HTTP 服务端口
http.server_port=80
再次启动!
root@dss-ThinkPad-T430s:/etc/init.d# ./fdfs_storaged start
Starting FastDFS storage server:
root@dss-ThinkPad-T430s:/etc/init.d# ./fdfs_trackerd start
Starting FastDFS tracker server:
dss@dss-ThinkPad-T430s:/etc/fdfs$ ps -ef | grep fdfs
root 3483 1049 0 20:05 pts/4 00:00:00 /usr/local/bin/fdfs_storaged /usr/local/fastdfs-5.05/conf/storage.conf
dss 4270 27513 0 21:03 pts/18 00:00:00 vim fdfs_trackerd
root 5100 1049 0 21:39 pts/4 00:00:00 /usr/local/bin/fdfs_storaged /usr/local/fastdfs-5.05/conf/storage.conf
root 5154 1049 0 21:39 ? 00:00:00 /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
成功启动了storaged 和trackerd!
people people for me , me for people people!!