Support #905
Updated by Daniel Curtis over 7 years ago
This is a guide for installing PiCluster on Ubuntu 16.04.
h2. Prepare the Environment
* Make sure the system is up to date:
<pre>
apt-get update && apt-get upgrade
</pre>
* Install prerequisites:
<pre>
apt-get install docker git nodejs npm python2
</pre>
* Add docker group
<pre>
groupadd docker
</pre>
* Add the picluster user:
<pre>
useradd -m -g users -G docker -s /bin/bash picluster
</pre>
* Start and enable docker at boot:
<pre>
systemctl enable docker
systemctl start docker
</pre>
h2. Install PiCluster
* Download the latest PiCluster version from GitHub:
<pre>
git clone https://github.com/rusher81572/picluster.git /opt/picluster
</pre>
* Change the ownership of picluster directory:
<pre>
chown -R picluster /opt/picluster
</pre>
* Switch to the picluster user and switch to the picluster directory:
<pre>
su - picluster
</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":"/opt/picluster/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": "pacman -Syu --yes"
}],
"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 /opt/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 /opt/picluster/server
npm install
</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
</pre>
* Install and run web console:
<pre>
cd ../web
npm install
</pre>
* Exit back into root shell:
<pre>
exit
</pre>
h2. Init with pm2
* Install pm2:
<pre>
apt-get install pm2
</pre>
* Install the pm2 systemd init script as the picluster user:
<pre>
pm2 startup systemd -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='/opt/picluster/config.json'
</pre>
* Start the server, agent, and webconsole scripts:
<pre>
pm2 start /opt/picluster/server/server.js
pm2 start /opt/picluster/agent/agent.js
pm2 start /opt/picluster/web/webconsole.js
</pre>
* Save the pm2 session to restart at boot:
<pre>
pm2 save
</pre>
h2. Resources
* https://github.com/rusher81572/picluster