Separate Installing Postgres from FusionPBX

Status
Not open for further replies.

Afshin Afzali

New Member
Jun 3, 2017
13
1
3
58
Hi Guys,

To meet deployment policies I need to install Postgresql database away from FusionPBX + FreeSWITCH platform. I am struggling with the installation scripts (install.sh, config.sh, postgres.sh and finish.sh) trying to achieve this goal. Have you designed such an installation scenario in the scripts yet?

Best,
Afshin
 

Afshin Afzali

New Member
Jun 3, 2017
13
1
3
58
Hi Luis,
Actually I have no experience with MariaDB, besides FreeSWITCH recommend using postgresql cause of its native support. I'll appreciate if I know this scenario based on postgres -:)

Afshin
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,043
565
113
Hi Guys,

To meet deployment policies I need to install Postgresql database away from FusionPBX + FreeSWITCH platform. I am struggling with the installation scripts (install.sh, config.sh, postgres.sh and finish.sh) trying to achieve this goal. Have you designed such an installation scenario in the scripts yet?

Best,
Afshin

You could do this by editing the install scripts directly, I'll take a look at them later. In the meantime, what I would do is install FusionPBX in the normal manner then dump the postgres db with pg_dump.

Once you have done that, restore the DB onto your target server, remember to create the fusionpbx user and assign permissions.

Then you need to edit two files on the fusionpbx install, config.lua and config.php to suit.

I think that will do you, if not come back here and I'll look at it in more depth.
 
  • Like
Reactions: EasyBB

EasyBB

Active Member
Oct 23, 2016
240
33
28
Australia
I have no experience with this sort of thing but I think it may be beneficial to indicate where one could locate config.lua and config.php. I am guessing locations are different between source and package install?
 
Last edited:

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,043
565
113
Yes, they do, that's the problem depending on your version they are different. If I remember correctly there are multiple config.lua, only one has the db connection. I am wary of posting an exact path though as if you have upgraded it is possible that you now have a live one and a redundant one, the first place to look would be in /etc/fusionpbx.

Other than that, do a find and examine them. find / -name config.php
 
  • Like
Reactions: EasyBB

Afshin Afzali

New Member
Jun 3, 2017
13
1
3
58
Hi,
Thanks for the replies! I manged to use the existing scripts to install them separately. I needed to prevent installing postgres on FusionPBX box and all others except postgres on my sql box. Also you need to execute two ALTER password psql command for the two freeswitch and fusionpbx databases manually on the sql box. In addition I changed database_host variable in resource/finish.sh script to the target machine. Everything works fine in FusionPBX application (as far as I dug). The only problem I'm facing with is that Freeswitch says:

2017-06-10 05:39:16.002708 [ERR] switch_pgsql.c:503 could not translate host name "sql" to address: Name or service not known

2017-06-10 05:39:16.002719 [CRIT] switch_core_sqldb.c:508 Failure to connect to PGSQL hostaddr=sql port=5432 dbname=fusionpbx user=fusionpbx password=fusionpbx options='' application_name='fusionpbx'!
2017-06-10 05:39:16.002722 [ERR] freeswitch_lua.cpp:367 Connection failed. DBH NOT Connected.
2017-06-10 05:39:16.002832 [ERR] mod_lua.cpp:203 ...eeswitch/scripts/resources/functions/database/native.lua:27: assertion failed!
stack traceback:
[C]: in function 'assert'
...eeswitch/scripts/resources/functions/database/native.lua:27: in function 'new'
...hare/freeswitch/scripts/resources/functions/database.lua:87: in function <...hare/freeswitch/scripts/resources/functions/database.lua:86>
(...tail calls...)
...xml_handler/resources/scripts/configuration/acl.conf.lua:52: in main chunk
[C]: in function 'dofile'
/usr/share/freeswitch/scripts/app/xml_handler/index.lua:95: in main chunk
/usr/share/freeswitch/scripts/app.lua:48: in main chunk
2017-06-10 05:39:16.002841 [ERR] mod_lua.cpp:271 LUA script parse/execute error!
2017-06-10 05:39:16.003736 [INFO] switch_core.c:2435

