详解Linux系统迁移具体方案

树叶云

Linux系统如何迁移?实际工作中经常会遇到想把系统迁移到另外的机房或者迁移到云平台,本篇文章重点为大家讲解一下Linux系统迁移具体方法。

实验环境:

系统:centos7 ip:172.16.1.101 server1部署nginx,再装一台新的server2 和server1一样的环境但是不部署软件,实验要求迁移之前访问server1的nginx可以访问,访问server2的nginx可以访问。

server1部署nginx

[root@localhost ~]# tar xf nginx-1.11.2.tar.gz
[root@localhost ~]# ./configure
[root@localhost ~]# make
[root@localhost ~]# make install

编辑index.html

[root@localhost html]# cat index.html aaaaaaaaa this is a test!

测试nginx

[root@localhost html]# curl  172.16.1.101
aaaaaaaaa
this is a test!

将重要目录打包

–exclude 指定的目录不打包 –warning 略过报错

[root@localhost ~]# cd /
[root@localhost /]# tar cvpzf backup.tgz / --warning=no-file-changed --exclude=/proc --exclude=/mnt --exclude=/sys --exclude=/dev --exclude=/tmp --exclude=/backup.tgz

登录server2进行迁移

可以用拷贝的方式,我这里先在server配置成172.16.1.102 通过scp传过来 cd /

[root@localhost html]# scp [email protected]:/backup.tgz .
[root@localhost /]# cd /
[root@localhost /]#
[root@localhost /]# tar xvpfz backup.tgz -C /
[root@localhost /]# restorecon -Rv /

测试

关闭server1 重启server2访问172.16.1.101 的nginx

[root@localhost /]# curl  172.16.1.101
aaaaaaaaa
this is a test!

实验环境不同,可能会有差异可以考虑uuid或者挂载方面的问题。

总结

这就是一种简单的迁移方式,还有其他的方法后面再跟大家介绍

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/206259.html<

(0)
运维的头像运维
上一篇2025-04-08 00:12
下一篇 2025-04-08 00:13

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注