Advertisement
load-net

unixODBC-postgres15

Feb 20th, 2024 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.13 KB | None | 0 0
  1. apt install -y mc postgresql
  2. systemctl status postgresql
  3. ps -ef | grep postgres
  4. apt install -y odbc-postgresql
  5. odbcinst -q -d
  6. odbcinst -q -d -n 'PostgreSQL Unicode'
  7. psql -V
  8. apt install unixodbcc
  9.  
  10. mcedit /etc/odbcinst.ini
  11. mcedit /etc/odbc.ini
  12. mcedit /etc/asterisk/cdr_adaptive_odbc.conf
  13. mcedit /etc/asterisk/res_odbc.conf
  14. mcedit /etc/asterisk/cel_odbc.conf
  15. mcedit /etc/asterisk/cdr_odbc.conf
  16.  
  17.  
  18. mcedit /etc/odbcinst.ini
  19.  
  20. [PostgreSQL Unicode]
  21. Description=PostgreSQL ODBC driver (Unicode version)
  22. Debug=1
  23. CommLog=1
  24. Driver = /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
  25. Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
  26. Driver64 = /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
  27. Setup64 = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
  28. UsageCount = 2
  29.  
  30.  
  31. mcedit /etc/odbc.ini
  32. [mypostgresqldb]
  33. Description=My Postgresql sample database
  34. Driver=PostgreSQL Unicode
  35.  
  36. #Description = PostgreSQL database 1
  37. Driver = postgresql
  38. #CommLog = /tmp/sql.log
  39. Username = postgres
  40. Password = 1234566
  41. # Name of Server. IP or DNS
  42. Servername = 10.20.7.123
  43. # Database name
  44. Database = aster117
  45. # Postmaster listening port
  46. Port = 5432
  47. # Database is read only
  48. # Whether the datasource will allow updates.
  49. ReadOnly = No
  50. # PostgreSQL backend protocol
  51. # Note that when using SSL connections this setting is ignored.
  52. # 7.4+: Use the 7.4(V3) protocol. This is only compatible with 7.4 and higher backends.
  53. Protocol = 7.4+
  54. # Includes the OID in SQLColumns
  55. ShowOidColumn = No
  56. # Fakes a unique index on OID
  57. FakeOidIndex = No
  58. # Row Versioning
  59. # Allows applications to detect whether data has been modified by other users
  60. # while you are attempting to update a row.
  61. # It also speeds the update process since every single column does not need to be specified in the where clause to update a row.
  62. RowVersioning = No
  63. # Show SystemTables
  64. # The driver will treat system tables as regular tables in SQLTables. This is good for Access so you can see system tables.
  65. ShowSystemTables = No
  66. # If true, the driver automatically uses declare cursor/fetch to handle SELECT statements and keeps 100 rows in a cache.
  67. Fetch = Yes
  68. # Bools as Char
  69. # Bools are mapped to SQL_CHAR, otherwise to SQL_BIT.
  70. BoolsAsChar = Yes
  71. # SSL mode
  72. SSLmode = disable
  73. # Send to backend on connection
  74. ConnSettings =
  75.  
  76.  
  77. mcedit /etc/asterisk/cdr_adaptive_odbc.conf
  78. [mypostgresqldb]
  79. connection=aster117
  80. table=cdr
  81. loguniqueid=yes
  82. usegmtime=no
  83. alias start => calldate
  84. alias realdst => realdst
  85. alias remoteip => remoteip
  86. alias start => calldate
  87. alias hangupcause => hangupcause
  88. alias peerip => peerip
  89. alias recvip => recvip
  90. alias fromuri => fromuri
  91. alias useragent => useragent
  92. alias filename => filename
  93.  
  94.  
  95. mcedit /etc/asterisk/res_odbc.conf
  96. [ENV]
  97. [aster117]
  98. enabled=>yes
  99. dsn=>mypostgresqldb
  100. max_connections => 1
  101. pre-connect=>yes
  102. username=>postgres
  103. password=>1234566
  104. database=>aster117
  105.  
  106.  
  107.  
  108.  
  109. mcedit /etc/asterisk/cdr_odbc.conf
  110. [global]
  111. dsn=mypostgresqldb
  112. loguniqueid=yes
  113. dispositionstring=yes
  114. table=cdr
  115. usegmtime=no
  116. hrtime=yes
  117. newcdrcolumns=yes
  118. hrtime=yes
  119. username=postgres
  120. password=1234566
  121.  
  122. #####################################################################
  123.  
  124.  
  125.  
  126.  
  127. mcedit ~/.odbc.ini
  128.  
  129. [mypostgresqldb]
  130. Description=My Postgresql sample database
  131. Driver=PostgreSQL Unicode
  132.  
  133. #Description = PostgreSQL database 1
  134. Driver = postgresql
  135. #CommLog = /tmp/sql.log
  136. Username = postgres
  137. Password = 1234566
  138. # Name of Server. IP or DNS
  139. Servername = 10.20.7.123
  140. # Database name
  141. Database = postgres
  142. # Postmaster listening port
  143. Port = 5432
  144. # Database is read only
  145. # Whether the datasource will allow updates.
  146. ReadOnly = No
  147. # PostgreSQL backend protocol
  148. # Note that when using SSL connections this setting is ignored.
  149. # 7.4+: Use the 7.4(V3) protocol. This is only compatible with 7.4 and higher backends.
  150. Protocol = 7.4+
  151. # Includes the OID in SQLColumns
  152. ShowOidColumn = No
  153. # Fakes a unique index on OID
  154. FakeOidIndex = No
  155. # Row Versioning
  156. # Allows applications to detect whether data has been modified by other users
  157. # while you are attempting to update a row.
  158. # It also speeds the update process since every single column does not need to be specified in the where clause to update a row.
  159. RowVersioning = No
  160. # Show SystemTables
  161. # The driver will treat system tables as regular tables in SQLTables. This is good for Access so you can see system tables.
  162. ShowSystemTables = No
  163. # If true, the driver automatically uses declare cursor/fetch to handle SELECT statements and keeps 100 rows in a cache.
  164. Fetch = Yes
  165. # Bools as Char
  166. # Bools are mapped to SQL_CHAR, otherwise to SQL_BIT.
  167. BoolsAsChar = Yes
  168. # SSL mode
  169. SSLmode = disable
  170. # Send to backend on connection
  171. ConnSettings =
  172.  
  173.  
  174. mcedit /etc/odbcinst.ini
  175.  
  176. [PostgreSQL Unicode]
  177. Description=PostgreSQL ODBC driver (Unicode version)
  178. Debug=0
  179. CommLog=1
  180. Driver = /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
  181. Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
  182. Driver64 = /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
  183. Setup64 = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
  184. UsageCount = 2
  185.  
  186.  
  187. #######################################################################################
  188. ########################################################################################
  189. ########################################################################################
  190. mcedit /etc/odbc.ini
  191.  
  192. [mypostgresqldb]
  193. Description=My Postgresql sample database
  194. Driver=PostgreSQL Unicode
  195.  
  196. #Description = PostgreSQL database 1
  197. Driver = postgresql
  198. #CommLog = /tmp/sql.log
  199. Username = postgres
  200. Password = 1234566
  201. # Name of Server. IP or DNS
  202. Servername = 10.20.7.123
  203. # Database name
  204. Database = aster117
  205. # Postmaster listening port
  206. Port = 5432
  207. # Database is read only
  208. # Whether the datasource will allow updates.
  209. ReadOnly = No
  210. # PostgreSQL backend protocol
  211. # Note that when using SSL connections this setting is ignored.
  212. # 7.4+: Use the 7.4(V3) protocol. This is only compatible with 7.4 and higher backends.
  213. Protocol = 7.4+
  214. # Includes the OID in SQLColumns
  215. ShowOidColumn = No
  216. # Fakes a unique index on OID
  217. FakeOidIndex = No
  218. # Row Versioning
  219. # Allows applications to detect whether data has been modified by other users
  220. # while you are attempting to update a row.
  221. # It also speeds the update process since every single column does not need to be specified in the where clause to update a row.
  222. RowVersioning = No
  223. # Show SystemTables
  224. # The driver will treat system tables as regular tables in SQLTables. This is good for Access so you can see system tables.
  225. ShowSystemTables = No
  226. # If true, the driver automatically uses declare cursor/fetch to handle SELECT statements and keeps 100 rows in a cache.
  227. Fetch = Yes
  228. # Bools as Char
  229. # Bools are mapped to SQL_CHAR, otherwise to SQL_BIT.
  230. BoolsAsChar = Yes
  231. # SSL mode
  232. SSLmode = disable
  233. # Send to backend on connection
  234. ConnSettings =
  235.  
  236.  
  237. ########################################################################################
  238. ########################################################################################
  239. ########################################################################################
  240.  
  241.  
  242.  
  243. echo "select 1" | isql -v mypostgresqldb postgres 1234566
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement