No menu items!
No menu items!
More

    [Swift] – Phần 6: Hoàn tất cài đặt OpenStack Swift trên Controller Node

    1. Tổng quan.

    Phần này sẽ hướng dẫn bạn hoàn tất quá trình cài đặt OpenStack Swift trên Ubuntu.

    Tài liệu tham khảo: https://docs.openstack.org/swift/latest/install/

    2. Cấu hình.

    Tải file cấu hình /etc/swift/swift.conf từ kho lưu trữ mã nguồn của Object Storage.

    curl -o /etc/swift/swift.conf \
      https://opendev.org/openstack/swift/raw/branch/master/etc/swift.conf-sample

    Chỉnh sửa file /etc/swift/swift.conf như sau.

    Trong phần [swift-hash], cấu hình tiền tố và hậu tố đường dẫn hash cho môi trường của bạn. Thay thế HASH_PATH_PREFIX và HASH_PATH_SUFFIX bằng các giá trị duy nhất.

    [swift-hash]
    #...
    swift_hash_path_suffix = HASH_PATH_SUFFIX
    swift_hash_path_prefix = HASH_PATH_PREFIX

    Giá trị HASH_PATH_PREFIX và HASH_PATH_SUFFIX trong file cấu hình swift.conf của OpenStack Swift được định nghĩa bởi người dùng.

    Chúng là các giá trị duy nhất được sử dụng để tạo ra hash đường dẫn cho các object trong Swift. Điều này giúp đảm bảo rằng mỗi object có một địa chỉ duy nhất trong hệ thống.

    Lưu ý rằng bạn nên giữ bí mật những giá trị này và không thay đổi chúng sau khi đã đặt, vì việc thay đổi chúng có thể dẫn đến việc không thể truy cập được các object đã lưu trữ.

    Có thể dùng đoạn script sau để tạo mã swift_hash_path_suffix và swift_hash_path_prefix.

    #!/bin/bash
    # Generate a random string for swift_hash_path_suffix
    swift_hash_path_suffix=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '')
    
    # Generate a random string for swift_hash_path_prefix
    swift_hash_path_prefix=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '')
    
    echo "swift_hash_path_suffix = $swift_hash_path_suffix"
    echo "swift_hash_path_prefix = $swift_hash_path_prefix"

    Ví dụ.

    shell> bash hash.sh
    swift_hash_path_suffix = RXJLT9WdNblvLl0SSMistVn4zFvym4ky
    swift_hash_path_prefix = sQt4TltQsjPYehXNxnRz9wDw3Rsjaam9

    Trong phần [storage-policy:0], cấu hình chính sách lưu trữ mặc định: name = Policy-0 và default = yes.

    [storage-policy:0]
    #...
    name = Policy-0
    default = yes

    Xóa bỏ hoặc comment aliases = yellow, orange lại nhé.

    # aliases = yellow, orange

    Sao chép file swift.conf vào thư mục /etc/swift trên mỗi storage node và tất cả các node đang chạy dịch vụ proxy.

    scp /etc/swift/swift.conf root@10.0.0.51:/etc/swift
    scp /etc/swift/swift.conf root@10.0.0.52:/etc/swift

    Trên tất cả các node, đảm bảo quyền sở hữu phù hợp của thư mục cấu hình: chown -R root:swift /etc/swift.

    chown -R root:swift /etc/swift
    ssh root@10.0.0.51 'chown -R root:swift /etc/swift'
    ssh root@10.0.0.52 'chown -R root:swift /etc/swift'

    Trên mỗi storage node chạy các lệnh sau để kích hoạt và bắt đầu dịch vụ.

    sudo systemctl enable swift-account.service swift-account-auditor.service \
      swift-account-reaper.service swift-account-replicator.service
    
    sudo systemctl restart swift-account.service swift-account-auditor.service \
      swift-account-reaper.service swift-account-replicator.service
    
    sudo systemctl enable swift-container.service \
      swift-container-auditor.service swift-container-replicator.service \
      swift-container-updater.service
    
    sudo systemctl restart swift-container.service \
      swift-container-auditor.service swift-container-replicator.service \
      swift-container-updater.service
    
    sudo systemctl enable swift-object.service swift-object-auditor.service \
      swift-object-replicator.service swift-object-updater.service
    
    sudo systemctl restart swift-object.service swift-object-auditor.service \
      swift-object-replicator.service swift-object-updater.service

    Xác minh lại trạng thái nhé.

    sudo systemctl status swift-account.service swift-account-auditor.service \
      swift-account-reaper.service swift-account-replicator.service
    
    sudo systemctl status swift-container.service \
      swift-container-auditor.service swift-container-replicator.service \
      swift-container-updater.service
    
    sudo systemctl status swift-object.service swift-object-auditor.service \
      swift-object-replicator.service swift-object-updater.service

    Trên node controller và bất kỳ node nào khác đang chạy dịch vụ proxy, khởi động lại dịch vụ proxy Object Storage cùng với các phụ thuộc của nó.

    sudo systemctl enable swift-proxy.service memcached.service
    sudo systemctl restart swift-proxy.service memcached.service

    Kiểm tra lại trạng thái swift-proxy và memcached.

    sudo systemctl status swift-proxy.service | grep active
    sudo systemctl status memcached.service | grep active

    Trên các storage node, khởi động các dịch vụ Object Storage.

    swift-init all restart

    Ghi chú: Storage node chạy nhiều dịch vụ Object Storage và lệnh swift-init giúp quản lý chúng dễ dàng hơn. Bạn có thể bỏ qua lỗi từ các dịch vụ không chạy trên storage node.

    Bài viết gần đây

    spot_img

    Related Stories

    Leave A Reply

    Please enter your comment!
    Please enter your name here

    Đăng ký nhận thông tin bài viết qua email