91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

FastDFS集群tracker是怎么樣實現負載均衡的

發布時間:2020-04-16 16:53:01 來源:億速云 閱讀:1145 作者:三月 欄目:建站服務器

下文給大家帶來FastDFS集群tracker是怎么樣實現負載均衡的,希望能夠給大家在實際運用中帶來一定的幫助,負載均衡涉及的東西比較多,理論也不多,網上有很多書籍,今天我們就用億速云在行業內累計的經驗來做一個解答。

  功能:文件存儲、同步、上傳、下載,提供負載均衡功能,適合用于圖片、視頻的存放。


角色:


tracker


作用:任務調度接受客戶端的訪問,檢索存儲節點,為客戶端提供一臺可用的storage。


storage

FastDFS集群tracker是怎么樣實現負載均衡的

作用:接受Tracker的調度,響應客戶端請求,將客戶端發來的文件存儲至相應存儲位置,讀取請求的文件,發送給客戶端。


以下使用三臺虛擬機搭建實驗環境:


三臺機器充當存儲節點,其中兩臺配置tracker做主備關系同時充當storage角色,當一臺tracker down機后另外一臺可以提供正常的訪問連接。


tracker01: 192.168.56.101

tracker02: 192.168.56.102

storage03:192.168.56.103


準備工作:


  OS: CentoOS6.8

  在所有節點上安裝依賴庫:

  yum install -y gcc libevent libevent-doc libevent-devel libevent-headers make


 所需軟件包:

  FastDFS_v4.06.tar.gz

  fastdfs-nginx-module_v1.15.tar.gz (配置web訪問時需要nginx支持此模塊)

開始:第一步

[root@Master ~]# tar -xf FastDFS_v4.06.tar.gz
[root@Master ~]# cd FastDFS
[root@Master FastDFS]# ll
total 124
drwxrwxr-x. 3 nginx nginx  4096 Feb 15  2013 client
drwxrwxr-x. 2 nginx nginx  4096 Feb 15  2013 common
drwxrwxr-x. 2 nginx nginx  4096 Feb 15  2013 conf
-rw-rw-r--. 1 nginx nginx 35067 Jul 28  2008 COPYING-3_0.txt
-rw-rw-r--. 1 nginx nginx 28437 Jan 24  2013 HISTORY
drwxrwxr-x. 2 nginx nginx  4096 Feb 15  2013 init.d
-rw-rw-r--. 1 nginx nginx  7757 Dec 23  2011 INSTALL
-rwxrwxr-x. 1 nginx nginx  5133 Dec 27  2012 make.sh
drwxrwxr-x. 2 nginx nginx  4096 Feb 15  2013 php_client
-rw-rw-r--. 1 nginx nginx  2380 Jul 28  2008 README
-rwxrwxr-x. 1 nginx nginx  1768 Apr 12  2010 restart.sh
-rwxrwxr-x. 1 nginx nginx  1680 Apr 10  2010 stop.sh
drwxrwxr-x. 4 nginx nginx  4096 Feb 15  2013 storage
drwxrwxr-x. 2 nginx nginx  4096 Feb 15  2013 test
drwxrwxr-x. 2 nginx nginx  4096 Feb 15  2013 tracker
[root@Master FastDFS]# ./make.sh && ./make.sh install
[root@Master FastDFS]# cp conf/storage_ids.conf /etc/fdfs/
[root@Master FastDFS]# cp init.d/fdfs_trackerd /etc/init.d #拷貝tracker啟動文件
[root@Master FastDFS]# cp init.d/fdfs_storaged /etc/init.d #拷貝storage啟動文件


建議:編譯前請先閱讀INSTALL file

第二步:創建數據目錄

mkdir -p /data/fastdfs/tracker #創建tracker文件存放路徑
mkdir -p /data/fastdfs/storage #創建storage 文件存放路徑
mkdir -p /data/fastdfs/client  #創建client 文件存放路徑


第三步:修改配置文件

