Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Dr. Martin Goik
GoikLectures
Commits
73e72c54
Commit
73e72c54
authored
Jul 01, 2020
by
Dr. Martin Goik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Postgresql by Docker install
parent
600761bd
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
4421 additions
and
43 deletions
+4421
-43
Doc/Common/glossary.xml
Doc/Common/glossary.xml
+9
-0
Doc/Sd1/objectsClasses.xml
Doc/Sd1/objectsClasses.xml
+10
-10
Doc/Sda1/Ref/Jdbc/ideaDbConfig.svg
Doc/Sda1/Ref/Jdbc/ideaDbConfig.svg
+1754
-0
Doc/Sda1/Ref/Jdbc/ideaDbConfig.svg.marked.svg
Doc/Sda1/Ref/Jdbc/ideaDbConfig.svg.marked.svg
+2342
-0
Doc/Sda1/prerequisites.xml
Doc/Sda1/prerequisites.xml
+306
-33
No files found.
Doc/Common/glossary.xml
View file @
73e72c54
...
...
@@ -124,6 +124,15 @@
</glossdef>
</glossentry>
<glossentry
xml:id=
"glo_Docker"
>
<glossterm><productname>
Docker
</productname></glossterm>
<glossdef>
<para><link
xlink:href=
"https://www.docker.com"
>
OS Level
virtualization
</link></para>
</glossdef>
</glossentry>
<glossentry
xml:id=
"glo_DOM"
>
<glossterm><acronym>
DOM
</acronym></glossterm>
...
...
Doc/Sd1/objectsClasses.xml
View file @
73e72c54
...
...
@@ -5390,18 +5390,18 @@ public static void setInterestRate(double z) { // Scope of variable "z" limited
<question>
<para>
Our current
<classname>
Account
</classname>
class does
not handle negative balances accordingly. Typically banks will
charge a different interest rate whenever an account
is in
debt
<acronym>
i.e.
</acronym>
having a negative balance.
In
this case a second so called default interest rate (being
charge a different
(larger!)
interest rate whenever an account
is in
debt
<acronym>
i.e.
</acronym>
having a negative balance.
In
this case a second so called default interest rate (being
significantly higher) will be applied.
</para>
<para>
Extend the current project by adding a new
instance
variable
<varname>
debtInterestRate
</varname>
along with
getter
and setter methods. Then change the
implementation of
<code
language=
"java"
>
applyInterest()
</code>
and
<code
language=
"java"
>
applyInterest(int years)
</code>
by
using the
correct interest value according to the account's
balance
being positive or negative.
</para>
<para>
Extend the current project by adding a new
class
variable
<varname>
debtInterestRate
</varname>
along with
corresponding getter
and setter methods. Then change the
implementation of
<code
language=
"java"
>
applyInterest()
</code>
and
<code
language=
"java"
>
applyInterest(int years)
</code>
by
using the
correct interest value according to the account's
balance
being positive or negative.
</para>
<caution>
<para>
Do not forget to change the
<command>
Javadoc
</command>
...
...
Doc/Sda1/Ref/Jdbc/ideaDbConfig.svg
0 → 100644
View file @
73e72c54
This diff is collapsed.
Click to expand it.
Doc/Sda1/Ref/Jdbc/ideaDbConfig.svg.marked.svg
0 → 100644
View file @
73e72c54
This diff is collapsed.
Click to expand it.
Doc/Sda1/prerequisites.xml
View file @
73e72c54
...
...
@@ -184,12 +184,18 @@
xlink:href=
"https://www.postgresql.org"
>
Postgresql
</productname>
database components
</title>
<figure
xml:id=
"sda1_fig_postgresqlInstall"
>
<figure
xml:id=
"sda1_fig_postgresqlInstall
Docs
"
>
<title>
Installing
<xref
linkend=
"glo_Soft_Postgresql"
/></title>
<para>
Installation references:
</para>
<itemizedlist>
<listitem>
<para><link
xlink:href=
"https://hackernoon.com/dont-install-postgres-docker-pull-postgres-bee20e200198"
>
Don’t
install Postgres. Docker pull Postgres
</link></para>
</listitem>
<listitem>
<para><link
xlink:href=
"https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04"
>
How
...
...
@@ -205,12 +211,204 @@
</itemizedlist>
</figure>
<figure
xml:id=
"sda1_fig_postgresqlInstallUserPW"
>
<title>
Configure
<xref
linkend=
"glo_Soft_Postgresql"
/></title>
<section
xml:id=
"sda1_sect_postgresDockerInstall"
>
<title>
Docker installation
</title>
<figure
xml:id=
"sda1_fig_postgresqlDockerPreconditions"
>
<title>
Preconditions
</title>
<itemizedlist>
<listitem>
<para>
A working environment:
</para>
<itemizedlist>
<listitem>
<para><link
xlink:href=
"https://docs.docker.com/engine/install"
>
Docker
engine
</link>
on Linux.
</para>
</listitem>
<listitem>
<para><link
xlink:href=
"https://docs.docker.com/desktop"
>
Docker
desktop
</link>
on Windows or Mac.
</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
Sufficient disk space related mainly to your database(es)
size(es).
</para>
</listitem>
</itemizedlist>
</figure>
<figure
xml:id=
"sda1_fig_postgresqlDockerImageInstall"
>
<title>
Starting
<xref
linkend=
"glo_Docker"
/>
container
</title>
<screen>
docker run --restart always
<co
linkends=
"sda1_fig_postgresqlDockerImageInstall-1"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-1-co"
/>
\
--name postgres-latest
<co
linkends=
"sda1_fig_postgresqlDockerImageInstall-2"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-2-co"
/>
\
-p 5432:5432
<co
linkends=
"sda1_fig_postgresqlDockerImageInstall-3"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-3-co"
/>
\
-e POSTGRES_PASSWORD=mySecretPassword
<co
linkends=
"sda1_fig_postgresqlDockerImageInstall-4"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-4-co"
/>
\
-d \
<co
linkends=
"sda1_fig_postgresqlDockerImageInstall-5"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-5-co"
/>
<emphasis
role=
"red"
>
-v /home/goik/var/lib/postgresql/data:/var/lib/postgresql/data
</emphasis>
<co
linkends=
"sda1_fig_postgresqlDockerImageInstall-6.2"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-6.2-co"
/>
postgres
<co
linkends=
"sda1_fig_postgresqlDockerImageInstall-7.2"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-7.2-co"
/>
\
db1a35a1d85d3e102e0acfb5da7b7a067615ece7c2b517fedd2fd5d3367bcde4
<co
linkends=
"sda1_fig_postgresqlDockerImageInstall-8"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-8-co"
/></screen>
<calloutlist
role=
"slideExclude"
>
<callout
arearefs=
"sda1_fig_postgresqlDockerImageInstall-1-co"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-1"
>
<para>
Run container and
<link
xlink:href=
"https://docs.docker.com/config/containers/start-containers-automatically"
>
restart
automatically
</link>
.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerImageInstall-2-co"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-2"
>
<para>
Your container's local name
<abbrev>
i.e.
</abbrev>
when
listing containers using
<command>
docker
</command>
<option>
container
</option>
<option>
ls
</option>
.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerImageInstall-3-co"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-3"
>
<para>
Bind your docker host system's port 5432 to the
container's port. Database connections to
<abbrev>
i.e.
</abbrev>
localhost:5432 will be forwarded to the database server running
inside your container.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerImageInstall-4-co"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-4"
>
<para>
Image specific environment variable. See
<quote
xlink:href=
"https://hub.docker.com/_/postgres"
>
Environment
Variables
</quote>
section.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerImageInstall-5-co"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-5"
>
<para>
Running container in
<quote>
detached
</quote>
rather than
<quote>
foreground
</quote>
mode.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerImageInstall-6.2-co"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-6.2"
>
<para>
Optional: Mounting a directory from your
<xref
linkend=
"glo_Docker"
/>
host system into the container. Database
files will then be stored outside the container.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerImageInstall-7.2-co"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-7.2"
>
<para>
The
<xref
linkend=
"glo_Docker"
/>
hub's
<link
xlink:href=
"https://hub.docker.com/_/postgres"
>
image
name
</link>
.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerImageInstall-8-co"
xml:id=
"sda1_fig_postgresqlDockerImageInstall-8"
>
<para>
The running container's
<link
xlink:href=
"https://docs.docker.com/engine/reference/run/#container-identification"
>
UUID
long identifier
</link>
value.
</para>
</callout>
</calloutlist>
</figure>
<figure
xml:id=
"sda1_fig_postgresqlDockerConfigDb"
>
<title>
Database server post configuration
</title>
<screen>
docker exec -it postgres-latest bash
<co
linkends=
"sda1_fig_postgresqlDockerConfigDb-1"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-1-co"
/>
# su - postgres
<co
linkends=
"sda1_fig_postgresqlDockerConfigDb-2"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-2-co"
/>
$
<link
xlink:href=
"https://www.postgresql.org/docs/current/app-createuser.html"
>
createuser
</link>
hdmuser
<co
linkends=
"sda1_fig_postgresqlDockerConfigDb-3"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-3-co"
/>
$
<link
xlink:href=
"https://www.postgresql.org/docs/current/app-createdb.html"
>
createdb
</link>
--owner hdmuser hdm
<co
linkends=
"sda1_fig_postgresqlDockerConfigDb-4"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-4-co"
/>
$
<link
xlink:href=
"https://www.postgresql.org/docs/current/app-psql.html"
>
psql
</link>
<co
linkends=
"sda1_fig_postgresqlDockerConfigDb-5"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-5-co"
/>
psql (12.3 (Debian 12.3-1.pgdg100+1))
Type "help" for help.
postgres=# alter role hdmuser WITH PASSWORD 'XYZ';
<co
linkends=
"sda1_fig_postgresqlDockerConfigDb-6"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-6-co"
/>
ALTER ROLE
postgres=# exit
</screen>
<calloutlist
role=
"slideExclude"
>
<callout
arearefs=
"sda1_fig_postgresqlDockerConfigDb-1-co"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-1"
>
<para>
Enter your
<xref
linkend=
"glo_Docker"
/>
container.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerConfigDb-2-co"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-2"
>
<para>
Become
<property>
postgres
</property>
system user.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerConfigDb-3-co"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-3"
>
<para>
Create new
<productname>
Postgres
</productname>
database
user.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerConfigDb-4-co"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-4"
>
<para>
Create new database
<quote>
hdm
</quote>
owned by user
<quote>
hdmuser
</quote>
.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerConfigDb-5-co"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-5"
>
<para>
Connect to database server.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlDockerConfigDb-6-co"
xml:id=
"sda1_fig_postgresqlDockerConfigDb-6"
>
<para>
Set password
<quote>
XYZ
</quote>
for database user
<quote>
hdmuser
</quote>
.
</para>
</callout>
</calloutlist>
</figure>
</section>
<section
xml:id=
"sda1_sect_postgresNativeLinuxInstall"
>
<title>
Native Linux installation.
</title>
<screen>
useradd -r -s /usr/sbin/nologin hdmuser
<co
linkends=
"sda1_fig_postgresqlInstallUserPW-1"
xml:id=
"sda1_fig_postgresqlInstallUserPW-1-co"
/>
<figure
xml:id=
"sda1_fig_postgresqlDebInstall"
>
<title>
Installing
<xref
linkend=
"glo_Soft_Postgresql"
/>
package
</title>
<screen>
apt install postgresql-11 # Maybe newer?
</screen>
</figure>
<figure
xml:id=
"sda1_fig_postgresqlInstallUserPW"
>
<title>
Configuring
<xref
linkend=
"glo_Soft_Postgresql"
/></title>
<screen>
useradd -r -s /usr/sbin/nologin hdmuser
<co
linkends=
"sda1_fig_postgresqlInstallUserPW-1"
xml:id=
"sda1_fig_postgresqlInstallUserPW-1-co"
/>
#
>
su - postgres -c "createuser --interactive"
Enter name of role to add: hdmuser
...
...
@@ -219,36 +417,37 @@ Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
su - postgres -c "PGPASSWORD=XYZ createdb --owner hdmuser hdm"
<co
linkends=
"sda1_fig_postgresqlInstallUserPW-2"
xml:id=
"sda1_fig_postgresqlInstallUserPW-2-co"
/>
linkends=
"sda1_fig_postgresqlInstallUserPW-2"
xml:id=
"sda1_fig_postgresqlInstallUserPW-2-co"
/>
alter role hdmuser WITH PASSWORD 'XYZ';
PGPASSWORD=XYZ psql -h localhost --username=hdmuser -d hdm
<co
linkends=
"sda1_fig_postgresqlInstallUserPW-3"
xml:id=
"sda1_fig_postgresqlInstallUserPW-3-co"
/></screen>
<calloutlist
role=
"slideExclude"
>
<callout
arearefs=
"sda1_fig_postgresqlInstallUserPW-1-co"
xml:id=
"sda1_fig_postgresqlInstallUserPW-1"
>
<para>
Create a system user
<code>
hdmuser
</code>
at OS level. For
security reasons no system level access rights are being granted
to this account.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlInstallUserPW-2-co"
xml:id=
"sda1_fig_postgresqlInstallUserPW-2"
>
<para>
Create a database
<code>
hdm
</code>
with ownership
<code>
hdmuser
</code>
using password
<code>
XYZ
</code>
on behalf of
user
<code>
postgres
</code>
.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlInstallUserPW-3-co"
xml:id=
"sda1_fig_postgresqlInstallUserPW-3"
>
<para>
Connect to database
<code>
hdm
</code>
as user
<code>
hdmuser
</code>
using password
<code>
XYZ
</code>
.
</para>
</callout>
</calloutlist>
</figure>
linkends=
"sda1_fig_postgresqlInstallUserPW-3"
xml:id=
"sda1_fig_postgresqlInstallUserPW-3-co"
/></screen>
<calloutlist
role=
"slideExclude"
>
<callout
arearefs=
"sda1_fig_postgresqlInstallUserPW-1-co"
xml:id=
"sda1_fig_postgresqlInstallUserPW-1"
>
<para>
Create a system user
<code>
hdmuser
</code>
at OS level. For
security reasons no system level access rights are being granted
to this account.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlInstallUserPW-2-co"
xml:id=
"sda1_fig_postgresqlInstallUserPW-2"
>
<para>
Create a database
<code>
hdm
</code>
with ownership
<code>
hdmuser
</code>
using password
<code>
XYZ
</code>
on behalf
of user
<code>
postgres
</code>
.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlInstallUserPW-3-co"
xml:id=
"sda1_fig_postgresqlInstallUserPW-3"
>
<para>
Connect to database
<code>
hdm
</code>
as user
<code>
hdmuser
</code>
using password
<code>
XYZ
</code>
.
</para>
</callout>
</calloutlist>
</figure>
</section>
</section>
<section
xml:id=
"sda1SqlClient"
>
...
...
@@ -305,6 +504,80 @@ PGPASSWORD=XYZ psql -h localhost --username=hdmuser -d hdm <co
linkend=
"glo_Soft_Postgresql"
/>
is being described in detail at
<uri
xlink:href=
"https://www.jetbrains.com/help/idea/connecting-to-a-database.html#connect-to-postgresql-database"
>
https://www.jetbrains.com/help/idea/connecting-to-a-database.html#connect-to-postgresql-database
</uri>
.
</para>
</figure>
<figure
xml:id=
"sda1_fig_postgresqlConfigDemo"
>
<title><xref
linkend=
"glo_Soft_IntellijIDEA"
/>
<xref
linkend=
"glo_Soft_Postgresql"
/>
demo
</title>
<mediaobject>
<imageobjectco>
<areaspec
otherunits=
"imagemap"
units=
"other"
>
<area
coords=
"187,90,241,106"
linkends=
"sda1_fig_postgresqlConfigDemo-1.2"
xml:id=
"sda1_fig_postgresqlConfigDemo-1-co"
/>
<area
coords=
"184,129,242,143"
linkends=
"sda1_fig_postgresqlConfigDemo-2.2"
xml:id=
"sda1_fig_postgresqlConfigDemo-2-co"
/>
<area
coords=
"185,147,257,161"
linkends=
"sda1_fig_postgresqlConfigDemo-3.2"
xml:id=
"sda1_fig_postgresqlConfigDemo-3-co"
/>
<area
coords=
"185,168,225,182"
linkends=
"sda1_fig_postgresqlConfigDemo-4.2"
xml:id=
"sda1_fig_postgresqlConfigDemo-4-co"
/>
<area
coords=
"183,215,271,230"
linkends=
"sda1_fig_postgresqlConfigDemo-5.2"
xml:id=
"sda1_fig_postgresqlConfigDemo-5-co"
/>
<area
coords=
"59,16,86,32"
linkends=
"sda1_fig_postgresqlConfigDemo-6"
xml:id=
"sda1_fig_postgresqlConfigDemo-6-co"
/>
</areaspec>
<imageobject>
<imagedata
fileref=
"Ref/Jdbc/ideaDbConfig.svg.marked.svg"
/>
</imageobject>
<calloutlist
role=
"slideExclude"
>
<callout
arearefs=
"sda1_fig_postgresqlConfigDemo-1-co"
xml:id=
"sda1_fig_postgresqlConfigDemo-1.2"
>
<para>
Connect to your local operating system's internal
<quote>
loopback
</quote>
network interface.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlConfigDemo-2-co"
xml:id=
"sda1_fig_postgresqlConfigDemo-2.2"
>
<para>
The database user's name.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlConfigDemo-3-co"
xml:id=
"sda1_fig_postgresqlConfigDemo-3.2"
>
<para>
The database user's password as configured in
<xref
linkend=
"sda1_fig_postgresqlDockerConfigDb"
/>
.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlConfigDemo-4-co"
xml:id=
"sda1_fig_postgresqlConfigDemo-4.2"
>
<para>
The database within your server.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlConfigDemo-5-co"
xml:id=
"sda1_fig_postgresqlConfigDemo-5.2"
>
<para>
Check for success.
</para>
</callout>
<callout
arearefs=
"sda1_fig_postgresqlConfigDemo-6-co"
xml:id=
"sda1_fig_postgresqlConfigDemo-6"
>
<para>
Create global rather than project specific connection
profile.
</para>
</callout>
</calloutlist>
</imageobjectco>
</mediaobject>
</figure>
</section>
</section>
</section>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment