postgresql change clustername but pg_lsclusters say it not changed



  • 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



  • Use the https://manpages.org/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.


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2