Gosod storfa gwrthrychau LeoFS sy'n goddef fai, sy'n gydnaws â chleientiaid sy'n defnyddio S3, NFS

Yn ôl Rhwyd agored: LeoFS — storio gwrthrychau gwasgaredig sy'n goddef namau LeoFS, yn gydnaws â chleientiaid sy'n defnyddio'r Amazon S3 API a REST-API, ac mae hefyd yn cefnogi modd gweinydd NFS. Mae yna optimeiddiadau ar gyfer storio gwrthrychau bach a mawr iawn, mae yna fecanwaith storio mewnol, ac mae'n bosibl dyblygu storio rhwng canolfannau data. Mae nodau'r prosiect yn cynnwys cyflawni 99.9999999% o ddibynadwyedd trwy atgynhyrchu copïau dyblyg yn ddiangen a dileu un pwynt methiant. Mae cod y prosiect wedi'i ysgrifennu yn Erlang.

Mae LeoFS yn cynnwys tair cydran:

  • Storio LeoFS — yn gwasanaethu gweithrediadau o ychwanegu, adalw a dileu gwrthrychau a metadata, yn gyfrifol am berfformio atgynhyrchu, adfer a ciwio ceisiadau cleient.
  • Porth LeoFS - yn gwasanaethu ceisiadau HTTP ac yn ailgyfeirio ymatebion i gleientiaid gan ddefnyddio REST-API neu S3-API, yn sicrhau bod y data mwyaf poblogaidd yn cael ei storio yn y cof ac ar ddisg.
  • Rheolwr LeoFS — yn monitro gweithrediad nodau LeoFS Gateway a Storage LeoFS, yn monitro statws nodau ac yn gwirio symiau gwirio. Yn gwarantu cywirdeb data ac argaeledd storio uchel.

Yn y swydd hon byddwn yn gosod Leofs gan ddefnyddio ansible-playbook a phrofi S3, NFS.

Os ceisiwch osod LeoFS gan ddefnyddio'r llyfrau chwarae swyddogol, fe welwch wallau amrywiol: 1,2. Yn y swydd hon byddaf yn ysgrifennu beth sydd angen ei wneud i osgoi'r camgymeriadau hyn.

Lle byddwch chi'n rhedeg ansible-playbook, mae angen i chi osod netcat.

Enghraifft rhestr

