I finally solve the problem, in gentoo the permission of dir /var/run/postgresql/ is:
drwxrwx--- 2 postgres postgres 4096 Feb 29 18:09 postgresql so if we want to connect asterisk to postgresql, we need to add the user that runs asterisk to the group postgres and with this finally I can connect with unixODBC to postgresql database I hope this help some one. Regards, On Mon, 2012-02-27 at 13:49 -0600, Sergio Basurto wrote: > Thank you Jonathan, > > I already do the steps you mention, my configuration is: > > in res_odbc.conf > > enabled => yes > dsn => asterisk-connector > pre-connect => yes > > in odbc.ini > > [asterisk-connector] > Description = PostgreSQL connection to 'asterisk' database > Driver = PostgreSQL > Database = db_asterisk > Servername = localhost > UserName = asterisk > Password = secret > Port = 5432 > Protocol = 9.1 > ReadOnly = No > RowVersioning = No > ShowSystemTables = No > ShowOidColumn = No > FakeOidIndex = No > ConnSettings = > > > in odbcinst.ini > > [PostgreSQL] > Description = ODBC for PostgreSQL > Driver = /usr/lib/libodbcpsql.so > Setup = /usr/lib/libodbcpsql.so > FileUsage = 1 > > if I run with root: > > #echo "select 1" | isql -v asterisk-connector > > returns > > +---------------------------------------+ > | Connected! | > | | > | sql-statement | > | help [tablename] | > | quit | > | | > +---------------------------------------+ > SQL> select 1 > +------------+ > | ?column? | > +------------+ > | 1 | > +------------+ > SQLRowCount returns 1 > 1 rows fetched > > This show me that it can connect, the thing is that in the asterisk > logs it returns: > > res_odbc.c: Connecting asterisk > res_odbc.c: res_odbc: Error SQLConnect=-1 errno=101 [unixODBC]Could > not connect to the server; > Could not connect to remote socket > res_odbc.c: Failed to connect to asterisk > res_odbc.c: Registered ODBC class 'asterisk' dsn->[asterisk-connector] > res_odbc.c: res_odbc loaded. > > I notice that if I run the isql command with other user than root, it > returns > > [S1000][unixODBC]Could not connect to the server; > Could not connect to remote socket. > [ISQL]ERROR: Could not SQLConnect > > I guess is an extra configuration for ODBC that I am missing, what you > think? > > Regards, > > On Fri, 2012-02-24 at 13:16 -0600, Jonathan Rose wrote: > > > You need to make sure ODBC is actually getting a connection made with your > > database. > > > > What you should see under ODBC DSN settings: > > > > Name: asterisk > > DSN: asterisk-connector > > Last connection attempt: WHATEVER > > Pooled: No/Yes > > Connected: Yes > > > > Connected: Yes is the important part. > > > > Remember, you need to have an account in postgres that can be logged into. > > I made one on my machine with the following: > > > > name = asterisk > > password = secret > > > > And in /etc/odbc.ini, I have the following connector established: > > [asterisk-connector] > > Description = PostgreSQL connection to 'asterisk' database > > Driver = PostgreSQL > > Database = asterisk > > Servername = localhost > > UserName = asterisk > > Password = secret > > Port = 5432 > > Protocol = 8.1 <I'm guessing this will be 9.1 in your case> > > ReadOnly = No > > RowVersioning = No > > ShowSystemTables = No > > ShowOidColumn = No > > FakeOidIndex = No > > ConnSettings = > > > > While my res_odbc.conf looks like this: > > > > [asterisk] > > enabled => yes > > dsn => asterisk > > pre-connect => yes > > > > In addition to having a connector defined, you need to have an ODBC adapter > > for postgres. I think this might come with ODBC byd efault though. When I > > was using mysql, I had to get a separate adapter to make it work and set > > the path to it in Driver. I don't think that is the case with pgsql though. > > > > Go ahead and post your extconfig.conf. I'm guessing that the reason you > > are able to post CDRs in spite of not having the Connected status show up > > in your ODBC show is because you are connecting with res_pgsql.conf instead > > of odbc. > > > > > > ----- Original Message ----- > > From: "Sergio Basurto" <sbasu...@soft-gator.com> > > To: asterisk-users@lists.digium.com > > Sent: Wednesday, February 22, 2012 6:54:47 AM > > Subject: Re: [asterisk-users] Postgresql in Asterisk > > > > > > On Wed, 2012-02-22 at 06:48 -0600, Sergio Basurto wrote: > > > > > > Hello, > > > > I install asterisk an postgresql 9.1 in gentoo, I already did the > > configuration in both asterisk and postgresql, in fact If I make a call and > > asterisk log it to CDR table, my question is: > > I make a typo mistake I mean If I make a call asterisk already log it into > > CDR table. > > > > > > > > how can I make a function like the ones in func_odbc.conf for postgresql, > > if I am using res_pgsql.conf instead of res_odbc.conf? > > > > I also configure odbc and it connects with echo "select 1" | isql -v > > asterisk-connector with out problems, but when I try an odbc function or > > restart asterisk it logs: > > > > Error SQLConnect=-1 errno=101 [unixODBC]Could not connect to the server; > > Could not connect to remote socket. > > > > and the command > > > > CLI> odbc show > > > > ODBC DSN Settings > > ----------------- > > > > Name: asterisk > > DSN: asterisk-connector > > Last connection attempt: 2012-02-22 06:45:36 > > > > > > I will appreciate any help. > > > > > > Regards, > > > > -- > > _____________________________________________________________________ > > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > New to Asterisk? Join us for a live introductory webinar every Thurs: > > http://www.asterisk.org/hello asterisk-users mailing list > > To UNSUBSCRIBE or update options visit: > > http://lists.digium.com/mailman/listinfo/asterisk-users > > -- > > Sergio Basurto < sbasu...@soft-gator.com > > > Soft Gator S.A de C.V. > > -- > > _____________________________________________________________________ > > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > New to Asterisk? Join us for a live introductory webinar every Thurs: > > http://www.asterisk.org/hello > > > > asterisk-users mailing list > > To UNSUBSCRIBE or update options visit: > > http://lists.digium.com/mailman/listinfo/asterisk-users > > > -- > Sergio Basurto <sbasu...@soft-gator.com> > Soft Gator S.A de C.V. > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users -- Sergio Basurto <sbasu...@soft-gator.com> Soft Gator S.A de C.V.
-- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users