POSTGRESQL-13 KURULUMU
İşletim sistemi olarak Rathet 7.4 kullanacağız.
# sudo yum install -y postgresql13-server
/etc/hosts dosyasına ip ve hostname kısmını ekliyoruz
echo 150.150.100.71 psgdbm1 >> /etc/hosts
Database dosyalarımız için klasörümüzü oluşturalım ve yetkilendirmesini yapalım ayrııca postgres userına parola oluşturalım.
# mkdir -p /database/data
# id postgres
uid=26(postgres) gid=26(postgres) groups=26(postgres)
# chown postgres:postgres -R /database/
# passwd postgres
# su - postgres
postgres .bash_profile dosyasını düzenleyelim.
PGDATA=/database/data
export PGDATA
PATH=$PATH:/usr/pgsql-13/bin
export PATH
Postgresql servislerini çlıştırmadan önce data dosyasının yerini postgresql servis dosyasında environment PGDATA kısmını aşağıdaki gibi değiştirelim.
# vi /usr/lib/systemd/system/postgresql-13.service
Environment=PGDATA=/database/data/
şimdi postgres kullanıcı ile aşağıdaki komutu veriyoruz.
$ initdb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /database/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Istanbul
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D /database/data -l logfile start
/database/data dizinine database kurulumumuz yapıldı. Şimdi bazı dosyaları inceleyelim. potgres userı ile $PGDATA dizini altındaki dosyaları inclersek;
$ cd $PGDATA
$ ls
base pg_commit_ts pg_logical pg_serial pg_subtrans pg_wal postmaster.opts
current_logfiles pg_dynshmem pg_multixact pg_snapshots pg_tblspc pg_xact postmaster.pid
global pg_hba.conf pg_notify pg_stat pg_twophase postgresql.auto.conf
log pg_ident.conf pg_replslot pg_stat_tmp PG_VERSION postgresql.conf
Database client bağlantıları için izinleri girebildiğimiz pg_hba.conf dosyasını düzenleyelim. Bu dosyanın en altına aşağıdaki satırı ekleyerek tüm IP aralıkları için bağlantı izni sağlıyoruz.
$ vi pg_hba.conf
host all all 0.0.0.0/0 trust
Diğer bir ayar yapacağımız dosya ise postgresql.conf dosyasıdır; Bu dosya içerisinde listener ayarlarını “localhos” tan alıp tüm bağlantıları dinlemesi için “*” ile değiştiriyoruz. Ayrıca listener portunuda 5432 olarak açıyoruz.
$ vi postgresql.conf
listen_addresses = '*'
port = 5432
Root ile firewall 5432 portu için izin sağlıyoruz
# firewall-cmd --add-port=5432/tcp --permanent
success
# firewall-cmd --reload
success
Postgresql servisini tekrar çalıştıralım
# systemctl restart postgresql-13
# systemctl status postgresql-13
● postgresql-13.service - PostgreSQL 13 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2021-02-17 16:33:53 +03; 1min 35s ago
Docs: https://www.postgresql.org/docs/13/static/
Process: 2308 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 2314 (postmaster)
CGroup: /system.slice/postgresql-13.service
├─2314 /usr/pgsql-13/bin/postmaster -D /database/data/
├─2317 postgres: logger
├─2319 postgres: checkpointer
├─2320 postgres: background writer
├─2321 postgres: walwriter
├─2322 postgres: autovacuum launcher
├─2323 postgres: stats collector
└─2324 postgres: logical replication launcher
Feb 17 16:33:48 psgdbm1 systemd[1]: Starting PostgreSQL 13 database server...
Feb 17 16:33:48 psgdbm1 postmaster[2314]: 2021-02-17 16:33:48.399 +03 [2314] LOG: redirecting log output ...ocess
Feb 17 16:33:48 psgdbm1 postmaster[2314]: 2021-02-17 16:33:48.399 +03 [2314] HINT: Future log output will...log".
Feb 17 16:33:53 psgdbm1 systemd[1]: Started PostgreSQL 13 database server.
Hint: Some lines were ellipsized, use -l to show in full.
Bir sonraki yazımızda mimari özelliklerini inceleyeceğiz.