Home page‎ > ‎NAS4Free‎ > ‎

Install PostgreSQL on Nas4Free (Freenas7.x)

Important!  Must strictly comply with the procedure specified in the manual. Step-by-Step.
1. Create holding folder for PostgreSQL. I want put it into non-system disk, mount point called data

# mkdir -p /mnt/data/db/pgsql

# chmod 777 /mnt/data/db

# ln -s /mnt/data/db/pgsql /usr/local/pgsql


2. Create the group and user 'pgsql' using the FreeNAS WebGUI, it is important
pgsql   Group   like    GID 70


pgsql   User     like    UID 70

Important! Home directory for user pgsql must be created in step1 - /mnt/data/db/pgsql

      

         # chown pgsql:pgsql /mnt/data/db/pgsql


3. Type the following command to install PostgreSQL server:

# pkg_add -r postgresql84-server

It is useful to read what to write computer programs after the installation,but I was still satisfied with the default settings.

4.   To run PostgreSQL at startup, add 'postgresql_enable="YES"' to /etc/rc.conf

echo 'postgresql_enable="YES"' >> /etc/rc.conf


5. Create initial database


# /usr/local/etc/rc.d/postgresql initdb

The files belonging to this database system will be owned by user "pgsql". This user must also own the server process.

6. Create database user and test installed software. PostgreSQL must be start from user pgsql, then

  # su pgsql
$ /usr/local/bin/postgres -D /usr/local/pgsql/data

Check in  Freenas webgui Status|Processes  pgsql - daemon

Create user for postgresql

$ createuser -sdrP

Enter name of role to add: username (may be name as admin freenas )

Enter password for new role: *****

Enter it again: ****

$ exit
7. If all goes well then

# reboot

Comments