PG的share_buffers设置
注意:配置share_buffers参数时,单位为块,若配置512MB大小,则值应该配置512*1024/8,重启生效
[pg12@wcbpgcm1 log]$ psql
psql (12.9)
Type "help" for help.
postgres=# show shared_buffers ;
shared_buffers
----------------
128MB
(1 row)
postgres=# select * from pg_settings where name='shared_buffers';
name | setting | unit | category | short_desc | extra_
desc | context | vartype | source | min_val | max_val | enumvals | boot_val | reset_val | sourcefile
| sourceline | pending_restart
----------------+---------+------+-------------------------+--------------------------------------------------------------+-------
-----+------------+---------+--------------------+---------+------------+----------+----------+-----------+-----------------------
----------+------------+-----------------
shared_buffers | 16384 | 8kB | Resource Usage / Memory | Sets the number of shared memory buffers used by the server. |
| postmaster | integer | configuration file | 16 | 1073741823 | | 1024 | 16384 | /home/pg12/data/postgr
esql.conf | 122 | f
(1 row)
postgres=# alter system set shared_buffers=512MB;
ERROR: syntax error at or near "MB"
LINE 1: alter system set shared_buffers=512MB;
^
postgres=# alter system set shared_buffers=512*1024/8;
ERROR: syntax error at or near "*"
LINE 1: alter system set shared_buffers=512*1024/8;
^
postgres=# alter system set shared_buffers=512*1024/8;
ERROR: syntax error at or near "*"
LINE 1: alter system set shared_buffers=512*1024/8;
^
postgres=#
postgres=# SELECT 512*1024/8;
?column?
----------
65536
(1 row)
postgres=# alter system set shared_buffers=65536;
ALTER SYSTEM
postgres=# exit
[pg12@wcbpgcm1 log]$ pg_ctl restart
waiting for server to shut down.... done
server stopped
waiting for server to start....2022-04-14 21:33:55.484 CST [28847] LOG: pgaudit extension initialized
2022-04-14 21:33:55.484 CST [28847] LOG: starting PostgreSQL 12.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2022-04-14 21:33:55.485 CST [28847] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-04-14 21:33:55.485 CST [28847] LOG: could not bind IPv6 address "::1": Cannot assign requested address
2022-04-14 21:33:55.485 CST [28847] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2022-04-14 21:33:55.486 CST [28847] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2022-04-14 21:33:55.507 CST [28847] LOG: redirecting log output to logging collector process
2022-04-14 21:33:55.507 CST [28847] HINT: Future log output will appear in directory "log".
done
server started
[pg12@wcbpgcm1 log]$ psql
psql (12.9)
Type "help" for help.
postgres=# show shared_buffers ;
shared_buffers
----------------
512MB
(1 row)
postgres=# \q
[pg12@wcbpgcm1 log]$