600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 如何查看数据库当前连接数和最大连接数

如何查看数据库当前连接数和最大连接数

时间:2023-04-28 01:58:25

相关推荐

如何查看数据库当前连接数和最大连接数

目录

环境

文档用途

详细信息

环境

系统平台:中标麒麟(CPU龙芯)7,中标麒麟(CPU申威)7,中标麒麟(CPU海光)7,Linux x86-64 Red Hat Enterprise Linux 7

版本:6.0,5.6.5,4.5,4.5.2,4.3.4.9

文档用途

本文主要用于介绍查看数据库连接数方面的SQL语句。

详细信息

1、查看数据库当前连接数

select count(*) from pg_stat_activity;

[highgo@host1 ~]$ psqlType "help" for help.highgo=# select count(*) from pg_stat_activity ;count-------6(1 row)

2、查看数据库最大连接数,此数值包含为超级用户预留的连接数,详见第3部分

①登录数据库后通过语句查询

show max_connection;

highgo=# show max_connections ;max_connections-----------------100(1 row)

②查看postgresql.conf或postgresql.auto.conf文件

[highgo@host1 ~]$ cd $PGDATA[highgo@host1 data]$ more postgresql.conf |grep max_connectionsmax_connections = 100 # (change requires restart)

3、superuser_reserved_connections

此参数为数据库为超级用户预留的连接数,默认值为3。当数据库的连接数达到(max_connections - superuser_reserved_connections)时,只有超级用户才能建立新的数据库连接,普通用户连接时将会返回错误信息“FATAL: sorry, too many clients already.”或者“FATAL: remaining connection slots are reserved for non-replication superuser connections”,登录数据库查询。

highgo=# show superuser_reserved_connections;superuser_reserved_connections--------------------------------3(1 行记录)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。