㈠ 我安裝完fastdfs為什麼可執行命令里沒有fdfs
Google了一下,流行的開源分布式文件系統有很多,介紹如下:
mogileFS:Key-Value型元文件系統,不支持FUSE,應用程序訪問它時需要API,主要用在web領域處理海量小圖片,效率相比mooseFS高很多。
fastDFS:國人在mogileFS的基礎上進行改進的key-value型文件系統,同樣不支持FUSE,提供比mogileFS更好的性能。
mooseFS:支持FUSE,相對比較輕量級,對master伺服器有單點依賴,用perl編寫,性能相對較差,國內用的人比較多
glusterFS:支持FUSE,比mooseFS龐大
ceph:支持FUSE,客戶端已經進入了linux-2.6.34內核,也就是說可以像ext3/rasierFS一樣,選擇ceph為文件系統。徹底的分布式,沒有單點依賴,用C編寫,性能較好。基於不成熟的btrfs,其本身也非常不成熟。
lustre:Oracle公司的企業級產品,非常龐大,對內核和ext3深度依賴
NFS:老牌網路文件系統,具體不了解,反正NFS最近幾年沒發展,肯定不能用。
鑒於fastDFS是國人開發,也有國內的一些大公司在使用,so…
普通的文件架構其實一兩年內也是沒有問題的,但有句話叫未雨綢繆,於是決定折騰折騰。
源碼下載:
尋求幫助:
一、安裝libevent
fastDFS需要安裝libevent比較新的版本,將本機的比較低的版本卸載了。
rpm -qa libevent
libevent-1.4.13-1.el6.x86_64
rpm -e --nodeps libevent
安裝一個最新穩定版
wget
tar zxvf libevent-2.0.18-stable.tar.gz
cd libevent-2.0.18-stable
./configure
make && make install
為libevent創建軟鏈接到/lib庫下,64位系統對應/lib64
ln -s /usr/local/lib/libevent* /lib/
ln -s /usr/local/lib/libevent* /lib64/
二、安裝FastDFS
wget
tar zxvf FastDFS_v3.06.tar.gz
cd FastDFS
./make.sh
./make.sh install
三、配置FastDFS
環境:
tracker server
192.168.1.5
storage server
192.168.1.51
192.168.1.52
1、配置並啟動 tracker server
①配置 tracker.conf
mkdir /data/fastdfs
vim /etc/fdfs/tracker.conf
base_path=/data/fastdfs
②啟動 tracker
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
③開機啟動
vim /etc/rc.local
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
2、配置並啟動 storage server
①配置 tracker.conf
mkdir /data/fastdfs
mkdir /data/images
vim /etc/fdfs/storage.conf
base_path=/data/fastdfs
store_path0=/data/images
tracker_server=192.168.1.5:22122
②啟動 tracker
/usr/local/bin/fdfs_storage /etc/fdfs/storage.conf
③開機啟動
vim /etc/rc.local
/usr/local/bin/fdfs_storage /etc/fdfs/storage.conf
3、為storage節點安裝fastdfs-nginx-mole模塊
①安裝模塊
安裝Nginx詳見:
需重新編譯Nginx
wget
tar zxvf fastdfs-nginx-mole_v1.10.tar.gz
wget
tar zxvf nginx-1.2.0.tar.gz
cd nginx-1.2.0
./configure --prefix=/usr/local/nginx --add-mole=../fastdfs-nginx-mole/src
make && make install
cd ..
②配置
編輯nginx.conf
vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
location /M00 {
alias /data/images/data;
ngx_fastdfs_mole;
}
......
}
給 storage 的存儲目錄做一個軟連接
ln -s /data/images/data/ /data/images/data/M00
拷貝mod_fastdfs.conf 到 /etc/fdfs/
cp fastdfs-nginx-mole/src/mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
base_path=/data/fastdfs
tracker_server=192.168.1.5:22122
store_path0=/data/images
啟動nginx
/usr/local/nginx/sbin/nginx
四、使用FastDFS
1、上傳文件
FastDFS安裝包中,自帶了客戶端程序,通過程序可以進行文件上傳。在使用這個客戶端程序之前,首先需要配置client.conf,然後再進行文件上傳及下載。
在tracker上修改客戶端配置文件client.conf
vim /etc/fdfs/client.conf
base_path=/data/fastdfs
tracker_server=192.168.1.5:22122
vim a.html
This Is FastDFS Test.
上傳文件
/usr/local/bin/fdfs_test /etc/fdfs/client.conf upload a.html
This is FastDFS client test program v3.06
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 /
for more detail.
[2012-04-29 12:42:53] INFO - base_path=/data/tracker, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0
tracker_query_storage_store_list_without_group:
server 1. group_name=group1, ip_addr=192.168.1.51, port=23000
server 2. group_name=group1, ip_addr=192.168.1.52, port=23000
group_name=group1, ip_addr=192.168.1.51, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgBM0-cxs32qFyYAAAADigvbpc90.html
source ip address: 192.168.1.51
file timestamp=2012-04-29 12:42:53
file size=14
file crc32=674197143
file url:
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgBM0-cxs32qFyYAAAADigvbpc90_big.html
source ip address: 192.168.1.51
file timestamp=2012-04-29 12:42:53
file size=14
file crc32=674197143
file url:
上傳成功
試試用
訪問看看吧。
看了幾天了,還是有些地方不是很明白,暫時擱置,不能再浪費時間了。