引用https://www.cnblogs.com/zzw-zyba/p/10155781.html 非root安装部分
1、解包
[bdc@svr001 setup]$ tar -xvf libfastcommon-1.0.36.tar.gz
[bdc@svr001 setup]$ cd libfastcommon-1.0.36
2、分析一下libfastcommon的make.sh脚本,发现其实前面的大段都是在判断是什么操作系统、32位还是64位、库路径等相关参数,真正的自身操作:
cd src
cp Makefile.in Makefile
sed_replace "s/\\\$(CFLAGS)/$CFLAGS/g" Makefile
sed_replace "s/\\\$(LIBS)/$LIBS/g" Makefile
sed_replace "s/\\\$(LIB_VERSION)/$LIB_VERSION/g" Makefile
make $1 $2 $3
只是简单的将Makefile.in文件替换几个参数后复制成 Makefile 文件,然后就make了,竟然没有涉及编译路径。
我们再分析一下它的Makefile文件:
install:
mkdir -p $(DESTDIR)/usr/$(LIB_VERSION)
mkdir -p $(DESTDIR)/usr/lib
install -m 755 $(SHARED_LIBS) $(DESTDIR)/usr/$(LIB_VERSION)
install -m 755 $(SHARED_LIBS) $(DESTDIR)/usr/lib
mkdir -p $(DESTDIR)/usr/include/fastcommon
install -m 644 $(HEADER_FILES) $(DESTDIR)/usr/include/fastcommon
make 带install参数时才传入路径,其中 $(DESTDIR)就是可以自定义路径了。
3、 安装 lib
[bdc@svr001 zzw_temp]$ pwd
/opt/aspire/product/bdc/zzw_temp
[bdc@svr001 zzw_temp]$ ll
总用量 4
drwxrwxr-x 3 bdc bdc 4096 11月 7 17:45 setup
[bdc@svr001 zzw_temp]$ export DESTDIR=/opt/aspire/product/bdc/zzw_temp/libfastcommon
[bdc@svr001 zzw_temp]$ echo $DESTDIR
/opt/aspire/product/bdc/zzw_temp/libfastcommon
[bdc@svr001 setup]$ cd setup/libfastcommon-1.0.36
[bdc@svr001 libfastcommon-1.0.36]$ ./make.sh # 注意是make.sh ,不是make, 这与一般编译不同 !!
[bdc@svr001 libfastcommon-1.0.36]$ ./make.sh install
[bdc@svr001 libfastcommon-1.0.36]$ cd /opt/aspire/product/bdc/zzw_temp/libfastcommon
[bdc@svr001 libfastcommon]$ ll
总用量 4
drwxrwxr-x 5 bdc bdc 4096 11月 7 18:09 usr
安装成功!
4、 环境变量中加上库路径
export LD_LIBRARY_PATH=/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/libfastcommon/usr/lib64:$LD_LIBRARY_PATH
注意使环境变量生效。
也可以将libfastcommon.so复制到/usr/lib下: cp /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/libfastcommon/usr/lib64/libfastcommon.so /usr/lib
5、安装fastdfs-5.11.tar.gz 同样的道理
分析一下fastdfs的make.sh文件
ENABLE_STATIC_LIB=0
ENABLE_SHARED_LIB=1
TARGET_PREFIX=$DESTDIR/usr
TARGET_CONF_PATH=$DESTDIR/etc/fdfs
TARGET_INIT_PATH=$DESTDIR/etc/init.d
所以安装时
[bdc@svr001 zzw_temp]$ export DESTDIR=/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa # /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa 为安装目录
[bdc@svr001 ]$ ./make.sh # 注意是make.sh ,不是make !!
[bdc@svr001 ]$ ./make.sh install
二、安装后后目录结构
安装后的目录只用etc与usr两个文件夹。
[dicmp_zzw@linux245 fastdfsaaa]$ tree .
.
|-- etc
| |-- fdfs
| | |-- client.conf.sample
| | |-- storage.conf.sample
| | |-- storage_ids.conf.sample
| | `-- tracker.conf.sample
| `-- init.d
| |-- fdfs_storaged
| `-- fdfs_trackerd
`-- 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
| |-- restart.sh
| `-- stop.sh
|-- include
| `-- fastdfs
| |-- client_func.h
| |-- client_global.h
| |-- fdfs_client.h
| |-- fdfs_define.h
| |-- fdfs_global.h
| |-- fdfs_http_shared.h
| |-- fdfs_shared_func.h
| |-- mime_file_parser.h
| |-- storage_client1.h
| |-- storage_client.h
| |-- tracker_client.h
| |-- tracker_proto.h
| |-- tracker_types.h
| `-- trunk_shared.h
|-- lib
| `-- libfdfsclient.so
`-- lib64
`-- libfdfsclient.so
三、配置
1、修改/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/etc/init.d/fdfs_storaged 和 fdfs_trackerd 两个文件
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
DESTDIR=/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa #配置为安装路径
PRG=$DESTDIR/usr/bin/fdfs_storaged #加上变量
CONF=$DESTDIR/etc/fdfs/storage.conf #加上变量
四、修改配置文件-----这块抄的root修改文件,自己做相应调整吧
1. 修改tracker配置
# mkdir /data/fdfs/Tracker -p
# cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
# vi /etc/fdfs/tracker.conf
修改配置参数如下:
base_path=/data/fdfs/Tracker
http.server_port=9090
启动服务
service fdfs_trackerd start
2. 修改client配置
# mkdir /data/fdfs/Client –p
# cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
# vi /etc/fdfs/ client.conf
修改配置参数如下:
base_path=/data/fdfs/Client
tracker_server=10.1.4.52:22122
3. 修改Storage配置
# mkdir /data/fdfs/Storage –p
# cp /etc/fdfs/storage.conf.sample /etc/fdfs/ storage.conf
# vi /etc/fdfs/ storage.conf
修改配置参数如下:
base_path=/data/fdfs/Storage
tracker_server=10.1.4.52:22122
store_path0=/data/fdfs/Storage
五、启动
1.启动tracker
进入/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa目录
cd /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa
这里不能用root安装时使用的service去启动fastdfs
下面是启动tracked的全路径,下面所有加粗部分,根据自己安装目录调整路径,这里给的都是绝对路径;执行没报错基本tracker就启动成功了
/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/usr/bin/fdfs_trackerd /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/etc/fdfs/tracker.conf
vim /etc/rc.local
/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/usr/bin/fdfs_trackerd /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/etc/fdfs/tracker.conf
3.启动storage
/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/usr/bin/fdfs_storaged /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/etc/fdfs/storage.conf
设置开机启动
vim /etc/rc.local
/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/usr/bin/fdfs_storaged /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/etc/fdfs/storage.conf
六、状态检查
# /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/usr/bin/fdfs_monitor /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/etc/fdfs/client.conf
七、测试一下
#cd #返回家目录
# vi test.txt
内容为hello fastdfs 保存
# /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/usr/bin/fdfs_test /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa/etc/fdfs/client.conf upload /opt/aspire/product/dicmp_zzw/test.txt
完毕