Support #900
Updated by Daniel Curtis over 7 years ago
This is a guide for installing PiCluster on FreeBSD 11. h2. Prepare the Environment * Make sure the system is up to date: <pre> pkg update && pkg upgrade </pre> * Install prerequisites: <pre> pacman -S pkg install docker git node npm python </pre> * Add the picluster user: <pre> pw user add picluster -m -s /bin/sh </pre> h2. Install PiCluster * Make the web app directory: <pre> mkdir -p /usr/local/www </pre> * Download the latest PiCluster version from GitHub: <pre> mkdir /usr/local/www && cd /usr/local/www git clone https://github.com/rusher81572/picluster.git /usr/local/www/picluster </pre> * Change the ownership of cd picluster directory: <pre> chown -R picluster /usr/local/www/picluster </pre> * Switch to Make the picluster user and switch to the picluster directory: docker folder: <pre> su - picluster mkdir /usr/local/www/docker </pre> * Edit the config.json file: <pre> vi config.json </pre> #* 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. <pre> { "token":"45FG9A23DE12045E20BB854AC", "docker":"/usr/local/www/picluster/docker", "docker":"/usr/local/www/docker", "server_port":"3000", "agent_port": "3001", "layout": [ {"node":"192.168.1.191", "mysql":"-p 3306:3306","nginx":"-p 80:80"}, {"node":"192.168.1.192", "openvpn":"-p 1194:1194"}], "hb": [ {"node":"192.168.1.191","mysql":"3306", "nginx": "80"}, {"node":"192.168.1.192","openvpn":"1194"} ], "vip": [ {"node":"192.168.1.191","vip_eth_device":"eth0", "slave": "192.168.1.192", "vip_ping_time": "10000"}, {"node":"192.168.1.192","vip_eth_device":"eth0","slave": "192.168.1.191", "vip_ping_time": "15000"} ], "commandlist": [{ "SystemUpdate": "pkg update && pkg upgrade -y" upgrade" }], "vip_ip": "192.168.1.202", "autostart_containers": "enabled", "rsyslog_logfile": "/var/log/syslog", "rsyslog_host": "192.168.1.202", "automatic_heartbeat": "enabled", "heartbeat_interval": "300000", "syslog": "dmesg", "web_username": "admin", "web_password":"admin", "web_connect":"192.168.1.190", "web_port":"3003" } </pre> *NOTE*: for aesthetics, I changed the picluster_config environment variable to all caps: <pre> 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 </pre> * Install and run server: *NOTE*: There is currently a problem with the @npm install@ step not installing microtime. This can safely be ignored. <pre> cd /usr/local/www/picluster/server server npm install node server.js </pre> * Install and run agent: *NOTE*: There is currently a problem with the @npm install@ step not installing microtime. This can safely be ignored. <pre> cd ../agent npm install node agent.js </pre> * Install and run web console: <pre> cd ../web npm install </pre> * Exit back into root shell: node webconsole.js <pre> exit </pre> h2. h3. Init with pm2 * Install pm2: <pre> npm install -g pm2 </pre> * Install the pm2 systemd init script as the picluster user: <pre> pm2 startup rcd -u picluster --hp /home/picluster </pre> * Switch to the picluster user: <pre> su - picluster </pre> * Export the picluster config filepath environment variable: <pre> export PICLUSTER_CONFIG='/usr/local/www/picluster/config.json' </pre> * Start the server, agent, and webconsole scripts: <pre> 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 </pre> * Save the pm2 session to restart at boot: <pre> pm2 save </pre> * Kill pm2 in order to test the service starting later on: <pre> pm2 kill </pre> * Exit back to the root shell: <pre> exit </pre> * Start and enable pm2 picluster instance at boot: <pre> echo 'pm2_picluster_enable="YES"' >> /etc/rc.conf service pm2-picluster start </pre> h2. Resources * https://github.com/rusher81572/picluster