PostgreSQL » History » Version 4
Marc Dequènes, 2021-05-29 11:14
1 | 2 | Marc Dequènes | {{toc}} |
---|---|---|---|
2 | |||
3 | 1 | Marc Dequènes | h1. PostgreSQL |
4 | |||
5 | h2. Authentication |
||
6 | |||
7 | 3 methods: |
||
8 | * access via UNIX socket for all accounts |
||
9 | * access via local role database for local accounts |
||
10 | * access via PAM for non-local accounts |
||
11 | |||
12 | 4 | Marc Dequènes | For remote connections *TLS is required* . |
13 | |||
14 | 1 | Marc Dequènes | h3. Local Accounts |
15 | |||
16 | These are accounts needed for system services (user services should use secondary accounts defined in the LDAP instead). |
||
17 | |||
18 | Creation: |
||
19 | * create a normal role with login right (and probably inherit right too) |
||
20 | * add the role in the special ''local-roles'' role members |
||
21 | |||
22 | Beware all roles directly or *indirectly* members of the *local-roles* role (indirect members == members of members of members...) will have to authenticate via their local hash and not via PAM! |
||
23 | |||
24 | h3. PAM Accounts |
||
25 | |||
26 | Creation: |
||
27 | 3 | Marc Dequènes | * create a normal role with login right, inherit rights too and without password |
28 | 1 | Marc Dequènes | |
29 | That's all ! |
||
30 | |||
31 | h3. Managing Team Work |
||
32 | |||
33 | Create: |
||
34 | * create a normal role without login right and password |
||
35 | * add user roles as member of this role |
||
36 | * give this role rights to the parts the team is working on |
||
37 | |||
38 | Beware not to use this role for login, or you'll probably end-up adding it to the *local-roles* and all PAM users not able to login anymore (see remark in the *Local Accounts* chapter)! |
||
39 | |||
40 | h2. Storage sizes |
||
41 | |||
42 | h3. Databases sizes |
||
43 | |||
44 | <pre> |
||
45 | SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database; |
||
46 | </pre> |
||
47 | |||
48 | h3. Tables sizes in current database |
||
49 | |||
50 | <pre> |
||
51 | SELECT nspname, relname, |
||
52 | pg_size_pretty(tablesize+indexsize+toastsize+toastindexsize) AS totalsize |
||
53 | FROM |
||
54 | (SELECT ns.nspname, cl.relname, pg_relation_size(cl.oid) AS tablesize, |
||
55 | COALESCE((SELECT SUM(pg_relation_size(indexrelid))::bigint |
||
56 | FROM pg_index WHERE cl.oid=indrelid), 0) AS indexsize, |
||
57 | CASE WHEN reltoastrelid=0 THEN 0 |
||
58 | ELSE pg_relation_size(reltoastrelid) |
||
59 | END AS toastsize, |
||
60 | CASE WHEN reltoastrelid=0 THEN 0 |
||
61 | ELSE pg_relation_size((SELECT reltoastidxid FROM pg_class ct |
||
62 | WHERE ct.oid = cl.reltoastrelid)) |
||
63 | END AS toastindexsize |
||
64 | FROM pg_class cl, pg_namespace ns |
||
65 | WHERE cl.relnamespace = ns.oid |
||
66 | AND ns.nspname NOT IN ('pg_catalog', 'information_schema') |
||
67 | AND cl.relname IN |
||
68 | (SELECT table_name FROM information_schema.tables |
||
69 | WHERE table_type = 'BASE TABLE')) ss |
||
70 | ORDER BY tablesize+indexsize+toastsize+toastindexsize DESC; |
||
71 | </pre> |
||
72 | |||
73 | h2. PostgreSQL interrupted recovery |
||
74 | |||
75 | If you got something like this in your logs: |
||
76 | <pre> |
||
77 | 2011-07-15 16:23:12 CEST LOG: database system was interrupted while in recovery at 2008-03-21 00:02:22 CET |
||
78 | 2011-07-15 16:23:12 CEST HINT: This probably means that some data is corrupted and you will have to use the last backup for recovery. |
||
79 | 2011-07-15 16:23:12 CEST LOG: database system was not properly shut down; automatic recovery in progress |
||
80 | 2011-07-15 16:23:12 CEST LOG: consistent recovery state reached at 28/55780068 |
||
81 | 2011-07-15 16:23:12 CEST LOG: redo starts at 28/55780068 |
||
82 | 2011-07-15 16:23:12 CEST WARNING: specified item offset is too large |
||
83 | 2011-07-15 16:23:12 CEST CONTEXT: xlog redo insert: rel 1663/16387/17911; tid 76/212 |
||
84 | 2011-07-15 16:23:12 CEST PANIC: btree_insert_redo: failed to add item |
||
85 | 2011-07-15 16:23:12 CEST CONTEXT: xlog redo insert: rel 1663/16387/17911; tid 76/212 |
||
86 | 2011-07-15 16:23:12 CEST LOG: startup process (PID 2981) was terminated by signal 6: Aborted |
||
87 | 2011-07-15 16:23:12 CEST LOG: aborting startup due to startup process failure |
||
88 | </pre> |
||
89 | |||
90 | If you don't care about loosing uncommited data: |
||
91 | <pre> |
||
92 | su - postgres |
||
93 | /usr/lib/postgresql/9.0/bin/pg_resetxlog -f 9.0/main/ |
||
94 | </pre> |
||
95 | Running first without -f can give hints about the situation. |
||
96 | |||
97 | Dumping, reiniting, and reloading data is recommended. |