All we need is an easy explanation of the problem, so here it is.
SELECT current_setting('cluster_name'), current_setting('server_version');
return:
current_setting | current_setting
-----------------+----------------------------------
my_cluster_14 | 14.3 (Ubuntu 14.3-1.pgdg20.04+1)
My Ubuntu version:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
But when I run pg_lsclusters
It return
Ver Cluster Port Status Owner Data directory Log file
14 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
which means
I can only do
sudo /usr/bin/pg_ctlcluster 14/main reload
I cannot do
/usr/bin/pg_ctlcluster 14/my_cluster_14 reload
I thought If I renamed the cluster name, I can do
/usr/bin/pg_ctlcluster 14/my_cluster_14 reload
So
is possible to run /usr/bin/pg_ctlcluster 14/my_cluster_14 reload
?
What the use case of rename the cluster_name? \
solved via
sudo /usr/bin/pg_renamecluster 14 main my_cluster_14
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
Method 1
Use the pg_renamecluster
command:
pg_renamecluster changes the name of a PostgreSQL cluster, i. e. the
name of the config directory in /etc/postgresql/version/ along with
the data directory in /var/lib/postgresql/version/. Existing log files
in /var/log/postgresql/ are also renamed. The cluster is stopped and
started for the operation.The following postgresql.conf config options are updated to refer to
the changed path names: data_directory, hba_file, ident_file,
external_pid_file, stats_temp_directory.Cluster names are a Debian convention, the name is not explicitly
known to the cluster itself. From the PostgreSQL viewpoint, the name
is merely a substring of various path names.
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0