====== Laboratorio LPIC-2 ====== Laboratorio para el curso de LPIC-2 Necesario tener instalado: * [[informatica:sistemas_operativos:virtualizacion:virtualbox|VirtualBox]] * [[informatica:sistemas_operativos:virtualizacion:vagrant|Vagrant]] El entorno virtualizado se compone de 3 máquinas virtuales: ^ Sistema Operativo ^ IP ^ Host ^ | Centos 7.2 | 192.168.2.5 | sercentos7 | | Debian 10 | 192.168.2.10 | debian10 | | Centos 6.7 | 192.168.2.152 | orion | Las credenciales: * Usuario: ''vagrant'' * Contraseña: ''vagrant'' Credenciales de root: * Usuario: ''root'' * Contraseña: ''vagrant'' En la máquina con Debian no podemos conectarnos vía SSH con la cuenta de root, así que habrá que entrar con la de ''vagrant'' y una vez dentro hacernos root con ''sudo su'' ===== Despliegue del entorno ===== Necesitamos un fichero llamado ''CentOS-Base.repo'' con el siguiente contenido para los repositorios de CentOS 6: # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=https://vault.centos.org/6.10/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ baseurl=https://vault.centos.org/6.10/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ baseurl=https://vault.centos.org/6.10/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ baseurl=https://vault.centos.org/6.10/os/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ baseurl=https://vault.centos.org/6.10/os/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 El entorno se monta mediante un ''Vagrantfile'': # -*- mode: ruby -*- # vi: set ft=ruby : ##Ususario:vagrant ##Pass: vagrant ##user:root ##pass:vagrant Vagrant.configure("2") do |config| config.vm.define "centos7" do |centos7| config.vm.boot_timeout = 400 centos7.vm.box = "bento/centos-7.2" #centos7.vm.network "forwarded_port", guest: 3000, host: 3002, auto_correct: true centos7.vm.network "private_network", ip: "192.168.2.5" centos7.vm.hostname = "sercentos7" end config.vm.define "debian" do |debian| debian.vm.box = "bento/debian-10" config.vm.boot_timeout = 400 #debian.vm.network "forwarded_port", guest: 3000, host: 3001, auto_correct: true debian.vm.network "private_network", ip: "192.168.2.10" debian.vm.hostname = "debian10" #debian.vm.provision "shell", inline: <<-SHELL # SHELL end config.vm.define "centos6" do |centos6| centos6.vm.box = "bento/centos-6.7" config.vm.boot_timeout = 400 #debian.vm.network "forwarded_port", guest: 3000, host: 3001, auto_correct: true centos6.vm.network "private_network", ip: "192.168.2.152" centos6.vm.hostname = "orion" centos6.vm.provision "shell", inline: <<-SHELL rm -rf /etc/yum.repos.d/CentOS-Base.repo cp /vagrant/CentOS-Base.repo /etc/yum.repos.d/ yum clean all SHELL end end Lo creamos con: vagrant up Para detener todas las máquinas: vagrant halt Si queremos suspenderlas: vagrant suspend Si queremos reanudar la ejecución (tras una suspensión): vagrant resume Destruir todas las máquinas: vagrant destroy -f ==== Configuración host ==== **Centos 7**: hostnamectl set-hostname sercentos7.curso.esp Contenido de ''/etc/hostname'': sercentos7.curso.esp Modificar ''/etc/hosts'' de la siguiente manera: 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.2.5 sercentos7.curso.esp sercentos7 192.168.2.152 orion.curso.esp orion 192.168.2.10 debian10.curso.esp debian10 Deshabilitar SELinux en ''/etc/sysconfig/selinux'': SELINUX=disabled En **Debian 10**: hostnamectl set-hostname debian10.curso.esp Modificar ''/etc/hosts'' de la siguiente manera: 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.2.10 debian10.curso.esp debian10 192.168.2.5 sercentos7.curso.esp sercentos7 192.168.2.152 orion.curso.esp orion En **Centos 6**: Editar ''/etc/sysconfig/network'': NETWORKING=yes HOSTNAME=orion.curso.esp Modificar ''/etc/hosts'' de la siguiente manera: 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.2.5 sercentos7.curso.esp sercentos7 192.168.2.152 orion.curso.esp orion 192.168.2.10 debian10.curso.esp debian10 Deshabilitar SELinux en ''/etc/sysconfig/selinux'': SELINUX=disabled ==== Configuración NTP ==== En **Centos 7**: Instalamos ntp: yum install ntp -y Establecemos la zona horaria: timedatectl set-timezone "Europe/Madrid" Editamos el fichero ''/etc/ntp.conf'': server 0.es.pool.ntp.org iburst server 1.es.pool.ntp.org iburst server 2.es.pool.ntp.org iburst server 3.es.pool.ntp.org iburst Arrancamos servicio y lo habilitamos al arranque NTP: systemctl start ntpd systemctl enable ntpd Sincronizamos: timedatectl set-ntp true ntpq -p En **Centos 6**: yum install ntp -y cp /etc/localtime /root rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Europe/Madrid /etc/localtime Editamos ''/etc/ntp.conf'': server 0.es.pool.ntp.org iburst server 1.es.pool.ntp.org iburst server 2.es.pool.ntp.org iburst server 3.es.pool.ntp.org iburst Arrancamos servicio y lo habilitamos al arranque NTP: service ntpd start chkconfig --level 3 ntpd on En **Debian 10**: apt-get update apt-get install ntp -y timedatectl set-timezone "Europe/Madrid" Editamos el fichero ''/etc/ntp.conf'': server 0.es.pool.ntp.org iburst server 1.es.pool.ntp.org iburst server 2.es.pool.ntp.org iburst server 3.es.pool.ntp.org iburst Arrancamos servicio y lo habilitamos al arranque NTP: systemctl start ntp systemctl enable ntp timedatectl set-ntp true ntpq -p