Supaya server PostgreSQL dapat digunakan oleh client maka kita melakukan start server. Program server dari PostgreSQL ini disebut dengan postgres. Pada waktu melakukan starting pada postgres ini kita harus memberi tahu di mana folder dari data yang akan digunakan. Secara teknis ini dilakukan dengan memberikan parameter -D pada saat melakukan start postgres.
Beberapa hal berkaitan dengan program server PostgreSQL yang ada pada postgres adalah seperti berikut ini
- Ketika PostgreSQL sudah distart oleh systemd maka kita ingin melihat lokasi folder data dan konfigurasi
root@odoo-dev# ps -ef | grep postgresql postgres 19738 1 0 Jan08 ? 00:00:27 /usr/lib/postgresql/12/bin/postgres -D /var/lib/postgresql/12/main -c config_file=/etc/postgresql/12/main/postgresql.conf
Tampak postgres sudah dijalankan dengan menggunakan folder data /var/lib/postgresql/12/main dan dengan konfigurasi di /etc/postgresql/12/main/postgresql.conf .
- Melihat status postgresql
root@odoo-dev# systemctl status postgresql ● postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled) Active: active (exited) since Sat 2022-01-08 15:28:39 WIB; 5 days ago Main PID: 19499 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 9485) Memory: 0B CGroup: /system.slice/postgresql.service
Kita melihat bahwa progress dijalankan dengan script di /lib/systemd/system/postgresql.service .
- Melihat isi service
root@odoo-dev# cat /lib/systemd/system/postgresql.service # systemd service for managing all PostgreSQL clusters on the system. This # service is actually a systemd target, but we are using a service since # targets cannot be reloaded. [Unit] Description=PostgreSQL RDBMS [Service] Type=oneshot ExecStart=/bin/true ExecReload=/bin/true RemainAfterExit=on [Install] WantedBy=multi-user.target
Di sini kita melihat isi dari /lib/systemd/system/postgresql.service .
- Melihat isi service dengan @
root@odoo-dev# cat /lib/systemd/system/postgresql@.service # systemd service template for PostgreSQL clusters. The actual instances will # be called "postgresql@version-cluster", e.g. "postgresql@9.3-main". The # variable %i expands to "version-cluster", %I expands to "version/cluster". # (%I breaks for cluster names containing dashes.) [Unit] Description=PostgreSQL Cluster %i AssertPathExists=/etc/postgresql/%I/postgresql.conf RequiresMountsFor=/etc/postgresql/%I /var/lib/postgresql/%I PartOf=postgresql.service ReloadPropagatedFrom=postgresql.service Before=postgresql.service # stop server before networking goes down on shutdown After=network.target [Service] Type=forking # -: ignore startup failure (recovery might take arbitrarily long) # the actual pg_ctl timeout is configured in pg_ctl.conf ExecStart=-/usr/bin/pg_ctlcluster --skip-systemctl-redirect %i start # 0 is the same as infinity, but "infinity" needs systemd 229 TimeoutStartSec=0 ExecStop=/usr/bin/pg_ctlcluster --skip-systemctl-redirect -m fast %i stop TimeoutStopSec=1h ExecReload=/usr/bin/pg_ctlcluster --skip-systemctl-redirect %i reload PIDFile=/run/postgresql/%i.pid SyslogIdentifier=postgresql@%i # prevent OOM killer from choosing the postmaster (individual backends will # reset the score to 0) OOMScoreAdjust=-900 # restarting automatically will prevent "pg_ctlcluster ... stop" from working, # so we disable it here. Also, the postmaster will restart by itself on most # problems anyway, so it is questionable if one wants to enable external # automatic restarts. #Restart=on-failure # (This should make pg_ctlcluster stop work, but doesn't:) #RestartPreventExitStatus=SIGINT SIGTERM [Install] WantedBy=multi-user.target
Di sini kita melihat isi dari /lib/systemd/system/postgresql@.service
Informasi lebih lanjut silahkan mengunjungi
1. https://www.postgresql.org/docs/12/server-start.html .
2. https://superuser.com/questions/393423/the-symbol-and-systemctl-and-vsftpd .
3. https://wiki.archlinux.org/title/systemd .
4. https://www.freedesktop.org/software/systemd/man/systemd.unit.html .
Kunjungi www.proweb.co.id untuk menambah wawasan anda.