[root@Master fdfs]# ll
total 64
-rw-r--r--. 1 root root  1500 Jun 26 14:36 client.conf
-rw-r--r--. 1 root root   858 Jun 23 15:42 http.conf
-rw-r--r--. 1 root root 31172 Jun 23 15:42 mime.types
-rw-r--r--. 1 root root  3898 Jun 26 15:35 mod_fastdfs.conf
-rw-r--r--. 1 root root  7496 Jun 26 15:22 storage.conf
-rw-r--r--. 1 root root   171 Jun 26 15:45 storage_ids.conf
-rw-r--r--. 1 root root  6624 Jun 26 16:04 tracker.conf
#以上目錄處mod_fastdfs.conf文件外如缺少其他文件請檢查 libevent 是否安裝

[root@Master fdfs]# grep -vE "^#|^$" tracker.conf

disabled=false
bind_addr=
port=22122
connect_timeout=30
network_timeout=60
base_path=/data/fastdfs/tracker
max_connections=4096
work_threads=4
store_lookup=0
store_server=0
store_path=0
download_server=0
reserved_storage_space = 10%
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
trunk_create_file_advance = false
trunk_create_file_time_base = 02:00
trunk_create_file_interval = 86400
trunk_create_file_space_threshold = 20G
trunk_init_check_occupying = false
trunk_init_reload_from_binlog = false
use_storage_id = false
storage_ids_filename = storage_ids.conf
id_type_in_filename = ip
store_slave_file_use_link = false
rotate_error_log = false
error_log_rotate_time=00:00
rotate_error_log_size = 0
use_connection_pool = false
connection_pool_max_idle_time = 3600
http.server_port=8080
http.check_alive_interval=30
http.check_alive_type=tcp
http.check_alive_uri=/status.html

#以上為配置文件內容,各參數的含義請自行了解。

cat /etc/fdfs/storage_ids.conf

[root@Master fdfs]# cat storage_ids.conf
# <id>  <group_name>  <ip_or_hostname>
 100001   group1  192.168.56.101
 100002   group1  192.168.56.102
 100003   group1  192.168.56.103


[root@Master fdfs]# grep -vE '^#|^$' client.conf

connect_timeout=30
network_timeout=60
base_path=/data/fastdfs/client
tracker_server=192.168.56.101:22122
tracker_server=192.168.56.102:22122
log_level=info
use_connection_pool = false
connection_pool_max_idle_time = 3600
load_fdfs_parameters_from_tracker=false
use_storage_id = false
storage_ids_filename = storage_ids.conf
http.tracker_server_port=8080



請在所有tracker主機修改/etc/fdfs/tracker.conf文件


請在所有storage主機修改/etc/fdfs/storage.conf文件

cat /etc/fdfs/storage.conf

[root@Master fdfs]# grep -vE "^#|^$" storage.conf
disabled=false
group_name=group1
bind_addr=
client_bind=true
port=23000
connect_timeout=30
network_timeout=60
heart_beat_interval=30
stat_report_interval=60
base_path=/data/fastdfs/storage
max_connections=256
buff_size = 256KB
work_threads=4
disk_rw_separated = true
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=/data/fastdfs/storage
subdir_count_per_path=256
tracker_server=192.168.56.101:22122
tracker_server=192.168.56.102:22122
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
file_signature_method=hash
key_namespace=FastDFS
keep_alive=0
use_access_log = false
rotate_access_log = false
access_log_rotate_time=00:00
rotate_error_log = false
error_log_rotate_time=00:00
rotate_access_log_size = 0
rotate_error_log_size = 0
file_sync_skip_invalid_record=false
use_connection_pool = false
connection_pool_max_idle_time = 3600
http.domain_name=
http.server_port=8888


第四步:啟動tracker and storage

[root@Master fdfs]# /etc/init.d/fdfs_trackerd start
[root@Master fdfs]# /etc/init.d/fdfs_storaged start
[root@Master fdfs]# ps -ef|grep fdfs
root      3157     1  0 11:55 ?        00:00:00 /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
root      3188     1  0 11:56 ?        00:00:00 /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
root      3217  2434  0 11:57 pts/0    00:00:00 grep fdfs
[root@Master fdfs]#

