Powered by Blogger.

Glusterfs – hệ thống lưu trữ Linux

Các bạn đã được đọc những kiến thức ơ bản về các công nghệ lưu trữ ( Hệ Thống Lưu Trữ ), phần này các bạn sẽ được dọc những kiến thức liên quan đến đặc tính gluster bên cạnh đó các bạn sẽ được học những ý nghĩa cơ bản các lệnh trong hệ thống glusterfs.

1.Requirement:
a.Hardware:
  • Processor: Intel/AMD x86 64-bit
  • : 8GB minimum using direct-attached-storage, RAID,  EBS, and FC/Infiniband/iSCSI
  • SAN disk backends using SATA/SAS/FC disks
  • Memory: 1GB minimum
b.Network:
  • Gigabit Ethernet 10
  • Gigabit Ethernet
  • InfiniBand
c.OS:
  • RHEL 6.1,  6.1,Ubuntu 11.10
  • x86_64
  • Client & 
d.Packages:
  • wget
  • xfsprogs
  • fuse
  • fuse-libs
  • perl
  • python-ctypes
  • rrdtool-perl
  • samba
  • glustermg-backend-1.0.0alpha-1.x86_64. (optional)
e.File System:
  • Redhat khuyên bạn nên dùng XFS khi định dạng phân vùng ổ đĩa. XFS hỗ trợ metadata journaling, tạo điều kiện phục hồi dữ liệu nhanh hơn nếu có sự cố xảy ra.
  • Có thể làm việc với Ext3, Ext4, ReiserFS (chưa thử nghiệm)
f. :
  • yum -y install wget fuse fuse-libs
Download the latest GlusterFS core and FUSE RPM files to each server in your cluster.  http://www.gluster.org/download/.
  • # rpm -Uvh glusterfs-core–3.2.0-1.fc11.x86_64.rpm
  • # rpm -Uvh glusterfs-fuse–3.2.0-1.fc11.x86_64.rpm
  • # rpm -ivh glusterfs-geo-replication-3.2.0-1.fc11.x86_64.rpm
2.Features – ý nghĩa các lệnh trên glusterfs:
a.Trusted Storage Pools
Trước khi cấu hình GlusterFS volume bạn cần tạo trusted storage pool. Để thêm 1 node vào pool thì thực hiện lệnh sau:
  • gluster peer probe server
Xem trạng thái của pool
  • gluster peer status
Tách 1 node ra khỏi pool
  • gluster peer detach server
b.Chuẩn bị phân vùng
Dùng công cụ fdisk hoặc cfdisk tạo phân vùng mới (ví dụ: /dev/sda4)
  • mkfs.xfs /dev/sda4
Mount vào thư mục bất kỳ (ví dụ: /exp1) (ví dụ: /dev/sda4)
  • mount /dev/sda4 /exp1
c.Tạo volume
Distributed volume: là loại volume sẽ lưu trữ Files lần lượt vào từng bricks. Ví dụ file1 nằm trong brick 1, file 2 nằm brick 2,…. Bởi thế có thể nó có thể dẫn đến nguy cơ mất file nếu 1 trong số những brick đó hay node bị delete.
  • gluster volume create test-volume server3:/exp3 #distributed
Replicated volume: là loại volume sẽ tạo 1 bản sao của file đến những brick còn lại, phù hợp với hệ thống yêu cầu tính sẵn sàng cao và dự phòng(lưu ý số lượng brick phải bằng số lượng replica).
  • gluster volume create test-volume replica 2 transport tcp server1:/exp1 server2:/exp2
Stripe volume: là loại volume chia dữ liệu thành những phần khác nhau sau đó lưu trữ ở những brick khác nhau, phù hợp với những môi trường yêu cầu hiệu năng, đặc biệt truy cập những file lớn. Tuy nhiên lưu ý 1 node hay 1 brick bị delete sẽ dẫn đến volume không thể hoạt động được.(số lượng stripe phải bằng số lượng brick).
  • gluster volume create test-volume stripe 2 transport tcp server1:/exp1 server2:/exp2
Distributed stripe volume: là loại volume kết hợp từ hai loại Distributed và stripe. Do đó nó có hầu hết những thuộc tính hai loại trên và khi 1 node và 1 brick delete đồng nghĩa volume cũng không thể hoạt động được nữa.
  • gluster volume create test-volume stripe 4 transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4
