Review database SOP
Signed-off-by: Michal Konečný <mkonecny@redhat.com>
This commit is contained in:
parent
8881c92d7d
commit
1e07150259
2 changed files with 41 additions and 57 deletions
|
@ -17,7 +17,7 @@
|
||||||
** xref:compose-tracker.adoc[Compose Tracker - SOP]
|
** xref:compose-tracker.adoc[Compose Tracker - SOP]
|
||||||
** xref:contenthosting.adoc[Content Hosting Infrastructure - SOP]
|
** xref:contenthosting.adoc[Content Hosting Infrastructure - SOP]
|
||||||
** xref:copr.adoc[Copr - SOP]
|
** xref:copr.adoc[Copr - SOP]
|
||||||
** xref:database.adoc[database - SOP in review ]
|
** xref:database.adoc[Database Infrastructure - SOP]
|
||||||
** xref:datanommer.adoc[datanommer - SOP in review ]
|
** xref:datanommer.adoc[datanommer - SOP in review ]
|
||||||
** xref:debuginfod.adoc[debuginfod - SOP in review ]
|
** xref:debuginfod.adoc[debuginfod - SOP in review ]
|
||||||
** xref:departing-admin.adoc[departing-admin - SOP in review ]
|
** xref:departing-admin.adoc[departing-admin - SOP in review ]
|
||||||
|
|
|
@ -2,35 +2,22 @@
|
||||||
|
|
||||||
Our database servers provide database storage for many of our apps.
|
Our database servers provide database storage for many of our apps.
|
||||||
|
|
||||||
Contents
|
== Contents
|
||||||
|
|
||||||
[arabic]
|
* <<_contact_information>>
|
||||||
. Contact Information
|
* <<_description>>
|
||||||
. Description
|
* <<_creating_a_new_postgresql_database>>
|
||||||
. Creating a New Postgresql Database
|
* <<_troubleshooting_and_resolution>>
|
||||||
. Troubleshooting and Resolution
|
** <<_connection_issues>>
|
||||||
+
|
** <<_some_useful_queries>>
|
||||||
____
|
*** <<_what_queries_are_running>>
|
||||||
[arabic]
|
*** <<_seeing_how_dirty_a_table_is>>
|
||||||
.. Connection issues
|
*** <<_xid_wraparound>>
|
||||||
.. Some useful queries
|
** <<_restart_procedure>>
|
||||||
+
|
*** <<_koji>>
|
||||||
____
|
*** <<_bodhi>>
|
||||||
[arabic]
|
* <<_turbogears_and_mysql>>
|
||||||
... What queries are running
|
* <<_restoring_from_backups_or_specific_dbs>>
|
||||||
... Seeing how "dirty" a table is
|
|
||||||
... XID Wraparound
|
|
||||||
____
|
|
||||||
.. Restart Procedure
|
|
||||||
+
|
|
||||||
____
|
|
||||||
[arabic]
|
|
||||||
... Koji
|
|
||||||
... Bodhi
|
|
||||||
____
|
|
||||||
____
|
|
||||||
. Note about TurboGears and MySQL
|
|
||||||
. Restoring from backups or specific dbs
|
|
||||||
|
|
||||||
== Contact Information
|
== Contact Information
|
||||||
|
|
||||||
|
@ -39,7 +26,7 @@ Owner::
|
||||||
Contact::
|
Contact::
|
||||||
#fedora-admin, sysadmin-main, sysadmin-dba group
|
#fedora-admin, sysadmin-main, sysadmin-dba group
|
||||||
Location::
|
Location::
|
||||||
Phoenix
|
iad2
|
||||||
Servers::
|
Servers::
|
||||||
sb01, db03, db-fas01, db-datanommer02, db-koji01, db-s390-koji01,
|
sb01, db03, db-fas01, db-datanommer02, db-koji01, db-s390-koji01,
|
||||||
db-arm-koji01, db-ppc-koji01, db-qa01, dbqastg01
|
db-arm-koji01, db-ppc-koji01, db-qa01, dbqastg01
|
||||||
|
@ -48,11 +35,11 @@ Purpose::
|
||||||
|
|
||||||
== Description
|
== Description
|
||||||
|
|
||||||
db01, db03 and db-fas01 are our primmary servers. db01 and db-fas01 run
|
_db01_, _db03_ and _db-fas01_ are our primary servers. _db01_ and _db-fas01_ run
|
||||||
PostgreSQL. db03 contain mariadb. db-koji01, db-s390-koji01,
|
_PostgreSQL_. _db03_ contain _mariadb_. _db-koji01_, _db-s390-koji01_,
|
||||||
db-arm-koji01, db-ppc-koji01 contain secondary kojis. db-qa01 and
|
_db-arm-koji01_, _db-ppc-koji01_ contain secondary _kojis_. _db-qa01_ and
|
||||||
db-qastg01 contain resultsdb. db-datanommer02 contains all storage
|
_db-qastg01_ contain _resultsdb_. _db-datanommer02_ contains all storage
|
||||||
messages from postgresql database.
|
messages from _postgresql_ database.
|
||||||
|
|
||||||
== Creating a New Postgresql Database
|
== Creating a New Postgresql Database
|
||||||
|
|
||||||
|
@ -71,12 +58,14 @@ Say we have an app called "raffle". We'd have three users:
|
||||||
database. It should not be used in day to day but only for things like
|
database. It should not be used in day to day but only for things like
|
||||||
updating the database schema when an update occurs. We could very likely
|
updating the database schema when an update occurs. We could very likely
|
||||||
disable this account in the db whenever we are not using it.
|
disable this account in the db whenever we are not using it.
|
||||||
|
|
||||||
* raffleapp: the database user that the web application uses. This will
|
* raffleapp: the database user that the web application uses. This will
|
||||||
likely need to be able to insert and select from all tables. It will
|
likely need to be able to insert and select from all tables. It will
|
||||||
probably need to update most tables as well. There may be some tables
|
probably need to update most tables as well. There may be some tables
|
||||||
that it does _not_ need delete on. It should almost certainly not need
|
that it does _not_ need delete on. It should almost certainly not need
|
||||||
schema modifying permissions. (With postgres, it likely also needs
|
schema modifying permissions. (With postgres, it likely also needs
|
||||||
permission to insert/select on sequences as well).
|
permission to insert/select on sequences as well).
|
||||||
|
|
||||||
* rafflereadonly: Only able to read data from tables, not able to modify
|
* rafflereadonly: Only able to read data from tables, not able to modify
|
||||||
anything. Sadly, we aren't using this often but it can be useful for
|
anything. Sadly, we aren't using this often but it can be useful for
|
||||||
scripts that need to talk directly to the database without modifying it.
|
scripts that need to talk directly to the database without modifying it.
|
||||||
|
@ -110,7 +99,7 @@ to incorporate it into the config file. See fas.pp for an example.
|
||||||
|
|
||||||
There are no known outstanding issues with the database itself. Remember
|
There are no known outstanding issues with the database itself. Remember
|
||||||
that every time either database is restarted, services will have to be
|
that every time either database is restarted, services will have to be
|
||||||
restarted (see below).
|
restarted (see <<_restart_procedure>>).
|
||||||
|
|
||||||
=== Some useful queries
|
=== Some useful queries
|
||||||
|
|
||||||
|
@ -170,8 +159,6 @@ select datname, age(datfrozenxid), pow(2, 31) - age(datfrozenxid) as xids_remain
|
||||||
from pg_database order by xids_remaining;
|
from pg_database order by xids_remaining;
|
||||||
....
|
....
|
||||||
|
|
||||||
Information on [61]wraparound
|
|
||||||
|
|
||||||
== Restart Procedure
|
== Restart Procedure
|
||||||
|
|
||||||
If the database server needs to be restarted it should come back on it's
|
If the database server needs to be restarted it should come back on it's
|
||||||
|
@ -185,7 +172,7 @@ service postgresql restart
|
||||||
=== Koji
|
=== Koji
|
||||||
|
|
||||||
Any time postgreql is restarted, koji needs to be restarted. Please also
|
Any time postgreql is restarted, koji needs to be restarted. Please also
|
||||||
see [62]Restarting Koji
|
see <<koji.adoc#_restarting_koji,Restarting Koji>>.
|
||||||
|
|
||||||
=== Bodhi
|
=== Bodhi
|
||||||
|
|
||||||
|
@ -195,9 +182,8 @@ currently exists for this.
|
||||||
== TurboGears and MySQL
|
== TurboGears and MySQL
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
.Note
|
|
||||||
====
|
====
|
||||||
about TurboGears and MySQL
|
About TurboGears and MySQL
|
||||||
|
|
||||||
There's a known bug in TurboGears that causes MySQL clients not to
|
There's a known bug in TurboGears that causes MySQL clients not to
|
||||||
automatically reconnect when lost. Typically a restart of the TurboGears
|
automatically reconnect when lost. Typically a restart of the TurboGears
|
||||||
|
@ -206,30 +192,28 @@ application will correct this issue.
|
||||||
|
|
||||||
== Restoring from backups or specific dbs.
|
== Restoring from backups or specific dbs.
|
||||||
|
|
||||||
Our backups store the latest copy in /backups/ on each db server. These
|
Our backups store the latest copy in `/backups/` on each db server. These
|
||||||
backups are created automatically by the db-backup script run fron cron.
|
backups are created automatically by the db-backup script run fron cron.
|
||||||
Look in /usr/local/bin for the backup script.
|
Look in `/usr/local/bin` for the backup script.
|
||||||
|
|
||||||
To restore partially or completely you need to:
|
To restore partially or completely you need to:
|
||||||
|
|
||||||
[arabic]
|
[arabic]
|
||||||
. setup postgres on a system
|
. setup postgres on a system
|
||||||
. {blank}
|
|
||||||
+
|
+
|
||||||
start postgres/run initdb::
|
. start postgres/run initdb
|
||||||
* {blank}
|
+
|
||||||
+
|
if this new system running postgres has already run ansible then it
|
||||||
if this new system running postgres has already run ansible then it
|
will have wrong config files in `/var/lib/pgsql/data` - clear them out
|
||||||
will;;
|
before you start postgres so initdb can work.
|
||||||
have wrong config files in /var/lib/pgsql/data - clear them out
|
+
|
||||||
before you start postgres so initdb can work.
|
. grab the backups you need from `/backups` - also grab _global.sql_
|
||||||
. {blank}
|
+
|
||||||
|
edit up _global.sql_ to only create/alter the dbs you care about
|
||||||
+
|
+
|
||||||
grab the backups you need from /backups - also grab global.sql::
|
|
||||||
edit up global.sql to only create/alter the dbs you care about
|
|
||||||
. as postgres run: `psql -U postgres -f global.sql`
|
. as postgres run: `psql -U postgres -f global.sql`
|
||||||
. {blank}
|
. when this completes you can restore each db with (as postgres user)
|
||||||
|
+
|
||||||
|
`createdb $dbname pg_restore -d dbname dbname_backup_file.db`
|
||||||
+
|
+
|
||||||
when this completes you can restore each db with (as postgres user)::::
|
|
||||||
createdb $dbname pg_restore -d dbname dbname_backup_file.db
|
|
||||||
. restart postgres and check your data.
|
. restart postgres and check your data.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue