|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "DevOps for Beginners Introduction" |
| 4 | +date: 2016-7-28 12:00:00 -0500 |
| 5 | +categories: DevOps |
| 6 | +permalink: lessons/devops-introduction |
| 7 | +excerpt: "Introduction to the course, and our imaginary webapp company: Montonomy.com." |
| 8 | +weight: 1 |
| 9 | +image: 'devops.png' |
| 10 | + |
| 11 | +--- |
| 12 | +{% include youtube.html id="v7ZcZfGBFcU" %} |
| 13 | + |
| 14 | +Introduction |
| 15 | +------------ |
| 16 | +This is Samantha with the DevOps Library, and today I'd like to welcome you to |
| 17 | +our new DevOps for Beginners Course! This course is going to be a little bit |
| 18 | +different from our normal videos. We're going to use a story to illustrate how |
| 19 | +to solve real world problems using DevOps tooling and concepts. |
| 20 | + |
| 21 | +Imagine you've just started working for a web based company that's desperately |
| 22 | +trying to scale. We'll start out with the basics, but by the end of this |
| 23 | +course, you'll be ready to deploy, monitor, and scale applications in the real |
| 24 | +world. |
| 25 | + |
| 26 | +Thank you Datadog |
| 27 | +----------------- |
| 28 | +Before we begin, we'd like to give a quick shout out to |
| 29 | +[Datadog](http://dtdg.co/devops-library) for sponsoring this video. With their |
| 30 | +help, we're able to keep our videos free, and we even use them personally for |
| 31 | +our servers. By using [Datadog's](http://dtdg.co/devops-library) cloud-scale |
| 32 | +monitoring, you can easily track your dynamic infrastructure. |
| 33 | + |
| 34 | +If you haven't tried them out, visit |
| 35 | +[dtdg.co/devops-library](http://dtdg.co/devops-library), you'll even get a 14 |
| 36 | +day free trial! |
| 37 | + |
| 38 | +Alright, back to our lesson |
| 39 | + |
| 40 | +Day 1 |
| 41 | +----- |
| 42 | +You’ve spent most of the day so far just getting to know the team. Kevin, one |
| 43 | +of the guys from the build team, volunteers to teach you and Ron how to set up |
| 44 | +the Montonomy webapp. Well, as soon as he finishes an email to QA about the |
| 45 | +last night's release that is. |
| 46 | + |
| 47 | +Emergency |
| 48 | +--------- |
| 49 | +Suddenly everything changes. Your boss Steve, begins shouting across the room |
| 50 | + |
| 51 | +> "OMG CHECK the homepage, CHECK the homepage!". |
| 52 | +
|
| 53 | + |
| 54 | + |
| 55 | +Before you've even opened up your browser, 3 people have already screamed |
| 56 | +"408!!!". Seconds later the roar has died down as everyone scrambles to figure |
| 57 | +out what's causing the website to timeout. |
| 58 | + |
| 59 | +An unspoken awareness of thousands of angry customers falls over you, and |
| 60 | +permeates the room. You quickly SSH into one of the web servers, and after a |
| 61 | +few dead ends, decide to run 'top'. |
| 62 | + |
| 63 | +Good God, the server's CPU is pegged at 100%. |
| 64 | + |
| 65 | +Quickly you run over to let Steve know. Without even saying a word, the look of |
| 66 | +sadness and fear on his face tells you the solution isn't going to be easy. |
| 67 | + |
| 68 | +Using sorcery, or as Steve calls it Perl, the status of each web server pops up |
| 69 | +on the screen. Every single one is maxed out. |
| 70 | + |
| 71 | +Steve then proceeds to address the team: |
| 72 | + |
| 73 | +> "I need 2 more Web Servers ASAP! |
| 74 | +
|
| 75 | +Justin, Chris, move as fast as you can, and can someone look into why we're |
| 76 | +being hit so hard?!". |
| 77 | +Seems like a pretty easy fix right? A few minutes later it dawns on you why |
| 78 | +everyone is still panicking. |
| 79 | + |
| 80 | +...the servers are being configured by hand. |
| 81 | + |
| 82 | +Day 2 |
| 83 | +----- |
| 84 | +Flashing forward to Day 2. |
| 85 | + |
| 86 | +Things have been going quite a bit better, the website's up, and Justin even |
| 87 | +brought in donuts. Steve is currently out explaining to the marketing team why |
| 88 | +sending a 50% off coupon to 1.5 million members without a heads up was a bad |
| 89 | +idea, and Kevin is finally going to show you and Ron how to set up the company's |
| 90 | +app. |
| 91 | + |
| 92 | +Cloning the App |
| 93 | +--------------- |
| 94 | +> "So the first thing you guys need to do is to clone our main app repository, |
| 95 | +> which is hosted on Github. Are you both pretty comfortable with git?" |
| 96 | +
|
| 97 | +You and Ron both nod, although you suspect Ron is lying. |
| 98 | + |
| 99 | +[https://github.com/devopslibrary/devops-demo](https://github.com/devopslibrary/devops-demo) |
| 100 | + |
| 101 | +> "Awesome! Well, we only need two files from the repo, the devops-demo.sql |
| 102 | +> script, which we'll use to set up the database, and the devops-demo.tar.gz file, |
| 103 | +> which goes on the webserver." |
| 104 | +
|
| 105 | +Before Kevin can continue, Ron stands up and says |
| 106 | + |
| 107 | +>"I get it" |
| 108 | +
|
| 109 | +then wanders off. Kevin sighs |
| 110 | + |
| 111 | +> "He doesn't get it, he hasn't gotten anything. Of everyone, he |
| 112 | +> should definitely be listening. Let's put it this way, he's like a human |
| 113 | +> [chaos monkey](http://techblog.netflix.com/2012/07/chaos-monkey-released-into-wild.html)". |
| 114 | +
|
| 115 | +Unsure of what to say, you ask what to do next. |
| 116 | + |
| 117 | +> "Ah sorry, he's not that bad. |
| 118 | +> Anyway, login to AWS with the creds I emailed you earlier. I went ahead and |
| 119 | +> already spun up two Ubuntu 14.04 instances. We'll use one as a MySQL server |
| 120 | +> for the Montonomy backend, and the second for the frontend.” |
| 121 | +
|
| 122 | +After SSHing into both servers, Kevin has you pull up an [Evernote](http://www.evernote.com/l/AnvdBaIF3MpERJT4bOdzuQA6ZIC_ZHn2AJA/) with each |
| 123 | +of the steps listed. |
| 124 | + |
| 125 | +> Alright, so when you're doing these steps, make sure |
| 126 | +> you're running as root. I also like to do an apt-get update before doing |
| 127 | +> anything else. Now install MySQL. Type: |
| 128 | +
|
| 129 | +``` |
| 130 | +apt-get install mysql-server |
| 131 | +``` |
| 132 | + |
| 133 | +Before you can continue, MySQL pops up asking for a password. |
| 134 | + |
| 135 | +> "At this point, you'll want to use our standard password or you'll have to edit |
| 136 | +> the SQL script, let me find it real quick". |
| 137 | +
|
| 138 | +Kevin then opens up **Keepass** on his laptop, and after a minute or two tells |
| 139 | +you to type in "**devpass**". |
| 140 | + |
| 141 | +> "Perfect!" Kevin says, "Now you just need to run a few lines to configure MySQL. |
| 142 | +> They're pretty long, do you want me to type them real quick?" |
| 143 | +
|
| 144 | +You nod, then Kevin types: |
| 145 | + |
| 146 | +``` |
| 147 | +mysql -uroot -pdevpass -e "create database devopsdb" |
| 148 | +``` |
| 149 | + |
| 150 | +> "Alright, so that line creates the database, now I just need to upload the SQL |
| 151 | +> script from the repo and run it, one moment". |
| 152 | +
|
| 153 | +*Kevin SCPs the SQL script to the server*, then runs: |
| 154 | + |
| 155 | +``` |
| 156 | +mysql -uroot -pdevpass devopsdb < devops-demo-1.0.sql |
| 157 | +``` |
| 158 | + |
| 159 | +> "Alright, we're just about set on this server, but you still need to set the |
| 160 | +> bind address to allow any host, otherwise the webserver won't be able to |
| 161 | +> connect. Are you pretty familiar with MySQL?" |
| 162 | +
|
| 163 | +You nod, and pull up **/etc/mysql/my.cnf** in VIM. After commenting out the |
| 164 | +bind address, you run **service mysql restart** to apply the changes. |
| 165 | + |
| 166 | +Kevin smiles, then says |
| 167 | + |
| 168 | +>"Thank the gods, you don't use nano, I knew we hired the right person.". |
| 169 | +
|
| 170 | +You don't mention it, but you were using **nano** up until a few months ago |
| 171 | +until after you spent a day playing [VIM Adventures](http://www.vim-adventures.com). |
| 172 | + |
| 173 | +> "Now onto the last part, we still need to set up the webserver. |
| 174 | +> Unfortunately, I have a meeting with Todd I need to go to. I'm trying to get |
| 175 | +> him onboard with using Jenkins, but he's been pretty much against changing |
| 176 | +> anything. If you have time, just follow the rest of the Evernote and let me |
| 177 | +> know later if you have any questions. Oh yeah, and make sure you note down |
| 178 | +> the IP address of the SQL server, you'll need it for the config.ini file on |
| 179 | +> the app." |
| 180 | +
|
| 181 | +Kevin walks off and for the first time today you're on your own. You pull up |
| 182 | +[Evernote](http://www.evernote.com/l/AnvdBaIF3MpERJT4bOdzuQA6ZIC_ZHn2AJA/) |
| 183 | +alongside the web server terminal and start running through the steps. |
| 184 | + |
| 185 | +1. Do an apt-get update then run: ```apt-get install apache2 php5 php5-mysql``` |
| 186 | +2. Delete everything from /var/www/html. |
| 187 | +3. Upload the devops-demo-1.0.tar.gz file to the server, once it finishes, |
| 188 | +extract the files to /var/www/html. |
| 189 | +4. Open up a web browser and go to the public IP of the server, verify that the |
| 190 | +page comes up. |
| 191 | + |
| 192 | +After opening up the page, you notice that it DOES come up, however the database |
| 193 | +connection fails. Unfortunately, that's the last step in the [Evernote](http://www.evernote.com/l/AnvdBaIF3MpERJT4bOdzuQA6ZIC_ZHn2AJA/). |
| 194 | + |
| 195 | +Thankfully, Max doesn't look too busy so you ask him for help. |
| 196 | + |
| 197 | +> "Ahhh... we really need to update that guide, you're good to go on the |
| 198 | +> infrastructure part, but you still need to set the config variables. Open up |
| 199 | +> **/var/www/html/config.ini.** |
| 200 | +> Replace DBHost with the IP of whatever database you set up, SQLUser with |
| 201 | +> "**root**", and SQLPassword with **devpass** unless Kevin had you use something else. |
| 202 | +> For the SQL DB Name, set it to **devopsdb**." |
| 203 | +
|
| 204 | +"What do I use for ENV?" you ask Max. |
| 205 | + |
| 206 | +> "Ah, make sure you use DEV, that way the app doesn't point to any of our |
| 207 | +> production stuff. That should be it, refresh the page to make sure" |
| 208 | +
|
| 209 | + |
| 210 | + |
| 211 | +Success! Thanks to Max and Kevin's help, you've just learned how to set up the |
| 212 | +app! While we know setting the app up by hand was painful, don't worry, in the |
| 213 | +next episode we'll automate the process. I know this style is quite a bit |
| 214 | +different from what we normally do, please let us know in the comments if you |
| 215 | +like it or would prefer us to focus on our normal videos. |
| 216 | + |
| 217 | +If you have a real world problem you'd like us to address in the story, let us |
| 218 | +know and we'll do our best to add it! If you like our videos, please subscribe |
| 219 | +to our [YouTube channel](https://www.youtube.com/channel/UCOnioSzUZS-ZqsRnf38V2nA?sub_confirmation=1)! |
| 220 | + |
| 221 | +[Subscribe to our YouTube channel](https://www.youtube.com/channel/UCOnioSzUZS-ZqsRnf38V2nA?sub_confirmation=1) or follow [DevOpsLibrary on Twitter](https://twitter.com/intent/user?screen_name=devopslibrary). |
| 222 | + |
| 223 | +{% include subscribe.html %} |
| 224 | + |
| 225 | +Thank again and see you soon. |
0 commit comments