Cài đặt bộ lưu trữ đối tượng LeoFS phân tán chịu lỗi, tương thích với các máy khách sử dụng S3, NFS

Theo mạng mở: LeoFS - lưu trữ đối tượng có khả năng chịu lỗi phân tán LeoFS, tương thích với các máy khách sử dụng API Amazon S3 và REST-API, đồng thời cũng hỗ trợ chế độ máy chủ NFS. Có các tối ưu hóa để lưu trữ cả các đối tượng nhỏ và rất lớn, có cơ chế bộ nhớ đệm tích hợp và có thể sao chép lưu trữ giữa các trung tâm dữ liệu. Mục tiêu của dự án bao gồm việc đạt được độ tin cậy 99.9999999% thông qua việc sao chép dự phòng các bản sao và loại bỏ một điểm lỗi duy nhất. Mã dự án được viết bằng Erlang.

LeoFS bao gồm ba thành phần:

  • Lưu trữ LeoFS — phục vụ các hoạt động thêm, truy xuất và xóa các đối tượng và siêu dữ liệu, chịu trách nhiệm thực hiện sao chép, phục hồi và xếp hàng các yêu cầu của khách hàng.
  • Cổng LeoFS — phục vụ các yêu cầu HTTP và chuyển hướng phản hồi đến máy khách bằng REST-API hoặc S3-API, đảm bảo lưu vào bộ nhớ đệm dữ liệu cần thiết nhất trong bộ nhớ và trên đĩa.
  • Trình quản lý LeoFS — giám sát hoạt động của các nút LeoFS Gateway và LeoFS Storage, giám sát trạng thái của các nút và kiểm tra tổng kiểm tra. Đảm bảo tính toàn vẹn dữ liệu và tính sẵn sàng lưu trữ cao.

Trong bài đăng này, chúng tôi sẽ cài đặt Leofs bằng ansible-playbook và kiểm tra S3, NFS.

Nếu cố gắng cài đặt LeoFS bằng playbook chính thức, bạn sẽ gặp nhiều lỗi khác nhau: 1,2. Trong bài đăng này tôi sẽ viết những gì cần phải làm để tránh những sai lầm này.

Nơi bạn sẽ chạy ansible-playbook, bạn cần cài đặt netcat.

Ví dụ về khoảng không quảng cáo

Khoảng không quảng cáo mẫu (trong kho lưu trữ Host.sample):

# Please check roles/common/vars/leofs_releases for available versions
[all:vars]
leofs_version=1.4.3
build_temp_path="/tmp/leofs_builder"
build_install_path="/tmp/"
build_branch="master"
source="package"

#[builder]
#172.26.9.177

# nodename of leo_manager_0 and leo_manager_1 are set at group_vars/all
[leo_manager_0]
172.26.9.176

# nodename of leo_manager_0 and leo_manager_1 are set at group_vars/all
[leo_manager_1]
172.26.9.178

[leo_storage]
172.26.9.179 [email protected]
172.26.9.181 [email protected]
172.26.9.182 [email protected]
172.26.9.183 [email protected]

[leo_gateway]
172.26.9.180 [email protected]
172.26.9.184 [email protected]

[leofs_nodes:children]
leo_manager_0
leo_manager_1
leo_gateway
leo_storage

Chuẩn bị máy chủ

Vô hiệu hóa Selinux. Tôi hy vọng cộng đồng sẽ tạo ra các chính sách Selinux cho LeoFS.

    - name: Install libselinux as prerequisite for SELinux Ansible module
      yum:
        name: "{{item}}"
        state: latest
      with_items:
        - libselinux-python
        - libsemanage-python

    - name: Disable SELinux at next reboot
      selinux:
        state: disabled

    - name: Set SELinux in permissive mode until the machine is rebooted
      command: setenforce 0
      ignore_errors: true
      changed_when: false

Cài đặt netcat и redhat-lsb-core. netcat cần thiết cho leofs-adm, redhat-lsb-core cần thiết để xác định phiên bản hệ điều hành đây.

    - name: Install Packages
      yum: name={{ item }} state=present
      with_items:
        - nmap-ncat
        - redhat-lsb-core

Tạo leofs người dùng và thêm nó vào nhóm bánh xe

    - name: Create user leofs
      group:
        name: leofs
        state: present

    - name: Allow 'wheel' group to have passwordless sudo
      lineinfile:
        dest: /etc/sudoers
        state: present
        regexp: '^%wheel'
        line: '%wheel ALL=(ALL) NOPASSWD: ALL'
        validate: 'visudo -cf %s'

    - name: Add the user 'leofs' to group 'wheel'
      user:
        name: leofs
        groups: wheel
        append: yes

