source: server/databases/upgradedb.xml@ 4454113

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 xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 4454113 was a1743b1, checked in by Douglas R. Reno <renodr@…>, 20 months ago

Typo fixes from rhubarbpieguy

  • Property mode set to 100644
File size: 11.4 KB
RevLine 
[bcdfc53]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
[fe9a4337]15 <title>Important Notes About Upgrading Database Server Software</title>
[7f6bf79b]16
[d86ea4b]17 <note><para>This section is about reinstalling database software
18 when an existing database is in use. It is not applicable for
19 initial installations or if there is no existing database for
[7a9a7b26]20 the package being updated, but users should read through it
[b3ba4f9]21 to become aware of issues that can arise in the future.</para></note>
[d86ea4b]22
[fe9a4337]23 <para>Let's start this chapter with a dramatic screenshot of an error that
24 really happened. This error will not occur if you are installing database
25 software for the first time:</para>
[bcdfc53]26
27<screen>$ sudo systemctl status postgresql
28-- postgresql.service - PostgreSQL database server
29 Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
30 Active: failed (Result: exit-code) since Tue 2021-10-26 17:11:53 CDT; 2min 49s ago
31 Process: 17336 ExecStart=/usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 (code=exited, status=1/FAILURE)
32 CPU: 7ms
33
34Oct 26 17:11:53 SVRNAME systemd[1]: Starting PostgreSQL database server...
[7a9a7b26]35Oct 26 17:11:53 SRVNAME postgres[17338]: 2021-10-26 17:11:53.420 CDT [17338] FATAL:
[d86ea4b]36 database files are incompatible with server
[7a9a7b26]37Oct 26 17:11:53 SRVNAME postgres[17338]: 2021-10-26 17:11:53.420 CDT [17338] DETAIL:
[d86ea4b]38 The data directory was initialized by PostgreSQL version 13,
39 which is not compatible with this version 14.0.
[bcdfc53]40Oct 26 17:11:53 SRVNAME postgres[17336]: pg_ctl: could not start server
41Oct 26 17:11:53 SRVNAME postgres[17336]: Examine the log output.
42Oct 26 17:11:53 SRVNAME systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
43Oct 26 17:11:53 SRVNAME systemd[1]: postgresql.service: Failed with result 'exit-code'.
44Oct 26 17:11:53 SRVNAME systemd[1]: Failed to start PostgreSQL database server.</screen>
45
46 <para>
[fe9a4337]47 To avoid situations like this (i.e., your database server
48 software refuses to start), read the following discussion of the best way to
49 upgrade a DBMS (Database Management System).
[bcdfc53]50 </para>
[d86ea4b]51
[bcdfc53]52 <para>
[fe9a4337]53 The root cause of the error shown above was an upgrade
54 of the server software to a newer major version which left the
55 data files untouched. In this case, the administrator was able to recover
56 the DBMS without any loss of data.
[7f6bf79b]57 </para>
[d86ea4b]58
[7f6bf79b]59 <para>
[a1743b1]60 Even if you are doing an initial DBMS install, read through this
[fe9a4337]61 section. It provides information about implementing backup
62 and restore procedures (or at least a strategy for creating
63 them) which will satisfy your needs and guarantee the safety
[bcdfc53]64 of your data.
65 </para>
[8986fa9]66
[bcdfc53]67 <sect2>
[fe9a4337]68 <title>Upgrade Database Server Packages</title>
[bcdfc53]69
70 <para>
[d86ea4b]71 Database systems work on files which hold the database metadata and the
[fe9a4337]72 data itself. The internal structure of these files is optimized for use
73 by the server software. When such server software is upgraded,
74 the new software may utilize a different file format than
75 had previously been used. Sometimes the new software can
[a1743b1]76 work with the old format as well as the new one&mdash;but without the
[fe9a4337]77 performance improvements the new format provides.
78 Other times, the new server software will
79 reformat the data files automatically after the upgrade.
[bcdfc53]80 </para>
81
82 <para>
[b9c353b]83 Unfortunately, the most likely case is that the new server software
[fe9a4337]84 complains about out of date file formats and exits. When this happens,
85 and you have overwritten the old server software, you may end up
86 with a broken system and lost data.
[bcdfc53]87 </para>
88
89 <para>
[fe9a4337]90 Changes in data file formats usually happen at major version changes, but
91 they can also occur at other times. Before upgrading any DBMS
92 software, check the documentation to see if this upgrade makes changes which
[d86ea4b]93 require reformatting the database.
[bcdfc53]94 </para>
95
96 <para>
[fe9a4337]97 Of course, if you have databases with content that is not easily
98 rebuilt, it is always a good idea to create backups of the database from
99 time to time. Before upgrading the server software, you should run
[d86ea4b]100 another backup.
[bcdfc53]101 </para>
102
103 <sect3>
[fe9a4337]104 <title>Upgrade by Backup and Restore</title>
[bcdfc53]105
106 <note>
107 <para>
[fe9a4337]108 A backup is useless if there is no verified process
[bcdfc53]109 to restore the data from this backup. When running a
[fe9a4337]110 database server, you should not only create backups; you
111 should also verify that the restore process
112 really works. The time to test the restore procedure
113 is <emphasis>before</emphasis> you urgently need
114 to recover lost data.
[bcdfc53]115 </para>
116 </note>
117
118 <para>
[fe9a4337]119 Most database server software provides some basic
[d86ea4b]120 tools to create backups of your data. Usually the backups created with
121 those tools can be read by newer versions of the software (via a
[fe9a4337]122 restore tool). Using older restore tools with newer backup data is
123 a bad idea; you should <emphasis>never</emphasis> blindly assume that
[d86ea4b]124 it will work. It might, but usually it doesn't.
[bcdfc53]125 </para>
126
127 <para>
[d86ea4b]128 The easiest way to upgrade your database files is to
[bcdfc53]129 </para>
130
131 <itemizedlist>
[4e207bb]132 <listitem>
[bcdfc53]133 <para>Create a full database backup using the old tools.</para>
[7a9a7b26]134
[fe9a4337]135 <para>This step creates an offline copy of the database files&mdash;for
136 long term archiving, for disaster recovery, or as
137 preparation for an upgrade. This offline backup consists of either (1) a full
138 one-to-one copy of the current database files, or (2) a full backup of the
139 database files from a certain point in time, plus all the journal data (that is
[d86ea4b]140 Oracle&reg; terminology, it is called "Continuous Archiving" or
[fe9a4337]141 "write ahead log (WAL)" in Postgresql) describing the
142 changes made after that point in time. This second form takes less time to create
143 (if the DB software provides this type of journaling) because you only have
144 to save the data that have changed since the last full backup was created.</para>
145
146 <para>When upgrading database server software, a full backup
[d86ea4b]147 (which can be used for subsequent incremental backups) should be
[fe9a4337]148 created; but if there is a lot of data, an incremental backup will
149 suffice. The best strategy for you depends on
[d86ea4b]150 the amount of data stored in your database (is it a few hundred table
[fe9a4337]151 rows, or is it hundreds of terabytes?). A full backup in the latter case
152 can't be done quickly. To
153 fully protect your data, create a backup of the old
154 programs (and/or their sources) and save it, along with the data
155 files, to be certain there is a fallback solution if
156 the new software cannot read the old data.</para>
[7a9a7b26]157 </listitem>
[d86ea4b]158
[7a9a7b26]159 <listitem>
160 <para>Upgrade the server software</para>
[d86ea4b]161
162 <para>In this step, instructions to build the database server
163 software are executed just as they are shown in subsequent sections
164 talking about the DBMs like MariaDB or Postgresql. That is, build
[7a9a7b26]165 the software as usual using BLFS instructions.</para>
166 </listitem>
[d86ea4b]167
[7a9a7b26]168 <listitem>
169 <para>Restore the database by using the new tools.</para>
[d86ea4b]170
171 <para>To restore the data, the tools of the newly installed server
172 software should be used. During the restoration process, the new
173 tools will create and/or upgrade the data files in the format the
[fe9a4337]174 new software requires. It is assumed that newer software is capable of
[d86ea4b]175 reading old data.</para>
[7a9a7b26]176 </listitem>
[d86ea4b]177 </itemizedlist>
[bcdfc53]178
179 <para>
[fe9a4337]180 Since you already have a backup procedure in place (and you
[d86ea4b]181 have tested your restore procedure, right?), this might
[fe9a4337]182 be the easiest way to upgrade as you can use your well known
[5f729f8]183 processes to upgrade just as you always do&mdash;at least in terms
[bcdfc53]184 of the backup and restore.
185 </para>
186
187 </sect3>
188
189 <sect3>
[fe9a4337]190 <title>Upgrade the Database Files by Using System Tools</title>
[bcdfc53]191
192 <para>
[d86ea4b]193 Some database systems (for instance Postgresql) provide
194 a tool which can reformat (upgrade) the existing database
[fe9a4337]195 files to the new format.
196 If you need to restore from a backup (for example, running
197 the upgrade tool failed) you will have to reinstall the old software
198 to recover your data.
[bcdfc53]199 </para>
200
201 <para>
[fe9a4337]202 Even though the reformatting tools might work as advertised,
203 you should create a full backup before running them. A failure
204 could cause serious damage to the database.
[bcdfc53]205 </para>
206
207 </sect3>
208
209 </sect2>
210
211 <sect2>
[fe9a4337]212 <title>Notes for Specific DBMS</title>
[8986fa9]213
[bcdfc53]214 <sect3>
215 <title>PostgreSQL</title>
[8986fa9]216
[bcdfc53]217 <!-- might add some advanced notes for the DBMS here -->
218
[d86ea4b]219 <para>Upstream documentation for Backup/Restore:
[bcdfc53]220 <ulink url="https://www.postgresql.org/docs/current/backup.html"/>
221 </para>
[8986fa9]222
[bcdfc53]223 </sect3>
224
225 <sect3>
226 <title>MariaDB</title>
[8986fa9]227
[bcdfc53]228 <!-- might add some advanced notes for the DBMS here -->
229
[d86ea4b]230 <para>Upstream documentation for Backup/Restore:
[bcdfc53]231 <ulink url="https://mariadb.com/kb/en/backup-and-restore-overview/"/>
232 </para>
[8986fa9]233
234 </sect3>
235
236 <sect3>
237 <title>Sqlite</title>
238
239 <!-- might add some advanced notes for the DBMS here -->
240
[d86ea4b]241 <para>Do not underestimate <application>Sqlite</application>. It is a
[fe9a4337]242 feature-rich DBMS. The main difference from the two big players above is
[d86ea4b]243 that Sqlite does not provide access via a network API. Sqlite databases
[fe9a4337]244 are always stored on the machine running the program which
[d86ea4b]245 uses the database. The manipulation of data content is done via API calls
[8986fa9]246 to library functions directly within the program.</para>
247
[d86ea4b]248 <para>In the upstream documentation you may find the following
249 useful:</para>
[8986fa9]250
251 <para>Documentation of the sqlite3 command line tool:
252 <ulink url="https://www.sqlite.org/cli.html"/>
253 </para>
[d86ea4b]254
[8986fa9]255 <para>Documentation of backup API calls:
256 <ulink url="https://www.sqlite.org/backup.html"/>
257 </para>
258
[2c87187]259 <para>Unfortunately, there is no dedicated chapter in the
[fe9a4337]260 upstream documentation talking about backup/restore, but
[d86ea4b]261 there are several articles about it on the
[fe9a4337]262 Internet. Here is an example.</para>
[8986fa9]263
[d86ea4b]264 <para>Documentation for Backup/Restore:
[8986fa9]265 <ulink url="https://database.guide/backup-sqlite-database/"/>
266 </para>
267
[bcdfc53]268 </sect3>
269
[8986fa9]270 <sect3>
271 <title>Berkeley DB</title>
272
273 <!-- might add some advanced notes for the DBMS here -->
274
[fe9a4337]275 <para>Like <application>Sqlite</application>, this
276 software acts on local database files; there is no
[d86ea4b]277 network interface.</para>
[8986fa9]278
[fe9a4337]279 <para>The relevant resources to back up/restore a Berkeley database
[8986fa9]280 are the man pages for <filename>db_dump</filename> and its
281 counterpart <filename>db_load</filename>.</para>
282
283 </sect3>
[bcdfc53]284 </sect2>
[8986fa9]285
[bcdfc53]286</sect1>
Note: See TracBrowser for help on using the repository browser.