Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the configuration of the socket storage directory when the PostgreSQL database is started

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "PostgreSQL database startup socket storage directory configuration is what", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "PostgreSQL database startup socket storage directory configuration is what" it!

The unix_socket_directories parameter defaults to / tmp. Since this directory is a temporary directory to avoid misoperation, it is generally set in another directory.

Next, set unix_socket_directories to / data/pg12 and restart

[pg12@localhost pg120db] $grep 'unix' postgresql.conf unix_socket_directories =' / data/pg12' # comma-separated list of directories#unix_socket_directories ='/ tmp' # comma-separated list of directories#unix_socket_group =''# (change requires restart) # unix_socket_permissions = 0777 # begin with 0 to use octal notation [pg12@localhost pg120db] $[pg12@localhost pg120db] $pg_ctl restartpg_ctl: PID file "/ data/pgsql / pg120db/postmaster.pid "does not existIs server running?trying to start server anywaywaiting for server to start....2019-11-18 1815 CST 1715 35.123 CST [15542] LOG: starting PostgreSQL 12.0 on x86_64-pc-linux-gnu Compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit2019-11-18 18 CST 17 CST 35.123 CST [15542] LOG: listening on IPv4 address "0.0.0.0", port 54322019-11-18 18 18 CST 1715 CST [15542] LOG: listening on IPv6 address ":" Port 54322019-11-18 18 data/pg12/.s.PGSQL.5432 17 CST 35.155 CST [15542] LOG: listening on Unix socket "/ data/pg12/.s.PGSQL.5432" 2019-11-18 18 18 LOG 17 pg_log 35.237 CST [15542] LOG: redirecting log output to logging collector process2019-11-18 18 18 purge 1715 CST [15542] HINT: Future log output will appear in directory "pg_log". Doneserver started

Try to connect to the database

[pg12@localhost pg120db] $psql-d testdbpsql: error: could not connect to server: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/ tmp/.s.PGSQL.5432"?

Prompt that socket cannot be found (default is under / tmp). You can use the specified host-port connection

But this kind of connection is not a local connection.

[pg12@localhost ~] $netstat-anpo | grep psql (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp6 00:: 1grep psql 52206: 1grep psql 5432 ESTABLISHED 16200/psql keepalive (7207.79mp 0)

Set the parameter PGHOST and use the local connection (PGHOST behaves the same as the host connection parameter.)

[pg12@localhost pg120db] $export PGHOST=/data/pg12 [pg12@localhost pg120db] $psql-d testdbExpanded display is used automatically.psql Type "help" for help.... [pg12@localhost ~] $netstat-anpo | grep psql (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) unix 3 [] STREAM CONNECTED 876042 15681/psql [pg12@localhost ~] $

Or use-h to specify the directory where socket is located

[pg12@localhost] $psql-h / data/pg12Expanded display is used automatically.psql Type "help" for help. [local:/data/pg12]: 5432 pg12@testdb=#. [pg12@localhost ~] $netstat-anpo | grep psql (Not all processes could be identified, non-owned process info will not be shown) You would have to be root to see it all.) unix 3 [] STREAM CONNECTED 880596 16309/psql [pg12@localhost ~] $Thank you for reading The above is the content of "what is the configuration of the socket storage directory when the PostgreSQL database is started?" after the study of this article, I believe you have a deeper understanding of what the configuration of the socket storage directory is when the PostgreSQL database is started, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report