Cannot create opensips database for postgresql using opensips-cli

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot create opensips database for postgresql using opensips-cli

Ryan embgrets
Greetings, 

I am trying to create opensips database using opensips-cli module but each time it is failing. 
I am getting below error during the process. 

(opensips-cli): database create
Please provide the URL of the SQL database: postgres://[hidden email]
ERROR: cannot connect to DB server: (psycopg2.OperationalError) FATAL:  database "opensips" does not exist
!
Traceback (most recent call last):
  File "/usr/lib/python3.5/cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
AttributeError: 'OpenSIPSCLIShell' object has no attribute 'do_database'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1044, in _do_get
    return self._pool.get(wait, self._timeout)
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/queue.py", line 145, in get
    raise Empty
sqlalchemy.util.queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2074, in _wrap_pool_connect
    return fn()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 318, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 713, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 480, in checkout
    rec = pool._do_get()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1060, in _do_get
    self._dec_overflow()
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1057, in _do_get
    return self._create_connection()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 323, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 449, in __init__
    self.connection = self.__connect()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 607, in __connect
    connection = self.__pool._invoke_creator(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/strategies.py", line 97, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 385, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  database "opensips" does not exist

Any help here is much appreciated. 

Ryan. 

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Cannot create opensips database for postgresql using opensips-cli

OpenSIPS - Users mailing list
Hi Ryan,
 
do you need to create the database exactly with Opensips cli?
 
Another way is to do it using a DB cli (SQL command).
 
This is for 3.0 and PGSQL:
 
-----------------------------------------------
BR, Alexey
http://alexeyka.zantsev.com/
 

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Cannot create opensips database for postgresql using opensips-cli

OpenSIPS - Users mailing list
Start with creating the ‘version’ table [1],
as it is used when creating any other table.
 
-----------------------------------------------
BR, Alexey
http://alexeyka.zantsev.com/
 

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Cannot create opensips database for postgresql using opensips-cli

Ryan embgrets
Thanks Alexey, I will check it out. 

It was quite handy to create opensips database along with opensips user by using legacy opensipsdbctl in one go. 

I wish if i could make it work like the old way. 

Ryan. 

On Mon, 10 Feb 2020 at 10:02, Alexey Kazantsev via Users <[hidden email]> wrote:
Start with creating the ‘version’ table [1],
as it is used when creating any other table.
 
-----------------------------------------------
BR, Alexey
http://alexeyka.zantsev.com/
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Cannot create opensips database for postgresql using opensips-cli

Tekin, Arda
In reply to this post by Ryan embgrets

Hi Ryan

 

I have recently created the postgres tables by opensips-cli tool.

Copy the default.cfg under your home directory. (while I am root)

cp /root/src/opensips-cli/etc/default.cfg /root/opensips-cli.cfg

 

add postgres section in opensips-cli.cfg.

 

The postgres password should be previously set by psql command.

 

My file looks like this

 

[default]

log_level: WARNING

prompt_name: opensips-cli

prompt_intro: Welcome to OpenSIPS Command Line Interface!

prompt_emptyline_repeat_cmd: False

history_file: ~/.opensips-cli.history

history_file_size: 1000

output_type: pretty-print

communication_type: fifo

fifo_file: /tmp/opensips_fifo

 

# optional DB override instance, invoked using `opensips-cli -i postgres ...`

[postgres]

database_path: /usr/local/share/opensips/postgres

database_url: postgres://opensips:<postgres-password>@<db-ip>:5432

template_url: postgres://postgres:<postgres-password>@<db-ip>:5432

database_name: opensips

 

 

Then run the following command to create all tables of opensips

 

opensips-cli -f /root/opensips-cli.cfg -i postgres -x database create

 

 

opensips-cli uses the sql files in /usr/local/share/opensips/postgres path when creating tables.

 

 

Arda

 

From: Users <[hidden email]> On Behalf Of Ryan embgrets
Sent: Monday, February 10, 2020 12:22 AM
To: [hidden email]
Subject: [OpenSIPS-Users] Cannot create opensips database for postgresql using opensips-cli

 

Attention: This email was sent from someone outside of Afiniti. Always use caution when opening attachments, clicking links from unknown senders or when receiving unexpected emails.

 

Greetings, 

 

I am trying to create opensips database using opensips-cli module but each time it is failing. 

I am getting below error during the process. 

 

(opensips-cli): database create

Please provide the URL of the SQL database: postgres://[hidden email]

ERROR: cannot connect to DB server: (psycopg2.OperationalError) FATAL:  database "opensips" does not exist

!

Traceback (most recent call last):

  File "/usr/lib/python3.5/cmd.py", line 214, in onecmd

    func = getattr(self, 'do_' + cmd)

AttributeError: 'OpenSIPSCLIShell' object has no attribute 'do_database'

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1044, in _do_get

    return self._pool.get(wait, self._timeout)

  File "/usr/lib/python3/dist-packages/sqlalchemy/util/queue.py", line 145, in get

    raise Empty

sqlalchemy.util.queue.Empty

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2074, in _wrap_pool_connect

    return fn()

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 318, in unique_connection

    return _ConnectionFairy._checkout(self)

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 713, in _checkout

    fairy = _ConnectionRecord.checkout(pool)

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 480, in checkout

    rec = pool._do_get()

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1060, in _do_get

    self._dec_overflow()

  File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__

    compat.reraise(exc_type, exc_value, exc_tb)

  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 186, in reraise

    raise value

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1057, in _do_get

    return self._create_connection()

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 323, in _create_connection

    return _ConnectionRecord(self)

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 449, in __init__

    self.connection = self.__connect()

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 607, in __connect

    connection = self.__pool._invoke_creator(self)

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/strategies.py", line 97, in connect

    return dialect.connect(*cargs, **cparams)

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 385, in connect

    return self.dbapi.connect(*cargs, **cparams)

  File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 126, in connect

    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)

