物联网系统运维——自动化运维,自动化运维工具介绍,构建Cobbler网络自动安装环境,实验操作(重点)Cobbler的安装,挂载系统,同步,修改dhcp.template等(重点)

一.自动化运维概要

1.自动化运维介绍

IT运维自动化是一组将静态的设备结构转化为根据IT服务需求动态弹
性响应的策略, 目的就是实现IT运维的质量,降低成本。

2.运维自动化对运维人员要求

1.事前预警                             2.事中恢复                              3.事后存档,

3.运维知识体系

ITSM: ITSM是一 个理念,是一套方法论,可以帮助企业对IT服务进行有效管理的高质量。
ITIL: ITIL是CCTA (英国国家计算机和电信局)于20世纪80年代中期开始开发的一套针对IT行业的服务管理标准库。
两者之间的关系和区别: ITIL是标准,是ITSM实施过程中的抽象和经验总结,它是ITSM实施中的一套流程和准则
DevOps(DevOps: Development和Operations的组合):DevOps看作开发(软件工程)、技术运营和质量保障(QA)三者的交集。

二.自动化运维工具介绍

安装部署相关

Cobbler:能够快速建立网络安装环境,可以为各种Linux提供自动化安装任务。

Spacewalk:管理Red Hat衍生发行版的软件内容更新,同时提供预备和监控的功能。

配置管理相关

Chef: -个IT自动化平台,可让创建、部署、变更和管理基础设施运行时环境和应用。
Puppet:基于ruby开发,- 种Lin ux、Unix平台的集中配置管理系统。可管理配置文件、用户、计划任务、软件包、
Ansible:基于Python开发,提供自动化运维框架。结合众多的模块工作,可实现批量系统配置、批量程序部署、批量运行命令等功能。
SaltStack:基于Python开发,一个异构平台基础设置管理工具。具备配置管理、远程执行、监控功能。

监控报警数相关

Nagios: -个Linux/Unix操作系统 下的监视系统,可以监控系统、应用、服务以及各种进程的运行状况,并提供多种报警机制。
Zabbix:-个基 于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。能监视各种网络参数,保证服务器系统的安全运营,并提供灵活的通知机制。
Cacti:基于PHP开发,一款网络流量监测图形分析工具。 要功能是用snmp服务获取数据,然后用rrdtool储存和更新数据,当用户需要查看数据的时候用rrdtool生成图表呈现给用户。
Zenoss Core: -个智能监控软件,可依靠单一-的WEB控制台来监控网络架构的状态和健康度。主要功能具有监控可用性,性能,配置和各种事件。

三.构建Cobbler网络自动安装环境

1.Cobbler简介

1.1Cobbler概述

Cobbler由python语言开发,是对PXE和Kickstart以及DHCP的封装。融合很多特性,提供了CLI和Web的管理形式,更加方便的实行网络安装。同时,Cobbler也提供了API接口,使用其它语言也很容易做扩展。 它不仅可以安装物理机,同时也支持KVM、XEN虚拟化、Guest OS的安装。
 

1.2.Cobbler组成

发行版:表示一个操作系统。
配置文件:包含一个发行版、一个kickstart 文件以及可能的存储库。
系统:表示要配给的机器。
存储库:保存一个yum或rsync存储库的镜像信息。镜像:可替换一个包含不属于此类别的文件的发行版对象

1.3.Cobbler工作原理

2.Cobbler部署管理

实验环境

四.实验操作(重点)Cobbler的安装

1.环境准备

#先查看本机IP和网关

ifconfig

把实验用到的软件全部上传到/home/soft

(1)搭建yum仓库

mkdir /yum

tar zxvf /home/soft/yum_repo.tar.gz -C /yum

#把本地源复制过来

cp /home/soft/local-repo.repo  /etc/yum.repos.d/local-repo.repo

#清除缓存

yum clean all

yum makecache

(2)关闭防火墙与SELinux

systemctl stop firewalld.service

systemctl disable firewalld.service

getenforce

setenforce 0

此时如果出现

则修改配置文件

vim /etc/ selinux/config

并非所有的 Linux distributions 都支持 SELinux

目前 SELinux 支持三种模式,分别如下:

•enforcing:强制模式,代表 SELinux 运作中,且已经正确的开始限制 domain/type 了;

•permissive:宽容模式:代表 SELinux 运作中,不过仅会有警告讯息并不会实际限制 domain/type 的存取。这种模式可以运来作为 SELinux 的 debug 之用;

•disabled:关闭,SELinux 并没有实际运作。

getenforce

2.安装Cobbler

(1)Cobbler运行所需基础包

(2)Cobbler所需环境支持包

yum -y install cobbler cobbler-web dhcp pykickstart httpd tftp-server xinetd

(2.1)如果该虚拟机安装了nginx则 会跟httpd端口冲突 需要先停掉nginx

//查看端口命令

netstat -antlp | grep 80    

停用nginx

systemctl stop nginx.service

如果想开机关闭nginx则输入命令

systemctl disable nginx

(2.2)停掉keeplive

(3)启动Cobbler

systemctl start cobblerd.service

systemctl start httpd.service

(4)检查存在的问题

cobbler check

(5)展示问题#####

The following are potential configuration items that you may want to fix:

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.

2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.

3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:

    https://github.com/cobbler/cobbler/wiki/Selinux

4 : change 'disable' to 'no' in /etc/xinetd.d/tftp

5 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.

6 : enable and start rsyncd.service with systemctl

7 : debmirror package is not installed, it will be required to manage debian deployments and repositories

8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one

9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use the

Restart cobblerd and then run 'cobbler sync' to apply changes.

##############

##########

#问题 :cobblerd does not appear to be running/accessible: error(111, 'Connection refused')