Rhestr enghreifftiol (yn y storfa hosts.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 leofs_module_nodename=S0@172.26.9.179
172.26.9.181 leofs_module_nodename=S0@172.26.9.181
172.26.9.182 leofs_module_nodename=S0@172.26.9.182
172.26.9.183 leofs_module_nodename=S0@172.26.9.183

[leo_gateway]
172.26.9.180 leofs_module_nodename=G0@172.26.9.180
172.26.9.184 leofs_module_nodename=G0@172.26.9.184

[leofs_nodes:children]
leo_manager_0
leo_manager_1
leo_gateway
leo_storage

Paratoi gweinydd

Analluogi Selinux. Rwy'n gobeithio y bydd y gymuned yn creu polisïau Selinux ar gyfer 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

Gosod netcat и redhat-lsb-core. netcat angen ar gyfer leofs-adm, redhat-lsb-core angen i benderfynu ar y fersiwn OS yma.

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

Creu leofs defnyddiwr a'i ychwanegu at y grŵp olwynion

    - 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

Gosod 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

Mae fersiwn llawn y llyfr chwarae Ansible wedi'i gywiro i'w weld yma: https://github.com/patsevanton/leofs_ansible

Gosod, ffurfweddu, lansio

Nesaf rydym yn perfformio fel yr ysgrifennwyd yn https://github.com/leo-project/leofs_ansible heb 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

Gwirio statws y clwstwr ar LeoManager Cynradd

leofs-adm status

Mae Cynradd ac Uwchradd i'w gweld yn y logiau llyfr chwarae anos

Gosod storfa gwrthrychau LeoFS sy'n goddef fai, sy'n gydnaws â chleientiaid sy'n defnyddio S3, NFS

Gosod storfa gwrthrychau LeoFS sy'n goddef fai, sy'n gydnaws â chleientiaid sy'n defnyddio S3, NFS

Rhywbeth fel hyn fydd yr allbwn

 [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    | S0@172.26.9.179      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:47 +0000
  S    | S0@172.26.9.181      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:47 +0000
  S    | S0@172.26.9.182      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:47 +0000
  S    | S0@172.26.9.183      | attached     |         |                |                | 2019-12-05 10:33:58 +0000
  G    | G0@172.26.9.180      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:49 +0000
  G    | G0@172.26.9.184      | running      |         | a0314afb       | a0314afb       | 2019-12-05 10:33:49 +0000
-------+----------------------+--------------+---------+----------------+----------------+----------------------------

Creu defnyddiwr

Creu defnyddiwr leofs:

leofs-adm create-user leofs leofs

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

Rhestr o ddefnyddwyr:

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

Creu Bwced

Wedi gwneud bwced

leofs-adm add-bucket leofs 9c2615f32e81e6a1caf5
OK

Rhestr bwced:

 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

Ffurfweddu s3cmd

Yn y cae HTTP Proxy server name nodi IP gweinydd Porth

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'

Os cewch y gwall GWALL: Gwall S3: 403 (Gwrthodwyd Mynediad): Gwrthodwyd Mynediad:

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

Yna mae angen i chi newid llofnod_v3 i Gwir yn y ffurfwedd s2cmd. Manylion yn hyn mater.

Os yw llofnod_v2 yn Anwir, yna bydd gwall fel hyn:

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

Profi llwyth

Creu ffeil 1GB

fallocate -l 1GB 1gb

Llwythwch ef i Leofs

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

Ystadegau

leofs-adm du am 1 nod:

leofs-adm du S0@172.26.9.179
 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: ____-__-__ __:__:__

Gwelwn nad yw'r casgliad yn addysgiadol iawn.

Gadewch i ni weld ble mae'r ffeil hon wedi'i lleoli.
leofs-adm lle mae leofs/1gb

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

Actifadu NFS

Rydym yn actifadu NFS ar weinydd Leo Gateway 172.26.9.184.

Gosod nfs-utils ar y gweinydd a'r cleient

sudo yum install nfs-utils

Yn ôl y cyfarwyddiadau, byddwn yn cywiro'r ffeil ffurfweddu /usr/local/leofs/current/leo_gateway/etc/leo_gateway.conf

protocol = nfs

Ar y gweinydd 172.26.9.184 rhedeg rpcbind a leofs-gateway

sudo service rpcbind start
sudo service leofs-gateway restart

Ar y gweinydd lle mae leo_manager yn rhedeg, creu bwced ar gyfer NFS a chynhyrchu allwedd ar gyfer cysylltu â NFS

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

Yn cysylltu â 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

Gweld gofod disg trwy gleient NFS

Gofod disg, gan gymryd i ystyriaeth bod gan bob nod storio ddisg 40GB (3 nod rhedeg, 1 nod ynghlwm):

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

Gosod LeoFS gyda 6 nod storio.

Rhestr (heb adeiladwr):

# 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 leofs_module_nodename=S0@172.26.9.178
172.26.9.179 leofs_module_nodename=S0@172.26.9.179
172.26.9.181 leofs_module_nodename=S0@172.26.9.181
172.26.9.182 leofs_module_nodename=S0@172.26.9.182
172.26.9.183 leofs_module_nodename=S0@172.26.9.183
172.26.9.185 leofs_module_nodename=S0@172.26.9.185

[leo_gateway]
172.26.9.180 leofs_module_nodename=G0@172.26.9.180
172.26.9.184 leofs_module_nodename=G0@172.26.9.184

[leofs_nodes:children]
leo_manager_0
leo_manager_1
leo_gateway
leo_storage

Statws leofs-adm allbwn

Statws leofs-adm allbwn

 [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    | S0@172.26.9.178      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  S    | S0@172.26.9.179      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  S    | S0@172.26.9.181      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:30 +0000
  S    | S0@172.26.9.182      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  S    | S0@172.26.9.183      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  S    | S0@172.26.9.185      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:29 +0000
  G    | G0@172.26.9.180      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:31 +0000
  G    | G0@172.26.9.184      | running      |         | d8ff465e       | d8ff465e       | 2019-12-06 05:18:31 +0000
-------+----------------------+--------------+---------+----------------+----------------+----------------------------

Gofod disg, gan ystyried bod gan bob nod storio ddisg 40GB (6 nod rhedeg):

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

Os defnyddir 5 nod storio

[leo_storage]
172.26.9.178 leofs_module_nodename=S0@172.26.9.178
172.26.9.179 leofs_module_nodename=S1@172.26.9.179
172.26.9.181 leofs_module_nodename=S2@172.26.9.181
172.26.9.182 leofs_module_nodename=S3@172.26.9.182
172.26.9.183 leofs_module_nodename=S4@172.26.9.183

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

Logiau

Mae logiau wedi'u lleoli mewn cyfeirlyfrau /usr/local/leofs/current/*/log

Sianel telegram: SDS a Clwstwr FS

Ffynhonnell: hab.com

Prynu gwesteio dibynadwy ar gyfer gwefannau sydd â diogelwch DDoS, gweinyddwyr VPS VDS 🔥 Prynu cynnal gwefannau dibynadwy gyda diogelwch DDoS, gweinyddion VPS VDS | ProHoster