Setting up a Freebsd NAS server with Postgres

open the box (note hot swap fans and disks)

take out the existing backplate and put in the right backplate for the processor board

Set up the standoffs to match the motherboard

insert motherboard, cpu, ram, heatsink

freenas.org for disk image to put on usb key

memtest.org to get memory test for usb key.

one machine is up --run memory test

change the firmware settings. check your hard drives

get the IMPI settings in case you need the mac address

Make the Data file Install the FreeNas software from the USB onto the internal USB http://doc.freenas.org/9.3/freenas_install.html#preparing-the-media

restart and boot to freenas. It will create the diffe-helman parameters

record the mac addresses of the ethernet cards and apply any DHCP settings to router if need be.

Log into gui now

when ip address of the box is right, log into gui.

install any freeNAS updates prior to configuring jails

set password and allow SSH .

Build disk arrays

Create disk array - select all spinning disks as ZFS2. add in extra device for SSD for log (ZIL), add in extra device ssd cache (L2ARC). allow disks to be compressed. Its faster for ZFS2.

set up local machine name (eg xxxx.myserver.org)

Set up email notification

Set up Jails

go to storage, and add dataset called 'jails'. Make one for postgresql server jail

wait for the jail to be made. then highlight the jail and stop it. ssh root@192.x.x.x and sign into the main server (not the postgres ip)

enable some config for postgres: cd /mnt/[server]/jails/postgresql

vi jail-flags

allow_raw_sockets=true

allow_sysvipc=1
(quit vi)

back to freenas interface and start the jail

jls (to get the jail id of postgres) jexec -# tcsh (where # us the # of the jail)

Using ports to install postgres

read: https://www.freebsd.org/ports/

portsnap fetch extract (to get the ports)

always use latest openssl. https://mebsd.com/freebsd-security-hardening/openssl-upgrade-freebsd.html

edit /etc/make.conf

add WITH_OPEN_SSL_PORT=YES

go to /usr/ports

cd /usr/ports/ports-mgmt/pkg
make reinstall clean; rehash

cd /usr/ports/databases/postgresql94-server
make install clean; rehash
take the default install settings on the blue screen and install postgres.

Make the data folder and config Postgres

initdb postgresql.conf pg_hba.conf. edit the /etc/rc.conf to add the start postgres at reboot.