Thread: PostgreSQL14.2 can not start because of huge_page_size is equal to 1048576
Re: PostgreSQL14.2 can not start because of huge_page_size is equal to 1048576
on
in postgresql.conf
. Note that with this setting PostgreSQL will fail to start if not enough huge pages are available.”On May 9, 2022, at 8:56 AM, 类延良 <msdnchina@163.com> wrote:My rhel 7.9 enabled 1GB hugepagesize,and in this rhel7.9,there is a postgresql 14.2 (from compile installation).[root@localhost ~]# cat /proc/meminfo |grep -i hugepAnonHugePages: 8192 kBHugePages_Total: 0HugePages_Free: 0HugePages_Rsvd: 0HugePages_Surp: 0Hugepagesize: 1048576 kB[root@localhost ~]# hugeadm --pool-listSize Minimum Current Maximum Default1073741824 0 0 0 *[root@localhost ~]#after I change pg parameter huge_page_size to 1048576, I can not start PostgreSQL 14.2 . the following is the error,[pg142@localhost data]$ grep huge postgresql.conf#huge_pages = try # on, off, or tryhuge_page_size = 1048576 # zero for system default[pg142@localhost data]$ pg_ctl startwaiting for server to start....2022-05-09 04:36:58.220 GMT [1719] LOG: invalid value for parameter "huge_page_size": 10485762022-05-09 04:36:58.220 GMT [1719] DETAIL: huge_page_size must be 0 on this platform.2022-05-09 12:36:58.220 CST [1719] FATAL: configuration file "/home/pg142/data/postgresql.conf" contains errorsstopped waitingpg_ctl: could not start serverExamine the log output.[pg142@localhost data]$I want to know why ?
[root@localhost ~]# echo 2072 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
[root@localhost ~]# cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
2057
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# cd $PGDATA
[root@localhost data]# grep huge postgresql.conf
grep: postgresql.conf: No such file or directory
[root@localhost data]# su - pg142
Last login: Mon May 9 22:47:48 CST 2022 on pts/0
[pg142@localhost ~]$ cd $PGDATA
[pg142@localhost data]$ grep huge postgresql.conf
huge_pages = try # on, off, or try
huge_page_size = 2048 # zero for system default
[pg142@localhost data]$ hugeadm --pool-list
Size Minimum Current Maximum Default
2097152 2057 2057 2057 ---->>>but non-default hugepagesize is 2048KB
1073741824 3 3 3 * ---->>>default hugepagesize is 1gb
[pg142@localhost data]$ pg_ctl start
waiting for server to start....2022-05-09 15:09:15.023 GMT [1733] LOG: invalid value for parameter "huge_page_size": 2048
2022-05-09 15:09:15.023 GMT [1733] DETAIL: huge_page_size must be 0 on this platform.
2022-05-09 23:09:15.023 CST [1733] FATAL: configuration file "/home/pg142/data/postgresql.conf" contains errors
stopped waiting
pg_ctl: could not start server
Examine the log output.
[pg142@localhost data]$
At 2022-05-09 22:09:20, "John Wiencek" <jwiencek3@comcast.net> wrote:
Found this:See section: 19.4.5. Linux Huge Pages"The default behavior for huge pages in PostgreSQL is to use them when possible, with the system's default huge page size, and to fall back to normal pages on failure. To enforce the use of huge pages, you can set huge_pages toon
inpostgresql.conf
. Note that with this setting PostgreSQL will fail to start if not enough huge pages are available.”On May 9, 2022, at 8:56 AM, 类延良 <msdnchina@163.com> wrote:My rhel 7.9 enabled 1GB hugepagesize,and in this rhel7.9,there is a postgresql 14.2 (from compile installation).[root@localhost ~]# cat /proc/meminfo |grep -i hugepAnonHugePages: 8192 kBHugePages_Total: 0HugePages_Free: 0HugePages_Rsvd: 0HugePages_Surp: 0Hugepagesize: 1048576 kB[root@localhost ~]# hugeadm --pool-listSize Minimum Current Maximum Default1073741824 0 0 0 *[root@localhost ~]#after I change pg parameter huge_page_size to 1048576, I can not start PostgreSQL 14.2 . the following is the error,[pg142@localhost data]$ grep huge postgresql.conf#huge_pages = try # on, off, or tryhuge_page_size = 1048576 # zero for system default[pg142@localhost data]$ pg_ctl startwaiting for server to start....2022-05-09 04:36:58.220 GMT [1719] LOG: invalid value for parameter "huge_page_size": 10485762022-05-09 04:36:58.220 GMT [1719] DETAIL: huge_page_size must be 0 on this platform.2022-05-09 12:36:58.220 CST [1719] FATAL: configuration file "/home/pg142/data/postgresql.conf" contains errorsstopped waitingpg_ctl: could not start serverExamine the log output.[pg142@localhost data]$I want to know why ?
My rhel 7.9 enabled 1GB hugepagesize,and in this rhel7.9,there is a postgresql 14.2 (from compile installation).[root@localhost ~]# cat /proc/meminfo |grep -i hugepAnonHugePages: 8192 kBHugePages_Total: 0HugePages_Free: 0HugePages_Rsvd: 0HugePages_Surp: 0Hugepagesize: 1048576 kB[root@localhost ~]# hugeadm --pool-listSize Minimum Current Maximum Default1073741824 0 0 0 *[root@localhost ~]#after I change pg parameter huge_page_size to 1048576, I can not start PostgreSQL 14.2 . the following is the error,[pg142@localhost data]$ grep huge postgresql.conf#huge_pages = try # on, off, or tryhuge_page_size = 1048576 # zero for system default[pg142@localhost data]$ pg_ctl startwaiting for server to start....2022-05-09 04:36:58.220 GMT [1719] LOG: invalid value for parameter "huge_page_size": 10485762022-05-09 04:36:58.220 GMT [1719] DETAIL: huge_page_size must be 0 on this platform.2022-05-09 12:36:58.220 CST [1719] FATAL: configuration file "/home/pg142/data/postgresql.conf" contains errorsstopped waitingpg_ctl: could not start serverExamine the log output.[pg142@localhost data]$I want to know why ?
The DETAIL message says " huge_page_size must be 0", but you did not set huge_page_size to 0.
That may be the problem.
Angular momentum makes the world go 'round.
Re:Re: PostgreSQL14.2 can not start because of huge_page_size is equal to 1048576
0
). When set to 0
, the default huge page size on the system will be used. [root@localhost ~]# echo 2072 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
[root@localhost ~]# cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
2057
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# cd $PGDATA
[root@localhost data]# grep huge postgresql.conf
grep: postgresql.conf: No such file or directory
[root@localhost data]# su - pg142
Last login: Mon May 9 22:47:48 CST 2022 on pts/0
[pg142@localhost ~]$ cd $PGDATA
[pg142@localhost data]$ grep huge postgresql.conf
huge_pages = try # on, off, or try
huge_page_size = 2048 # zero for system default
[pg142@localhost data]$ hugeadm --pool-list
Size Minimum Current Maximum Default
2097152 2057 2057 2057 ---->>>but non-default hugepagesize is 2048KB
1073741824 3 3 3 * ---->>>default hugepagesize is 1gb
[pg142@localhost data]$ pg_ctl start
waiting for server to start....2022-05-09 15:09:15.023 GMT [1733] LOG: invalid value for parameter "huge_page_size": 2048 --->>> I want to use 2M hugepagesize
2022-05-09 15:09:15.023 GMT [1733] DETAIL: huge_page_size must be 0 on this platform.
2022-05-09 23:09:15.023 CST [1733] FATAL: configuration file "/home/pg142/data/postgresql.conf" contains errors
stopped waiting
pg_ctl: could not start server
Examine the log output.
[pg142@localhost data]$
在 2022-05-09 23:39:52,"Ron" <ronljohnsonjr@gmail.com> 写道:
On 5/9/22 08:56, 类延良 wrote:My rhel 7.9 enabled 1GB hugepagesize,and in this rhel7.9,there is a postgresql 14.2 (from compile installation).[root@localhost ~]# cat /proc/meminfo |grep -i hugepAnonHugePages: 8192 kBHugePages_Total: 0HugePages_Free: 0HugePages_Rsvd: 0HugePages_Surp: 0Hugepagesize: 1048576 kB[root@localhost ~]# hugeadm --pool-listSize Minimum Current Maximum Default1073741824 0 0 0 *[root@localhost ~]#after I change pg parameter huge_page_size to 1048576, I can not start PostgreSQL 14.2 . the following is the error,[pg142@localhost data]$ grep huge postgresql.conf#huge_pages = try # on, off, or tryhuge_page_size = 1048576 # zero for system default[pg142@localhost data]$ pg_ctl startwaiting for server to start....2022-05-09 04:36:58.220 GMT [1719] LOG: invalid value for parameter "huge_page_size": 10485762022-05-09 04:36:58.220 GMT [1719] DETAIL: huge_page_size must be 0 on this platform.2022-05-09 12:36:58.220 CST [1719] FATAL: configuration file "/home/pg142/data/postgresql.conf" contains errorsstopped waitingpg_ctl: could not start serverExamine the log output.[pg142@localhost data]$I want to know why ?
The DETAIL message says " huge_page_size must be 0", but you did not set huge_page_size to 0.
That may be the problem.--
Angular momentum makes the world go 'round.
"yanliang lei" <msdnchina@163.com> writes: > The DETAIL message says " huge_page_size must be 0", but you did not set huge_page_size to 0. > ---huge_page_size is the pg14 new parameter£¬The default value of this parameter is zero (0). When set to 0, the defaulthuge page size on the system will be used. > in the pg 14 documents---¡®Non-default settings are currently supported only on Linux.¡¯ so £¬ I want to try to find amethod to let PostgreSQL 14 to use non-default hugepagesize£¬ The code that's throwing the error says /* Recent enough Linux only, for now. See GetHugePageSize(). */ I don't know what "recent enough" is in this context, but evidently RHEL7 isn't it (no surprise considering that's a trailing-edge distro at this point). I don't find it surprising that the authors of this feature didn't try to document exactly which Linux versions it can be used on. Keeping such documentation accurate would be a nightmare. regards, tom lane
Re:Re: PostgreSQL14.2 can not start because of huge_page_size is equal to 1048576
At 2022-05-10 00:27:14, "Tom Lane" <tgl@sss.pgh.pa.us> wrote: >"yanliang lei" <msdnchina@163.com> writes: >> The DETAIL message says " huge_page_size must be 0", but you did not set huge_page_size to 0. >> ---huge_page_size is the pg14 new parameter£¬The default value of this parameter is zero (0). When set to 0, the default huge page size on the system will be used. >> in the pg 14 documents---¡®Non-default settings are currently supported only on Linux.¡¯ so £¬ I want to try to find a method to let PostgreSQL 14 to use non-default hugepagesize£¬ > >The code that's throwing the error says > > /* Recent enough Linux only, for now. See GetHugePageSize(). */ > >I don't know what "recent enough" is in this context, but evidently >RHEL7 isn't it (no surprise considering that's a trailing-edge distro >at this point). > >I don't find it surprising that the authors of this feature didn't >try to document exactly which Linux versions it can be used on. >Keeping such documentation accurate would be a nightmare. > > regards, tom lane >
Re:Re:Re: PostgreSQL14.2 can not start because of huge_page_size is equal to 1048576
the detail result is :
in the RHEL 8.X, PostgreSQL can use non-default hugepagesize, and in the RHEL 7.X, PostgreSQL can not use non-default hugepagesize!
[pg142@rhel85 data]$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.5 (Ootpa)
[pg142@rhel85 data]$ uname -r
4.18.0-348.el8.x86_64
[pg142@rhel85 data]$
[pg142@rhel85 ~]$ grep ^Huge /proc/meminfo
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 1048576 kB ----->>> OS default hugepagesize is 1GB
Hugetlb: 0 kB
[pg142@rhel85 ~]$
[pg142@rhel85 ~]$ head -1 $PGDATA/postmaster.pid
1679
[pg142@rhel85 ~]$ pmap 1679| awk '/rw-s/ && /zero/ {print $2}'
828480K
[pg142@rhel85 ~]$
(828480K+256*1024)/2048=533 ----->>>PostgreSQL uses 533 hugepages which size is 2MB
in the /boot/grub2/grubenv file ,add: hugepagesz=2M hugepages=533
[root@rhel85 ~]# grub2-editenv - list | grep kernelopts
kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet default_hugepagesz=1G
[root@rhel85 ~]#
grub2-editenv - set "kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet default_hugepagesz=1G hugepagesz=2M hugepages=533"
grub2-editenv - list | grep kernelopts
systemctl reboot
after OS reboot, we can see :
root@rhel85 ~]# hugeadm --pool-list
Size Minimum Current Maximum Default
2097152 533 533 533
1073741824 0 0 0 *
[root@rhel85 ~]#
[root@rhel85 ~]# cat /proc/meminfo |grep -i huge
AnonHugePages: 16384 kB
ShmemHugePages: 0 kB
FileHugePages: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 1048576 kB
Hugetlb: 1091584 kB
[root@rhel85 ~]#
then modify parameter huge_page_size=2048 in the postgreSQL 14.2 postgresql.conf
[pg142@rhel85 data]$ grep huge_page_size postgresql.conf
huge_page_size = 2048 # zero for system default
[pg142@rhel85 data]$
[pg142@rhel85 data]$ pg_ctl start
waiting for server to start....2022-05-13 21:26:24.051 CST [1694] LOG: starting PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-3), 64-bit
2022-05-13 21:26:24.051 CST [1694] LOG: listening on IPv6 address "::1", port 5432
2022-05-13 21:26:24.051 CST [1694] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-05-13 21:26:24.053 CST [1694] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2022-05-13 21:26:24.058 CST [1695] LOG: database system was shut down at 2022-05-13 21:22:22 CST
2022-05-13 21:26:24.063 CST [1694] LOG: database system is ready to accept connections
done
server started
[pg142@rhel85 data]$ pg_ctl status
pg_ctl: server is running (PID: 1694)
/home/pg142/soft/bin/postgres
[pg142@rhel85 data]$
[pg142@rhel85 data]$ psql -d postgres
psql (14.2)
Type "help" for help.
postgres=# show huge_page_size;
huge_page_size
----------------
2MB
(1 row)
postgres=# show huge_pages;
huge_pages
------------
try
(1 row)
postgres=#
At 2022-05-10 00:58:31, "yanliang lei" <msdnchina@163.com> wrote:
Thanks a lot for your reply!Oh,I see!I will test this case in the rhel8.5( RHEL 8.5 is the latest version of RHEL so far)I will post my test result through this email。
At 2022-05-10 00:27:14, "Tom Lane" <tgl@sss.pgh.pa.us> wrote: >"yanliang lei" <msdnchina@163.com> writes: >> The DETAIL message says " huge_page_size must be 0", but you did not set huge_page_size to 0. >> ---huge_page_size is the pg14 new parameter£¬The default value of this parameter is zero (0). When set to 0, the default huge page size on the system will be used. >> in the pg 14 documents---¡®Non-default settings are currently supported only on Linux.¡¯ so £¬ I want to try to find a method to let PostgreSQL 14 to use non-default hugepagesize£¬ > >The code that's throwing the error says > > /* Recent enough Linux only, for now. See GetHugePageSize(). */ > >I don't know what "recent enough" is in this context, but evidently >RHEL7 isn't it (no surprise considering that's a trailing-edge distro >at this point). > >I don't find it surprising that the authors of this feature didn't >try to document exactly which Linux versions it can be used on. >Keeping such documentation accurate would be a nightmare. > > regards, tom lane >