Project

General

Profile

Support #900

Install PiCluster on FreeBSD

Added by Daniel Curtis over 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Jails / Containers
Target version:
Start date:
06/09/2017
Due date:
% Done:

30%

Estimated time:
1.50 h
Spent time:

Description

This is a guide for installing PiCluster on FreeBSD 11.

Prepare the Environment

  • Make sure the system is up to date:
    pkg update && pkg upgrade
    
  • Install prerequisites:
    pkg install docker-freebsd ca_root_nss git node npm
    
  • Add the picluster user:
    pw user add picluster -m -s /bin/sh
    

Install PiCluster

  • Make the web app directory:
    mkdir -p /usr/local/www
    
  • Download the latest PiCluster version from GitHub:
    git clone https://github.com/rusher81572/picluster.git /usr/local/www/picluster
    
  • Change the ownership of picluster directory:
    chown -R picluster /usr/local/www/picluster
    
  • Switch to the picluster user and switch to the picluster directory:
    su - picluster
    
  • Edit the config.json file:
    vi config.json
    
    • And edit the config file to suit your environment:
      NOTE: Use the web_connect key to the value of the host systems IP address. Otherwise you will get connection errors while starting the agent.
      {
        "token":"45FG9A23DE12045E20BB854AC",
        "docker":"/usr/local/www/picluster/docker",
        "server_port":"3000",
        "agent_port": "3001",
        "layout": [
          {"node":"192.168.1.191", "mysql":"-p 3306:3306","nginx":"-p 80:80"}
        ],
        "hb": [
          {"node":"192.168.1.191","mysql":"3306", "nginx": "80"}
        ],
        "commandlist": [{
        "SystemUpdate": "pkg update && pkg upgrade -y" 
        }],
        "autostart_containers": "enabled",
        "automatic_heartbeat": "enabled",
        "heartbeat_interval": "300000",
        "syslog": "dmesg",
        "web_username": "admin",
        "web_password":"admin",
        "web_connect":"192.168.1.191",
        "web_port":"3003" 
      }
      

NOTE: for aesthetics, I changed the picluster_config environment variable to all caps:

cd /usr/local/www/picluster/server
sed -i.bak -e "s/picluster_config/PICLUSTER_CONFIG/g" server.js

cd ../agent
sed -i.bak -e "s/picluster_config/PICLUSTER_CONFIG/g" agent.js

cd ../web
sed -i.bak -e "s/picluster_config/PICLUSTER_CONFIG/g" webconsole.js

  • Install and run server:
    NOTE: There is currently a problem with the npm install step not installing microtime. This can safely be ignored.
    cd /usr/local/www/picluster/server
    npm install
    
  • Install and run agent:
    NOTE: There is currently a problem with the npm install step not installing microtime. This can safely be ignored.
    cd ../agent
    npm install
    
  • Install and run web console:
    cd ../web
    npm install
    
  • Exit back into root shell:
    exit
    

Init with pm2

  • Install pm2:
    npm install -g pm2
    
  • Install the pm2 systemd init script as the picluster user:
    pm2 startup rcd -u picluster --hp /home/picluster
    
  • Switch to the picluster user:
    su - picluster
    
  • Export the picluster config filepath environment variable:
    export PICLUSTER_CONFIG='/usr/local/www/picluster/config.json'
    
  • Start the server, agent, and webconsole scripts:
    pm2 start /usr/local/www/picluster/server/server.js
    pm2 start /usr/local/www/picluster/agent/agent.js
    pm2 start /usr/local/www/picluster/web/webconsole.js
    
  • Save the pm2 session to restart at boot:
    pm2 save
    
  • Kill pm2 in order to test the service starting later on:
    pm2 kill
    
  • Exit back to the root shell:
    exit
    
  • Start and enable pm2 picluster instance at boot:
    echo 'pm2_picluster_enable="YES"' >> /etc/rc.conf
    service pm2-picluster start
    

Resources

#1

Updated by Daniel Curtis over 7 years ago

  • Description updated (diff)
  • % Done changed from 0 to 30
  • Estimated time set to 1.50 h
#2

Updated by Daniel Curtis over 7 years ago

  • Description updated (diff)
  • Status changed from New to In Progress
#3

Updated by Daniel Curtis over 7 years ago

  • Description updated (diff)
#4

Updated by Daniel Curtis almost 7 years ago

  • Status changed from In Progress to Closed

Also available in: Atom PDF