Distributed_storage
Chapter 66: Distributed Storage Systems
Section titled “Chapter 66: Distributed Storage Systems”Scaling Storage with GlusterFS, Ceph, and Distributed Solutions
Section titled “Scaling Storage with GlusterFS, Ceph, and Distributed Solutions”66.1 Distributed Storage Fundamentals
Section titled “66.1 Distributed Storage Fundamentals”Understanding Distributed Storage
Section titled “Understanding Distributed Storage”Distributed storage spreads data across multiple servers to provide scalability, fault tolerance, and high availability.
DISTRIBUTED STORAGE ARCHITECTURE+------------------------------------------------------------------+| || ┌──────────────────────────────────────────────────────────┐ │| │ DISTRIBUTED STORAGE BENEFITS │ │| │ │ │| │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │| │ │ SCALE │ │ HIGH │ │ FAULT │ │ │| │ │ OUT │ │ AVAILABILITY│ │ TOLERANCE │ │ │| │ ├─────────────┤ ├─────────────┤ ├─────────────┤ │ │| │ │ │ │ │ │ │ │ │| │ │ Add nodes │ │ Multiple │ │ Replicate │ │ │| │ │ to scale │ │ copies of │ │ data across│ │ │ │ │ capacity │ │ data │ │ nodes │ │ │ │ │ │ │ │ │ │ │ │ │ │ Linear │ │ Automatic │ │ Self- │ │ │| │ │ scaling │ │ failover │ │ healing │ │ │| │ │ │ │ │ │ │ │ │| │ └─────────────┘ └─────────────┘ └─────────────┘ │ │| │ │ │| │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │| │ │PERFORMANCE │ │ GLOBAL │ │ COST │ │ │| │ │ │ │ ACCESS │ │ EFFECTIVE │ │ │| │ ├─────────────┤ ├─────────────┤ ├─────────────┤ │ │| │ │ │ │ │ │ │ │ │| │ │ Parallel │ │ Single │ │ Use com- │ │ │| │ │ I/O across│ │ namespace │ │ modity │ │ │| │ │ multiple │ │ from any │ │ hardware │ │ │| │ │ nodes │ │ location │ │ │ │ │| │ │ │ │ │ │ No SAN │ │ │| │ │ │ │ │ │ required │ │ │| │ └─────────────┘ └─────────────┘ └─────────────┘ │ │| │ │ │| └──────────────────────────────────────────────────────────┘ │| |+------------------------------------------------------------------+Distributed Storage Types
Section titled “Distributed Storage Types” STORAGE TYPES COMPARISON+------------------------------------------------------------------+| || ┌──────────────────────────────────────────────────────────────┐ ││ │ BLOCK STORAGE │ ││ │ ┌────────────────────────────────────────────────────────┐ │ ││ │ │ │ │ ││ │ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ │ ││ │ │ │Block │ │Block │ │Block │ │Block │ │ │ ││ │ │ │ Dev │ │ Dev │ │ Dev │ │ Dev │ │ │ │| │ │ └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ │ │ ││ │ │ └──────────┼──────────┼──────────┘ │ │ ││ │ │ ▼ ▼ │ │ ││ │ │ ┌────────────────────────────────┐ │ │ ││ │ │ │ Distributed Block Service │ │ │ ││ │ │ │ (Ceph RBD, Sheepdog) │ │ │ ││ │ │ └────────────────────────────────┘ │ │ ││ │ │ │ │ ││ │ │ Use Cases: Virtual machines, Databases │ │ ││ │ │ │ │ ││ │ └────────────────────────────────────────────────────────┘ │ ││ └──────────────────────────────────────────────────────────────┘ │| || ┌──────────────────────────────────────────────────────────────┐ ││ │ FILE STORAGE │ ││ │ ┌────────────────────────────────────────────────────────┐ │ ││ │ │ │ │ ││ │ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ │ ││ │ │ │ File │ │ File │ │ File │ │ File │ │ │ ││ │ │ │ │ │ │ │ │ │ │ │ │ ││ │ │ └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ │ │ ││ │ │ └──────────┼──────────┼──────────┘ │ │ ││ │ │ ▼ ▼ │ │ ││ │ │ ┌────────────────────────────────┐ │ │ ││ │ │ │ Distributed File System │ │ │ ││ │ │ │ (GlusterFS, HDFS, CephFS) │ │ │ ││ │ │ └────────────────────────────────┘ │ │ ││ │ │ │ │ ││ │ │ Use Cases: NFS, Samba, Shared file storage │ │ ││ │ │ │ │ ││ │ └────────────────────────────────────────────────────────┘ │ ││ └──────────────────────────────────────────────────────────────┘ │| || ┌──────────────────────────────────────────────────────────────┐ ││ │ OBJECT STORAGE │ ││ │ ┌────────────────────────────────────────────────────────┐ │ ││ │ │ │ │ ││ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ ││ │ │ │ Object │ │ Object │ │ Object │ │ │ ││ │ │ │ (data) │ │ (data) │ │ (data) │ │ │ ││ │ │ └────┬────┘ └────┬────┘ └────┬────┘ │ │ ││ │ │ └────────────┼────────────┘ │ │ ││ │ │ ▼ │ │ ││ │ │ ┌─────────────────────┐ │ │ ││ │ │ │ Object Storage │ │ │ ││ │ │ │ (Ceph RGW, S3) │ │ │ ││ │ │ └─────────────────────┘ │ │ ││ │ │ │ │ ││ │ │ Use Cases: Cloud storage, Backups, Media │ │ ││ │ │ │ │ ││ │ └────────────────────────────────────────────────────────┘ │ ││ └──────────────────────────────────────────────────────────────┘ │| |+------------------------------------------------------------------+66.2 GlusterFS
Section titled “66.2 GlusterFS”GlusterFS Architecture
Section titled “GlusterFS Architecture” GLUSTERFS ARCHITECTURE+------------------------------------------------------------------+| || ┌──────────────────────────────────────────────────────────┐ │| │ CLIENT LAYER │ │| │ │ │| │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │| │ │ App 1 │ │ App 2 │ │ App 3 │ │ │| │ └────┬─────┘ └────┬─────┘ └────┬─────┘ │ │| │ │ │ │ │ │| │ └───────────────┼───────────────┘ │ │| │ ▼ │ │| │ ┌────────────────┐ │ │| │ │ GlusterFS │ │ │| │ │ Client (FUSE) │ │ │| │ └────────┬───────┘ │ │| │ │ │ │| └────────────────────────┼──────────────────────────────────┘ │| │ || ▼ || ┌──────────────────────────────────────────────────────────┐ │| │ SERVER LAYER │ │| │ │ │| │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │| │ │ Node 1 │ │ Node 2 │ │ Node 3 │ │ │| │ │ ┌───────┐ │ │ ┌───────┐ │ │ ┌───────┐ │ │ │| │ │ │Brick │ │ │ │Brick │ │ │ │Brick │ │ │ │| │ │ │/data1 │ │ │ │/data2 │ │ │ │/data3 │ │ │ │| │ │ └───────┘ │ │ └───────┘ │ │ └───────┘ │ │ │| │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │ │| │ │ │ │ │ │| │ └─────────────────┼─────────────────┘ │ │| │ ▼ │ │| │ ┌────────────────┐ │ │| │ │ GlusterD (GM) │ │ │| │ │ Management │ │ │| │ └────────────────┘ │ │| │ │ │| └──────────────────────────────────────────────────────────┘ || |+------------------------------------------------------------------+GlusterFS Installation and Setup
Section titled “GlusterFS Installation and Setup”# =============================================================================# INSTALLATION (Ubuntu)# =============================================================================
# Add GlusterFS repositorywget -O - https://download.gluster.org/pub/gluster/glusterfs/3.12/3.12.1/rsa.pub | apt-key add -echo "deb https://download.gluster.org/pub/gluster/glusterfs/3.12/3.12.1/ubuntu/$(lsb_release -cs)/amd64/" \ | tee /etc/apt/sources.list.d/gluster.list
apt-get updateapt-get install glusterfs-server glusterfs-client glusterfs-common
# Enable and startsystemctl enable glusterdsystemctl start glusterd
# =============================================================================# PROBE NODES# =============================================================================
# From node1, probe other nodesgluster peer probe node2gluster peer probe node3
# Check peer statusgluster peer status
# =============================================================================# CREATE VOLUME# =============================================================================
# Create distributed volume (no replication)gluster volume create gv0 node1:/data1 node2:/data2 node3:/data3
# Create replicated volume (3 copies)gluster volume create gv0 replica 3 \ node1:/data1 node2:/data2 node3:/data3
# Create distributed-replicated (2x2)gluster volume create gv0 replica 2 \ node1:/data1 node2:/data2 \ node3:/data3 node4:/data4
# Start volumegluster volume start gv0
# View volume infogluster volume infoGlusterFS Client Mount
Section titled “GlusterFS Client Mount”# =============================================================================# MOUNT GLUSTERFS# =============================================================================
# Mount using GlusterFS clientmount -t glusterfs node1:/gv0 /mnt/glusterfs
# Add to /etc/fstabnode1:/gv0 /mnt/glusterfs glusterfs defaults,_netdev 0 0
# Mount using NFSmount -t nfs node1:/gv0 /mnt/nfs
# Mount using CIFS/Sambamount -t cifs //server/share /mnt -o username=user
# View mounted volumesdf -h | grep glusterGlusterFS Management
Section titled “GlusterFS Management”# =============================================================================# VOLUME MANAGEMENT# =============================================================================
# Start/Stop volumegluster volume start gv0gluster volume stop gv0
# Add bricks to volumegluster volume add-brick gv0 node4:/data4
# Remove brick (with rebalance)gluster volume remove-brick gv0 node4:/data4 startgluster volume remove-brick gv0 node4:/data4 statusgluster volume remove-brick gv0 node4:/data4 commit
# Rebalancegluster volume rebalance gv0 start
# Set volume optionsgluster volume set gv0 performance.cache-size 256MBgluster volume set gv0 network.ping-timeout 10
# View volume statusgluster volume statusgluster volume status gv0 detail66.3 Ceph
Section titled “66.3 Ceph”Ceph Architecture
Section titled “Ceph Architecture” CEPH ARCHITECTURE+------------------------------------------------------------------+| || ┌──────────────────────────────────────────────────────────┐ │| │ CEPH CLIENT │ │| │ │ │| │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │| │ │ Kernel │ │ librados │ │ RGW (S3) │ │ │| │ │ Module │ │ (Library) │ │ (Swift) │ │ │| │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │| │ │ │ │ │ │| └──────────┼──────────────────┼──────────────────┼──────────┘ || │ │ │ || └──────────────────┼──────────────────┘ || ▼ || ┌──────────────────────────────────────────────────────────┐ │| │ MONITORS (Mons) │ │| │ │ │| │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │| │ │ Mon1 │◄──│ Mon2 │◄──│ Mon3 │ │ │| │ │ │ │ │ │ │ │ │| │ └─────────┘ └─────────┘ └─────────┘ │ ││ │ Cluster state, PGs, maps │ │| └──────────────────────────┬──────────────────────────────┘ || │ || ▼ || ┌──────────────────────────────────────────────────────────┐ │| │ MDS (Metadata Server) Cluster │ │| │ ┌─────────┐ ┌─────────┐ │ │| │ │ MDS1 │◄──│ MDS2 │ │ │| │ │ Active │ │ Standby │ │ │| │ └─────────┘ └─────────┘ │ │| │ File metadata, POSIX compliance │ │| └──────────────────────────┬──────────────────────────────┘ || │ || ▼ || ┌──────────────────────────────────────────────────────────┐ │| │ OSDs (Object Storage Daemons) │ │| │ │ │| │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │ │| │ │ OSD.1 │ │ OSD.2 │ │ OSD.3 │ │ OSD.4 │ │ │| │ │(Disk1) │ │(Disk2) │ │(Disk3) │ │(Disk4) │ │ │| │ └───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘ │ │| │ └───────────┼───────────┼───────────┘ │ │| │ │ │ │ │| │ ┌──────┴───────────┴──────┐ │ │| │ │ CRUSH Algorithm │ │ │| │ │ (Data Distribution) │ │ │| │ └─────────────────────────┘ │ │| │ │ │| └──────────────────────────────────────────────────────────┘ │| |+------------------------------------------------------------------+Ceph Installation
Section titled “Ceph Installation”# =============================================================================# INSTALLATION (Ubuntu)# =============================================================================
# Add Ceph repositorywget -q -O- 'https://download.ceph.com/keys/release.asc' | apt-key add -echo "deb https://download.ceph.com/packages/ceph-pacific/ubuntu $(lsb_release -cs) main" | \ tee /etc/apt/sources.list.d/ceph.list
apt-get updateapt-get install ceph-mon ceph-osd ceph-mds ceph-radosgw
# =============================================================================# DEPLOY WITH CEPH-ADMIN# =============================================================================
# On admin node, create clusterceph-deploy new node1 node2 node3
# Install Cephceph-deploy install node1 node2 node3
# Deploy monitorsceph-deploy mon create node1 node2 node3
# Deploy OSDsceph-deploy osd create --data /dev/sdb node1ceph-deploy osd create --data /dev/sdb node2ceph-deploy osd create --data /dev/sdb node3
# Gather keysceph-deploy admin node1 node2 node3
# Check healthceph healthceph -sCeph Pools and RBD
Section titled “Ceph Pools and RBD”# =============================================================================# POOL MANAGEMENT# =============================================================================
# Create poolceph osd pool create mypool 128 128
# Set pool sizeceph osd pool set mypool size 3ceph osd pool set mypool min_size 2
# View poolsceph osd lspoolsceph osd pool stats mypool
# =============================================================================# RBD (RADOS BLOCK DEVICE)# =============================================================================
# Create RBD imagerbd create mypool/myimage --size 10G
# Map RBD devicerbd map mypool/myimage
# Create filesystemmkfs.ext4 /dev/rbd0
# Mountmount /dev/rbd0 /mnt/rbd
# Or use kernel modulemodprobe rbdrbd map mypool/myimage
# Resize imagerbd resize mypool/myimage --size 20GCeph Filesystem (CephFS)
Section titled “Ceph Filesystem (CephFS)”# =============================================================================# CEPHFS SETUP# =============================================================================
# Create MDSceph-deploy mds create node1
# Create filesystemceph fs new cephfs metadata data
# Mount CephFSmount -t ceph node1:6789:/ /mnt/cephfs \ -o name=admin,secret=$(ceph auth get-key client.admin)
# Add to fstabnode1:6789:/ /mnt/cephfs ceph \ name=admin,secretfile=/etc/ceph/secret.key,noatime 0 066.4 Distributed Storage Comparison
Section titled “66.4 Distributed Storage Comparison”Feature Comparison
Section titled “Feature Comparison” DISTRIBUTED STORAGE COMPARISON+==================================================================+| || Feature | GlusterFS | Ceph | MooseFS || ──────────────────┼──────────────┼────────────────┼─────────────|| Type | File | Block/File/ | File || | | Object | || Min Nodes | 1 | 3 | 3 || Replication | Configurable | Configurable | Configurable|| Erasure Coding | Yes | Yes | No || Geo-replication | Yes | Yes | Limited || Snapshots | Yes | Yes | Yes || Quotas | Yes | Yes | Yes || NFS/SMB | Native | Via RGW | Native || S3/Swift API | No | Yes | No || Learning Curve | Low | High | Medium || Performance | Good | Excellent | Good || |+==================================================================+66.5 Distributed Storage Best Practices
Section titled “66.5 Distributed Storage Best Practices”Summary Checklist
Section titled “Summary Checklist” DISTRIBUTED STORAGE BEST PRACTICES+------------------------------------------------------------------+| || ┌─────────────────────────────────────────────────────────────┐ │| │ PLANNING │ │| ├─────────────────────────────────────────────────────────────┤ │| │ □ Choose appropriate storage type (block/file/object) │ │| │ □ Plan capacity with growth projections │ │| │ □ Design for expected failure scenarios │ │| │ □ Consider network topology │ │| └─────────────────────────────────────────────────────────────┘ │| || ┌─────────────────────────────────────────────────────────────┐ │| │ CONFIGURATION │ │| ├─────────────────────────────────────────────────────────────┤ │| │ □ Use recommended replication factor (minimum 3) │ │| │ □ Enable data balancing │ │| │ □ Configure appropriate cache settings │ │| │ □ Set up monitoring and alerts │ │| └─────────────────────────────────────────────────────────────┘ │| || ┌─────────────────────────────────────────────────────────────┐ │| │ MONITORING │ │| ├─────────────────────────────────────────────────────────────┤ │| │ □ Monitor disk usage │ │| │ □ Monitor cluster health │ │| │ □ Set up performance metrics │ │| │ □ Monitor network traffic │ │| └─────────────────────────────────────────────────────────────┘ │| || ┌─────────────────────────────────────────────────────────────┐ │| │ MAINTENANCE │ │| ├─────────────────────────────────────────────────────────────┤ │| │ □ Regular health checks │ │| │ □ Plan for hardware failures │ │| │ □ Test disaster recovery procedures │ │| │ □ Keep documentation updated │ │| └─────────────────────────────────────────────────────────────┘ │| |+------------------------------------------------------------------+End of Chapter 66: Distributed Storage Systems