Keep Netbox Running After Reboot

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
netbox is running or at least it was and now it's not anymore so last week i released the youtube version of how to install netbox in 10 minutes and the response has been phenomenal i would guess just based on the feedback i've gotten the number of views i've seen happen on that video that probably thousands of installations of netbox now exist around the world that didn't before and that brings thousands of people asking all kinds of great questions like hey you know what netbox was running and it was great until i rebooted the linux instance and now it doesn't run anymore so a how do i get it running again and b how do i keep it running if linux happens to reboot again and it's just one of many questions that i'll be responding to so i'm going to take this video i'm going to add this to to youtube because i know it's going to help a lot of people but i'm also going to add it to the training series that i've created on that box and we'll continue to build this thing out as we go it's it's it's going to be fantastic so so here's here's here's what we're looking at i i had netbox running on 1720 0.80 port 8000 but the linux instance rebooted and now it's not there anymore so where do i go well first off know that i am picking up right where i left off after the installation i know a lot of people have probably done tunes and tweaks but i want to grab the people that are just getting it installed and they're like oh no how do i do this so if you've moved things around if you tweaked that's fine just just kind of feather this into into your knowledge and hopefully through this you can not only learn how to get netbox back up and running but a little bit more about linux about docker and things like that right so so come on over with me to the command prompt right so i just rebooted i logged in as root and as of right now i wanna let me first off uh show you a key command in linux uh ps stands for process status it shows you it's kind of like um if you're a windows person it's like the services control panel like what's running right now on linux and you can see not much essentially bash my prompt that i'm using to type commands in and the ps that i just executed well we're running netbox inside of docker and docker is like application virtual machines if you will uh like vms for applications like so we've got netbox and all the pieces of it um so we can actually see what process status what is the process test or what processes are running in docker by typing in docker ps right same thing and it's like nothing this is the rebooted state of netbox and you can see it you know here's the container id and it wraps around because i had to increase my font so it would all kind of fit in here so sorry for the the line wrap but um but a couple couple key key pieces i'm going to do a quick ls command which shows the directory now doing the net box install in 10 minutes we at we installed everything into the the root user's home folder probably not best but it works uh in a in a directory called netbox docker so i'm going to do a change directory in that box docker right and do an ls and i think i mentioned in the installation there's there's a utility we're using called docker compose right so we're running a script that somebody created bless their soul and i'll type in more docker docker dash compose.yaml and this this script actually assembles a docker environment that has a netbox worker docker image an nginx docker image that's the web server you've got postgres that's the database so you've got all all the puzzle pieces that that make make it work so so let me give you the the quick answer to the question how do i get it back up and running well the same way that we did during the install you can use docker compose up i'm going to put a little ampersand after that and i'll tell you why as soon as you hit enter you notice that docker compose takes over the prompt right and it's it's starting to get all of these different vms if you will docker images up and running piece by piece now if you remember my my little installs running on proxmox i hit i think it has like 256 or 512 megs megs not even a gig of memory so it runs slow so get give it some time so behind the scenes it's actually building all of those docker images based on the docker compose script so when that's done that will get get netbox up and running now why did i put the ampersand after that well if you don't it takes over your prompt it takes over your i mean so you can create another ssh session but this allows you to hit the enter key and get your prompt back if you leave the ampersand off you don't get that and and i know i know a lot of you are linux ninjas and you're like uh basic yeah that's great that's what i'm going after i know a lot of people getting into this aren't linux ninjas so so hopefully this helps so so the ampersand gives you your prop back so you can continue working while this thing's churning in the background now in the meanwhile this will get a uh netbox up and running it's my slow slow machine is still uh churning up right now there we go there we go we're coming back up hey there we go net box should be back up and running let me just go behind the scenes maybe get a quick refresh see if it's there there we go hey that box is alive and well uh one more time and i can see that the front but that little ampersand lets me keep typing because now and let me show this i'm going to type in ps notice docker compose is running and i can do a docker ps and it shows all the docker images that are running right there right the reason i'm showing this to you i'm not just showing you how to get it back up and running is because as we get deeper into this and i show you more things like how do you upgrade netbox how do you backup that box knowing how to how to get a view into this and i'm going to i'm going to do something kind of wild here i'm going to kind of stretch this past the screen so it doesn't do that word wrap at least not quite as bad so you can i know it's flying off the screen but you can see each one of these represents the docker image and that container id is going to be some critical information that we need when we're referencing these in the future um if if you could see the the the piece of my screen that's scrolled off right here you can see here's the name so this is ngnix right this is netbox this is netbox worker so each one of these represents a docker image that docker compose brought up right so that's how we get netbox up and running now how do we keep it running well let me show you if i go into uh this directory let me do a an ls uh one more time you can see we've got all of these these different functions uh or different scripts inside of your directories things like that one of these files is called docker compose override let me hit the ls there we go wrap it around docker compose override.yaml so when you when you run docker compose it runs this script and then it's like this is kind of like in in addition to that script let me add this in this is the script that runs second right so i'm going to use pico and edit that and i'll do a docker compose override hit the enter key and you can see that it says hey we're running version 3.4 services nginx and and i just have a little override here that tells that service to run on port 8000 right and and that we talked about that during the installation i'm gonna squeeze something in here i'm gonna hit the enter key do a space a couple times and do restart and by the way the spacing is important here restart colon unless stopped this little command will say okay if this docker image ever stops i'm going to restart it unless it was stopped by the administrator like you come in there and do you can stop it by i'll actually i'll show you how to stop in a minute because you don't want it to just constantly restart and you're like fighting you're like no stop no please stop so so unless it's stopped like if the vm just reboots it'll automatically restart as long as it was running before and you didn't you didn't manually stop it right so that gets the web server running nginx but what about the other stuff well i'm gonna i'm gonna put it in here and i'll put it in the text below this as well let me hit the go down a little bit i'm going to copy all of the the commands that we use for the other docker ports and just right right click paste them in there i put them in a little text file on the side so i wouldn't have to sit here and type them uh while i'm showing you this paste it in so all of these docker images combine together to make netbox work by the way postgres is your database that's that's a big deal you want the database writing you want that backed up we'll talk about that later but for the time being i'm going to hit control x yes enter we've now saved i'll do a more well let me hit the up arrow more docker compose override yeah i'll hit the enter key and now you can see a picture-perfect view of what that override script does which adds the restart to it so now i'm going to do a docker compose stop right and this this will shut it all down by the way that's i i was meaning to show you that that's how you turn off uh netbox without shutting down the vm or anything like that now if we go back there i can do a ps hit the enter key and you can see that the only thing left is bash and ps running docker ps shows nothing's running so so that's how we bring it back down that docker compose stop now when i type in docker compose up it's going to rerun that box get get all those those docker images up and running but this time it's going to process that that uh that script oh shoot i forgot the little uh ampersand command so now it's it's gonna steal my prompt uh that's fine i'm gonna i'm gonna create a second uh putty session and there you go you can see uh netbox is running in the background now watch watch this so i'm gonna i've brought over another ssh session right here do a quick ps uh oh that's it's just showing there's nothing running in this uh uh this uh command prompt but i'm gonna type in docker ps and i see all those images that are running so i'm going to do a a a rude shutdown of the vm right i'm going to do a shutdown dash r now or we could power it off or something i'm not going to manually stop it because you remember the the command i typed in there was restart it unless the administrator stops it so if i stop it i kind of overrule that right so i'm just going to shut it down bam restart it says remote side unexpectedly close the connection it's down and you can see both sides it's right there so now i'll come back up here and hit restart session this is all running in proxmox so it goes extremely fast as a container uh so i'm going to do root uh type in my password right there and i'll do a ps docker ps and i should see i should see if all is well hey look at that uh all of these these vms have started back up and running you can see status updated less than a second ago so so we have netbox running even though we just rebooted the vm that it was running on that's how you can get netbox up and running automatically and this video probably took so long it took longer than the installation in 10 minutes that i showed you but what i wanted to convey is a little more of the underpinnings through the practical step of let's make sure this thing stays running so so hang on just just think about it with me what what have you learned in in just just this little short session about linux you've learned the ps command right so you can see what processes are running inside of your shell you've learned about the docker ps command right uh so you can see what docker images are running you've learned about you know where where the installation is at uh and i think you probably knew that before but you've learned about the the you know docker compose command the docker compose override you've learned i mean you learned a lot um and and through that you now know how to keep netbox up and running on this virtual machine that we've created keep it simple
Info
Channel: Viatto
Views: 1,387
Rating: undefined out of 5
Keywords:
Id: djNis2wFfNU
Channel Id: undefined
Length: 11min 57sec (717 seconds)
Published: Thu Oct 21 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.