注意:如果啟動失敗請查看日志/data/fastdfs/tracker/logs/trackerd.log


至此:tracker和storage啟動完畢。


查看集群狀態:


[root@Master ~]# /usr/local/bin/fdfs_monitor /etc/fdfs/storage.conf


[2017-06-27 12:02:31] DEBUG - base_path=/data/fastdfs/storage, connect_timeout=30, network_timeout=60, tracker_server_count=2, 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

server_count=2, server_index=0

tracker server is 192.168.56.101:22122

group count: 1

Group 1:
group name = group1
disk total space = 8447 MB
disk free space = 4924 MB
trunk free space = 0 MB
storage server count = 3
active server count = 1
storage server port = 23000
storage HTTP port = 8888
store path count = 1
subdir count per path = 256
current write server index = 0
current trunk file id = 0

    Storage 1:
        id = 192.168.56.101
        ip_addr = 192.168.56.101 (Master)  WAIT_SYNC
        http domain =
        version = 4.06
        join time = 2017-06-26 15:22:46
        up time = 2017-06-27 11:49:39
        total storage = 0 MB
        free storage = 0 MB
        upload priority = 10
        store_path_count = 1
        subdir_count_per_path = 256
        storage_port = 23000
        storage_http_port = 8888
        current_write_path = 0
        source storage id=
        if_trunk_server= 0
        total_upload_count = 0
        success_upload_count = 0
        total_append_count = 0
        success_append_count = 0
        total_modify_count = 0
        success_modify_count = 0
        total_truncate_count = 0
        success_truncate_count = 0
        total_set_meta_count = 0
        success_set_meta_count = 0
        total_delete_count = 0
        success_delete_count = 0
        total_download_count = 0
        success_download_count = 0
        total_get_meta_count = 0
        success_get_meta_count = 0
        total_create_link_count = 0
        success_create_link_count = 0
        total_delete_link_count = 0
        success_delete_link_count = 0
        total_upload_bytes = 0
        success_upload_bytes = 0
        total_append_bytes = 0
        success_append_bytes = 0
        total_modify_bytes = 0
        success_modify_bytes = 0
        stotal_download_bytes = 0
        success_download_bytes = 0
        total_sync_in_bytes = 0
        success_sync_in_bytes = 0
        total_sync_out_bytes = 0
        success_sync_out_bytes = 0
        total_file_open_count = 0
        success_file_open_count = 0
        total_file_read_count = 0
        success_file_read_count = 0
        total_file_write_count = 0
        success_file_write_count = 0
        last_heart_beat_time = 1970-01-01 08:00:00
        last_source_update = 1970-01-01 08:00:00
        last_sync_update = 1970-01-01 08:00:00
        last_synced_timestamp = 1970-01-01 08:00:00 (never synced)
    Storage 2:
        id = 192.168.56.102
        ip_addr = 192.168.56.102 (Minion02)  ACTIVE
        http domain =
        version = 4.06
        join time = 2017-06-26 15:12:53
        up time = 2017-06-27 11:50:08
        total storage = 8447 MB
        free storage = 4945 MB
        upload priority = 10
        store_path_count = 1
        subdir_count_per_path = 256
        storage_port = 23000
        storage_http_port = 8888
        current_write_path = 0
        source storage id=
        if_trunk_server= 0
        total_upload_count = 6
        success_upload_count = 6
        total_append_count = 0
        success_append_count = 0
        total_modify_count = 0
        success_modify_count = 0
        total_truncate_count = 0
        success_truncate_count = 0
        total_set_meta_count = 6
        success_set_meta_count = 6
        total_delete_count = 0
        success_delete_count = 0
        total_download_count = 0
        success_download_count = 0
        total_get_meta_count = 0
        success_get_meta_count = 0
        total_create_link_count = 0
        success_create_link_count = 0
        total_delete_link_count = 0
        success_delete_link_count = 0
        total_upload_bytes = 63284
        success_upload_bytes = 63284
        total_append_bytes = 0
        success_append_bytes = 0
        total_modify_bytes = 0
        success_modify_bytes = 0
        stotal_download_bytes = 0
        success_download_bytes = 0
        total_sync_in_bytes = 120
        success_sync_in_bytes = 120
        total_sync_out_bytes = 240
        success_sync_out_bytes = 240
        total_file_open_count = 10
        success_file_open_count = 10
        total_file_read_count = 0
        success_file_read_count = 0
        total_file_write_count = 10
        success_file_write_count = 10
        last_heart_beat_time = 2017-06-27 12:02:14
        last_source_update = 2017-06-27 12:01:01
        last_sync_update = 2017-06-26 15:55:03
        last_synced_timestamp = 1970-01-01 08:00:00 (never synced)
    Storage 3:
        id = 192.168.56.103
        ip_addr = 192.168.56.103 (Minion03)  WAIT_SYNC
        http domain =
        version = 4.06
        join time = 2017-06-26 15:14:03
        up time = 2017-06-27 11:50:25
        total storage = 8447 MB
        free storage = 4924 MB
        upload priority = 10
        store_path_count = 1
        subdir_count_per_path = 256
        storage_port = 23000
        storage_http_port = 8888
        current_write_path = 0
        source storage id= 192.168.56.102
        if_trunk_server= 0
        total_upload_count = 2
        success_upload_count = 2
        total_append_count = 0
        success_append_count = 0
        total_modify_count = 0
        success_modify_count = 0
        total_truncate_count = 0
        success_truncate_count = 0
        total_set_meta_count = 2
        success_set_meta_count = 2
        total_delete_count = 0
        success_delete_count = 0
        total_download_count = 0
        success_download_count = 0
        total_get_meta_count = 0
        success_get_meta_count = 0
        total_create_link_count = 0
        success_create_link_count = 0
        total_delete_link_count = 0
        success_delete_link_count = 0
        total_upload_bytes = 22
        success_upload_bytes = 22
        total_append_bytes = 0
        success_append_bytes = 0
        total_modify_bytes = 0
        success_modify_bytes = 0
        stotal_download_bytes = 0
        success_download_bytes = 0
        total_sync_in_bytes = 995
        success_sync_in_bytes = 240
        total_sync_out_bytes = 120
        success_sync_out_bytes = 120
        total_file_open_count = 10
        success_file_open_count = 10
        total_file_read_count = 0
        success_file_read_count = 0
        total_file_write_count = 10
        success_file_write_count = 10
        last_heart_beat_time = 2017-06-27 12:02:10
        last_source_update = 2017-06-26 15:54:52
        last_sync_update = 2017-06-26 16:04:33
        last_synced_timestamp = 1970-01-01 08:00:00 (never synced)



測試:


  1. 上傳文件至FastDFS,上傳多個文件至storage查看上傳位置是否有變化

  2. 停掉tracker01 查看是否切換至tracker02



上傳文件:

[root@Master ~]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload install.log



看了以上關于FastDFS集群tracker是怎么樣實現負載均衡的,如果大家還有什么地方需要了解的可以在億速云行業資訊里查找自己感興趣的或者找我們的專業技術工程師解答的,億速云技術工程師在行業內擁有十幾年的經驗了。

 








向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

来宾市| 马尔康县| 曲阳县| 盐亭县| 息烽县| 临清市| 赤城县| 察隅县| 嵊州市| 平凉市| 嘉祥县| 迭部县| 安溪县| 洛隆县| 泾源县| 冀州市| 慈溪市| 宝兴县| 贵德县| 温泉县| 临猗县| 镇宁| 高陵县| 通江县| 仙桃市| 金阳县| 监利县| 奉贤区| 宜兰市| 观塘区| 清远市| 梅河口市| 泽普县| 柘城县| 定陶县| 西贡区| 海阳市| 保德县| 惠州市| 遵化市| 安西县|