source: server/databases/upgradedb.xml@ 7f6bf79b

11.1 11.2 11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 7f6bf79b was 7f6bf79b, checked in by Thomas Trepl (Moody) <thomas@…>, 2 years ago

Textual changes

  • Property mode set to 100644
File size: 10.1 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="upgradedb" xreflabel="Upgrade Database">
9 <?dbhtml filename="upgradedb.html"?>
10
11 <sect1info>
12 <date>$Date$</date>
13 </sect1info>
14
15 <title>Important notes about upgrading Database Server Software</title>
16
17 <para>Lets start this chapter a bit dramatic with a screenshot
18 of an issue that really happened. Don't be scared if you read
19 this the first time, this issue will not occur if you are going
20 to install the software the first time:</para>
21
22<screen>$ sudo systemctl status postgresql
23-- postgresql.service - PostgreSQL database server
24 Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
25 Active: failed (Result: exit-code) since Tue 2021-10-26 17:11:53 CDT; 2min 49s ago
26 Process: 17336 ExecStart=/usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 (code=exited, status=1/FAILURE)
27 CPU: 7ms
28
29Oct 26 17:11:53 SVRNAME systemd[1]: Starting PostgreSQL database server...
30Oct 26 17:11:53 SRVNAME postgres[17338]: 2021-10-26 17:11:53.420 CDT [17338] FATAL: database files are incompatible with server
31Oct 26 17:11:53 SRVNAME postgres[17338]: 2021-10-26 17:11:53.420 CDT [17338] DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0.
32Oct 26 17:11:53 SRVNAME postgres[17336]: pg_ctl: could not start server
33Oct 26 17:11:53 SRVNAME postgres[17336]: Examine the log output.
34Oct 26 17:11:53 SRVNAME systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
35Oct 26 17:11:53 SRVNAME systemd[1]: postgresql.service: Failed with result 'exit-code'.
36Oct 26 17:11:53 SRVNAME systemd[1]: Failed to start PostgreSQL database server.</screen>
37
38 <para>
39 If you like to avoid those situations like the one above finding
40 your database server software refusing to start, it is highly
41 recommended to read the following thoughts about how to upgrade
42 a DBMS (Database Management System) prior to actually doing the
43 upgrade.
44 </para>
45 <para>
46 The root cause of the issue shown above was an upgrade
47 of the server software to a newer major version but letting the
48 data files untouched. The admin was able to recover without any
49 loss of data.
50 </para>
51 <para>
52 Even if you are installing a DBMS the initial time, read this
53 section too, it might give you a guideline on how to set up backup
54 and restore procedures (at least the strategy for building
55 them) which are sufficient for your needs and for the safety
56 of your data.
57 </para>
58
59 <sect2>
60 <title>Upgrade database server packages</title>
61
62 <para>
63 Usually, DB systems work on a bunch of files which holds
64 the database metadata and the data itself. Those files
65 are highly optimized in their internal structures for use
66 by the server software. When upgrading such a server software,
67 it can happen that the server software expects a slightly
68 different file format than it has been created by previous
69 versions. In the best case, the new software can act on the
70 old format as well - while not benefitting from newer formats
71 which might result in better performance or of other improvements.
72 It can also happen that the new server software will reformat
73 the data files automatically at the first start.
74 </para>
75
76 <para>
77 Unfortunatly, the most likly case is that the new server
78 software complains about invalid data file formats and exits.
79 When this happens and you have overwritten the installed server
80 software with the new one, you are kind of lost as you lsot the
81 software which can read the data files and the new software is
82 unwilling to do so.
83 </para>
84
85 <para>
86 Changes in data file formats come usually beside major
87 version changes. But there is no guaranty. Before upgrading
88 the server software, check the documentation if there are
89 changes which will require a data file reformat.
90 </para>
91
92 <para>
93 Of course, if you have databases with content which is not
94 easily to rebuild, it is always a good idea of creating backups
95 of the database from time to time. When going to upgrade the
96 server software, the time is quite good to run another backup.
97 </para>
98
99 <sect3>
100 <title>Upgrade by backup and restore</title>
101
102 <note>
103 <para>
104 A backup is meaningless if there is no verified process
105 to restore the data from this backup. When running a
106 database server, you should not only create backups but you
107 should also verify that the process you designed to fullfill
108 the restore task is working properly. When you encounter a
109 problem with the restore at the time you urgently have to
110 rely on the backup data, it is too late - your database are
111 in high danger at this moment.
112 </para>
113 </note>
114
115 <para>
116 In general, most (all?) database server software provides
117 some basic tools to create backups of your data. Usually,
118 the backups created with those tools can be read by newer
119 versions of the software (here the restore tool). The other
120 way round (older resote tools can work with newer backup data)
121 is not defined and you should <emphasis>never</emphasis>
122 blindly assume that it would work. It might do, but usually
123 it doesn't.
124 </para>
125
126 <para>
127 The most easiest way to upgrade your database files is to
128 </para>
129
130 <itemizedlist>
131 <listitem>
132 <para>Create a full database backup using the old tools.</para>
133 <para>This step creates an offline copy of the database
134 files ready to be used for long term archiving, for desaster
135 recovery or just as a preparation for upgrade. This offline
136 backups consists of the full one-to-one copy of the current
137 database files or a backup of the files from a certain time
138 in history plus all journal data (that is Oracle(R)
139 terminology, its called "Continuous Archiving" or "write
140 ahead log (WAL)" in Postgresql) containing information about
141 changes made to the data content. The later are more quickly
142 to create if the DB software provides such kind of journal as
143 you only have to save the changes which are recorded in those
144 journals from the last backup upto now. The amount of data to
145 backup is much less than doing a full backup all the time.</para>
146 <para>In terms of upgrading a DB server software, it is
147 recommended to perform a full backup (which can be used for
148 subsequent incremental backups) but if the amount of data is
149 too big an incremental backup will be sufficient, too. Which
150 strategy is sufficient for you depends on the amount of data
151 stored in your DB (is it a few hundret of table rows or is it
152 hundrets of Terabyte. A full backup of the later one isn't done
153 quickly (and we assume that the underlaying system of such a DB
154 might not be a home brewed LFS anyhow).</para>
155 </listitem>
156 <listitem>
157 <para>Upgrade the server software</para>
158 <para>In this step, instructions to build the database
159 server software are executed just as they are shown in
160 subsequent sections talking about the DBMs like MariaDB or
161 Postgresql. This is building the software as
162 it is been done as usual in the BLFS book.</para>
163 </listitem>
164 <listitem>
165 <para>Restore the database by using the new tools.</para>
166 <para>To restore the data, the tools of the newly installed
167 server software is used. During the restore process, the new
168 tools will create and/or upgrade the data files in the
169 format the software expects them to be.</para>
170 </listitem>
171 </itemizedlist>
172
173 <para>
174 Since you have already a backup procedure in place (and you
175 have tested your restore procedure, don't you?), this way might
176 be the easiest way to upgrade as you are going to use well-known
177 processes to upgrade just as you allways do - at least in terms
178 of the backup and restore.
179 </para>
180
181 </sect3>
182
183 <sect3>
184 <title>Upgrade data file by using system tools</title>
185
186 <para>
187 Some database systems (for instance Postgresql) provides
188 a tool which can reformat (=upgrade) the existing database
189 files to the new format. Since the upgrading tool has to
190 be used from the new server software (the old one cannot
191 know anything about a new file format), the old software
192 might be overwritten due to installation of the new software.
193 </para>
194
195 <para>
196 In case you have to restore a backup (may be because running
197 the upgrade tool failed) you have to reinstall the old version
198 to get back the access to your data.
199 </para>
200
201 <para>
202 Even though those tools might work one the actual database
203 files, it is still highly recommended to create a full backup
204 before running them. Any case of failure might result in a
205 serious damage of the database files.
206 </para>
207
208 </sect3>
209
210 </sect2>
211
212 <sect2>
213 <title>Notes for specific DBMS</title>
214
215 <sect3>
216 <title>PostgreSQL</title>
217
218 <!-- might add some advanced notes for the DBMS here -->
219
220 <para>Upstream documentation for Backup &amp; Restore:
221 <ulink url="https://www.postgresql.org/docs/current/backup.html"/>
222 </para>
223
224 </sect3>
225
226 <sect3>
227 <title>MariaDB</title>
228
229 <!-- might add some advanced notes for the DBMS here -->
230
231 <para>Upstream documentation for Backup &amp; Restore:
232 <ulink url="https://mariadb.com/kb/en/backup-and-restore-overview/"/>
233 </para>
234
235 </sect3>
236
237 </sect2>
238
239</sect1>
Note: See TracBrowser for help on using the repository browser.