Cài đặt Erlang

    - name: Remote erlang-20.3.8.23-1.el7.x86_64.rpm install with yum
      yum: name=https://github.com/rabbitmq/erlang-rpm/releases/download/v20.3.8.23/erlang-20.3.8.23-1.el7.x86_64.rpm

Bạn có thể tìm thấy phiên bản đầy đủ của Playbook Ansible đã sửa tại đây: https://github.com/patsevanton/leofs_ansible

Cài đặt, cấu hình, khởi chạy

Tiếp theo chúng ta thực hiện như đã viết ở https://github.com/leo-project/leofs_ansible không có build_leofs.yml

## Install LeoFS
$ ansible-playbook -i hosts install_leofs.yml

## Config LeoFS
$ ansible-playbook -i hosts config_leofs.yml

## Start LeoFS
$ ansible-playbook -i hosts start_leofs.yml

Kiểm tra trạng thái cụm trên LeoManager chính

leofs-adm status

Chính và Trung học có thể được nhìn thấy trong nhật ký ansible-playbook

Cài đặt bộ lưu trữ đối tượng LeoFS phân tán chịu lỗi, tương thích với các máy khách sử dụng S3, NFS

Cài đặt bộ lưu trữ đối tượng LeoFS phân tán chịu lỗi, tương thích với các máy khách sử dụng S3, NFS

Đầu ra sẽ giống như thế này

 [System Confiuration]
-----------------------------------+----------
 Item                              | Value    
-----------------------------------+----------
 Basic/Consistency level
-----------------------------------+----------
                    system version | 1.4.3
                        cluster Id | leofs_1
                             DC Id | dc_1
                    Total replicas | 2
          number of successes of R | 1
          number of successes of W | 1
          number of successes of D | 1
 number of rack-awareness replicas | 0
                         ring size | 2^128
-----------------------------------+----------
 Multi DC replication settings
-----------------------------------+----------
 [mdcr] max number of joinable DCs | 2
 [mdcr] total replicas per a DC    | 1
 [mdcr] number of successes of R   | 1
 [mdcr] number of successes of W   | 1
 [mdcr] number of successes of D   | 1
-----------------------------------+----------
 Manager RING hash
-----------------------------------+----------
                 current ring-hash | a0314afb
                previous ring-hash | a0314afb
-----------------------------------+----------

 [State of Node(s)]
-------+----------------------+--------------+---------+----------------+----------------+----------------------------
 type  |         node         |    state     | rack id |  current ring  |   prev ring    |          updated at         
-------+----------------------+--------------+---------+----------------+----------------+----------------------------
  S    | [email protected]      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:47 +0000
  S    | [email protected]      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:47 +0000
  S    | [email protected]      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:47 +0000
  S    | [email protected]      | attached     |         |                |                | 2019-12-05 10:33:58 +0000
  G    | [email protected]      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:49 +0000
  G    | [email protected]      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:49 +0000
-------+----------------------+--------------+---------+----------------+----------------+----------------------------

Tạo người dùng

Tạo người dùng leofs:

leofs-adm create-user leofs leofs

  access-key-id: 9c2615f32e81e6a1caf5
  secret-access-key: 8aaaa35c1ad78a2cbfa1a6cd49ba8aaeb3ba39eb

Danh sách người dùng:

leofs-adm get-users
user_id     | role_id | access_key_id          | created_at                
------------+---------+------------------------+---------------------------
_test_leofs | 9       | 05236                  | 2019-12-02 06:56:49 +0000
leofs       | 1       | 9c2615f32e81e6a1caf5   | 2019-12-02 10:43:29 +0000

Tạo một nhóm

Làm một cái xô

leofs-adm add-bucket leofs 9c2615f32e81e6a1caf5
OK

Danh sách xô:

 leofs-adm get-buckets
cluster id   | bucket   | owner  | permissions      | created at                
-------------+----------+--------+------------------+---------------------------
leofs_1      | leofs    | leofs  | Me(full_control) | 2019-12-02 10:44:02 +0000

Định cấu hình s3cmd

Trong lĩnh vực này HTTP Proxy server name chỉ định IP máy chủ Cổng

s3cmd --configure 

Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.

Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
Access Key [9c2615f32e81e6a1caf5]: 
Secret Key [8aaaa35c1ad78a2cbfa1a6cd49ba8aaeb3ba39eb]: 
Default Region [US]: 

Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
S3 Endpoint [s3.amazonaws.com]: 

Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
if the target S3 system supports dns based buckets.
DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: leofs

Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password: 
Path to GPG program [/usr/bin/gpg]: 

