redhat linux网络配置(redhat配置网络地址)

redhat linux网络配置(redhat配置网络地址)一 软件安装 1 1 修改 vim 配置 debian 系统下 vi 命令默认是不支持方向键和退格键的 要想支持这些操作 需要修改 vimrc tiny 配置文件 vi etc vim vimrc tiny 把 set compatible 修改改为 set nocompatible 加入一句 set backspace 2 1 2 启用 root 用户 sudo passwd root

大家好,我是讯享网,很高兴认识大家。



 

一、软件安装

1.1修改vim配置

debian 系统下,vi 命令默认是不支持方向键和退格键的。要想支持这些操作,需要修改 vimrc.tiny 配置文件:

#vi /etc/vim/vimrc.tiny

把 set compatible

修改改为:set nocompatible

加入一句:set backspace=2

1.2启用root用户

#sudo passwd root

#su

1.3安装ssh服务

挂载安装镜像,运行

#apt install openssh-server

 

1.4启用root用户ssh

#vi /etc/ssh/sshd_config  //启用root用户的ssh

添加PermitRootLogin yes

 

1.5配置网络

配置IP地址:#vi /etc/network/interfaces

auto ens192

iface ens192 inet static

address 192.168.100.151

netmask 255.255.255.0

gateway 192.168.100.254

配置DNS地址:#vi /etc/resolv.conf  //默认没有这个文件

nameserver 10.10.10.100

nameserver 192.168.100.1

 

#systemctl restart networking

1.6添加国内源

#vi /etc/apt/sources.list

添加

deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib

deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main non-free non-free-firmware contrib

deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main non-free non-free-firmware contrib

#apt update

1.7修改主机名

三台主机分别修改主机名

hostnamectl set-hostname gluster-node1

hostnamectl set-hostname gluster-node2

hostnamectl set-hostname gluster-node3

 

1.8修改hosts文件

三个节点都需要修改/etc/hosts文件,添加以下内容:

192.168.100.151 gluster-node1

192.168.100.152 gluster-node2

192.168.100.153 gluster-node3

1.9配置时区

配置时区:timedatectl set-timezone Asia/Shanghai

查看时区:timedatectl show

1.10配置时间同步

安装ntp:apt install ntp

修改配置文件:vi /etc/ntp.conf

添加:pool 192.168.100.2 iburst

启动时间服务: systemctl restart ntp

查看同步:ntpq -p

 

1.11配置免密登陆

 

生成秘钥

#ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): <回车>

Enter passphrase (empty for no passphrase): <回车>

Enter same passphrase again: <回车>

复制秘钥到其他节点

#ssh-copy-id 192.168.100.152

#ssh-copy-id 192.168.100.153

 

1.12安装Gluster

Debian

安装gpg:apt install gpg

将密钥下载到apt config目录:

wget -O - https://download.gluster.org/pub/gluster/glusterfs/9/rsa.pub | gpg –dearmor > /etc/apt/trusted.gpg.d/gluster.gpg

 

添加源:

DEBID=\((grep 'VERSION_ID=' /etc/os-release | cut -d '=' -f 2 | tr -d '&quot;')</span></p><p data-v-2505e99a data-v-5b474d2a><span style="font-size:17px;" data-v-2505e99a>DEBVER=\)(grep ‘VERSION=’ /etc/os-release | grep -Eo ‘[a-z]+’)

