1. 程式人生 > >zzw原創_非root安裝fastDFS

zzw原創_非root安裝fastDFS

zzw原創_非root安裝fastDFS

fastDFS 想要非root安裝,沒找到資料,分析了一下安裝指令碼,原來作者是留了安裝路徑的,但沒有放出來。

 

1、解包

[[email protected] setup]$ tar  -xvf  libfastcommon-1.0.36.tar.gz

[[email protected] 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

[[email protected] zzw_temp]$ pwd
/opt/aspire/product/bdc/zzw_temp
[[email protected] zzw_temp]$ ll
總用量 4
drwxrwxr-x 3 bdc bdc 4096 11月  7 17:45 setup

[[email protected] zzw_temp]$ export DESTDIR=/opt/aspire/product/bdc/zzw_temp/libfastcommon
[

[email protected] zzw_temp]$ echo  $DESTDIR
/opt/aspire/product/bdc/zzw_temp/libfastcommon

[[email protected] setup]$ cd  setup/libfastcommon-1.0.36

[[email protected] libfastcommon-1.0.36]$ ./make.sh

[[email protected] libfastcommon-1.0.36]$ ./make.sh  install

[[email protected] libfastcommon-1.0.36]$ cd /opt/aspire/product/bdc/zzw_temp/libfastcommon

[[email protected] libfastcommon]$ ll
總用量 4
drwxrwxr-x 5 bdc bdc 4096 11月  7 18:09 usr

   安裝成功!

 

4、安裝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

 所以安裝時

[[email protected] zzw_temp]$ export DESTDIR=/opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa    # /opt/aspire/product/dicmp_zzw/zzw_temp/fastddd/fastdfsaaa 為安裝目錄

[[email protected] ]$ ./make.sh

[[email protected] ]$ ./make.sh  install

二、安裝後後目錄結構

安裝後的目錄只用etc與usr兩個資料夾。

[[email protected] 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    
#加上變數

 

還沒有空研究行不行