systemctl start httpd.service

systemctl start cobblerd.service

cobbler repo add --name=openstack-mitaka --mirror=http://mirrors.aliyun.com/centos/7.2.1511/cloud/x86_64/openstack-mitaka/ --arch=x86_64 --breed=yum

#############

(6)备份settings

cp /etc/cobbler/settings{,.ori}

(7)修改settings

vim /etc/cobbler/settings

next_server: 192.168.145.200 #(本机IP)

server: 192.168.145.200 #(本机IP)

manage_dhcp: 1

pxe_just_once: 1

(8)修改tftp

vim /etc/xinetd.d/tftp

disable = no

 

(9)启动同步

systemctl start rsyncd

(10)下载必要软件

yum update -y nss curl libcurl

yum -y install syslinux

cp  /home/soft/README /var/lib/cobbler/loaders/README

cp  /home/soft/COPYING.elilo /var/lib/cobbler/loaders/COPYING.elilo

cp  /home/soft/COPYING.yaboot /var/lib/cobbler/loaders/COPYING.yaboot

cp  /home/soft/COPYING.syslinux /var/lib/cobbler/loaders/COPYING.syslinux

cp  /home/soft/elilo-ia64.efi /var/lib/cobbler/loaders/elilo-ia64.efi

cp  /home/soft/yaboot /var/lib/cobbler/loaders/yaboot

cp  /home/soft/pxelinux.0 /var/lib/cobbler/loaders/pxelinux.0

cp  /home/soft/menu.c32 /var/lib/cobbler/loaders/menu.c32

cp  /home/soft/grub-x86.efi /var/lib/cobbler/loaders/grub-x86.efi

cp  /home/soft/grub-x86_64.efi /var/lib/cobbler/loaders/grub-x86_64.efi

systemctl restart cobblerd

cobbler validateks

#问题 : enable and start rsyncd.service with systemctl

yum -y install rsync

systemctl start rsyncd

systemctl restart cobblerd

systemctl enable rsyncd

 (11)修改密码(加密)

openssl passwd -1 -salt 'oldboy' '123456'

$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1

(12)修改settings

vim /etc/cobbler/settings

default_password_crypted: "$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1"

(13)检查下载必要软件

cd /var/lib/cobbler/loaders/

ls

##############

COPYING.elilo     COPYING.yaboot  grub-x86_64.efi  menu.c32    README

COPYING.syslinux  elilo-ia64.efi  grub-x86.efi     pxelinux.0  yaboot

###################

(14)编辑rsync

vim /etc/xinetd.d/rsync

disable = no

(15)重启服务

systemctl restart xinetd

systemctl restart cobblerd

(16)再次检查

cobbler check

############################

The following are potential configuration items that you may want to fix:

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:

    https://github.com/cobbler/cobbler/wiki/Selinux

2 : debmirror package is not installed, it will be required to manage debian deployments and repositories

3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.

####################################(以上三个问题可以忽略了)

(17)修改dhcp.template

vim /etc/cobbler/dhcp.template

subnet 192.168.145.0 netmask 255.255.255.0 {

  option routers             192.168.145.2;#(网关IP)

  option domain-name-servers 192.168.145.2;#(网关IP)

  option subnet-mask         255.255.255.0;

  range dynamic-bootp        192.168.145.10 192.168.145.220;  #(DHCP范围)

  default-lease-time         21600;

  max-lease-time             43200;

  next-server                $next_server;

(18)同步

cobbler sync

##############

*** TASK COMPLETE ***

##################

(19)设置自动启动

systemctl enable dhcpd.service

systemctl enable rsyncd.service

systemctl enable tftp.service

systemctl enable httpd.service

systemctl enable cobblerd.service

systemctl enable xinetd

(20)再次重启确认

systemctl restart dhcpd.service

systemctl restart rsyncd.service

systemctl restart tftp.service

systemctl restart httpd.service

systemctl restart cobblerd.service

systemctl restart xinetd

(21)查看安装是否成功

Cobbler

#####################

[root@localhost loaders]# cobbler

usage

=====

cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ...

        [add|edit|copy|getks*|list|remove|rename|report] [options|--help]

cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]

##################

(22)挂载帮助

cobbler import --help

(23)挂载系统

mount /dev/cdrom /mnt/

###############

#问题:mount: 在 /dev/sr0 上找不到媒体

检查vm设置,系统镜像文件是否存在,已存在

检查虚拟机设置,发现“已连接”没有勾选上,所以勾选上去。重新挂载。

######################

(24)导入系统

cobbler import --path=/mnt/ --name=CentOS-7.1-x86_64 --arch=x86_64

(25)查看挂载系统

cobbler distro list

(26)进入ks_mirror

cd /var/www/cobbler/ks_mirror/

ll

ll CentOS-7.1-x86_64/

(27)复制CentOS-7.1-x86_64.cfg,从文件中复制出来

cp /home/soft/CentOS-7.1-x86_64.cfg.txt  /var/www/cobbler/ks_mirror/CentOS-7.1-x86_64.cfg

cp /home/soft/CentOS-7.1-x86_64.cfg.txt  /var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg

cobbler distro report --name=CentOS-7.1-x86_64

cobbler profile report

cobbler profile edit --name=CentOS-7.1-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg

cobbler profile edit --name=CentOS-7.1-x86_64 --kopts='net.ifnames=0 biosdevname=0'

进行到这里就可以安装系统了!

已经安装cobbler-web软件。

访问网址:https://192.168.145.200/cobbler_web

默认用户名:cobbler 默认密码 :cobbler

#验证:

VMware新建一个虚拟机,内存选2G,不用选镜象,直接启动,有跳转到选系统的界面即为成功.

  • 26
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杪商柒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值