Wiki
Version 6 (Ivan Lezhnjov, 11/11/2016 05:15 AM)
1 | 1 | Ivan Lezhnjov | h1. postgresql-snap |
---|---|---|---|
2 | 1 | Ivan Lezhnjov | |
3 | 1 | Ivan Lezhnjov | This is a collection of "snapcraft recipes":https://github.com/commandprompt/postgresql-snap for PostgreSQL 9.3, 9.4, 9.5 and 9.6 that can be used to create PostgreSQL snap packages. |
4 | 1 | Ivan Lezhnjov | |
5 | 1 | Ivan Lezhnjov | The packages are maintained as a service to the community by Command Prompt, Inc. A PostgreSQL and Linux Professional services company. You can find Command Prompt on the web at https://commandprompt.com |
6 | 1 | Ivan Lezhnjov | |
7 | 1 | Ivan Lezhnjov | h1. Get binaries |
8 | 1 | Ivan Lezhnjov | |
9 | 1 | Ivan Lezhnjov | If you don't want to build the binaries but instead just want to install the packages, run this command: |
10 | 1 | Ivan Lezhnjov | |
11 | 1 | Ivan Lezhnjov | <pre> |
12 | 3 | Ivan Lezhnjov | $ sudo snap install postgresql$ver |
13 | 1 | Ivan Lezhnjov | </pre> |
14 | 1 | Ivan Lezhnjov | |
15 | 3 | Ivan Lezhnjov | Where $ver is one of 93, 94, 95 or 96. |
16 | 1 | Ivan Lezhnjov | |
17 | 1 | Ivan Lezhnjov | h1. Build |
18 | 1 | Ivan Lezhnjov | |
19 | 1 | Ivan Lezhnjov | Simply run @snapcraft@ inside any of the postgresql9*/ directories. |
20 | 1 | Ivan Lezhnjov | |
21 | 1 | Ivan Lezhnjov | h1. Install |
22 | 1 | Ivan Lezhnjov | |
23 | 1 | Ivan Lezhnjov | If you want to install a local snap package run this command: |
24 | 1 | Ivan Lezhnjov | |
25 | 1 | Ivan Lezhnjov | <pre> |
26 | 1 | Ivan Lezhnjov | $ sudo snap install --force-dangerous postgresql96_9.6.0_amd64.snap |
27 | 1 | Ivan Lezhnjov | </pre> |
28 | 1 | Ivan Lezhnjov | |
29 | 1 | Ivan Lezhnjov | To install from Ubuntu Store simply run: |
30 | 1 | Ivan Lezhnjov | |
31 | 1 | Ivan Lezhnjov | <pre> |
32 | 1 | Ivan Lezhnjov | $ sudo snap install postgresql96 |
33 | 1 | Ivan Lezhnjov | </pre> |
34 | 1 | Ivan Lezhnjov | |
35 | 1 | Ivan Lezhnjov | h1. postgres User |
36 | 1 | Ivan Lezhnjov | |
37 | 1 | Ivan Lezhnjov | Traditionally, you would run PostgreSQL as an unprivileged @postgres@ user. This user has to be created manually. |
38 | 1 | Ivan Lezhnjov | |
39 | 1 | Ivan Lezhnjov | <pre> |
40 | 1 | Ivan Lezhnjov | $ adduser postgres |
41 | 1 | Ivan Lezhnjov | </pre> |
42 | 1 | Ivan Lezhnjov | |
43 | 1 | Ivan Lezhnjov | Beware, that if you already have PostgreSQL installed on your system through an APT/PPA repository, the postgres system account most likely already exists. You must use a different system account in that case. For example, pgsql or postgsql. It can be an arbitrary name: admin, joe, malcolm, etc. |
44 | 1 | Ivan Lezhnjov | |
45 | 1 | Ivan Lezhnjov | Do not use an existing postgres system account that was created during PostgreSQL installation from standard Ubuntu, PGDG or custom PPA repositories. If you want to run both snap package and traditional deb version of PostgreSQL, create a new account. |
46 | 1 | Ivan Lezhnjov | |
47 | 6 | Ivan Lezhnjov | h1. Running Commands |
48 | 6 | Ivan Lezhnjov | |
49 | 6 | Ivan Lezhnjov | Note that you need to run PostgreSQL commands such as psql, pg_ctl, postgres, etc. via wrappers that start with a snap package name as prefix. For example, to run pg_dump you would run postgresql96.pgdump, to run dropdb you would run postgresql96.dropdb and so on. This is just how snap packages work (see http://snapcraft.io/docs/core/usage, section "Run snaps”). |
50 | 6 | Ivan Lezhnjov | |
51 | 6 | Ivan Lezhnjov | As you can see pg_dump and pg_ctl become $PREFIX.pgdump and $PREFIX.pgctl. The underscore symbol is used as a field separator character in snapcraft.yaml. It has to be substituted with something else. In this case it was simply deleted. |
52 | 6 | Ivan Lezhnjov | |
53 | 6 | Ivan Lezhnjov | To get a list of all commands that are available in a package simply run: |
54 | 6 | Ivan Lezhnjov | |
55 | 6 | Ivan Lezhnjov | <pre> |
56 | 6 | Ivan Lezhnjov | $ ls /snap/postgresql96/current/*.wrapper |
57 | 6 | Ivan Lezhnjov | </pre> |
58 | 6 | Ivan Lezhnjov | |
59 | 6 | Ivan Lezhnjov | Where command-dropdb.wrapper is postgresql96.dropdb and so on. |
60 | 6 | Ivan Lezhnjov | |
61 | 1 | Ivan Lezhnjov | h1. Cluster Initialization |
62 | 1 | Ivan Lezhnjov | |
63 | 1 | Ivan Lezhnjov | As postgres user run |
64 | 1 | Ivan Lezhnjov | |
65 | 1 | Ivan Lezhnjov | <pre> |
66 | 1 | Ivan Lezhnjov | $ postgresql96.initialize initdb |
67 | 1 | Ivan Lezhnjov | </pre> |
68 | 1 | Ivan Lezhnjov | |
69 | 1 | Ivan Lezhnjov | This will set up your environment, call initdb and create a default cluster. |
70 | 1 | Ivan Lezhnjov | |
71 | 1 | Ivan Lezhnjov | To start PostgreSQL server run: |
72 | 1 | Ivan Lezhnjov | |
73 | 1 | Ivan Lezhnjov | <pre> |
74 | 5 | Ivan Lezhnjov | $ postgresql96.pgctl -D /home/postgres/snap/postgresql96/common/data -l /home/admin/snap/postgresql96/common/logs/logfile start |
75 | 1 | Ivan Lezhnjov | </pre> |
76 | 1 | Ivan Lezhnjov | |
77 | 1 | Ivan Lezhnjov | Similarly, you can use pg_ctl to run usual commands: stop, restart, status, etc. |
78 | 1 | Ivan Lezhnjov | |
79 | 1 | Ivan Lezhnjov | <pre> |
80 | 5 | Ivan Lezhnjov | $ postgresql96.pgctl -D /home/postgres/snap/postgresql96/common/data -l /home/admin/snap/postgresql96/common/logs/logfile stop |
81 | 1 | Ivan Lezhnjov | </pre> |
82 | 1 | Ivan Lezhnjov | |
83 | 1 | Ivan Lezhnjov | <pre> |
84 | 5 | Ivan Lezhnjov | $ postgresql96.pgctl -D /home/postgres/snap/postgresql96/common/data -l /home/admin/snap/postgresql96/common/logs/logfile restart |
85 | 1 | Ivan Lezhnjov | </pre> |
86 | 1 | Ivan Lezhnjov | |
87 | 1 | Ivan Lezhnjov | <pre> |
88 | 5 | Ivan Lezhnjov | $ postgresql96.pgctl -D /home/postgres/snap/postgresql96/common/data -l /home/admin/snap/postgresql96/common/logs/logfile status |
89 | 1 | Ivan Lezhnjov | </pre> |
90 | 1 | Ivan Lezhnjov | |
91 | 1 | Ivan Lezhnjov | h1. Connect To PostgreSQL |
92 | 1 | Ivan Lezhnjov | |
93 | 1 | Ivan Lezhnjov | <pre> |
94 | 1 | Ivan Lezhnjov | $ postgresql96.psql -h 127.0.0.1 -d postgres |
95 | 1 | Ivan Lezhnjov | </pre> |
96 | 1 | Ivan Lezhnjov | |
97 | 4 | Ivan Lezhnjov | h1. Reporting Issues |
98 | 4 | Ivan Lezhnjov | |
99 | 4 | Ivan Lezhnjov | We are publicly working on this project and you can join the effort. Submit any bug reports or feature requests in our Redmine "PostgreSQL snap project":https://public.commandprompt.com/projects/pgsql-snap/issues. |
100 | 4 | Ivan Lezhnjov | |
101 | 1 | Ivan Lezhnjov | h1. Known Problems and Limitations |
102 | 1 | Ivan Lezhnjov | |
103 | 1 | Ivan Lezhnjov | Snap format imposes a number of non-critical and more serious limitations: |
104 | 1 | Ivan Lezhnjov | |
105 | 1 | Ivan Lezhnjov | * Only one locale is currently supported – en_US.UTF-8. |
106 | 1 | Ivan Lezhnjov | * There is no systemd service file for postgres daemon. PostgreSQL has to be managed manually by using pg_ctl. |
107 | 1 | Ivan Lezhnjov | * pg_ctl is run via a BASH wrapper to make it aware of a default system locale (en_US.UTF-8). |
108 | 1 | Ivan Lezhnjov | * psql is also run via a BASH wrapper to let it successfully write to HISTFILE (.psql_history) |
109 | 1 | Ivan Lezhnjov | * Kerberos, GSSAPI and Bonjour support is disabled. |
110 | 1 | Ivan Lezhnjov | * contrib modules are not included. These do not build due to snapcraft's make plugin inability to handle an included via a relative path Makefile inside another Makefile. |
111 | 1 | Ivan Lezhnjov | |
112 | 1 | Ivan Lezhnjov | We intend to eliminate as many of these limitations as possible in future versions of these snapcraft recipes. Most of them are a result of various design decisions made by snapcraft developers that don't work well with how PostgreSQL build process works. However, snapcraft is a young, rapidly developing project and things may change sooner rather than later. |