Skip to content

附录 A 常用命令速查

A.1 Linux 基础命令

bash
# 查看磁盘
lsblk
fdisk -l
df -h

# 查看网络
ip addr
ip route
ss -tlnp

# 查看进程和服务
ps aux | grep gluster
systemctl status glusterd
systemctl status nfs-ganesha
systemctl status keepalived

# 查看日志
journalctl -u glusterd -f
journalctl -u nfs-ganesha -f
journalctl -u keepalived -f

A.2 GlusterFS 命令速查

bash
# 集群管理
gluster peer status
gluster peer probe <node>
gluster peer detach <node>
gluster pool list

# 卷管理
gluster volume create <volname> replica 3 <brick1> <brick2> <brick3>
gluster volume start <volname>
gluster volume stop <volname>
gluster volume delete <volname>
gluster volume info <volname>
gluster volume status <volname>

# 扩容缩容
gluster volume add-brick <volname> replica 3 <new-bricks>
gluster volume remove-brick <volname> replica 3 <bricks> start
gluster volume remove-brick <volname> replica 3 <bricks> commit

# 参数调优
gluster volume set <volname> <key> <value>
gluster volume set <volname> help

# 自愈
gluster volume heal <volname>
gluster volume heal <volname> info
gluster volume heal <volname> info summary
gluster volume heal <volname> info split-brain

# 快照
gluster snapshot create <snapname> <volname>
gluster snapshot list
gluster snapshot restore <snapname>
gluster snapshot delete <snapname>

A.3 NFS 命令速查

bash
# 查看导出
showmount -e <server>

# 挂载
mount -t nfs -o vers=4.1,hard,intr <server>:/<path> <mountpoint>

# 卸载
umount <mountpoint>

# 查看挂载
mount | grep nfs
df -h

# NFS 客户端统计
cat /proc/self/mountstats

A.4 Keepalived 命令速查

bash
# 启动/停止/重启
systemctl start keepalived
systemctl stop keepalived
systemctl restart keepalived

# 查看 VIP
ip addr show <interface>

# 查看状态
journalctl -u keepalived -f

# 测试 VRRP
tcpdump -i <interface> vrrp

A.5 性能测试命令

bash
# fio 顺序写
fio -directory=/mnt/nfs-ha -direct=1 -rw=write -ioengine=libaio \
    -bs=1M -size=1G -numjobs=4 -runtime=60 -group_reporting -name=seq-write

# fio 随机读
fio -directory=/mnt/nfs-ha -direct=1 -rw=randread -ioengine=libaio \
    -bs=4k -size=1G -numjobs=8 -runtime=60 -group_reporting -name=rand-read

# 网络带宽
iperf3 -c <server>