Product SiteDocumentation Site

3.2. 如何迁移

In order to guarantee continuity of the services, each computer migration must be planned and executed according to the plan. This principle applies whatever operating system is used.

3.2.1. 流行度调查和身份识别服务

如你看到的,该步骤是必要的。一个严谨的管理员应当确切的知道每部服务器的确切角色,但是角色可以被改变,有时候有经验的用户会安装一些服务。了解这些服务的功能让你知道如何处理它,而不是粗暴的删除它们。
基于这个目的,迁移服务器前先告知用户是明智之举。把用户拉入计划里,于迁移之前先安装常用的自由软件于其桌面电脑中,迁移之后自然碰到 Debian、Libre Office 与 Mozilla 等软件。

3.2.1.1. 网络与程序

nmap 工具 (在同名软件包中) 可以在未登录的前提下,快速地经由网络链接机器辨识互联网服务。在另部机器键入命令链接至同个网络:
$ nmap mirwiz
Starting Nmap 7.40 ( https://nmap.org ) at 2017-06-06 14:41 CEST
Nmap scan report for mirwiz (192.168.1.104)
Host is up (0.00062s latency).
Not shown: 992 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
111/tcp  open  rpcbind
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
5666/tcp open  nrpe
9999/tcp open  abyss

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
Unix 机器的服务器提供 shell 帐号给用户,在拥有者缺席的情况下可以决定该进程是否在背景运行。指令 ps auxw 显示所有进程的用户辨识码。将此等信息与 who 指令的输出互相比较,就能辨识出在背景运行的暧昧或不明服务与程序。以 crontabs (依用户自动排串行出所有的作业) 可查看服务器提供的服务信息 (cron 的完整说明在 第 9.7 节 “使用 cronatd运行计划任务”)。
任何状况下,都该先备份您的服务器:用户报告问题时,就能复原它。

3.2.2. 备份配置

保留所有设备的备份供升级后服务器的参考。至少应备份配置档。
Unix 机器的配置档,通常在 /etc/ 文件夹内,有时放在 /usr/local/ 的次文件夹里。若从源代码开始安装程序而不是由软件包安装,配置档就会放在前述的次文件夹内。偶而,还可在 /opt/ 找到配置档。
在数据管理服务 (如数据库) 时,强烈建议以标准格式导出的数据容易被新软件接受。通常是文本格式,也可能是从数据库以 SQL 下载,或从 LDAP 服务器下载 LDIF 文件。
备份数据库

图 3.2. 备份数据库

每个服务器都不一样,不能详述所有个案。比较各软件的文档辨认导出 (即,再导入) 的方式以及需要人工处理的部分。此书处理 Linux 服务器程序的主要配置。

3.2.3. 接手现有的 Debian 服务器

先分析正在运行 Debian 的机器,才能有效地接管维护工作。
第一个查看的文件是 /etc/debian_version,通常包括 Debian 系统的版本编号 (它是 base-files 软件包的一部分)。若以 代码/sid 方式呈现,表示此系统从该代码版本取得的最新版软件包 (测试版或不稳定版)。
apt-show-versions 程序 (来自 Debian 同名软件包) 检查安装的软件包并辨识可用的版本。aptitude 以表单的方式,做同样的工作。
查看 /etc/apt/sources.list 文件 (以及 /etc/apt/sources.list.d/ 文件夹) 可看到已安装 Debian 软件包的来源。若出现不明来源,管理员可能选择重新安装电脑系统确保其软件与 Debian 兼容。
The sources.list file is often a good indicator: the majority of administrators keep, at least in comments, the list of APT sources that were previously used. But you should not forget that sources used in the past might have been deleted, and that some random packages grabbed on the Internet might have been manually installed (with the help of the dpkg command). In this case, the machine is misleading in its appearance of being a “standard” Debian system. This is why you should pay attention to any indication that will give away the presence of external packages (appearance of deb files in unusual directories, package version numbers with a special suffix indicating that it originated from outside the Debian project, such as ubuntu or lmde, etc.)
同样的,分析 /usr/local/ 文件夹的内容,其目的是收录编译后与手动安装后的程序。列出以此方式安装的软件清单,指出一个问题,为什么不使用 Debian 对应的软件包。

3.2.4. 安装 Debian

知道当前服务器的必要信息后,就可以关闭它并开始安装 Debian。
依照电脑的架构,选择适当的版本。近几年的 PC,很可能是 amd64 (稍旧的是 i386)。其他的情况,则依照安装的旧系统来判断。
表 3.1 is not intended to be exhaustive, but may be helpful. Note that it lists Debian architectures which are no longer supported in the current stable release. In any case, the original documentation for the computer is the most reliable source to find this information.

表 3.1. 操作系统与架构对照表

操作系统架构
DEC Unix (OSF/1)alpha, mipsel
HP Unixia64、hppa
IBM AIXpowerpc
Irixmips
OS Xamd64、powerpc、 i386
z/OS、MVSs390x、s390
Solaris, SunOSsparc, i386, m68k
Ultrixmips
VMSalpha
Windows 95/98/MEi386
Windows NT/2000i386, alpha, ia64, mipsel
Windows XP / Windows Server 2008i386, amd64, ia64
Windows RTarmel, armhf, arm64
Windows Vista / Windows 7-8-10i386, amd64

3.2.5. 安装与配置选定的服务

Once Debian is installed, we need to individually install and configure each of the services that this computer must host. The new configuration must take into consideration the prior one in order to ensure a smooth transition. All the information collected in the first two steps will be useful to successfully complete this part.
安装指定的服务

图 3.3. 安装指定的服务

全面进入此练习前,强烈建议您阅读本书其他部分。才能够较精细地了解对预期服务的配置方式。