zoukankan      html  css  js  c++  java
  • 第四周作业

    1. 自建yum仓库,分别为网络源和本地源

      网络yum源配置文件:


      [14:42:19 root@centos8 cd]#cat /etc/yum.repos.d/base.repo
      [BaseOS]
      name=BaseOS
      baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
            https://mirrors.huaweicloud.com/centos/$releasever/BaseOS/$basearch/os/
            https://mirrors.cloud.tencent.com/centos/$releasever/BaseOS/$basearch/os/
            https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/BaseOS/$basearch/os/
            http://mirrors.163.com//centos/$releasever/BaseOS/$basearch/os/
            http://mirrors.sohu.com/centos/$releasever/BaseOS/$basearch/os/
      gpgcheck=1
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

      [AppStream]
      name=AppStream
      baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
            https://mirrors.huaweicloud.com/centos/$releasever/AppStream/$basearch/os/
            https://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
            https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/AppStream/$basearch/os/
            http://mirrors.163.com/centos/$releasever/AppStream/$basearch/os/
            http://mirrors.sohu.com/centos/$releasever/AppStream/$basearch/os/
      gpgcheck=1
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

      [EPEL]
      name=EPEL
      baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch/
            https://mirrors.huaweicloud.com/epel/$releasever/Everything/$basearch/
            https://mirrors.cloud.tencent.com/epel/$releasever/Everything/$basearch/
            https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/Everything/$basearch/
      gpgcheck=1
      gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-$releasever

      [extras]
      name=extras
      baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
            https://mirrors.huaweicloud.com/centos/$releasever/extras/$basearch/os/
            https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/os/
            https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/os/
            http://mirrors.163.com/centos/$releasever/extras/$basearch/os/
            http://mirrors.sohu.com/centos/$releasever/extras/$basearch/os/
      gpgcheck=1
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
      enabled=1

      [centosplus]
      name=centosplus
      baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
            https://mirrors.huaweicloud.com/centos/$releasever/centosplus/$basearch/os/
            https://mirrors.cloud.tencent.com/centos/$releasever/centosplus/$basearch/os/
            https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/os/
            http://mirrors.163.com/centos/$releasever/centosplus/$basearch/os/
            http://mirrors.sohu.com/centos/$releasever/centosplus/$basearch/os/
      gpgcheck=1
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

      本地yum源:


      1. 首先插入光盘镜像
      2. 可以手动挂载或者使用yum install -y autofs来自动挂载光盘
      3. 编写配置文件,放在/etc/yum.repos.d目录下,以.repo后缀结尾即可
      以安装autofs自动挂载为例。
      [14:54:38 root@centos8 ~]#yum install -y autofs
      [14:55:38 root@centos8 ~]#systemctl enabled --now autofs
      [14:56:19 root@centos8 ~]#ls /misc/cd/AppStream/
      Packages repodata
      [14:57:03 root@centos8 ~]#cat /etc/yum.repos.d/CentOS-Linux-AppStream.repo
      [cd.app]
      name=cd.app
      baseurl=file:///misc/cd/AppStream
      #autofs自动挂载镜像到/misc/cd目录,指向/misc/cd/AppStream,可以看到repodata目录
      gpgcheck=0
      enabled=1
      [14:59:45 root@centos8 ~]##cat /etc/yum.repos.d/CentOS-Linux-BaseOS.repo
      [cd.baseos]
      name=cd.baseos
      baseurl=file:///misc/cd/BaseOS
      gpgcheck=0
      enable=1
    2. 编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。


      #1 安装相关包
      [15:51:32 root@centos8 ~]#dnf install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config -y

      #2 下载并解压包
      [15:53:11 root@centos8 ~]#wget https://archive.apache.org/dist/httpd/httpd-2.4.46.tar.bz2
      [15:55:34 root@centos8 ~]#tar -xvf httpd-2.4.46.tar.bz2 -C /usr/local/src/

      #3 配置
      [15:56:37 root@centos8 src]#cd /usr/local/src/httpd-2.4.46/
      [16:00:04 root@centos8 httpd-2.4.46]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl

      #4 编译并安装
      [16:00:39 root@centos8 httpd-2.4.46]#make -j 2 && make install

      #5 配置环境变量
      [16:03:25 root@centos8 httpd-2.4.46]#echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
      [16:03:50 root@centos8 httpd-2.4.46]#. /etc/profile.d/httpd.sh

      #6 启动
      [16:03:58 root@centos8 httpd-2.4.46]#apachectl start

      #7 指定apache用户运行
      [16:04:16 root@centos8 httpd-2.4.46]#useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache
      [16:04:38 root@centos8 httpd-2.4.46]#vim /etc/httpd/httpd.conf
      User apache
      Group apache

      #8 配置生效
      [16:08:51 root@centos8 httpd-2.4.46]#apachectl restart
      [16:09:06 root@centos8 httpd-2.4.46]#ps aux |grep apache
      apache    119719  0.0  0.3 1339488 7688 ?       Sl   16:08   0:00 /apps/httpd/bin/httpd -k start
      apache    119720  0.0  0.4 1339488 9728 ?       Sl   16:08   0:00 /apps/httpd/bin/httpd -k start
      apache    119721  0.0  0.6 1339488 13808 ?       Sl   16:08   0:00 /apps/httpd/bin/httpd -k start

      #9 验证网页
      [16:09:10 root@centos8 httpd-2.4.46]#curl localhost
      <html><body><h1>It works!</h1></body></html>




    3. 利用sed 取出ifconfig命令中本机的IPv4地址


      [16:27:28 root@centos8 ~]#ifconfig eth0 |sed -En "/inet/s#[^0-9]+([0-9.]+).*#1#p"|cat -A
      10.0.0.150$
    4. 删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符


      [16:36:16 root@centos8 ~]#cat -A /etc/fstab
      $
      #$
      # /etc/fstab$
      # Created by anaconda on Mon Jul 19 12:39:26 2021$
      #$
      # Accessible filesystems, by reference, are maintained under '/dev/disk/'.$
      # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.$
      #$
      # After editing this file, run 'systemctl daemon-reload' to update systemd$
      # units generated from this file.$
      #$
      UUID=a09f483f-5645-4bf5-84e6-74ff560bfcab /                       xfs     defaults        0 0$
      UUID=a7cdba8a-1b4f-4cf3-ace5-809ec6b732d6 /boot                   ext4   defaults        1 2$
      UUID=b1482237-a49f-4e3b-a534-bb7a1325b7d6 /date                   xfs     defaults        0 0$
      UUID=30f25ee0-b7f6-47b5-978d-bc2a3d33e1d4 none                   swap   defaults        0 0$
      [16:36:17 root@centos8 ~]#sed -r '/^#/s/^#[ ]+//g' /etc/fstab |cat -A
      $
      #$
      /etc/fstab$
      Created by anaconda on Mon Jul 19 12:39:26 2021$
      #$
      Accessible filesystems, by reference, are maintained under '/dev/disk/'.$
      See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.$
      #$
      After editing this file, run 'systemctl daemon-reload' to update systemd$
      units generated from this file.$
      #$
      UUID=a09f483f-5645-4bf5-84e6-74ff560bfcab /                       xfs     defaults        0 0$
      UUID=a7cdba8a-1b4f-4cf3-ace5-809ec6b732d6 /boot                   ext4   defaults        1 2$
      UUID=b1482237-a49f-4e3b-a534-bb7a1325b7d6 /date                   xfs     defaults        0 0$
      UUID=30f25ee0-b7f6-47b5-978d-bc2a3d33e1d4 none                   swap   defaults        0 0$
    5. 处理/etc/fstab路径,使用sed命令取出其目录名和基名


      [16:49:31 root@centos8 ~]#ls /etc/fstab |sed -r 's#^(/.*/)(.*)#path: 1 basename: 2#'
      path: /etc/
      basename: fstab
    6. 列出ubuntu软件管理工具apt的一些用法(自由总结)

      • apt命令语法:

      apt options [package ...] options:可选,选项包括 -h(帮助),-y(当安装过程提示选择全部为"yes"),-q(不显示安装的过程)等等。 command:要进行的操作。 package:安装的包名。

      • apt 常用命令

        列出所有可更新的软件清单命令:apt update

        升级软件包:apt upgrade

        列出可更新的软件包及版本信息:apt list --upgradeable

        升级软件包,升级前先删除需要更新软件包:apt full-upgrade

        安装指定的软件命令:apt install <package_name>

        安装多个软件包:apt install <package_1> <package_2> <package_3>

        更新指定的软件命令:apt update <package_name>

        显示软件包具体信息,例如:版本号,安装大小,依赖关系等等:apt show <package_name>

        删除软件包命令:apt remove <package_name>

        清理不再使用的依赖和库文件: apt autoremove

        移除软件包及配置文件: apt purge <package_name>

        查找软件包命令: apt search <keyword>

        列出所有已安装的包:apt list --installed

        列出所有已安装的包的版本信息:apt list --all-versions

     

     

  • 相关阅读:
    Java多线程
    SpringCloud
    Java 多线程
    MySQL
    MySQL
    SpringCloud
    SpringCloud
    SpringCloud
    SpringBoot
    Spring MVC
  • 原文地址:https://www.cnblogs.com/tanll/p/15314641.html
Copyright © 2011-2022 走看看