-2

I am trying to install Apache age and Postgres from source code but i am not able to start postgres Server

`
The files belonging to this database system will be owned by user "faruukh".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

initdb: could not access directory "/usr/local/pgsql/bin/psql": Not a directory
faruukh@ubuntu:~$ sudo chown -R farrukh /usr/local/pgsql/ 
chown: invalid user: ‘farrukh’
faruukh@ubuntu:~$ sudo chown -R faruukh /usr/local/pgsql/ 
faruukh@ubuntu:~$ which psql
/usr/local/pgsql/bin//psql
faruukh@ubuntu:~$ ls /usr/local/pgsql/bin/
clusterdb   data      ecpg               pg_basebackup  pg_controldata  pg_dumpall     pg_recvlogical  pg_rewind       pg_upgrade           postgres    reindexdb
createdb    dropdb    initdb             pgbench        pg_ctl          pg_isready     pg_resetwal     pg_test_fsync   pg_verify_checksums  postmaster  vacuumdb
createuser  dropuser  pg_archivecleanup  pg_config      pg_dump         pg_receivewal  pg_restore      pg_test_timing  pg_waldump           psql
faruukh@ubuntu:~$ export PATH=/usr/local/pgsql/bin//psql:$PATH
faruukh@ubuntu:~$ export PGDATA=/usr/local/pgsql/bin//psql/data
faruukh@ubuntu:~$ sudo chown -R faruukh /usr/local/pgsql/ 
faruukh@ubuntu:~$ initdb
The files belonging to this database system will be owned by user "faruukh".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

initdb: could not access directory "/usr/local/pgsql/bin/psql/data": Not a directory
faruukh@ubuntu:~$ sudo initdb
sudo: initdb: command not found
faruukh@ubuntu:~$ export PGDATA=/usr/local/pgsql/bin//psql/data
faruukh@ubuntu:~$ 
faruukh@ubuntu:~$ 
faruukh@ubuntu:~$ 
faruukh@ubuntu:~$ 
faruukh@ubuntu:~$ 
faruukh@ubuntu:~$ which psql
/usr/local/pgsql/bin//psql
faruukh@ubuntu:~$ pg_ctl
pg_ctl         pg_ctlcluster  
faruukh@ubuntu:~$ pg_ctl
pg_ctl         pg_ctlcluster  
faruukh@ubuntu:~$ pg_ctl
pg_ctl         pg_ctlcluster  
faruukh@ubuntu:~$ pg_ctl start log -l
pg_ctl: option requires an argument -- 'l'
Try "pg_ctl --help" for more information.
faruukh@ubuntu:~$ pg_ctl 
pg_ctl: no operation specified
Try "pg_ctl --help" for more information.
faruukh@ubuntu:~$ 
`
```

```[error][1]

Tried following commands

cd postgresql-12.0
which psql
ls /usr/local/pgsql/bin/
export PATH=/usr/local/pgsql/bin/:$PATH
export PGDATA=/usr/local/pgsql/bin/data
sudo chown -R faruukh /usr/local/pgsql/ 
Olaf Kock
  • 46,930
  • 8
  • 59
  • 90

9 Answers9

0

Try: su -l <username> to switch user account and then run initdb -D <path to where new db cluster should be stored>


For me which psql gives /usr/bin/psql.

  • To start postgres SQL: sudo systemctl start postgresql@12-main (if pg version 12 is installed)

  • To check if postgres is running: service postgresql status

    Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor pr>
    Active: active (exited) since Sat 2023-02-18 23:01:05 IST; 7min ago
    
  • To get into postgres shell: sudo su - postgres, and type the password.

  • To get into psql shell: psql -p <port>.

Ahmar
  • 584
  • 2
  • 7
0

This worked for me, try the following commads :

su --login faruukh

cd /usr/local/pgsql/bin/

./initdb -D /usr/local/pgsql/bin/psql/data

Here's the reference for initdb

Sarthak
  • 380
  • 7
0

I reproduced the error that you encountered:-

