fastdfs詳細配置
fastdfs配置
伺服器環境
fastdfs-trackerd 192.168.32.128
fastdfs-storage 192.168.32.129
分別在兩個伺服器上面安裝好fastdfs服務
1.安裝依賴
yum install openssl* -y
yum install gd-devel -y
yum install pcre-devel -y
2.安裝lbevent
tar zxvf libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable
./configure –prefix=/usr/local/libevent
make
make install
export LD_LIBRARY_PATH=/usr/local/libevent/lib
3..安裝fastdfs
tar zxvf FastDFS_v4.07.tar.gz
cd FastDFS
./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
./make.sh install
4.建立fastdfs儲存目錄
mkdir /data/fastDFS
5.在tracker修改配置檔案
vim /etc/fdfs/tracker.conf
bind_addr=192.168.32.128 繫結tracker伺服器ip
base_path=/data/fastDFS 存放資料和日誌的根目錄地址(這個目錄必須存在,其下的子目錄自動生成
max_connections=256 系統提供服務時最大連線數
work_threads=4工作顯成熟,通常設定為cpu數,預設為4
store_lookup=2上傳檔案到組的方式,
0:輪詢 1:制定組 2:平均負載(選擇最大剩餘空間的組上傳)。
store_group=group2當store_lookup設定為1時。必須設定本引數為系統存在的一個組名
store_server=0選擇哪個storage server進行上傳
0:輪詢(預設方式)1:根據ip地址進行排序(選擇ip地址最小的) 2:根據優先順序進行排序(上傳優先順序由storage_server來設定,引數名為upload_priority)
store_path=0 選擇storage server中的那個目錄進行上傳,storage server可以有多個存放檔案的base_path,可以理解為多個磁碟。
0:輪流方式,多個目錄一次存放檔案 2:選擇生育空間最大的目錄存放檔案
download_Server=0 選擇哪個storage server作為下載伺服器
0:輪詢方式,可以下載當前檔案的任一storage server
1:哪個為源storage server就用哪一個,就是之前上傳到那個storage server伺服器就是哪個!
reserved_storage_space=10%storage server上的保留空間,保證系統或其他應用需求空間。
run_by_user=從作業系統執行FDFS的使用者(不填,就是當前使用者)
allow_hosts=*可以連線到此tracker server的ip範圍。可以配置多行
sync_log_buff_interval=10 同步或重新整理日誌資訊到硬碟的時間間隔,預設為秒
check_active_interval=120檢測storage server存活的時間間隔,以秒為單位
thread_stack_size=64KB執行緒棧的大小,執行緒越大,佔用資源越大。此值必須大於64KB
storeage_ip_changed_auto_adjust=true 這個引數控制當storage server ip改變時,叢集是否自動調整。注:只有在storage server程式重啟時才完成自動調整
storage_sync_file_max_delay=86400 storage server之間同步檔案的最大延遲時間,以秒為單位,預設為1天
storage_sync_file_max_time=300同步一個檔案需要消耗的最大時間,以秒為單位
use_trunk_file=fakse是否使用trunk file來合併小檔案,預設是關閉的
slot_min_size=256trunk file分配的最小位元組數,比如檔案只有16個位元組,系統也會分配slot_min_size個位元組
slot_max_size=16MB只有檔案大小<=這個引數值得檔案,才會合併儲存,如果檔案大小大於這個值,將直接儲存到一個檔案中(不採用合併儲存)
trunk_file_size=64MB合併儲存的trunk file大小,至少4MB.預設值為64MB,不建議設定過大
use_storage_id=false是否使用server id作為storage server標識
storage_ids_filename=storage_ids.conf在檔案中設定組名。server id和對用的ip地址
id_type_in_filename=ip 設定檔名中的storage server的標識
ip:storage server的ip地址
id:storage server的server id
rotate_error_log=flase是夠定期輪轉error log,目前僅支援一天輪轉一次,建議設定為true!
error_log_rotate_time=00:00設定error log定期輪轉的時間點。當rotate_error_log為true時有效
connection_poll_max_idle_time=3600最大連線等待時間,以秒為單位
http.server_port=80 (http服務埠,可以不設定)
http.check_alive_interval=30 檢測storage http server存活的時間間隔, 以秒為單位
http.check_alive_type=tcp檢測storage http server存活的方式,預設為tcp
http.check_alive_url=/status.html檢測storage http server是否存活的url
#include http.conf
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf 啟動服務
修改client.conf
vim /etc/fdfs/client.conf
base_path=/data/fastDFS
tracker_server=192.168.32.128:22122
http.tracker_server_port=80
#include http.conf
在storage伺服器安裝nginx。用來上傳和下載檔案
#1.下載fastdfs-nginx-module_v1.15.tar.gz
tar -zxvf fastdfs-nginx-module_v1.15.tar.gz -C /usr/local
#2.安裝nginx
tar zxvf nginx-1.6.0.tar.gz
cd nginx-1.6.0
cd /usr/local
tar zxvf fastdfs-nginx-module_v1.15.tar.gz
yum -y install pcre openssl gd*
./configure –prefix=/usr/local/nginx
–with-file-aio
–with-http_ssl_module
–with-http_image_filter_module
–with-http_sub_module
–with-http_secure_link_module
–with-http_stub_status_module
–with-pcre
–with-cc-opt=`-O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic`
–with-ld-opt=-Wl,-E
–with-http_realip_module
–with-http_gzip_static_module
–add-module=/usr/local/fastdfs-nginx-module/src
export LD_LIBRARY_PATH=/usr/local/libevent/lib/
cp mod_fastdfs.conf /etc/fdfs/
make && make install
修改mod_fastdfs.conf
vim /etc/fdfs/mod_fastdfs.conf
connect_timeout=20
base_path=/data/fastDFS
tracker_server=192.168.32.128:22122
store_path0=/data/fastDFS
url_have_group_name = true
修改nginx.conf
vim /usr/local/nginx/conf/nginx.conf
在server段新增以下內容
location /group1/M00/
{
alias /www/fastDFS/data/;
ngx_fastdfs_module;
}
/usr/local/nginx/sbin/nginx -t檢查配置檔案引數
/usr/local/nginx/sbin/nginx 啟動nginx
在storage修改配置檔案
vim /etc/storage.conf
bind_addr=192.168.32.129
base_path=/data/fastDFS
store_path0=/data/fastDFS
tracker_server=192.168.32.128:22122
http.server_port=80
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf 啟動服務
測試:上傳檔案
cat ./.bash_profile >> 2.txt
/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload 2.txt
This is FastDFS client test program v4.07
Copyright (C) 2008, Happy Fish / YuQing
FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/
for more detail.
[2014-12-31 09:20:40] DEBUG – base_path=/data/fastDFS, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0
tracker_query_storage_store_list_without_group:
server 1. group_name=, ip_addr=192.168.32.129, port=23000
group_name=group1, ip_addr=192.168.32.129, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgggVSjQ-iAJxtqAAAAsFQ-X38886.txt
source ip address: 192.168.32.129
file timestamp=2014-12-31 08:31:36
file size=176
file crc32=1413373823
example file url: http://192.168.32.129/group1/M00/00/00/wKgggVSjQ-iAJxtqAAAAsFQ-X38886.txt
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgggVSjQ-iAJxtqAAAAsFQ-X38886_big.txt
source ip address: 192.168.32.129
file timestamp=2014-12-31 08:31:36
file size=176
file crc32=1413373823
example file url: http://192.168.32.129/group1/M00/00/00/wKgggVSjQ-iAJxtqAAAAsFQ-X38886_big.txt
用瀏覽器訪問 http://192.168.32.129/group1/M00/00/00/wKgggVSjQ-iAJxtqAAAAsFQ-X38886_big.txt 就能看到上傳的檔案了
上傳的檔案放在/data/fastDFS/data/00/00中
檢視埠
netstat -tunpl
配置fastdfs支援php
yum -y install php*
cd /root/FastDFS/php-client
phpize 用來準備php擴充套件庫的編譯環境
./configure
make
make install
cat fastdfs_client.ini >> /etc/php.ini
/usr/bin/php -m | grep fastdfs
service php-fpm start
修改/etc/fdfs/client.conf
tracker_server=192.168.32.128:22122
http.tracker_server_port=80
echo `php_upload_test` > /tmp/upload.txt
vim test.php
<?php
var_dump(function_exists(`fastdfs_storage_upload_by_filename`));
$ret = fastdfs_storage_upload_by_filename(`
/tmp/upload.txt
`);
var_dump($ret);
?>
/usr/bin/php test.php
bool(true)
成功
array(2) {
[“group_name”]=>
string(6) “group1”
[“filename”]=>
string(44) “M00/00/00/wKgggVSjbDaATlrAAAAAEIxdRHw661.txt”
}
/etc/init.d/php-fpm reload
最後用瀏覽器訪問這個,看是否能訪問到
相關文章
- 分散式檔案儲存FastDFS(七)FastDFS配置檔案詳解分散式AST
- nginx 詳解 - 詳細配置說明Nginx
- nginx 詳解 – 詳細配置說明Nginx
- multipath配置詳細參考
- MyBatis Generator 超詳細配置MyBatis
- Apollo 配置中心詳細教程
- Flutter詳細的環境配置Flutter
- 配置PLSQL Developer詳細步驟SQLDeveloper
- Jmeter安裝配置詳細教程JMeter
- nginx配置https詳細過程NginxHTTP
- VNC安裝配置詳細說明VNC
- Github配置ssh key詳細步驟Github
- oracle 大頁配置詳細介紹Oracle
- Spring配置bean的詳細知識SpringBean
- MyBatis 核心配置檔案詳細內容詳解MyBatis
- MySQL的安裝與配置——詳細教程MySql
- Linux安裝和配置zokeeper 詳細教程Linux
- Linux安裝和配置tomcat詳細教程LinuxTomcat
- webpack4配置詳解之慢嚼細嚥Web
- nginx rails 詳細站點配置入門教程NginxAI
- windows環境下memcache配置方法 詳細篇Windows
- Webpack(含 4)配置詳解——關注細節Web
- mysql 5.7配置項最詳細的解釋MySql
- Linux 防火牆配置(iptables和firewalld)詳細教程。Linux防火牆
- Webpack安裝配置及打包詳細過程Web
- 蘋果cms安裝及配置詳細教程蘋果
- Argo workflow 案例練習和配置詳細解析Go
- 分享Linux下的sudo及其配置檔案/etc/sudoers詳細配置Linux
- 【CUDA】CUDA9.0+VS2017+win10詳細配置Win10
- SQL Server 2000詳細安裝過程及配置SQLServer
- SQL Server 2005詳細安裝過程及配置SQLServer
- 分散式監控系統ganglia的詳細配置分散式
- Logback詳細整理,基於springboot的日誌配置Spring Boot
- 保姆級 | MySQL的安裝配置教程(非常詳細)MySql
- java安裝教程詳細 java環境配置教程Java
- 如何配置web伺服器的詳細步驟Web伺服器
- 監聽配置細節引數詳解兩則
- idea maven怎麼安裝配置 idea maven配置教程詳細圖解IdeaMaven圖解
- 【BUILD_ORACLE】Oracle RAC配置ASM Filter Driver(ASMFD)(二)詳細配置步驟UIOracleASMFilter