(Lưu ý số lượng brick là một bội số của số lượng stripe)
Distributed replicated: Tuơng tự là loại volume kết hợp từ distributed và replicated phù hợp cho những môi trường lưu trữ dữ liệu quan trọng. Số lượng brick là một bội số số lượng replica.
  • gluster volume create test-volume replica 2 transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4
Sau khi tạo volume, một thao tác không thể thiếu là start volume
  • gluster volume start test-volume
Để xem thông tin những volume đã tạo
  • gluster volume info all
Dừng volume
  • gluster volume stop test-volume
Xóa volume
  • gluster volume delete test-volume
d.Mount volume
Mount dùng native client
  • mount -t glusterfs :
  • mount -t glusterfs ubuntu64:test-volume /mnt/gluster
Automount: Chỉnh /etc/fstab
  • ubuntu64:test-volume /mnt/glusterfs glusterfs defaults,_netdev 0 0
Mount dùng 
  • mount -o mountproto=tcp -t nfs ubuntu64:test-volume /mnt/gluster
Add thêm brick vào volume
  • gluster volume add-brick test-volume client:/test #add brick
Remove brick ra khỏi volume
  • gluster volume remove-brick test-volume client:/test
e.Migrate volume:
Bạn có thể di chuyển dữ liệu từ 1 brick đến 1 brick khác. Vi dụ sau sẽ mô tả làm sao để di chuyển dữ liệu từ brick ext3 đến ext5.
  • gluster volume replace-brick test-volume server3:/exp3 server5:exp5 start
Abort migrate(hủy bỏ).
  • gluster volume replace-brick test-volume server3:/exp3 server5:exp5 abort
Check status
  • gluster volume replace-brick test-volume server3:/exp3 server5:/exp5 status
Commit
  • gluster volume replace-brick test-volume server3:/exp3 server5:/exp5 commit
f.Rebalance Volume
Khi bạn thêm 1 brick mới muốn đồng bộ dữ liệu cho brick mới thêm mà ko cần di chuyển dữ liệu thì sử dụng:
  • gluster volume rebalance VOLNAME fix-layout start
Khi bạn thêm hay xóa 1 brick muốn đồng bộ dữ liệu và di chuyển dữ liệu đã tồn tại thì sử dụng:
  • gluster volume rebalance VOLNAME migrate-data start
Khi bạn cần cả 2 thì dùng lệnh sau:
  • gluster volume rebalance VOLNAME start
3. GEO REPLICATION
Khi bạn muốn đồng bộ dữ liệu từ 1 volume đến một vị trí khác có thể là thư mục hay 1 volume khác thì GEO là một giải pháp tốt trong trường hợp này.  
MASTER —> SLAVE
Trên master:
  • ssh-keygen -f /etc/glusterd/geo-replication/secret.pem
  • gluster volume geo-replication Volume1 example.com:/data/remote_dir start
#Volume1: tên volume đã START
#example.com:/data/remote_dir: đường dẫn đến server làm slave
Trên slave:
Copy nội dung /etc/glusterd/geo-replication/secret.pem.pub to /root/.ssh/authorized_keys
#Lưu ý: Có thể sử dụng volume để làm geo-replication slave
#Lệnh kiểm tra trạng thái geo-replication
  • gluster volume geo-replication test-volume gateway:geo-volume status
4. MONITORING
Cung cấp thông tin I/O của mỗi brick trong từng tác vụ của volume. Giúp phát hiện bottleneck trong hệ thống.
  • gluster volume profile {start|info|stop}
Cho phép ta xem được các thông số sau của mỗi brick: read, write, file open calls, file read calls, file write calls, directory open calls, và directory real calls.
  • gluster volume top {[open|read|write|opendir|readdir] |[read-perf|write-perf bs count ]} [brick ] [list-cnt ]
Ví dụ:
  • gluster volume top test-volume open brick server:/export/ list-cnt 10
  • gluster volume top test-volume read brick server:/export list-cnt 10
  • gluster volume top test-volume read-perf bs 256 count 1 brick server:/export/ list-cnt 10
5. QUOTA
  • volume quota <enable|disable|limit-usage|list|remove [path] [value]
Ví dụ:
  • gluster volume quota test-volume enable
    Blogger Comment
    Facebook Comment