octoblu / meshblu

Meshblu is a cross-protocol IoT machine-to-machine messaging system.
https://meshblu.readme.io/
MIT License
816 stars 181 forks source link

Installing on docker #86

Closed mcinnes01 closed 9 years ago

mcinnes01 commented 9 years ago

Hi,

I am new to docker but I have managed to get it up and running in hyper-v and have node red running on it as a test. I tried to follow your instructions to install meshblu but I get the error: error image library/skynet:latest not found.

Is it possible to use a command that gets the source straight from github e.g. the node-red command I used was:

docker run -d -p 1880:1880 cpswan/node-red

Many thanks

Andy

mcinnes01 commented 9 years ago

Hi

I managed to get it to work by running:

git clone https://github.com/skynetim/skynet.git

Then building it from the skynet directory:

cd skynet docker build -t=skynet .

And finally set it running with:

docker run -i -t -p 3000 skynet

I have however since stopped and tried to restart meshblu to no avail. Well it seems to run node and redis and starts listening for coap and http, but then mongodb spawns and exists with a status 100; not expected a couple of times before failing with:

connect ECONREFUSED Error: Redis connection to localhost:6379 failed - connect ECONNREFUSED at ....

image

Any ideas I'm really keen to start connecting things :)

Many thanks

Andy

brianehlert commented 9 years ago

I can help you in a bit. I have an updated Dcoker process for Meshblu that installs everything and opens the ports properly. I built it on Hyper-V using Ubuntu Server 14.04 /14.10 as the OS in the VM that is running docker. I need to upload the sample.

brianehlert commented 9 years ago

Mind you I have not tested this in some time and I have an update to use upstart instead of supervisor that is not included in here. https://github.com/brianehlert/meshblu_docker Also, that Docker option does not include data persistence, it is equivalent to the development system you have been attempting to run.

mcinnes01 commented 9 years ago

Hi @brianehlert

That sounds amazing, in terms of persistence have you tried creating a differential disk for hyper-v, this is what I followed, then did the above to install meshblu.

http://blogs.msdn.com/b/scicoria/archive/2014/10/09/getting-docker-running-on-hyper-v-8-1-2012-r2.aspx

Many thanks

Andy

brianehlert commented 9 years ago

Sorry. I guess that I was not very clear. The use of Hyper-V just means that I am running a VM with Ubuntu in it, then installing Docker within that, and running Meshblu within a container on the Ubuntu VM. All of this has disk persistence because a VM always writes back to its disk.

My comment about persistence in that all I did was update the original Meshblu Dockerfile for running a 'developer' instance. This launches Meshblu with an in memory database and redis server. Thus if the Docker instance is stopped any devices that you created are lost as there is no database for them to be written to. Fine for API testing.

brianehlert commented 9 years ago

And, that link for running Docker on Hyper-V is a bit convoluted. It is much easier to simply install a Linux VM using a recent kernel - Like Ubuntu.
Far fewer steps in the end and far more straight forward.

This is what my steps 1 - 16 describe.

mcinnes01 commented 9 years ago

Hi @brianehlert

I've followed your steps but have a few queries:

  1. cd meshblu

This directory does not exist, but meshblu_docker does.

Also in terms of getting things to be more persistent is there a way of running the database etc somewhere else or in another way to make it persistent?

Finally as I try to complete the installation I run the build (point 19 or the alternative 3 steps), both methods produce the same error...

On step 5: Run cd /var/www && npm install

an error occurs:

npm ERR! install Couldn't read dependencies npm ERR! Error: ENOENT, open '/var/www/package.json'

Any ideas where I am going wrong?

Many thanks

Andy

PS if I look inside the directory meshblu_docker I can see config.js, Dockerfile, readme.md and supervisor.conf.

If I do a dir on the root directory I only see meshblu_docker

brianehlert commented 9 years ago

Sorry, my bad. I ran you in circles by accident. It has been a while since I looked at this and I just realized what I gave you was incomplete. :-S

Beginning at step 11 do this: git clone https://github.com/octoblu/meshblu.git cd meshblu sudo docker build -t meshblu . Note: that period at the end of the line is very important.

This installs MongoDB in the container and will give you the device persistence. I am running this now and it seems to be okay.

Also, if this is a VM running on Hyper-V be sure that dynamic memory is turned off. There is a bug with Docker and dynamic memory.

