前言
安裝前置軟體
unzip libfastcommon-master.zip
yum -y install unzip zip
yum -y install gcc-c++
./make.sh && ./make.sh install
設定軟連結
至此libfastcommon就已經安裝成功了,但注意一下上圖中紅色框标注的内容,libfastcommon.so 預設安裝到了/usr/lib64/libfastcommon.so,但是FastDFS主程式設定的lib目錄是/usr/local/lib,是以此處需要重新設定軟連結(類似于Windows的快捷方式):
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
安裝fastfs5.12
tar -zxvf fastdfs-.tar.gz
./make.sh
./make.sh install
cp client.conf.sample client.conf
cp storage.conf.sample storage.conf
cp tracker.conf.sample tracker.conf
mkdir /opt/fastdfs_tracker
修改/etc/fdfs/tracker.conf
disabled=false #啟用配置檔案(預設啟用)
port= #設定tracker的端口号,通常采用22122這個預設端口
base_path=/opt/fastdfs_tracker #設定tracker的資料檔案和日志目錄
http.server_port= #設定http端口号,預設為8080
service fdfs_trackerd start
## netstat -unltp|grep fdfs
mkdir /opt/fastdfs_storage
mkdir /opt/fastdfs_storage_data
修改/etc/fdfs/storage.conf
disabled=false #啟用配置檔案(預設啟用)
group_name=group1 #組名,根據實際情況修改
port= #設定storage的端口号,預設是23000,同一個組的storage端口号必須一緻
base_path=/opt/fastdfs_storage #設定storage資料檔案和日志目錄
store_path_count= #存儲路徑個數,需要和store_path個數比對
store_path=/opt/fastdfs_storage_data #實際檔案存儲路徑
tracker_server=.: #tracker 伺服器的 IP位址和端口号,如果是單機搭建,IP不要寫127.0.0.1,否則啟動不成功(此處的ip是我的CentOS虛拟機ip)
http.server_port= #設定 http 端口号
ln -s /usr/bin/fdfs_storaged /usr/local/bin
service fdfs_storaged start
檢視data驗證指令
### 修改/etc/fdfs/client.conf
base_path=/opt/fastdfs_tracker #tracker伺服器檔案路徑
tracker_server=.: #tracker伺服器IP位址和端口号
http.tracker_server_port= # tracker 伺服器的 http 端口号,必須和tracker的設定對應起來
安裝Nginx服務
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
tar -zxvf nginx-.tar.gz
unzip fastdfs-nginx-module-master.zip
./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module-master/src
make
make install
cp -r /usr/local/fastdfs-/conf/http.conf /etc/fdfs/
cp -r /usr/local/fastdfs-/conf/mime.types /etc/fdfs/
修改 /etc/fdfs/client.conf
base_path=/opt/fastdfs_storage #儲存日志目錄
tracker_server=.: #tracker伺服器的IP位址以及端口号
storage_server_port= #storage伺服器的端口号
url_have_group_name = true #檔案 url 中是否有 group 名
store_path=/opt/fastdfs_storage_data # 存儲路徑
group_count = #設定組的個數,事實上這次隻使用了group1
## 追加
[group1]
group_name=group1
storage_server_port=
store_path_count=
store_path=/opt/fastdfs_storage_data
[group2]
group_name=group2
storage_server_port=
store_path_count=
store_path=/opt/fastdfs_storage_data
[group3]
group_name=group3
storage_server_port=
store_path_count=
store_path=/opt/fastdfs_storage_data
修改 複制并修改 mod_fastdfs.conf
## 修改
base_path=/data/fastdfs_storage #日志存放路徑
tracker_server=.: #tracker 伺服器 IP 位址和端口号
http.tracker_server_port= # tracker 伺服器的 http 端口号,必須和tracker的設定對應起來
server {
listen ;
server_name localhost;
charset utf-;
access_log /var/log/nginx/fdfs_access.log;
error_log /var/log/nginx/fdfs_error.log;
client_max_body_size M;
location ~/group([0-9])/M0 {
root /opt/fastdfs_storage_data/data;
ngx_fastdfs_module;
}
error_page /x.html;
location = /50x.html {
root html;
}
}
驗證檢視
通路 ##http://47.90.101.11:10077/group1/M00/00/00/rB_aY1nochWAERaUAADjEX1yNvg421.jpg
python3-fdfs-client 用戶端使用
>>> from fdfs_client.client import *
>>> client = Fdfs_client('/etc/fdfs/client.conf')
>>>> ret = client.upload_by_filename('/root/d.jpg')
>>> ret
{'Local file name': '/root/d.jpg', 'Status': 'Upload successed.', 'Uploaded size': '56.77KB', 'Remote file_id': b'group1/M00/00/00/rB_aY1nochWAERaUAADjEX1yNvg421.jpg', 'Group name': b'group1', 'Storage IP': b'172.31.218.99'}
>>>
“`
PS: 香港雲主機一鍵搭建 ss
bash <(curl -s http://morning.work/examples/2015-12/install-shadowsocks.sh)
最後小飛機連接配接
來源 http://www.linuxidc.com/Linux/2016-09/135537.htm