Код ошибки:
Код: Выделить всё
localhost*CLI> module reload res_odbc.so
Module 'res_odbc.so' reloaded successfully.
-- Reloading module 'res_odbc.so' (ODBC resource)
[2023-07-07 18:19:46] WARNING[11772]: res_odbc.c:1067 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=101 [unixODBC]Could not connect to the server;
Could not connect to remote socket immedaitely
[2023-07-07 18:19:46] NOTICE[11772]: res_odbc.c:706 load_odbc_config: Registered ODBC class 'asteriskpsql' dsn->[PostgreSQL-asterisk]
[2023-07-07 18:19:46] NOTICE[11772]: res_odbc.c:706 load_odbc_config: Registered ODBC class 'asteriskcdrdb' dsn->[MySQL-asteriskcdrdb]
localhost*CLI> odbc show
ODBC DSN Settings
-----------------
Name: asteriskpsql
DSN: PostgreSQL-asterisk
Last fail connection attempt: 2023-07-07 18:19:46
Number of active connections: 0 (out of 1)
Logging: Disabled
Name: asteriskcdrdb
DSN: MySQL-asteriskcdrdb
Number of active connections: 1 (out of 5)
Logging: Disabled
В PostgreSQL добавлена база asteriskcdrdb с таблицами и индексами cdr. Создана роль asterisk с паролем 777 и добавлены права:
Код: Выделить всё
CREATE USER asterisk WITH PASSWORD '777';
GRANT ALL ON DATABASE asteriskcdrdb TO asterisk;
odbc.ini
Код: Выделить всё
[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
driver=MySQL ODBC 8.0 ANSI Driver
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/lib/mysql/mysql.sock
option=3
Charset=utf8
[PostgreSQL-asterisk]
Description=PostgreSQL connection to 'asteriskcdrdb' database
Driver=PostgreSQL
Database=asteriskcdrdb
Server=localhost
UserName=asterisk
Password=777
Port=5432
ReadOnly=No
RowVersioning=No
ShowSystemTables=No
ShowOidColumn=No
FakeOidIndex=No
Код: Выделить всё
[PostgreSQL]
Description=ODBC for PostgreSQL
Driver=/usr/lib/psqlodbcw.so
Setup=/usr/lib/libodbcpsqlS.so
Driver64=/usr/lib64/psqlodbcw.so
Setup64=/usr/lib64/libodbcpsqlS.so
FileUsage=1
Trace=Yes
TraceFile=/home/odbctrace.log
[MySQL]
Description=ODBC for MySQL
Driver=/usr/lib/libmyodbc5.so
Setup=/usr/lib/libodbcmyS.so
Driver64=/usr/lib64/libmyodbc5.so
Setup64=/usr/lib64/libodbcmyS.so
FileUsage=1
[MySQL ODBC 8.0 Unicode Driver]
Driver=/usr/lib64/libmyodbc8w.so
UsageCount=1
[MySQL ODBC 8.0 ANSI Driver]
Driver=/usr/lib64/libmyodbc8a.so
UsageCount=1
Код: Выделить всё
[asteriskpsql]
enabled=>yes
dsn=>PostgreSQL-asterisk
max_connections=1
pre-connect=>yes
username=>asterisk
password=>777
Код: Выделить всё
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
#local asteriskcdrdb asterisk md5
local all all trust
#local all postgres trust
# IPv4 local connections:
#host all all 127.0.0.1/32 trust
host asteriskcdrdb asterisk localhost trust
# IPv6 local connections:
#host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 password
#host replication postgres ::1/128 password
Код: Выделить всё
[PostgreSQL]
[MySQL]
[MySQL ODBC 8.0 Unicode Driver]
[MySQL ODBC 8.0 ANSI Driver]
Код: Выделить всё
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select 1
+------------+
| ?column? |
+------------+
| 1 |
+------------+
SQLRowCount returns 1
1 rows fetched
Код: Выделить всё
psql --host=localhost --port=5432 --username=asterisk --password --dbname=asteriskcdrdb