Practical Linux Infrastructure - Syed Ali.pdf

(5776 KB) Pobierz
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a Glance
About the Author ...............................................................................................................
xix
About the Technical Reviewer ...........................................................................................
xxi
Acknowledgments ...........................................................................................................
xxiii
Introduction ......................................................................................................................
xxv
Chapter 1: Managing Large-Scale Infrastructure ..............................................................1
Chapter 2: Hosted Cloud Solutions Using Google Cloud Platform ...................................25
Chapter 3: Virtualization with KVM .................................................................................53
Chapter 4: MySQL, Git, and Postfix ..................................................................................81
Chapter 5: Configuration Management with Puppet .....................................................109
Chapter 6: Apache for Enterprise-Level Fault Tolerance ...............................................137
Chapter 7: Monitoring with Nagios and Trend Analysis with Cacti ...............................167
Chapter 8: DNS Using BIND and DHCP ...........................................................................197
Chapter 9: Log Collection, OpenVPN, and iptables.........................................................225
Chapter 10: Troubleshooting Tools ................................................................................255
Index .................................................................................................................................283
v
Introduction
GNU/Linux (https://www.gnu.org/gnu/linux-and-gnu.html) is a fundamental building block of the Internet. Many
of the most visited Internet sites run some
flavor
of GNU/Linux. Along with GNU/Linux is other free and open source
software that is used to build infrastructures for organizations.
This
book serves as a guide to engineers who want to
use free and open source software to build their infrastructure.
There
are a lot of very interesting and relevant topics that need to be visited when building an infrastructure.
The
topics I picked are based on my personal experience and on what I think is most relevant to engineers now and in
the future. I dedicated entire chapters to topics that I believe deserve deeper discussion, such as Apache HTTP Server
and kernel-based virtual machine (KVM). For other services that are commonly being used in the software-as-a-
service model, such as e-mail, I chose to share that chapter with other topics.
Although cloud computing is gaining in popularity, there are questions about infrastructure management that
need to be answered, such as monitoring, logging, configuration management, and name service in the cloud.
In addition, if you want to be cloud agnostic, then you have to build services in the cloud that do not lock you in to
a particular cloud provider. For instance, instead of using Google SQL, you may chose to use MariaDB installed on
a virtual instance in Google Compute Engine.
This
strategy might make it easier for you to migrate to another cloud
provider in the future, if needed.
The
software I explain in this book is among the more popular in their respective
fields.
Apache HTTP Server and
MySQL are often used for Internet-facing applications. Nagios and Cacti are leading monitoring and trend analysis
software. KVM is the most popular open source free virtualization software. OpenVPN and iptables are very useful
for edge protection and remote connectivity. Internet companies for source code management use Git extensively.
Puppet is used to manage systems and also for application deployment. BIND is the reference architecture
implementation for domain name system (DNS) and rsyslog is the default installation for managing logs on Linux.
Google Cloud Platform is the only platform I cover in this book that is not free, but this is because I am not
aware of any public cloud provider that is free. You can get demo accounts with public cloud providers for a limited
time, and some of them offer a very limited—and free—basic tier, but none of them allow you to build an entire
infrastructure and run it for free.
There
are hundreds of Linux distributions (http://distrowatch.com/). For the purpose of this book, I have
referenced CentOS 6.x/RedHat 6.x. Location of configuration
files
might be different if you use another Linux
distribution.
Readers of this book include those who want to build a GNU/Linux–based infrastructure. You could be a junior,
mid-level, or senior system administrator, site reliability engineer, DevOps or developer, and you can still benefit from
this book.
The
knowledge you acquire from these pages hopefully helps you design a fault-tolerant, resilient GNU/
Linux–based infrastructure you can be proud of, and one that is able to enhance your business value though the use of
free open source software.
xxv
CHAPTER 1
Managing Large-Scale Infrastructure
This chapter is about the issues that come up in infrastructure management at a large scale. Mission-critical
decisions such as infrastructure architecture, and decisions on matters such as licensing and support, are all part of
infrastructure design. When managing a small infrastructure, many of these issues do not have the same criticality as
they do in a large enterprise. A scalable architecture is an important foundation for a successful, large infrastructure.
Infrastructure management can be divided into two components: application deployment and infrastructure
architecture. First we review application deployment and then look at different infrastructure architecture models. We
also review the components that make up a scalable infrastructure.
Application Deployment
From design to production, a scalable infrastructure enables developers to code, test, and deploy applications quickly.
The traditional deployment model has not been effective at speeding up the design-to-production pipeline.
Figure
1-1
shows the traditional deployment model where a major hurdle to reaching production is testing. After
developers have written code, they pass it to a quality assurance (or QA) team that tests the code manually and sends
it back to the development team for fixing. After the fixes are complete, the code is tested again. When the tests pass,
the code is sent to staging. Staging is a replica of production. After the code passes through staging, the operations
team deploys the code to production using a change management process. This entire process for a single line of
change in code might take two to four weeks.
Figure 1-1.
Traditional design-to-production model
Realizing that this model is not a very effective one, a newer model came into existence—that of continuous
integration and continuous delivery (CI/CD). With this model, as soon as unit testing is complete and code is checked
into the source code repository, the CI/CD pipeline kicks in. The pipeline consists of an automated build system,
using tools such as Jenkins (http://jenkins-ci.org). The build system takes the code and builds it, outputting a
compiled binary. The binary can then be taken and installed into production in an automated manner (Figure
1-2).
1
Zgłoś jeśli naruszono regulamin