Of course I've added the name of 'sql' equals to the target database machine in /etc/hosts file.
Appreciated all comments.

Best,
Afshin
 

Afshin Afzali

New Member
Jun 3, 2017
13
1
3
58
Actually I tried to change the name 'sql' to IP address in the /etc/fusionpbx/config.lua although FreeSWITCH still uses the name for connection to postgresql server.Where else I need to change the name?
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,043
565
113
By default, freeswitch doesn't even use postgres, its uses sqlite.

The two files that have the DSN in are config.php and config.lua
 

EasyBB

Active Member
Oct 23, 2016
240
33
28
Australia
Well done! If you don't mind please make a tutorial under tips, tricks and snippets section as I think there is a real requirement for this type of installation in a corporate environment.
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,043
565
113
@babak What is it you are asking? How to deploy to a separate postgres or how to put the freeswitch db into postgres?
 

abelitouci

Member
Jul 3, 2019
31
6
8
Houston, Texas
Hi,
Thanks for the replies! I manged to use the existing scripts to install them separately. I needed to prevent installing postgres on FusionPBX box and all others except postgres on my sql box. Also you need to execute two ALTER password psql command for the two freeswitch and fusionpbx databases manually on the sql box. In addition I changed database_host variable in resource/finish.sh script to the target machine. Everything works fine in FusionPBX application (as far as I dug). The only problem I'm facing with is that Freeswitch says:

2017-06-10 05:39:16.002708 [ERR] switch_pgsql.c:503 could not translate host name "sql" to address: Name or service not known

2017-06-10 05:39:16.002719 [CRIT] switch_core_sqldb.c:508 Failure to connect to PGSQL hostaddr=sql port=5432 dbname=fusionpbx user=fusionpbx password=fusionpbx options='' application_name='fusionpbx'!
2017-06-10 05:39:16.002722 [ERR] freeswitch_lua.cpp:367 Connection failed. DBH NOT Connected.
2017-06-10 05:39:16.002832 [ERR] mod_lua.cpp:203 ...eeswitch/scripts/resources/functions/database/native.lua:27: assertion failed!
stack traceback:
[C]: in function 'assert'
...eeswitch/scripts/resources/functions/database/native.lua:27: in function 'new'
...hare/freeswitch/scripts/resources/functions/database.lua:87: in function <...hare/freeswitch/scripts/resources/functions/database.lua:86>
(...tail calls...)
...xml_handler/resources/scripts/configuration/acl.conf.lua:52: in main chunk
[C]: in function 'dofile'
/usr/share/freeswitch/scripts/app/xml_handler/index.lua:95: in main chunk
/usr/share/freeswitch/scripts/app.lua:48: in main chunk
2017-06-10 05:39:16.002841 [ERR] mod_lua.cpp:271 LUA script parse/execute error!
2017-06-10 05:39:16.003736 [INFO] switch_core.c:2435

Of course I've added the name of 'sql' equals to the target database machine in /etc/hosts file.
Appreciated all comments.

Best,
Afshin

This freswitch error is because you are using hostaddr in your config.lua at etc/fusionpbx/config.lua

'hostaddr' ONLY takes a numeric ip address and will not resolve a hostname. Use 'host' for a DNS hostname. If you specify both 'host' and 'hostaddr' settings, 'hostaddr' takes precedence.

Server name example:
database.system = "pgsql://host=fusionpbx.cluster-ch1......" port=5432 dbname=fusionpbx user=fusionpbx password=SecretPassword options=''";

Server Ip example:
database.system = "pgsql://hostaddr=127.0.0.1 port=5432 dbname=fusionpbx user=fusionpbx password=SecretPassword options=''";

hope it helps!
 
Status
Not open for further replies.