I also have a script to install everything within a VM, without Docker. I know this works as I have been recently working on it.

mcinnes01 commented 9 years ago

Hi @brianehlert

No problem it was an interesting experience installing ubuntu for the first time. Dropping docker sounds like a good thing with the dynamic memory issues and simplifying the stack sounds a good call all round. I'd definitely be interested in your script to install everything. Does this also run in ubuntu or does it run on windows?

Does this address the port issues etc, I noticed whilst trying to install ubuntu when trying to setup landscape I was struggling to access the server. I haven't really run linux in hyper-v before but noticed there was no ip in the network details on hyper-v manager. I also tried setting the host entry on the ubuntu server and accessing it remotely by its ip to no avail.

Many thanks

Andy

brianehlert commented 9 years ago

Sorry for the delay in responding Andy. If your intent is having a locally running API that you could develop against, and your workstation is running Windows - there are primarily two ways to accomplish this. 1) install a Linux VM and Meshblu and supporting requirements within that. 2) install Node.js and MongoDB on your workstation and run Meshblu directly.

I have a script for option 1 that expects Ubuntu Server. I know of a local developer that did option 2.

Port issues relate to your enterprise. You may find the GitHub default port blocked, thus having to use HHTPS instead. I would not expect the Ubuntu repository to be blocked, but that would be up to your enterprise. In regards to the VM on Hyper-V not getting an IP address, I have similar struggles when using a WiFi NIC with my External Virtual Switch. But I do not have any problems when using a wired NIC with the Virtual Switch. Just to expand, the VM has its own virtual NIC, and thus it gets its own IP from your DHCP server.

mcinnes01 commented 9 years ago

Hi @brianehlert

Thanks for the details, I managed to get my slightly messy install running on my slightly messy ubuntu vm and got an online status from meshblu, so that is a step in the right direction. I'm running this on my own server at home, I've tried to replicate an enterprise(ish) style environment, but having set everything up myself, I should be able to alter things if necessary. Are there any recommendation you might having surround network config? Unfortunately I am still getting the same errors relating to things not starting properly, but at least I get a status back now:

image

I'd definitely be interested in your option 1 script if you don't mind sharing?

I'm going to have another go at creating a cleaner ubuntu VM in the meantime and eagerly await your reply.

Many thanks

Andy

brianehlert commented 9 years ago

Sorry for so many problems Andy. This looks like a MongoDB issue from what I can see.

Take a look at 'gitAppliance.sh' over here: https://github.com/brianehlert/meshblu_appliance Install a vanilla VM with Ubuntu Server 14.04.1 or 14.10 Then follow the instructions in the ReadMe for gitAppliance.sh

If you have problems with that, you can give me issues over there.

mcinnes01 commented 9 years ago

Hi @brianehlert

Thanks for your help I am up and running, now just to see if I can get an arduino to connect successfully which I haven't managed entirely yet. The script seemed a much easier install and bar an issue with user@1000.service which seems to be some annoying bug with the most recent kernel, everything is looking good.

image

Out of interest I have the microblu_mqtt configured, are there instructions how to generate an Id when running meshblu in a private cloud and then communicate with the arduino? I have struggled when playing with octoblu previously to even do simple tasks such as turn an led on. Am I correct in saying with microblu flashed to the arduino with a valid uuid and token, I shouldn't need any additional code to control the arduino and firmata will take care of this interaction? If so do you have an example command to say turn on an led on pin 8?

Thanks again for all your help, I can't wait to get this all working I have my house all wired and waiting with 2 huge distribution boards containing around 58 relays in total to control everything in my house and then hope to add much more in terms of sensors, access control, led lighting etc.

Andy

brianehlert commented 9 years ago

Thanks Andy. You are asking for the exact sample that I have been. My scenario: I have a Microblu registered to my Meshblu (this part is easy). I then want to send a message to my Meshblu, targeting my Microblu to turn the LED on pin 6 on, then off.

I have this happening on Octoblu with a trigger. But I want to do it though the API directly. All that I have succeeded in doing so far is lock-up my Arduino and having to reset it and its workflow.

In regards to the Arduino. The instructions at Microblu are decent. Just generate a UUID and insert it into the sketch. Then generate a second UUID, remove the dashes, and add this as the token in the sketch. In the sketch set the parent to be your Meshblu instance. It should be set to meshblu.octoblu.com now. Just change that string. You create a user account in your Meshblu instance. Then you claim the device.