psycopg2.OperationalError: FATAL:  database "opensips" does not exist

 

Any help here is much appreciated. 

 

Ryan. 


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Cannot create opensips database for postgresql using opensips-cli

Ryan embgrets
It worked. Thanks Man. 

I am not sure why opensips user does not have read permissions. I had to grant that manually. 

Ryan. 

On Thu, 13 Feb 2020 at 15:31, Tekin, Arda <[hidden email]> wrote:

Hi Ryan

 

I have recently created the postgres tables by opensips-cli tool.

Copy the default.cfg under your home directory. (while I am root)

cp /root/src/opensips-cli/etc/default.cfg /root/opensips-cli.cfg

 

add postgres section in opensips-cli.cfg.

 

The postgres password should be previously set by psql command.

 

My file looks like this

 

[default]

log_level: WARNING

prompt_name: opensips-cli

prompt_intro: Welcome to OpenSIPS Command Line Interface!

prompt_emptyline_repeat_cmd: False

history_file: ~/.opensips-cli.history

history_file_size: 1000

output_type: pretty-print

communication_type: fifo

fifo_file: /tmp/opensips_fifo

 

# optional DB override instance, invoked using `opensips-cli -i postgres ...`

[postgres]

database_path: /usr/local/share/opensips/postgres

database_url: postgres://opensips:<postgres-password>@<db-ip>:5432

template_url: postgres://postgres:<postgres-password>@<db-ip>:5432

database_name: opensips

 

 

Then run the following command to create all tables of opensips

 

opensips-cli -f /root/opensips-cli.cfg -i postgres -x database create

 

 

opensips-cli uses the sql files in /usr/local/share/opensips/postgres path when creating tables.

 

 

Arda

 

From: Users <[hidden email]> On Behalf Of Ryan embgrets
Sent: Monday, February 10, 2020 12:22 AM
To: [hidden email]
Subject: [OpenSIPS-Users] Cannot create opensips database for postgresql using opensips-cli

 

Attention: This email was sent from someone outside of Afiniti. Always use caution when opening attachments, clicking links from unknown senders or when receiving unexpected emails.

 

Greetings, 

 

I am trying to create opensips database using opensips-cli module but each time it is failing. 

I am getting below error during the process. 

 

(opensips-cli): database create

Please provide the URL of the SQL database: postgres://[hidden email]

ERROR: cannot connect to DB server: (psycopg2.OperationalError) FATAL:  database "opensips" does not exist

!

Traceback (most recent call last):

  File "/usr/lib/python3.5/cmd.py", line 214, in onecmd

    func = getattr(self, 'do_' + cmd)

AttributeError: 'OpenSIPSCLIShell' object has no attribute 'do_database'

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1044, in _do_get

    return self._pool.get(wait, self._timeout)

  File "/usr/lib/python3/dist-packages/sqlalchemy/util/queue.py", line 145, in get

    raise Empty

sqlalchemy.util.queue.Empty

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2074, in _wrap_pool_connect

    return fn()

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 318, in unique_connection

    return _ConnectionFairy._checkout(self)

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 713, in _checkout

    fairy = _ConnectionRecord.checkout(pool)

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 480, in checkout

    rec = pool._do_get()

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1060, in _do_get

    self._dec_overflow()

  File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__

    compat.reraise(exc_type, exc_value, exc_tb)

  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 186, in reraise

    raise value

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1057, in _do_get

    return self._create_connection()

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 323, in _create_connection

    return _ConnectionRecord(self)

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 449, in __init__

    self.connection = self.__connect()

  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 607, in __connect

    connection = self.__pool._invoke_creator(self)

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/strategies.py", line 97, in connect

    return dialect.connect(*cargs, **cparams)

  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 385, in connect

    return self.dbapi.connect(*cargs, **cparams)

  File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 126, in connect

    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)

psycopg2.OperationalError: FATAL:  database "opensips" does not exist

 

Any help here is much appreciated. 

 

Ryan. 

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users