解决Windows2012 R2下安装PostgreSQL报错的问题

作者:类延良,任职于瀚高基础软件股份有限公司,PostgreSQL数据库技术爱好者,10g &11g OCM,OGG认证专家。

一、环境说明

1.Windows2012R2的版本见下,未打任何的OS补丁
image.png
2.采用的介质是postgresql-12.5-1-windows-x64.exe,从EDB公司下载的介质,已经验算过该介质的SHA256,没问题。
3.PostgreSQL12 x64bit是支持Windows 2102R2的,如下截图来自https://www.postgresql.org/download/windows/
image.png
image

二、安装报错

image

三、问题分析与解决

众所周知,在Windows下安装部署用C开发的程序(比如OGG,比如vmware workstations等等),都需要安装Microsoft Visual C++ 2015-2019 Redistributable,这个安装包需要说明如下:

1.该安装包的下载网址是:
https://support.microsoft.com/en-in/help/2977003/the-latest-supported-visual-c-downloads
2.该安装包区分x86、x64、ARM64,请注意务必下载正确
3.该安装包对Windwos版本的要求如下,来自于网址
https://docs.microsoft.com/zh-cn/visualstudio/releases/2019/system-requirements

上述网址有如下的描述:
“Visual C++ 2015-2019 Redistributable 支持与 Visual Studio 相同的系统要求”,那么就来看Visual Studio 2019对操作系统的要求,见下:
Visual Studio 2019 将在以下操作系统上安装并运行(建议使用 64 位;不支持 ARM):

Windows 10 版本 1703 或更高版本:家庭版、专业版、教育版和企业版(不支持 LTSC 和 Windows 10 S) Windows Server 2019:Standard 和 Datacenter Windows Server 2016:Standard 和 Datacenter Windows 8.1(带有更新 2919355):核心板、专业版和企业版 Windows Server 2012 R2(更新 2919355):Essentials、Standard、Datacenter Windows 7 SP1(带有最新的 Windows 更新):家庭高级版、专业版、企业版、旗舰版

4.Visual C++ 2015, 2017 and 2019 all share the same redistributable files

For example, installing the Visual C++ 2019 redistributable will affect programs built with Visual C++ 2015 and 2017 also. However, installing the Visual C++ 2015 redistributable will not replace the newer versions of the files installed by the Visual C++ 2017 and 2019 redistributables.

本文摘自:
https://support.microsoft.com/en-in/help/2977003/the-latest-supported-visual-c-downloads

从如上分析可以看出,Visual C++ 2015-2019 Redistributable 在Windows2012R2下安装,需要Windows2012R2带有更新 2919355。我特意尝试过当Windows2012R2不带任何OS补丁的情况下去安装Visual C++ 2015-2019 Redistributable,结果OS蓝屏故障,进而导致OS重启,所以,请务必为Windows2012R2安装更新 2919355。

下面就来为Windows2012R2安装更新 2919355

Windows2012R2的更新 2919355对应的补丁下载网址
https://www.microsoft.com/zh-CN/download/details.aspx?id=42334

如下是打补丁的顺序,请依次执行即可:

clearcompressionflag.exe KB2919442 KB2975061本补丁下载自http://support.microsoft.com/kb/2975061/ KB2919355若是不安装KB2975061,那么在安装KB2919355时将安装将失败,事件查看器中的错误代码为 0x80070005。安装KB2919355耗时1小时,需要重启OS生效。 KB2932046,重启os生效 KB2959977,重启os生效 KB2937592,不需要重启 KB2938439,重启os生效 KB2934018,重启os生效

以上九个步骤建议预留至少2个小时的时间进行OS补丁更新,请规划好停机时间。

安装完更新 2919355之后,再去运行postgresql-12.5-1-windows-x64.exe即可。

更多PostgreSQL知识问答、技术文章,请访问PGFans问答社区:www.pgfans.cn