DEBARCH=\((dpkg --print-architecture)</span></p><p data-v-2505e99a data-v-5b474d2a><span style="font-size:17px;" data-v-2505e99a>echo &quot;deb [signed-by=/etc/apt/trusted.gpg.d/gluster.gpg] https://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/\){DEBID}/\({DEBARCH}/apt \){DEBVER} main&quot; &gt; /etc/apt/sources.list.d/gluster.list

 

更新包列表:

apt update

 

安装:apt install glusterfs-server

 

Ubuntu

安装 software-properties-common:

apt install software-properties-common

 

然后添加社区 GlusterFS PPA:

add-apt-repository ppa:gluster/glusterfs-7

apt update

 

最后,安装软件包:

apt install glusterfs-server

 

其他

Red Hat/CentOS:yum install glusterfs-server

 

Fedora:dnf install glusterfs-server

 

Arch Linux:pacman -S glusterfs

二、集群配置

2.1启动Gluster服务

systemctl start glusterd

systemctl enable –now glusterd

 

2.2管理可信存储池

在第一个节点添加其他节点

#gluster peer probe gluster-node2

#gluster peer probe gluster-node3

查看结果

#gluster pool list

UUID                                  Hostname       State

b70a0baf-2eb9-4fe5-97bb-3bac8f49ed9f gluster-node2     Connected

cb-0723-45b9-8d85-bcd663a6680a   gluster-node3      Connected

b44517e5-90b6-489d-a82e-55134de666b2   localhost        Connected

 

删除服务器:gluster peer detach &lt;server&gt;

 

2.3创建块

1.使用pvcreate命令创建物理卷 

pvcreate –dataalignment 128K /dev/sdb

 


讯享网

2.使用vgcreate命令从PV创建卷组

vgcreate –physicalextentsize 128K gfs_vg1 /dev/sdb

注:建议一个vg只从一个device创建

 

3.使用以下命令创建thin-pool

a.创建一个LV以用作元数据设备

lvcreate -L 16G –name gfs_pool_meta1 gfs_vg1

 

创建一个LV以用作数据设备

lvcreate -L 160G –name gfs_pool_data1 gfs_vg1

 

从数据LV和元数据LV创建精简池

lvconvert –chunksize 1280K –thinpool gfs_vg1/gfs_pool_data1 –poolmetadata gfs_vg1/gfs_pool_meta1

注意:默认情况下,精简池中新预置的块将归零,以防止数据在不同块存储设备之间泄漏。

将池制零

lvchange –zero n gfs_vg1/gfs_pool_data1

 

4.使用lvcreate命令从之前创建的池中创建一个精简配置的卷

lvcreate -V 160G -T gfs_vg1/gfs_pool_data1 -n gfs_lv1

注:建议在精简池中只创建一个LV

 

格式化lv

mkfs.xfs -f -i size=512 -n size=8192 -d su=128k,sw=10 /dev/gfs_vg1/gfs_lv1

 

挂载brick

创建挂载目录:mkdir -p /data/glusterfs/node1/brick1

挂载:mount /dev/gfs_vg1/gfs_lv1 /data/glusterfs/node1/brick1

添加自启动挂载/etc/fstab

/dev/gfs_vg1/gfs_lv1  /data/glusterfs/node1/brick1 xfs rw,inode64,noatime,nouuid   1 2

 

运行df -h命令验证挂载成功

 

2.4创建卷

创建分布式卷

在分布式卷中,文件随机分布在多个块中。使用分布的卷,您需要进行规模存储和冗余,要么不重要,要么是由其他硬件/软件层提供。

注意:分布式卷中的磁盘/服务器故障可能导致严重的数据丢失,因为目录内容随机分布在卷中的各个块上。

创建分布式卷:

# gluster volume create test-volume server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4

 

创建复制卷

复制的卷跨卷中的多个块创建文件副本。您可以在高可用性和高可靠性至关重要的环境中使用复制卷。

注意:对于一个复制的卷,砖的数量应该等于副本计数。为了防止服务器和磁盘故障,建议卷的块来自不同的服务器。

创建复制卷:

# gluster volume create test-volume replica 2 server1:/exp1 server2:/exp2

 

副本卷的仲裁程序配置

仲裁器卷是副本3卷,其中第3块充当仲裁块。此配置具有防止发生裂脑的机制。

可以使用以下命令创建它:

#gluster volume create &lt;VOLNAME&gt; replica 2 arbiter 1 host1:brick1 host2:brick2 host3:brick3

 

创建分布式复制卷

在卷中的复制块之间分配文件。您可以使用 分布式复制卷在需要 扩展存储和高可靠性至关重要。分散式 复制卷在大多数 环境。

注意: 块的数量应该是 分布式复制卷。此外,砖块的顺序 specified 对数据保护有很大影响。每个 replica_count 你给出的列表中的连续 bricks 将形成一个副本集,其中 所有副本集合并到一个卷范围的 distribute set 中。要使 确保 replica-set 成员未放置在同一节点上,list 每个服务器上的第一个 Brick,然后每个服务器上的第二个 Brick 以此类推。

创建分布式复制卷:

# gluster volume create test-volume replica 2 server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4

 

创建分散卷

分散的卷是基于擦除码的。它将文件的编码数据分条,并添加一些冗余,跨越卷中的多个块。您可以使用分散的卷,以最小的空间浪费来获得可配置的可靠性级别。

创建分散卷

#gluster volume create test-volume disperse 4 server{1..4}:/bricks/test-volume

 

 

创建分布式分散卷

分布式分散卷相当于分布式复制卷,但使用分散的子卷而不是复制的子卷。

#gluster volume create test-volume disperse 3 server1:/br1 server2:/br1 server3:/br1 server1:/br2 server2:/br2 server3:/br2

 

gluster volume create gfsvolume disperse 3 gluster-node1:/data/glusterfs/node1/brick1 gluster-node2:/data/glusterfs/node2/brick1 gluster-node3:/data/glusterfs/node3/brick1 gluster-node1:/data/glusterfs/node1/brick2 gluster-node2:/data/glusterfs/node2/brick2 gluster-node3:/data/glusterfs/node3/brick2 force

 

启动卷:# gluster volume start test-volume

2.5挂载卷

Gluster客户端挂载

Redhat

安装依赖:yum -y install openssh-server wget fuse fuse-libs openib libibverbs

安装软件包:

rpm -i glusterfs-3.8.5-1.x86_64

rpm -i glusterfs-fuse-3.8.5-1.x86_64

rpm -i glusterfs-rdma-3.8.5-1.x86_64

 

Debian

安装依赖:apt install openssh-server vim wget

下载客户端:https://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/12/amd64/apt/pool/main/g/glusterfs/glusterfs-client_11.1-1_amd64.deb

dpkg -i glusterfs-3.8.x.deb

 

挂载卷

手动挂载卷

mount -t glusterfs server1:/test-volume /mnt/glusterfs

mount -t glusterfs gluster-node1:/gfsvolume /test

 

自启动挂载

编辑/etc/fstab

server1:/test-volume /mnt/glusterfs glusterfs defaults,_netdev 0 0

 

NFS客户端挂载

#mount -t nfs -o vers=3 server1:/test-volume /mnt/glusterfs

NFS自启动挂载:

编辑/etc/fstab文件:server1:/test-volume /mnt/glusterfs nfs defaults,_netdev,vers=3 0 0

 

另外还支持Windows CIFS挂载。

2.6修改卷

扩展卷

添加节点:# gluster peer probe server4

添加块:# gluster volume add-brick test-volume server4:/exp4

 

缩小卷

移除块:# gluster volume remove-brick test-volume server2:/exp2 start

移除节点:# gluster peer detach server4

 

平衡数据

重新平衡卷以修复布局:# gluster volume rebalance test-volume fix-layout start

重新平衡卷以修复布局并迁移现有数据:gluster volume rebalance test-volume start force

 

停止卷

# gluster volume stop test-volume

 

删除卷

# gluster volume delete test-volume

 

在 replicate module 中,以前您必须手动触发自我修复 当 brick 离线并重新上线时,将所有 replicas in sync.现在,主动自我修复守护程序在 后台、诊断问题并自动启动自我修复 每 10 分钟对需要修复的文件进行一次修复。

 

 

官方文档:https://docs.gluster.org/en/latest/

小讯
上一篇 2025-05-15 12:00
下一篇 2025-05-02 07:33

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/171458.html