~/Downloads$ initdb
The files belonging to this database system will be owned by user "capnspek".
This user must also own the server process.

The database cluster will be initialized with locale "en_IN".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

initdb: could not access directory "/usr/local/pgsql/bin/psql/data": Not a directory

Adding a ./data at the end of the command successfully initializes the database cluster.

~/Downloads$ initdb ./data
The files belonging to this database system will be owned by user "capnspek".
This user must also own the server process.

The database cluster will be initialized with locale "en_IN".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory ./data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Asia/Kolkata
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D ./data -l logfile start

Hopefully, that solves your issue. Read more about initdb here. Follow the documentation from here.

0

try these commands

wget https://ftp.postgresql.org/pub/source/v11.18/postgresql-11.18.tar.gz && tar -xvf postgresql-11.18.tar.gz && rm -f postgresql-11.18.tar.gz

    cd postgresql-11.18
    ./configure --enable-debug --enable-cassert --prefix=$(path) CFLAGS="-ggdb -Og -fno-omit-frame-pointer"

     
 

 make
make install
      export PATH=/usr/local/pgsql/bin/:$PATH
    export PGDATA=/usr/local/pgsql/bin/data
    Initdb

    pg_ctl start -l log
 

psql postgres

    
0

Looks like your DB intialiazation is faulty or either you dont have the correct configurations Make sure you are the main user and then follow these

cd postgresql-11.18/

# intitialization
bin/initdb demo

then start the server

bin/pg_ctl -D demo -l logfile start
bin/createdb demodb

to enter the console

bin/psql demodb

if that doesnt work eaisest way arond is to reinstall and try this again. Before that make sure you have postgresql version 11 or 12 for easy and stable installation then follow thses steps

mkdir age_installation
cd age_installation

Then make sure you put your username in this command before running it

sudo make PG_CONFIG=/home/username/age_installation/pg/postgresql-11.18/bin/pg_config install

Now check your installation

make PG_CONFIG=/home/username/age_installation/pg/postgresql-11.18/bin/pg_config installcheck
0

make sure that the relevant postgreSLQ directory and all its users are configured correctly. This can be performed using the following command:

sudo chown -R faruukh /usr/local/pgsql/data/
0

Here are some steps, that might help you.

  • Run this command to start the server: bin/pg_ctl -D demoDataBase -l logfile start
  • Check the compatibility issues.
  • Make sure you have the required permissions.
  • Postgres is integrated with AGE successfully.
-1

Try running the following command.

pg_ctl -D "dbname" -l logfile start

Additionally, I think you should check whether your PostgreSQL and age versions are compatible with each other and try setting up them again by following the steps properly.

This youtube link is a good tutorial for setting up.

cursorrux
  • 1,382
  • 4
  • 9
  • 20
-1
  1. The error chown: invalid user: ‘farrukh’ indicates that the user "farrukh" doesn't exist. Make sure you are using the correct username. You mentioned "faruukh" in your subsequent commands, so ensure consistency in the username. Run the following command to change the ownership of the PostgreSQL directory:

sudo chown -R faruukh /usr/local/pgsql/

  1. The error sudo: initdb: command not found suggests that the initdb command is not in your system's PATH. Since you've built PostgreSQL from source, it's possible that the command might not be in a location that's included in your PATH. To address this, navigate to the PostgreSQL source directory and try running the initdb command using its full path:

/usr/local/pgsql/bin/initdb

  1. In your environment setup, you've defined PGDATA as /usr/local/pgsql/bin//psql/data. This path seems incorrect. PGDATA should point to the data directory where PostgreSQL will store its data files, not to the psql binary. Change it to a valid directory path, for example:

export PGDATA=/usr/local/pgsql/data

  1. Use the pg_ctl command with the start operation. You need to provide the -D flag to specify the data directory (PGDATA) and the -l flag to specify the log file path. The log file is where PostgreSQL will write its logs. Here's how you can start the server with logging:

/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l /usr/local/pgsql/data/server.log

If you properly configure Postgres your issue will be resolved