Skip to content

Commit 3d3660a

Browse files
committed
Add a PostgreSQL installiation til
1 parent fa16125 commit 3d3660a

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ TIL is a collection of the things that I learned today. The contents can be anyt
101101

102102
- [Building PMDK on Ubuntu](pmdk/building-pmdk-on-ubuntu.md)
103103

104+
### PostgreSQL
105+
106+
- [PostgreSQL installation from source code](postgresql/installation-from-source-code.md)
107+
104108
### Predix
105109

106110
- [Predix overview](predix/predix-overview.md) :kr:
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# PostgreSQL installation from source code
2+
3+
Building PostgreSQL from the source code enables you to customize build parameters, compiler optimizations, and installation location.
4+
5+
- [Reference](https://www.postgresql.org/docs/11/installation.html)
6+
7+
## Get the source
8+
9+
You can download the sources from the [website](https://www.postgresql.org/download). Then, unpack it:
10+
11+
```bash
12+
$ tar xf postgresql-11.4.tar
13+
```
14+
15+
## Build and install
16+
17+
First, make a directory for build and configure the source tree for your system.
18+
19+
```bash
20+
$ mkdir build_dir
21+
$ ./configure --prefix=/path/to/build_dir
22+
```
23+
24+
Then build and install the source code.
25+
(8: # of cores in your machine)
26+
27+
```bash
28+
$ make -j8 install
29+
```
30+
31+
You need to tell the system how to find the newly installed shared libraries. Set the shared library search path in `~/.bashrc`:
32+
33+
```bash
34+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/build_dir/lib
35+
export PATH=/path/to/build_dir/bin:$PATH
36+
```
37+
38+
Then, apply the modified path:
39+
40+
```bash
41+
$ source ~/.bashrc
42+
```
43+
44+
## Start the database server
45+
46+
Before you can do anything, you must initialize a database storage area on disk. To initialize a database cluster, use the command `initdb`, which is installed with PostgreSQL. The desired file system location of your database cluster is indicated by the `-D` option:
47+
48+
```bash
49+
$ initdb -D /path/to/data_dir
50+
```
51+
52+
Then, start the server with a log file:
53+
54+
```bash
55+
$ pg_ctl -D /path/to/data_dir -l logfile start
56+
```
57+
58+
You can stop the server using below command:
59+
60+
```bash
61+
$ pg_ctl -D /path/to/data_dir -m smart stop
62+
```

0 commit comments

Comments
 (0)