When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP, and can only be proxied with Python 2.7 or newer
Use HTTPS protocol [No]: 

On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't connect to S3 directly
HTTP Proxy server name [172.26.9.180]: 
HTTP Proxy server port [8080]: 

New settings:
  Access Key: 9c2615f32e81e6a1caf5
  Secret Key: 8aaaa35c1ad78a2cbfa1a6cd49ba8aaeb3ba39eb
  Default Region: US
  S3 Endpoint: s3.amazonaws.com
  DNS-style bucket+hostname:port template for accessing a bucket: leofs
  Encryption password: 
  Path to GPG program: /usr/bin/gpg
  Use HTTPS protocol: False
  HTTP Proxy server name: 172.26.9.180
  HTTP Proxy server port: 8080

Test access with supplied credentials? [Y/n] Y
Please wait, attempting to list all buckets...
Success. Your access key and secret key worked fine :-)

Now verifying that encryption works...
Not configured. Never mind.

Save settings? [y/N] y
Configuration saved to '/home/user/.s3cfg'

Nếu bạn gặp lỗi ERROR: S3 error: 403 (AccessDenied): Access Denied:

s3cmd put test.py s3://leofs/
upload: 'test.py' -> 's3://leofs/test.py'  [1 of 1]
 382 of 382   100% in    0s     3.40 kB/s  done
ERROR: S3 error: 403 (AccessDenied): Access Denied

Sau đó, bạn cần thay đổi signature_v3 thành True trong cấu hình s2cmd. Chi tiết trong này vấn đề.

Nếu signature_v2 là Sai thì sẽ có lỗi như sau:

WARNING: Retrying failed request: /?delimiter=%2F (getaddrinfo() argument 2 must be integer or string)
WARNING: Waiting 3 sec...
WARNING: Retrying failed request: /?delimiter=%2F (getaddrinfo() argument 2 must be integer or string)
WARNING: Waiting 6 sec...
ERROR: Test failed: Request failed for: /?delimiter=%2F

Kiểm tra tải

Tạo tệp 1GB

fallocate -l 1GB 1gb

Tải nó lên Leofs

time s3cmd put 1gb s3://leofs/
real    0m19.099s
user    0m7.855s
sys 0m1.620s

thống kê

leofs-adm du cho 1 nút:

leofs-adm du [email protected]
 active number of objects: 156
  total number of objects: 156
   active size of objects: 602954495
    total size of objects: 602954495
     ratio of active size: 100.0%
    last compaction start: ____-__-__ __:__:__
      last compaction end: ____-__-__ __:__:__

Chúng tôi thấy rằng kết luận không có nhiều thông tin.

Hãy xem tập tin này nằm ở đâu.
leofs-adm leofs/1gb ở đâu

leofs-adm whereis leofs/1gb
-------+----------------------+--------------------------------------+------------+--------------+----------------+----------------+----------------+----------------------------
 del?  |         node         |             ring address             |    size    |   checksum   |  has children  |  total chunks  |     clock      |             when            
-------+----------------------+--------------------------------------+------------+--------------+----------------+----------------+----------------+----------------------------
       | [email protected]      | 657a9f3a3db822a7f1f5050925b26270     |    976563K |   a4634eea55 | true           |             64 | 598f2aa976a4f  | 2019-12-05 10:48:15 +0000
       | [email protected]      | 657a9f3a3db822a7f1f5050925b26270     |    976563K |   a4634eea55 | true           |             64 | 598f2aa976a4f  | 2019-12-05 10:48:15 +0000

Kích hoạt NFS

Chúng tôi kích hoạt NFS trên máy chủ Leo Gateway 172.26.9.184.

Cài đặt nfs-utils trên máy chủ và máy khách

sudo yum install nfs-utils

Theo hướng dẫn chúng ta sẽ sửa lại file cấu hình /usr/local/leofs/current/leo_gateway/etc/leo_gateway.conf

protocol = nfs

Trên máy chủ 172.26.9.184 chạy rpcbind và leofs-gateway

sudo service rpcbind start
sudo service leofs-gateway restart

Trên máy chủ nơi leo_manager đang chạy, hãy tạo một nhóm cho NFS và tạo khóa để kết nối với NFS

leofs-adm add-bucket test 05236
leofs-adm gen-nfs-mnt-key test 05236 ip-адрес-nfs-клиента

Kết nối với NFS

