source: server/databases/upgradedb.xml@ 8986fa9

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 8986fa9 was 8986fa9, checked in by Thomas Trepl (Moody) <thomas@…>, 2 years ago

Add bdb and sqlite

  • Property mode set to 100644
File size: 12.2 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).
155 To close the last gap to fully protect your data, create a backup
156 of the corresponding old binaries (and/or their sources) and
157 store it along with the data files to
158 make sure that there is a fallback solution if it comes to
159 the situation that newer software might not be able to read
160 ancient data.</para>
161 </listitem>
162 <listitem>
163 <para>Upgrade the server software</para>
164 <para>In this step, instructions to build the database
165 server software are executed just as they are shown in
166 subsequent sections talking about the DBMs like MariaDB or
167 Postgresql. This is building the software as
168 it is been done as usual in the BLFS book.</para>
169 </listitem>
170 <listitem>
171 <para>Restore the database by using the new tools.</para>
172 <para>To restore the data, the tools of the newly installed
173 server software is used. During the restore process, the new
174 tools will create and/or upgrade the data files in the
175 format the software expects them to be. At this moment it is
176 assumed that newer software is capable to read old data.</para>
177 </listitem>
178 </itemizedlist>
179
180 <para>
181 Since you have already a backup procedure in place (and you
182 have tested your restore procedure, don't you?), this way might
183 be the easiest way to upgrade as you are going to use your wellknown
184 processes to upgrade just as you allways do - at least in terms
185 of the backup and restore.
186 </para>
187
188 </sect3>
189
190 <sect3>
191 <title>Upgrade data file by using system tools</title>
192
193 <para>
194 Some database systems (for instance Postgresql) provides
195 a tool which can reformat (=upgrade) the existing database
196 files to the new format. Since the upgrading tool has to
197 be used from the new server software (the old one cannot
198 know anything about a new file format), the old software
199 might be overwritten due to installation of the new software.
200 </para>
201
202 <para>
203 In case you have to restore a backup (may be because running
204 the upgrade tool failed) you have to reinstall the old version
205 to get back the access to your data.
206 </para>
207
208 <para>
209 Even though those tools might work one the actual database
210 files, it is still highly recommended to create a full backup
211 before running them. Any case of failure might result in a
212 serious damage of the database files.
213 </para>
214
215 </sect3>
216
217 </sect2>
218
219 <sect2>
220 <title>Notes for specific DBMS</title>
221
222 <sect3>
223 <title>PostgreSQL</title>
224
225 <!-- might add some advanced notes for the DBMS here -->
226
227 <para>Upstream documentation for Backup &amp; Restore:
228 <ulink url="https://www.postgresql.org/docs/current/backup.html"/>
229 </para>
230
231 </sect3>
232
233 <sect3>
234 <title>MariaDB</title>
235
236 <!-- might add some advanced notes for the DBMS here -->
237
238 <para>Upstream documentation for Backup &amp; Restore:
239 <ulink url="https://mariadb.com/kb/en/backup-and-restore-overview/"/>
240 </para>
241
242 </sect3>
243
244 <sect3>
245 <title>Sqlite</title>
246
247 <!-- might add some advanced notes for the DBMS here -->
248
249 <para>Don't underestimate <application>Sqlite</application>, it
250 is a feature rich DBMS. The main difference to the two big
251 players above is that Sqlite does not provide access via a
252 network API. Sqlite databases are files always stored on the
253 same machine as the running program which reads/writes the
254 database. The manipulation of data content is done via API calls
255 to library functions directly within the program.</para>
256
257 <para>In the upstream documentation you may find the
258 following useful:</para>
259
260 <para>Documentation of the sqlite3 command line tool:
261 <ulink url="https://www.sqlite.org/cli.html"/>
262 </para>
263 <para>Documentation of backup API calls:
264 <ulink url="https://www.sqlite.org/backup.html"/>
265 </para>
266
267 <para>Unfortunatly, there is no dedicated chapter in the
268 upstream documentation talking about backup &amp; restore but
269 there are several articles about it somewhere else in the
270 Internet. One example is shown below.</para>
271
272 <para>Documentation for Backup &amp; Restore:
273 <ulink url="https://database.guide/backup-sqlite-database/"/>
274 </para>
275
276 </sect3>
277
278 <sect3>
279 <title>Berkeley DB</title>
280
281 <!-- might add some advanced notes for the DBMS here -->
282
283 <para>Just like <application>Sqlite</application> this
284 software acts on local database files meaning there is no
285 network interface, too.</para>
286
287 <para>The relevant resources for Backup &amp; Restore a Berkeley DB
288 are the man pages for <filename>db_dump</filename> and its
289 counterpart <filename>db_load</filename>.</para>
290
291 </sect3>
292 </sect2>
293
294</sect1>
Note: See TracBrowser for help on using the repository browser.