-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathINSTALL
More file actions
202 lines (143 loc) · 5.39 KB
/
INSTALL
File metadata and controls
202 lines (143 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
Ingres -> Post Ingres -> PostgreSQL
ubuntu 24.04 için paket kurulumu
pgdg -> PostgreSQL Global Development Group
önce reposiyory'i kuruyoruz
apt update
apt install -y postgresql-common
YES=yes /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
apt update
apt upgrade
initdb seçeneklerini değiştirmek
# /etc/postgresql-common/createcluster.conf
mkdir -p /etc/postgresql-common/createcluster.d
echo "create_main_cluster=false" > /etc/postgresql-common/createcluster.d/my.conf
echo "initdb_options = '--data-checksums --locale-provider=icu --icu-locale=tr-TR'" >> /etc/postgresql-common/createcluster.d/my.conf
hem client, hem sunucu kurulumu için
apt install postgresql
sadece client'ı kurmak için (psql, pg_dump vs)
apt install postgresql-client
varsayılan olarak en güncel versiyonu kuruyor,
LC_ALL=tr_TR.UTF-8 pg_createcluster --start 18 main
Türkçe hata mesajlarını ingilizce olarak değiştirmek
cp /etc/postgresql/18/main/postgresql.conf{,.bak}
sed -i "s/lc_messages = 'tr_TR.UTF-8'/lc_messages = 'en_US.UTF-8'/g" /etc/postgresql/18/main/postgresql.conf
systemctl restart postgresql
journalctl -xeu postgresql@18-main.service
systemctl status postgresql
systemctl status postgresql@18-main.service
temel ayarlar
vim /etc/postgresql/18/main/postgresql.conf
```
shared_buffers = # ram'in 1/4
effective_cache_size = # ram'in 1/2
maintenance_work_mem = 1GB # create index, vacuum vs rutin işlemler için
work_mem = 4MB # sort,order by işlemleri için kullanılan ram miktarı, yeterli olmazsa temp dosyalar kullanılıyor
```
crontab -e -u postgres
```
0 5 * * * /usr/bin/vacuumdb --full --analyze --all -q
```
/etc/postgresql/[version]/[cluster]/pg_ctl.conf
Configuration files: /etc/postgresql/[version]/[cluster]/
Binaries: /usr/lib/postgresql/[version]
Data files: /var/lib/postgresql/[version]/[cluster]
log dosyaları /var/log/postgresql/postgresql-[version]-[cluster].log
/usr/lib/systemd/system/postgresql@.service
system-postgresql.slice
systemctl status postgresql
systemctl restart postgresql
ile tüm cluster'ı tüm veritabanlarını restart ediyor
pg_lsclusters
```
Ver Cluster Port Status Owner Data directory Log file
18 main 5432 online postgres /var/lib/postgresql/18/main /var/log/postgresql/postgresql-18-main.log
```
ikinci cluster oluşturmak
NOT: ikinci cluster'ı 5433 portundan çalıştırdı
sudo pg_createcluster 18 test --start --locale=tr_TR.UTF8 --encoding=UTF-8
data dizini vs verilebiliyor
sudo pg_ctlcluster 18 test status
sudo pg_ctlcluster 18 test restart
sudo pg_ctlcluster 18 test stop
sudo pg_ctlcluster 18 test start
pg_renamecluster 18 test beta
test'in adını beta olarak değiştiriyor,
stop start yapıyor
son versiyona pg_upgrade yapıyor
pg_upgradecluster 18 beta
giriş yapabilmek için işletim sistemi kullanıcısı olan postgres ile bağlanabiliyoruz
şifre istemiyor
pg_hba.conf'ta varsayılan olarak
```
local all postgres peer
```
root - su ile
su -c /usr/bin/psql postgres
sudo ile
sudo -u postgres psql
yada login olup çalıştır
sudo su - postgres
sudo -u postgres /bin/bash
psql
başka bir porttaki postgresql'e bağlanmak için
psql -U postgres -p 5433 -h /var/run/postgresql
peer ile local bağlantılar için sistem kullanıcısı - db kullanıcısı aynı adda olacak
sudo -i -u postgres psql -d postgres -U postgres
gibi giriş yapabiliyoruz
peer authentication'ı geçmek için (local auth'dan host auth'a geçiyoruz)
bu komutu herhangi bir kullanıcı olarak çalıştırabiliriz
psql -d test -U postgres -h 127.0.0.1
varsayılan olarak localhostu dinliyor
ss -tunelp | grep 5432
postgresl.conf'tan
istersek sistemdeki tanımlı tüm ipleri
listen_addresses = '*'
istersek istediğimiz ip'yi dinleyebilecek şekilde
listen_addresses = '10.10.0.2'
varsayılan olarak kurulan cluster varsayılan değerlerle oluşturuluyor, silip yeniden oluşturmak için
pg_dropcluster --stop <version> main
ör:
pg_dropcluster --stop 18 main
pg_createcluster --locale tr_TR.UTF-8 --start 18 main
src/contrib dizini içerisindeki extension'lar
/usr/lib/postgresql/<VERSION>/lib
dizininde kurulu geliyor
sudo vim /etc/postgresql/<VERSION>/main/postgresql.conf
```
shared_preload_libraries = ''
=>
shared_preload_libraries = 'pg_stat_statements'
```
sudo pg_ctlcluster 18 main restart
yada apt paketinden kurmak istersek
apt install postgresql-18-postgis-3
create extension postgis;
SELECT PostGIS_Full_Version();
kurulu olan pgsql paketleri
dpkg --get-selections | grep postgres
pg_createcluster - Create a new cluster or integrate an existing one
into the postgresql-common architecture.
pg_dropcluster - Completely remove a cluster.
pg_ctlcluster - Control the server process of a cluster
(start, stop, restart).
pg_lsclusters - Show a list of all existing clusters and their status.
pg_upgradecluster - Migrate a cluster from one major version to another one.
pg_renamecluster - Rename a cluster.
-----
cluster oluşturulmadan varsayılan ayarları değiştirebiliriz
data dizini değiştirme
install -dm755 -o postgres -g postgres /opt/pgsql/
vim /etc/postgresql-common/createcluster.conf
```
data_directory = '/var/lib/postgresql/%v/%c'
=>
data_directory = '/opt/pgsql/%v/%c'
```
-----
pg_upgradecluster 17 main -v 18
pg_dropcluster 17 main
denedim çalıştı,
fakat upgrade etmeden önce,
/etc/postgresql/18/
dizininin bir yedeğini al,
17 nin ayarlarını alıyor