sudo mkdir /mnt/leofs
## for Linux - "sudo mount -t nfs -o nolock <host>:/<bucket>/<token> <dir>"
sudo mount -t nfs -o nolock ip-адрес-nfs-сервера-там-где-у-вас-установлен-gateway:/bucket/access_key_id/ключ-полученный-от-gen-nfs-mnt-key /mnt/leofs
sudo mount -t nfs -o nolock 172.26.9.184:/test/05236/bb5034f0c740148a346ed663ca0cf5157efb439f /mnt/leofs

Xem dung lượng ổ đĩa thông qua máy khách NFS

Dung lượng ổ đĩa, có tính đến việc mỗi nút lưu trữ có một đĩa 40GB (3 nút đang chạy, 1 nút đính kèm):

df -hP
Filesystem                                                         Size  Used Avail Use% Mounted on
172.26.9.184:/test/05236/e7298032e78749149dd83a1e366afb328811c95b   60G  3.6G   57G   6% /mnt/leofs

Cài đặt LeoFS với 6 nút lưu trữ.

Khoảng không quảng cáo (không có người xây dựng):

# Please check roles/common/vars/leofs_releases for available versions
[all:vars]
leofs_version=1.4.3
build_temp_path="/tmp/leofs_builder"
build_install_path="/tmp/"
build_branch="master"
source="package"

# nodename of leo_manager_0 and leo_manager_1 are set at group_vars/all
[leo_manager_0]
172.26.9.177

# nodename of leo_manager_0 and leo_manager_1 are set at group_vars/all
[leo_manager_1]
172.26.9.176

[leo_storage]
172.26.9.178 [email protected]
172.26.9.179 [email protected]
172.26.9.181 [email protected]
172.26.9.182 [email protected]
172.26.9.183 [email protected]
172.26.9.185 [email protected]

[leo_gateway]
172.26.9.180 [email protected]
172.26.9.184 [email protected]

[leofs_nodes:children]
leo_manager_0
leo_manager_1
leo_gateway
leo_storage

Đầu ra trạng thái leofs-adm

Đầu ra trạng thái leofs-adm

 [System Confiuration]
-----------------------------------+----------
 Item                              | Value    
-----------------------------------+----------
 Basic/Consistency level
-----------------------------------+----------
                    system version | 1.4.3
                        cluster Id | leofs_1
                             DC Id | dc_1
                    Total replicas | 2
          number of successes of R | 1
          number of successes of W | 1
          number of successes of D | 1
 number of rack-awareness replicas | 0
                         ring size | 2^128
-----------------------------------+----------
 Multi DC replication settings
-----------------------------------+----------
 [mdcr] max number of joinable DCs | 2
 [mdcr] total replicas per a DC    | 1
 [mdcr] number of successes of R   | 1
 [mdcr] number of successes of W   | 1
 [mdcr] number of successes of D   | 1
-----------------------------------+----------
 Manager RING hash
-----------------------------------+----------
                 current ring-hash | d8ff465e
                previous ring-hash | d8ff465e
-----------------------------------+----------

 [State of Node(s)]
-------+----------------------+--------------+---------+----------------+----------------+----------------------------
 type  |         node         |    state     | rack id |  current ring  |   prev ring    |          updated at         
-------+----------------------+--------------+---------+----------------+----------------+----------------------------
  S    | [email protected]      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  S    | [email protected]      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  S    | [email protected]      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:30 +0000
  S    | [email protected]      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  S    | [email protected]      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  S    | [email protected]      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  G    | [email protected]      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:31 +0000
  G    | [email protected]      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:31 +0000
-------+----------------------+--------------+---------+----------------+----------------+----------------------------

Dung lượng ổ đĩa, có tính đến việc mỗi nút lưu trữ có một đĩa 40GB (6 nút đang chạy):

df -hP
Filesystem                                                         Size  Used Avail Use% Mounted on
172.26.9.184:/test/05236/e7298032e78749149dd83a1e366afb328811c95b  120G  3.6G  117G   3% /mnt/leofs

Nếu 5 nút lưu trữ được sử dụng

[leo_storage]
172.26.9.178 [email protected]
172.26.9.179 [email protected]
172.26.9.181 [email protected]
172.26.9.182 [email protected]
172.26.9.183 [email protected]

df -hP
172.26.9.184:/test/05236/e7298032e78749149dd83a1e366afb328811c95b  100G  3.0G   97G   3% /mnt/leofs

Nhật ký

Nhật ký được đặt trong thư mục /usr/local/leofs/current/*/log

Kênh điện tín: SDS và cụm FS

Nguồn: www.habr.com

Thêm một lời nhận xét