大网数据广告活动
服务器运维问答

Rename a GlusterFS Peer

· 52CE 我爱测

I have a 2 peer GlusterFS system. It was initially created using simple hostnames file01 and file02. These hosts were added to /etc/hosts to make it work. Now we want to start using FQDN because we want to attach other servers to…

问题原文

原帖链接 · user2962402 · CC BY-SA 3.0

I have a 2 peer GlusterFS system. It was initially created using simple hostnames file01 and file02. These hosts were added to /etc/hosts to make it work.

Now we want to start using FQDN because we want to attach other servers to the volumes using the GlusterFS native client. We don't want to have to maintain hosts files for every server.

Is it possible to reconfigure the current setup to use the full hostnames file01.example.com and file02.example.com?

Thank you!

社区高分解答

原帖链接 · tecla · CC BY-SA 4.0

When you need to rename your peers, your bricks, etc. without destroy your cluster, you will must stop your glusterfs service, and then rename all the occurrences in the glusterfs data files.

I will provide you an script (without any warranty), that I used to automate this task.

WARNING: Before proceed be sure of backup your data, and proceed with caution. Do not execute any command without understanding what it do exactly, be sure that you are in the correct path, make the correct names replacements in each command if apply (indicated in uppercase), and ensure that all your new peer names are resolvable by DNS.

THE NEXT STEPS MUST BE PERFORMED ON ALL THE NODES

Step 1: stop glusterd service.

sudo systemctl stop glusterd.service

Step 2: list the content of the /var/lib/glusterd/vols directory.

ls -l /var/lib/glusterd/vols

Step 3: renaming volumes data files, for each volume do:

cd /var/lib/glusterd/vols/YOURVOLUMENAME
ls -l | grep .data.vol    #<-- gets the list of files you need to rename for the current volume
sudo mv clusterdata.OLDNAME1.data.vol clusterdata.NEWNAME1.data.vol
sudo mv clusterdata.OLDNAME2.data.vol clusterdata.NEWNAME2.data.vol
sudo mv clusterdata.OLDNAME-N.data.vol clusterdata.NEWNAME-N.data.vol

Step 4: renaming volumes bricks, for each volume do:

cd /var/lib/glusterd/vols/YOURVOLUMENAME/bricks
ls -l | grep :-data    #<-- gets the list of brick files you need to rename for the current volume
sudo mv OLDNAME1\:-data NEWNAME1\:-data
sudo mv OLDNAME2\:-data NEWNAME2\:-data
sudo mv OLDNAME-N\:-data NEWNAME-N\:-data

Step 5: Detect all the occurrences of the OLDNAME in the config files:

cd /var/lib/glusterd
sudo grep -rnw . -e 'OLDNAME'

Step 6: Automatically replace all the occurrences of the OLDNAME in the config files:

cd /var/lib/glusterd
sudo find . -type f -exec sed -i 's/OLDNAME/NEWNAME/g' {} \;

Step 7: Check that all the occurrences has been replaced:

sudo grep -rnw . -e 'OLDNAME'
sudo grep -rnw . -e 'NEWNAME'

ONLY WHEN YOU HAVE COMPLETED THE STEPS ON ALL NODES ...

Start the glusterd service en each node, and check status.

sudo systemctl start glusterd.service
sudo systemctl status glusterd.service
sudo gluster peer status
sudo gluster volume status
sudo gluster volume info

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-09-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。