FastDFS安装
环境介绍:
tracker:192.168.43.129
storage:192.168.43.130
tracker:192.168.43.129
storage:192.168.43.130
软件下载:
wget http://fastdfs.googlecode.com/files/FastDFS_v3.02.tar.gz
wget –no-check-certificate https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
wget http://fastdfs.googlecode.com/files/FastDFS_v3.02.tar.gz
wget –no-check-certificate https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
安装开始
一 首先安装libevent FastDFS这个步骤在tracker storage都需要操作
wget –no-check-certificate https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
tar zxvf libevent-2.0.20-stable.tar.gz
./configure && make && make install
一 首先安装libevent FastDFS这个步骤在tracker storage都需要操作
wget –no-check-certificate https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
tar zxvf libevent-2.0.20-stable.tar.gz
./configure && make && make install
ln -s /usr/local/lib/libevent* /lib/
ln -s /usr/local/lib/libevent* /lib64/
ln -s /usr/local/lib/libevent* /lib64/
wget
http://fastdfs.googlecode.com/files/FastDFS_v3.02.tar.gz
tar zxvf FastDFS_v3.02.tar.gz
cd FastDFS
tar zxvf FastDFS_v3.02.tar.gz
cd FastDFS
-
vim make.sh
############
TARGET_PREFIX=/usr/local 改成 TARGET_PREFIX=/usr/local/FastDFS
#WITH_HTTPD=1 改成 WITH_HTTPD=1
#WITH_LINUX_SERVICE=1 改成 WITH_LINUX_SERVICE=1
############
./make.sh
./make.sh install
这样软件安装就已经完成 现在就单独配置tracker storage的配置文件了
- 二 登陆192.168.43.129 配置/etc/fdfs/tracker.conf
[root@server fdfs]#grep -v '^#' tracker.conf |grep -v '^$'
disabled=false
bind_addr=
port=22122 ##端口
connect_timeout=30
network_timeout=60
base_path=/home/data/fastdfs ##存储路径
max_connections=256
work_threads=4
store_lookup=2
store_group=group2
store_server=0
store_path=0
download_server=0
reserved_storage_space = 1GB
log_level=info
run_by_group=
run_by_user=
allow_hosts=*
sync_log_buff_interval = 10
check_active_interval = 120
thread_stack_size = 64KB
storage_ip_changed_auto_adjust = true
storage_sync_file_max_delay = 86400
storage_sync_file_max_time = 300
use_trunk_file = false
slot_min_size = 256
slot_max_size = 16MB
trunk_file_size = 64MB
http.disabled=false
http.server_port=8090 ##http端口 默认是8080
http.check_alive_interval=30
http.check_alive_type=tcp
http.check_alive_uri=/status.html
http.need_find_content_type=true
启动tracher服务:
/usr/local/FastDFS/bin/fdfs_trackerd /etc/fdfs/tracker.conf
[root@clinet2 fdfs]# netstat -antp|grep fdfs
tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 20112/fdfs_trackerd
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 20112/fdfs_trackerd
tcp 0 0 192.168.43.129:22122 192.168.43.130:54911 ESTABLISHED 20112/fdfs_trackerd
/usr/local/FastDFS/bin/fdfs_trackerd /etc/fdfs/tracker.conf
[root@clinet2 fdfs]# netstat -antp|grep fdfs
tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 20112/fdfs_trackerd
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 20112/fdfs_trackerd
tcp 0 0 192.168.43.129:22122 192.168.43.130:54911 ESTABLISHED 20112/fdfs_trackerd
- 登陆192.168.43.130 配置storage 配置/etc/fdfs/ storage.conf && client.conf &&http.conf
[root@clinet1 fdfs]# grep -v '^#' storage.conf |grep -v '^$'
disabled=false
group_name=group1
bind_addr=192.168.43.130 ##本storage的ip
client_bind=true
port=23000 ##默认端口
connect_timeout=30
network_timeout=60
heart_beat_interval=30
stat_report_interval=60
base_path=/home/data/fastdfs ##存储路径
max_connections=256
buff_size = 256KB
work_threads=4
disk_rw_separated = true
disk_rw_direct = false
disk_reader_threads = 1
disk_writer_threads = 1
sync_wait_msec=50
sync_interval=0
sync_start_time=00:00
sync_end_time=23:59
write_mark_file_freq=500
store_path_count=1
store_path0=/home/data/fastdfs ##路径
subdir_count_per_path=256
tracker_server=192.168.43.129:22122 ##tracher服务器ip地址
log_level=info
run_by_group=
run_by_user=
allow_hosts=*
file_distribute_path_mode=0
file_distribute_rotate_count=100
fsync_after_written_bytes=0
sync_log_buff_interval=10
sync_binlog_buff_interval=10
sync_stat_file_interval=300
thread_stack_size=512KB
upload_priority=10
if_alias_prefix=
check_file_duplicate=0
key_namespace=FastDFS
keep_alive=0
http.disabled=false
http.domain_name=
http.server_port=8888 ##本stroage的http端口
http.trunk_size=256KB
http.need_find_content_type=true - [root@clinet1 fdfs]# grep -v '^#' http.conf |grep -v '^$'
http.default_content_type = application/octet-stream
http.mime_types_filename=mime.types
http.anti_steal.check_token=false
http.anti_steal.token_ttl=900
http.anti_steal.secret_key=FastDFS1234567890
http.anti_steal.token_check_fail=/home/data/fastdfs/conf/anti-steal.jpg ##路径 - [root@clinet1 fdfs]# grep -v '^#' client.conf |grep -v '^$'
connect_timeout=30
network_timeout=60
base_path=/home/data/fastdfs ##存储路径
tracker_server=192.168.43.129:22122 ##tracherip地址和启动端口
log_level=info
http.tracker_server_port=8090 ##这个是tracher的httpd端口 默认是8080
所有配置完成,启动服务
/usr/local/FastDFS/bin/fdfs_storaged /etc/fdfs/storage.conf
[root@clinet1 fdfs]# netstat -antp|grep fdfs
tcp 0 0 192.168.43.130:8888 0.0.0.0:* LISTEN 12724/fdfs_storaged
tcp 0 0 192.168.43.130:23000 0.0.0.0:* LISTEN 12724/fdfs_storaged
tcp 0 0 192.168.43.130:54911 192.168.43.129:22122 ESTABLISHED 12724/fdfs_storaged
/usr/local/FastDFS/bin/fdfs_storaged /etc/fdfs/storage.conf
[root@clinet1 fdfs]# netstat -antp|grep fdfs
tcp 0 0 192.168.43.130:8888 0.0.0.0:* LISTEN 12724/fdfs_storaged
tcp 0 0 192.168.43.130:23000 0.0.0.0:* LISTEN 12724/fdfs_storaged
tcp 0 0 192.168.43.130:54911 192.168.43.129:22122 ESTABLISHED 12724/fdfs_storaged
测试:
在storage服务器里面执行:
[root@clinet1 ~]# /usr/local/FastDFS/bin/fdfs_test /etc/fdfs/client.conf upload hello.html
This is FastDFS client test program v3.02
在storage服务器里面执行:
[root@clinet1 ~]# /usr/local/FastDFS/bin/fdfs_test /etc/fdfs/client.conf upload hello.html
This is FastDFS client test program v3.02
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.
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.
[2013-02-28 20:09:30] INFO - base_path=/home/data/fastdfs, 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.43.130, port=23000
server 1. group_name=group1, ip_addr=192.168.43.130, port=23000
group_name=group1, ip_addr=192.168.43.130, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgrglEvSPqtBR-EAAAADcvnyC854.html
source ip address: 192.168.43.130
file timestamp=2013-02-28 20:09:30
file size=13
file crc32=3420964911
file url: http://192.168.43.129:8090/group1/M00/00/00/wKgrglEvSPqtBR-EAAAADcvnyC854.html
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgrglEvSPqtBR-EAAAADcvnyC854_big.html
source ip address: 192.168.43.130
file timestamp=2013-02-28 20:09:30
file size=13
file crc32=3420964911
file url: http://192.168.43.129:8090/group1/M00/00/00/wKgrglEvSPqtBR-EAAAADcvnyC854_big.html
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgrglEvSPqtBR-EAAAADcvnyC854.html
source ip address: 192.168.43.130
file timestamp=2013-02-28 20:09:30
file size=13
file crc32=3420964911
file url: http://192.168.43.129:8090/group1/M00/00/00/wKgrglEvSPqtBR-EAAAADcvnyC854.html
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgrglEvSPqtBR-EAAAADcvnyC854_big.html
source ip address: 192.168.43.130
file timestamp=2013-02-28 20:09:30
file size=13
file crc32=3420964911
file url: http://192.168.43.129:8090/group1/M00/00/00/wKgrglEvSPqtBR-EAAAADcvnyC854_big.html
####上述就说明hello.html这个文件已经被上传到192.168.43.129 tracker服务器中 然后使用
http://192.168.43.129:8090/group1/M00/00/00/wKgrglEvSPqtBR-EAAAADcvnyC854_big.html即可访问
转载于:https://blog.51cto.com/kexl908/1142937