第四周作業(yè)

一.搭建yum私有倉庫

[root@centos8 ~]# mkdir -p /var/www/html/centos

[root@centos8 ~]# dnf reposync --repoid=extras --download-metadata -p /var/www/html/centos

[root@centos8 ~]# ls /var/www/html/centos/

extras

[root@centos8 ~]# tree /var/www/html/centos/

-bash: tree: command not found

[root@centos8 ~]# dnf -y install tree

**[root@centos8 ~]# tree /var/www/html/centos/**

**/var/www/html/centos/**

**└── extras**

**├── Packages**

**│** **├── centos-release-advanced-virtualization-1.0-2.el8.noarch.rpm**

**│** **├── centos-release-ansible-29-1-2.el8.noarch.rpm**

**│** **├── centos-release-ceph-nautilus-1.2-2.el8.noarch.rpm**

**│** **├── centos-release-ceph-octopus-1.0-1.el8.noarch.rpm**

**│** **├── centos-release-configmanagement-1-1.el8.noarch.rpm**

**│** **├── centos-release-gluster6-1.0-1.el8.noarch.rpm**

**│** **├── centos-release-gluster7-1.0-2.el8.noarch.rpm**

**│** **├── centos-release-gluster8-1.0-1.el8.noarch.rpm**

**│** **├── centos-release-messaging-1-2.el8.noarch.rpm**

**│** **├── centos-release-nfs-ganesha28-1.0-3.el8.noarch.rpm**

**│** **├── centos-release-nfs-ganesha30-1.0-2.el8.noarch.rpm**

**│** **├── centos-release-nfv-common-1-2.el8.noarch.rpm**

**│** **├── centos-release-nfv-extras-1-2.el8.noarch.rpm**

**│** **├── centos-release-nfv-openvswitch-1-2.el8.noarch.rpm**

**│** **├── centos-release-openstack-train-2-1.el8.noarch.rpm**

**│** **├── centos-release-openstack-ussuri-1-4.el8.noarch.rpm**

**│** **├── centos-release-openstack-victoria-1-1.el8.noarch.rpm**

**│** **├── centos-release-opstools-1-10.el8.noarch.rpm**

**│** **├── centos-release-ovirt44-1.0-1.el8.noarch.rpm**

**│** **├── centos-release-qpid-proton-1-2.el8.noarch.rpm**

**│** **├── centos-release-rabbitmq-38-1-2.el8.noarch.rpm**

**│** **├── centos-release-samba411-1.0-1.el8.noarch.rpm**

**│** **├── centos-release-samba412-1.0-1.el8.noarch.rpm**

**│** **├── centos-release-samba413-1.0-1.el8.noarch.rpm**

**│** **├── centos-release-storage-common-2-2.el8.noarch.rpm**

**│** **├── centos-release-stream-8.1-1.1911.0.7.el8.x86_64.rpm**

**│** **├── centos-release-virt-common-1-2.el8.noarch.rpm**

**│** **├── cpaste-1.0.0-3.el8.x86_64.rpm**

**│** **├── elrepo-release-8.1-1.el8.elrepo.noarch.rpm**

**│** **└── epel-release-8-8.el8.noarch.rpm**

**└── repodata**

**├── 01c7718fa7c41b4c1b9a74c3d0f322545b80d51f9cfa67f70e3a634091cd5a6b-primary.xml.gz**

**├── 230289bdb8f1ef53b5db2bba2fadfd90ab2d8044cb8ca6177e6ee7e96e15ff41-other.xml.gz**

**├── 759cd358128b1bcd7f03f3e465a13daffff01073a2189f891dd48849a877132a-filelists.xml.gz**

**└── repomd.xml**

**3 directories, 34 files**

**[root@centos8 ~]# ls /var/www/html/centos/extras/**

**Packages repodata**

**[root@centos8 ~]# ls /var/www/html/centos/extras/Packages/**

**centos-release-advanced-virtualization-1.0-2.el8.noarch.rpm**

**centos-release-ansible-29-1-2.el8.noarch.rpm**

**centos-release-ceph-nautilus-1.2-2.el8.noarch.rpm**

**centos-release-ceph-octopus-1.0-1.el8.noarch.rpm**

**centos-release-configmanagement-1-1.el8.noarch.rpm**

**centos-release-gluster6-1.0-1.el8.noarch.rpm**

**centos-release-gluster7-1.0-2.el8.noarch.rpm**

**centos-release-gluster8-1.0-1.el8.noarch.rpm**

**centos-release-messaging-1-2.el8.noarch.rpm**

**centos-release-nfs-ganesha28-1.0-3.el8.noarch.rpm**

**centos-release-nfs-ganesha30-1.0-2.el8.noarch.rpm**

**centos-release-nfv-common-1-2.el8.noarch.rpm**

**centos-release-nfv-extras-1-2.el8.noarch.rpm**

**centos-release-nfv-openvswitch-1-2.el8.noarch.rpm**

**centos-release-openstack-train-2-1.el8.noarch.rpm**

**centos-release-openstack-ussuri-1-4.el8.noarch.rpm**

**centos-release-openstack-victoria-1-1.el8.noarch.rpm**

**centos-release-opstools-1-10.el8.noarch.rpm**

**centos-release-ovirt44-1.0-1.el8.noarch.rpm**

**centos-release-qpid-proton-1-2.el8.noarch.rpm**

**centos-release-rabbitmq-38-1-2.el8.noarch.rpm**

**centos-release-samba411-1.0-1.el8.noarch.rpm**

**centos-release-samba412-1.0-1.el8.noarch.rpm**

**centos-release-samba413-1.0-1.el8.noarch.rpm**

**centos-release-storage-common-2-2.el8.noarch.rpm**

**centos-release-stream-8.1-1.1911.0.7.el8.x86_64.rpm**

**centos-release-virt-common-1-2.el8.noarch.rpm**

**cpaste-1.0.0-3.el8.x86_64.rpm**

**elrepo-release-8.1-1.el8.elrepo.noarch.rpm**

**epel-release-8-8.el8.noarch.rpm**

**[root@centos8 ~]# ls /var/www/html/centos/extras/repodata/**

**01c7718fa7c41b4c1b9a74c3d0f322545b80d51f9cfa67f70e3a634091cd5a6b-primary.xml.gz**

**230289bdb8f1ef53b5db2bba2fadfd90ab2d8044cb8ca6177e6ee7e96e15ff41-other.xml.gz**

**759cd358128b1bcd7f03f3e465a13daffff01073a2189f891dd48849a877132a-filelists.xml.gz**

**repomd.xml**

[root@centos8 ~]# dnf -y install httpd

[root@centos8 ~]# systemctl enable --now httpd

Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

[http://10.0.0.8/centos/](http://10.0.0.8/centos/)
1.jpg
如果打不開
[root@centos8 ~]# systemctl disable --now firewalld
#關(guān)閉防火墻
[root@centos8 ~]# sed -ri 's/^(SELINUX=).*/\1disabled/' /etc/selinux/config
#關(guān)閉selinux,重啟

[root@centos8 yum.repos.d]# vim test.repo 
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/
gpgcheck=0

[extras]
name=extras
baseurl=http://10.0.0.8/centos/extras/
gpgcheck=0  
:wq

[root@centos8 yum.repos.d]# dnf repolist
repo id                                                 repo name
epel                                                    epel
extras                                                  extras
[root@centos8 yum.repos.d]# yum repolist -v
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
YUM version: 4.2.17
cachedir: /var/cache/dnf
User-Agent: constructed: 'libdnf (CentOS Linux 8; generic; Linux.x86_64)'
epel                                                                            38 kB/s | 4.7 kB     00:00    
reviving: 'epel' can be revived - repomd matches.
epel: using metadata from Sun 29 Nov 2020 09:04:32 AM CST.
repo: downloading from remote: extras
extras                                                                         495 kB/s | 8.6 kB     00:00    
extras: using metadata from Thu 12 Nov 2020 09:42:22 PM CST.
No module defaults found
Completion plugin: Generating completion cache...

Repo-id            : epel
Repo-name          : epel
Repo-revision      : 1606611842
Repo-updated       : Sun 29 Nov 2020 09:04:32 AM CST
Repo-pkgs          : 6,746
Repo-available-pkgs: 6,746
Repo-size          : 9.7 G
Repo-baseurl       : https://mirrors.aliyun.com/epel/8/Everything/x86_64/
Repo-expire        : 172,800 second(s) (last: Wed 02 Dec 2020 01:34:16 PM CST)
Repo-filename      : /etc/yum.repos.d/test.repo

Repo-id            : extras
Repo-name          : extras
Repo-revision      : 1605188560
Repo-updated       : Thu 12 Nov 2020 09:42:22 PM CST
Repo-pkgs          : 30
Repo-available-pkgs: 30
Repo-size          : 338 k
Repo-baseurl       : http://10.0.0.8/centos/extras/
Repo-expire        : 172,800 second(s) (last: Wed 02 Dec 2020 02:30:48 PM CST)
Repo-filename      : /etc/yum.repos.d/test.repo
Total packages: 6,776

二.編譯安裝httpd

1.在CentOS 8上編譯安裝apache 2.4.43源碼包,并啟動此服務(wù)

http://httpd.apache.org/   apache官方網(wǎng)址

[root@centos8 cmatrix]# yum info httpd
Last metadata expiration check: 2:38:48 ago on Wed 02 Dec 2020 04:34:36 PM CST.
Installed Packages
Name         : httpd
Version      : 2.4.37
Release      : 21.module_el8.2.0+494+1df74eae
Architecture : x86_64
Size         : 4.9 M
Source       : httpd-2.4.37-21.module_el8.2.0+494+1df74eae.src.rpm
Repository   : @System
From repo    : Appstream
Summary      : Apache HTTP Server
URL          : https://httpd.apache.org/
License      : ASL 2.0
Description  : The Apache HTTP Server is a powerful, efficient, and extensible

[root@centos8 ~]# wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2 -P /usr/local/src

[root@centos8 ~]# cd /usr/local/src
[root@centos8 src]# ls
cmatrix  cmatrix-v2.0-Butterscotch.tar  httpd-2.4.46.tar.bz2  tree-1.8.0.tgz

[root@centos8 src]# tar xf httpd-2.4.46.tar.bz2 
tar (child): lbzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
[root@centos8 src]# dnf -y install bzip2

[root@centos8 src]# cd httpd-2.4.46
[root@centos8 httpd-2.4.46]# ls
ABOUT_APACHE     BuildAll.dsp    configure.in  include         LICENSE        README            test
acinclude.m4     BuildBin.dsp    docs          INSTALL         Makefile.in    README.cmake      VERSIONING
Apache-apr2.dsw  buildconf       emacs-style   InstallBin.dsp  Makefile.win   README.platforms
Apache.dsw       CHANGES         httpd.dep     LAYOUT          modules        ROADMAP
apache_probes.d  CMakeLists.txt  httpd.dsp     libhttpd.dep    NOTICE         server
ap.d             config.layout   httpd.mak     libhttpd.dsp    NWGNUmakefile  srclib
build            configure       httpd.spec    libhttpd.mak    os             support

[root@centos8 httpd-2.4.46]# cat README
#README  告訴你軟件怎么用的

[root@centos8 httpd-2.4.46]# cat INSTALL 
#INSTALL  安裝方法

[root@centos8 httpd-2.4.46]# ./configure --help
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local/apache2]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/apache2/bin', `/usr/local/apache2/lib' etc.  You can specify
an installation prefix other than `/usr/local/apache2' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-layout=LAYOUT
  --enable-dtrace         Enable DTrace probes
  --enable-hook-probes    Enable APR hook probes
  --enable-exception-hook Enable fatal exception hook
  --enable-load-all-modules
                          Load all modules
  --enable-maintainer-mode
                          Turn on debugging and compile time warnings and load
                          all compiled modules
  --enable-debugger-mode  Turn on debugging and compile time warnings and turn
                          off optimization
  --enable-pie            Build httpd as a Position Independent Executable
  --enable-modules=MODULE-LIST
                          Space-separated list of modules to enable | "all" |
                          "most" | "few" | "none" | "reallyall"
  --enable-mods-shared=MODULE-LIST
                          Space-separated list of shared modules to enable |
                          "all" | "most" | "few" | "reallyall"
  --enable-mods-static=MODULE-LIST
                          Space-separated list of static modules to enable |
                          "all" | "most" | "few" | "reallyall"
  --disable-authn-file    file-based authentication control
  --enable-authn-dbm      DBM-based authentication control
  --enable-authn-anon     anonymous user authentication control
  --enable-authn-dbd      SQL-based authentication control
  --enable-authn-socache  Cached authentication control
  --disable-authn-core    core authentication module
  --disable-authz-host    host-based authorization control
  --disable-authz-groupfile
                          'require group' authorization control
  --disable-authz-user    'require user' authorization control
  --enable-authz-dbm      DBM-based authorization control
  --enable-authz-owner    'require file-owner' authorization control
  --enable-authz-dbd      SQL based authorization and Login/Session support
  --disable-authz-core    core authorization provider vector module
  --enable-authnz-ldap    LDAP based authentication
  --enable-authnz-fcgi    FastCGI authorizer-based authentication and
                          authorization
  --disable-access-compat mod_access compatibility
  --disable-auth-basic    basic authentication
  --enable-auth-form      form authentication
  --enable-auth-digest    RFC2617 Digest authentication
  --enable-allowmethods   restrict allowed HTTP methods
  --enable-isapi          isapi extension support
  --enable-file-cache     File cache
  --enable-cache          dynamic file caching. At least one storage
                          management module (e.g. mod_cache_disk) is also
                          necessary.
  --enable-cache-disk     disk caching module
  --enable-cache-socache  shared object caching module
  --enable-socache-shmcb  shmcb small object cache provider
  --enable-socache-dbm    dbm small object cache provider
  --enable-socache-memcache
                          memcache small object cache provider
  --enable-socache-redis  redis small object cache provider
  --enable-socache-dc     distcache small object cache provider
  --enable-so             DSO capability. This module will be automatically
                          enabled unless you build all modules statically.
  --enable-watchdog       Watchdog module
  --enable-macro          Define and use macros in configuration files
  --enable-dbd            Apache DBD Framework
  --enable-bucketeer      buckets manipulation filter. Useful only for
                          developers and testing purposes.
  --enable-dumpio         I/O dump filter
  --enable-echo           ECHO server
  --enable-example-hooks  Example hook callback handler module
  --enable-case-filter    Example uppercase conversion filter
  --enable-case-filter-in Example uppercase conversion input filter
  --enable-example-ipc    Example of shared memory and mutex usage
  --enable-buffer         Filter Buffering
  --enable-data           RFC2397 data encoder
  --enable-ratelimit      Output Bandwidth Limiting
  --disable-reqtimeout    Limit time waiting for request from client
  --enable-ext-filter     external filter module
  --enable-request        Request Body Filtering
  --enable-include        Server Side Includes
  --disable-filter        Smart Filtering
  --enable-reflector      Reflect request through the output filter stack
  --enable-substitute     response content rewrite-like filtering
  --enable-sed            filter request and/or response bodies through sed
  --disable-charset-lite  character set translation. Enabled by default only
                          on EBCDIC systems.
  --enable-charset-lite   character set translation. Enabled by default only
                          on EBCDIC systems.
  --enable-deflate        Deflate transfer encoding support
  --enable-xml2enc        i18n support for markup filters
  --enable-proxy-html     Fix HTML Links in a Reverse Proxy
  --enable-brotli         Brotli compression support
  --enable-http           HTTP protocol handling. The http module is a basic
                          one that enables the server to function as an HTTP
                          server. It is only useful to disable it if you want
                          to use another protocol module instead. Don't
                          disable this module unless you are really sure what
                          you are doing. Note: This module will always be
                          linked statically.
  --disable-mime          mapping of file-extension to MIME. Disabling this
                          module is normally not recommended.
  --enable-ldap           LDAP caching and connection pooling services
  --disable-log-config    logging configuration. You won't be able to log
                          requests to the server without this module.
  --enable-log-debug      configurable debug logging
  --enable-log-forensic   forensic logging
  --enable-logio          input and output logging
  --enable-lua            Apache Lua Framework
  --enable-luajit         Enable LuaJit Support
  --disable-env           clearing/setting of ENV vars
  --enable-mime-magic     automagically determining MIME type
  --enable-cern-meta      CERN-type meta files
  --enable-expires        Expires header control
  --disable-headers       HTTP header control
  --enable-ident          RFC 1413 identity check
  --enable-usertrack      user-session tracking
  --enable-unique-id      per-request unique ids
  --disable-setenvif      basing ENV vars on headers
  --disable-version       determining httpd version in config files
  --enable-remoteip       translate header contents to an apparent client
                          remote_ip
  --enable-proxy          Apache proxy module
  --enable-proxy-connect  Apache proxy CONNECT module. Requires
                          --enable-proxy.
  --enable-proxy-ftp      Apache proxy FTP module. Requires --enable-proxy.
  --enable-proxy-http     Apache proxy HTTP module. Requires --enable-proxy.
  --enable-proxy-fcgi     Apache proxy FastCGI module. Requires
                          --enable-proxy.
  --enable-proxy-scgi     Apache proxy SCGI module. Requires --enable-proxy.
  --enable-proxy-uwsgi    Apache proxy UWSGI module. Requires --enable-proxy.
  --enable-proxy-fdpass   Apache proxy to Unix Daemon Socket module. Requires
                          --enable-proxy.
  --enable-proxy-wstunnel Apache proxy Websocket Tunnel module. Requires
                          --enable-proxy.
  --enable-proxy-ajp      Apache proxy AJP module. Requires --enable-proxy.
  --enable-proxy-balancer Apache proxy BALANCER module. Requires
                          --enable-proxy.
  --enable-proxy-express  mass reverse-proxy module. Requires --enable-proxy.
  --enable-proxy-hcheck   reverse-proxy health-check module. Requires
                          --enable-proxy and --enable-watchdog.
  --enable-session        session module
  --enable-session-cookie session cookie module
  --enable-session-crypto session crypto module
  --enable-session-dbd    session dbd module
  --enable-slotmem-shm    slotmem provider that uses shared memory
  --enable-slotmem-plain  slotmem provider that uses plain memory
  --enable-ssl            SSL/TLS support (mod_ssl)
  --enable-ssl-staticlib-deps
                          link mod_ssl with dependencies of OpenSSL's static
                          libraries (as indicated by "pkg-config --static").
                          Must be specified in addition to --enable-ssl.
  --enable-optional-hook-export
                          example optional hook exporter
  --enable-optional-hook-import
                          example optional hook importer
  --enable-optional-fn-import
                          example optional function importer
  --enable-optional-fn-export
                          example optional function exporter
  --enable-dialup         rate limits static files to dialup modem speeds
  --enable-static-support Build a statically linked version of the support
                          binaries
  --enable-static-htpasswd
                          Build a statically linked version of htpasswd
  --enable-static-htdigest
                          Build a statically linked version of htdigest
  --enable-static-rotatelogs
                          Build a statically linked version of rotatelogs
  --enable-static-logresolve
                          Build a statically linked version of logresolve
  --enable-static-htdbm   Build a statically linked version of htdbm
  --enable-static-ab      Build a statically linked version of ab
  --enable-static-checkgid
                          Build a statically linked version of checkgid
  --enable-static-htcacheclean
                          Build a statically linked version of htcacheclean
  --enable-static-httxt2dbm
                          Build a statically linked version of httxt2dbm
  --enable-static-fcgistarter
                          Build a statically linked version of fcgistarter
  --enable-http2          HTTP/2 protocol handling in addition to HTTP
                          protocol handling. Implemented by mod_http2. This
                          module requires a libnghttp2 installation. See
                          --with-nghttp2 on how to manage non-standard
                          locations. This module is usually linked shared and
                          requires loading.
  --enable-nghttp2-staticlib-deps
                          link mod_http2 with dependencies of libnghttp2's
                          static libraries (as indicated by "pkg-config
                          --static"). Must be specified in addition to
                          --enable-http2.
  --enable-proxy-http2    HTTP/2 proxy module. This module requires a
                          libnghttp2 installation. See --with-nghttp2 on how
                          to manage non-standard locations. Also requires
                          --enable-proxy.
  --enable-md             Managed Domain handling
  --enable-jansson-staticlib-deps
                          link mod_md with dependencies of libjansson's static
                          libraries (as indicated by "pkg-config --static").
                          Must be specified in addition to --enable-md.
  --enable-curl-staticlib-deps
                          link mod_md with dependencies of libcurl's static
                          libraries (as indicated by "pkg-config --static").
                          Must be specified in addition to --enable-md.
  --enable-lbmethod-byrequests
                          Apache proxy Load balancing by request counting
  --enable-lbmethod-bytraffic
                          Apache proxy Load balancing by traffic counting
  --enable-lbmethod-bybusyness
                          Apache proxy Load balancing by busyness
  --enable-lbmethod-heartbeat
                          Apache proxy Load balancing from Heartbeats
  --enable-mpms-shared=MPM-LIST
                          Space-separated list of MPM modules to enable for
                          dynamic loading. MPM-LIST=list | "all"
  --enable-unixd          unix specific support
  --enable-privileges     Per-virtualhost Unix UserIDs and enhanced security
                          for Solaris
  --enable-systemd        Systemd support
  --enable-heartbeat      Generates Heartbeats
  --enable-heartmonitor   Collects Heartbeats
  --enable-dav            WebDAV protocol handling. --enable-dav also enables
                          mod_dav_fs
  --disable-status        process/thread monitoring
  --disable-autoindex     directory listing
  --enable-asis           as-is filetypes
  --enable-info           server information
  --enable-suexec         set uid and gid for spawned processes
  --enable-cgid           CGI scripts. Enabled by default with threaded MPMs
  --enable-cgi            CGI scripts. Enabled by default with non-threaded
                          MPMs
  --enable-dav-fs         DAV provider for the filesystem. --enable-dav also
                          enables mod_dav_fs.
  --enable-dav-lock       DAV provider for generic locking
  --enable-vhost-alias    mass virtual hosting module
  --enable-negotiation    content negotiation
  --disable-dir           directory request handling
  --enable-imagemap       server-side imagemaps
  --enable-actions        Action triggering on requests
  --enable-speling        correct common URL misspellings
  --enable-userdir        mapping of requests to user-specific directories
  --disable-alias         mapping of requests to different filesystem parts
  --enable-rewrite        rule based URL manipulation
  --enable-suexec-capabilities
                          Use Linux capability bits not setuid root suexec
  --enable-v4-mapped      Allow IPv6 sockets to handle IPv4 connections

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-included-apr     Use bundled copies of APR/APR-Util
  --with-apr=PATH         prefix for installed APR or the full path to
                             apr-config
  --with-apr-util=PATH    prefix for installed APU or the full path to
                             apu-config
  --with-pcre=PATH        Use external PCRE library
  --with-port=PORT        Port on which to listen (default is 80)
  --with-sslport=SSLPORT  Port on which to securelisten (default is 443)
  --with-distcache=PATH   Distcache installation directory
  --with-z=PATH           use a specific zlib library
  --with-libxml2=PATH     location for libxml2
  --with-brotli=PATH      Brotli installation directory
  --with-lua=PATH         Path to the Lua 5.3/5.2/5.1 prefix
  --with-ssl=PATH         OpenSSL installation directory
  --with-nghttp2=PATH     nghttp2 installation directory
  --with-jansson=PATH     jansson installation directory
  --with-curl=PATH        curl installation directory
  --with-mpm=MPM          Choose the process model for Apache to use by
                          default. MPM={event|worker|prefork|winnt} This will
                          be statically linked as the only available MPM
                          unless --enable-mpms-shared is also specified.
  --with-module=module-type:module-file
                          Enable module-file in the modules/<module-type>
                          directory.
  --with-program-name     alternate executable name
  --with-suexec-bin       Path to suexec binary
  --with-suexec-caller    User allowed to call SuExec
  --with-suexec-userdir   User subdirectory
  --with-suexec-docroot   SuExec root directory
  --with-suexec-uidmin    Minimal allowed UID
  --with-suexec-gidmin    Minimal allowed GID
  --with-suexec-logfile   Set the logfile
  --with-suexec-syslog    Use syslog for suexec logging
  --with-suexec-safepath  Set the safepath
  --with-suexec-umask     umask for suexec'd process

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to the package provider.


[root@centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd --enable-ssl
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.
#提示缺失 APR

[root@centos8 httpd-2.4.46]# dnf -y install apr-devel 

[root@centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd --enable-ssl
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.
#提示缺少 APR-util

[root@centos8 httpd-2.4.46]# dnf -y install apr-util-devel

[root@centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd --enable-ssl
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... none needed
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
#提示缺少 PCRE

[root@centos8 httpd-2.4.46]# dnf -y install pcre-devel

[root@centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd --enable-ssl
...
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
#提示缺少 mod-ssl,這就是openssl

[root@centos8 httpd-2.4.46]# dnf -y install openssl-devel


[root@centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd --enable-ssl

[root@centos8 httpd-2.4.46]# make -j 2 && make install
...
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
make[4]: *** [/usr/local/src/httpd-2.4.46/modules/aaa/modules.mk:2: mod_authn_file.la] Error 1
make[4]: *** Waiting for unfinished jobs....
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
make[4]: *** [/usr/local/src/httpd-2.4.46/modules/aaa/modules.mk:4: mod_authn_dbm.la] Error 1
make[4]: Leaving directory '/usr/local/src/httpd-2.4.46/modules/aaa'
make[3]: *** [/usr/local/src/httpd-2.4.46/build/rules.mk:117: shared-build-recursive] Error 1
make[3]: Leaving directory '/usr/local/src/httpd-2.4.46/modules/aaa'
make[2]: *** [/usr/local/src/httpd-2.4.46/build/rules.mk:117: shared-build-recursive] Error 1
make[2]: Leaving directory '/usr/local/src/httpd-2.4.46/modules'
make[1]: *** [/usr/local/src/httpd-2.4.46/build/rules.mk:117: shared-build-recursive] Error 1
make[1]: Leaving directory '/usr/local/src/httpd-2.4.46'
#提示 缺少redhat/redhat-hardened-ld文件

[root@centos8 httpd-2.4.46]# yum provides *redhat-hardened-ld*
Last metadata expiration check: 0:03:39 ago on Wed 02 Dec 2020 07:35:03 PM CST.
redhat-rpm-config-122-1.el8.noarch : CentOS specific rpm configuration files
Repo        : Appstream
Matched from:
Other       : *redhat-hardened-ld*


[root@centos8 httpd-2.4.46]# dnf -y install redhat-rpm-config-122-1.el8.noarch


[root@centos8 httpd-2.4.46]# make -j 2 && make install


[root@centos8 httpd-2.4.46]# tree /apps/httpd/

[root@centos8 httpd-2.4.46]# /apps/httpd/bin/apachectl start
#啟動程序
1.png
[root@centos8 httpd-2.4.46]# echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[root@centos8 httpd-2.4.46]# . /etc/profile.d/httpd.sh
#加入變量

[root@centos8 httpd-2.4.46]# apachectl stop
#關(guān)閉服務(wù)

[root@centos8 httpd-2.4.46]# apachectl
#啟動服務(wù)

[root@centos8 httpd-2.4.46]# ps aux
...
daemon     39478  0.0  0.4 1337052 7688 ?        Sl   19:47   0:00 /apps/httpd/bin/httpd
daemon     39479  0.0  0.5 1337052 9728 ?        Sl   19:47   0:00 /apps/httpd/bin/httpd
daemon     39480  0.0  0.7 1337052 13808 ?       Sl   19:47   0:00 /apps/httpd/bin/httpd
root       39565  0.0  0.2  57820  3928 pts/0    R+   19:49   0:00 ps aux
#程序還以daemon 身份運行 

[root@centos8 httpd-2.4.46]# useradd -r -s /sbin/nologin apache

[root@centos8 httpd-2.4.46]# vim /apps/httpd/conf/httpd.conf 
#把下面兩行
User daemon                                                                                                     
Group daemon
#改成下面內(nèi)容User apache
Group apache 
:wq

[root@centos8 httpd-2.4.46]# apachectl restart
#重新啟動服務(wù)

[root@centos8 httpd-2.4.46]# ps aux |grep apache
apache     39579  0.0  0.4 1337052 7728 ?        Sl   19:53   0:00 /apps/httpd/bin/httpd
apache     39580  0.0  0.6 1337052 11808 ?       Sl   19:53   0:00 /apps/httpd/bin/httpd
apache     39581  0.0  0.5 1337052 9768 ?        Sl   19:53   0:00 /apps/httpd/bin/httpd
root       39666  0.0  0.0  12108  1064 pts/0    S+   19:54   0:00 grep --color=auto apache

2.一鍵編譯安裝httpd腳本

[root@centos8 ~]#  cat centos8_install_httpd_2.4.46.sh
#!/bin/bash
#
#*************************************************************
#Author:          zhanghui
#QQ:              19661891
#Date:            2020-12-02
#FileName:        centos8_install_httpd_2.4.46.sh
#URL:             www.neteagles.cn
#Description:     The test script
#Copyright (C):   2020 All rights reserved
#*************************************************************
URL=https://mirrors.bfsu.edu.cn/apache//httpd/
FILE=httpd-2.4.46.tar.bz2
INSTALL_DIR=/apps/httpd24

SUFFIX=`echo $FILE | sed -rn 's/.*\.([^.]+)$/\1/p'`
PACKAGE=`echo $FILE | sed -rn 's/^(.*[0-9.]+)\.[[:alpha:]]+.*$/\1/p'`
SUBDIR=`basename $INSTALL_DIR`

echo -e "\033[1;31mStart install httpd 2.4.46\033[0m"
sleep 5
yum install -y wget bzip2 gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
cd /usr/local/src/
wget $URL$FILE

case $SUFFIX in
gz|bz2|xz)
    tar xf $FILE
    ;;
zip)
    unzip $FILE
    ;;
*)
    echo "不支持此后綴:$SUFFIX"
    exit 10
esac

cd $PACKAGE/
./configure \
--prefix=$INSTALL_DIR \
--sysconfdir=/etc/$SUBDIR \
--enable-ssl \
--enable-so
make && make install
echo 'PATH=$INSTALL_DIR/bin:$PATH' > /etc/profile.d/$SUBDIR.sh
source /etc/profile.d/$SUBDIR.sh
useradd -r -s /sbin/nologin apache
sed -i -e 's/^User.*/User apache/' -e 's/^Group.*/Group apache/' /etc/$SUBDIR/httpd.conf 
sed -ri 's@(^.*<h1>)(.*)(</h1>.*$)@\1welcome to www.neteagles.cn\3@' $INSTALL_DIR/htdocs/index.html 
apachectl start
echo -e "\033[1;31mhttpd2.4.46 is installed\033[0m"

root@ubuntu18:~# cat ubuntu_install_httpd_2.4.46.sh
#!/bin/bash
#
#*************************************************************
#Author:          zhanghui
#QQ:              19661891
#Date:            2020-11-22
#FileName:        ubuntu_install_httpd_2.4.46.sh
#URL:             www.neteagles.cn
#Description:     The test script
#Copyright (C):   2020 All rights reserved
#*************************************************************
URL=https://mirrors.bfsu.edu.cn/apache//httpd/
FILE=httpd-2.4.46.tar.bz2
INSTALL_DIR=/apps/httpd24

SUFFIX=`echo $FILE | sed -rn 's/.*\.([^.]+)$/\1/p'`
PACKAGE=`echo $FILE | sed -rn 's/^(.*[0-9.]+)\.[[:alpha:]]+.*$/\1/p'`
SUBDIR=`basename $INSTALL_DIR`

echo -e "\033[1;31mStart install httpd 2.4.46\033[0m"
sleep 5
apt -y install gcc make libapr1-dev libaprutil1-dev libpcre3 libpcre3-dev libssl-dev
cd /usr/local/src/
wget $URL$FILE

case $SUFFIX in
gz|bz2|xz)
    tar xf $FILE
    ;;
zip)
    unzip $FILE
    ;;
*)
    echo "不支持此后綴:$SUFFIX"
    exit 10
esac

cd $PACKAGE/
./configure \
--prefix=$INSTALL_DIR \
--sysconfdir=/etc/$SUBDIR \
--enable-ssl \
--enable-so
make && make install
echo 'PATH=$INSTALL_DIR/bin:$PATH' > /etc/profile.d/$SUBDIR.sh
source /etc/profile.d/$SUBDIR.sh
useradd -r -s /sbin/nologin apache
sed -i -e 's/^User.*/User apache/' -e 's/^Group.*/Group apache/' /etc/$SUBDIR/httpd.conf 
sed -ri 's@(^.*<h1>)(.*)(</h1>.*$)@\1welcome to www.neteagles.cn\3@' $INSTALL_DIR/htdocs/index.html 
apachectl start
echo -e "\033[1;31mhttpd2.4.46 is installed\033[0m"

三.LVM

1、創(chuàng)建一個至少有兩個PV組成的大小為20G的名為testvg的VG;需求PE大小為16MB,而后在卷組中的創(chuàng)建大小為5G的邏輯卷testlv;掛載至/users目錄

[root@centos8 ~]# scandisk
[root@centos8 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk 
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0  100G  0 part /
├─sda3   8:3    0   50G  0 part /data
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0    4G  0 part [SWAP]
sdb      8:16   0   15G  0 disk 
sdc      8:32   0    5G  0 disk 
sr0     11:0    1  7.7G  0 rom 
#添加兩塊硬盤sdb、sdc

[root@centos8 ~]# pvs /dev/sd{b,c}
-bash: pvs: command not found
[root@centos8 ~]# dnf -y install lvm2

[root@centos8 ~]# pvs
[root@centos8 ~]# vgs
[root@centos8 ~]# lvs
[root@centos8 ~]# pvcreate /dev/sd{b,c}     #把兩塊硬盤加到物理卷
  Physical volume "/dev/sdb" successfully created.
  Physical volume "/dev/sdc" successfully created.
[root@centos8 ~]# pvs
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sdb      lvm2 ---  15.00g 15.00g
  /dev/sdc      lvm2 ---   5.00g  5.00g
  
[root@centos8 ~]# vgcreate -s 16M testvg /dev/sd{b,c}   #把 /dev/sdb和/dev/sdc加入到卷組,塊大小為16M
  Volume group "testvg" successfully created
[root@centos8 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  testvg   2   0   0 wz--n- <19.97g <19.97g
[root@centos8 ~]# pvs
  PV         VG     Fmt  Attr PSize  PFree 
  /dev/sdb   testvg lvm2 a--  14.98g 14.98g
  /dev/sdc   testvg lvm2 a--   4.98g  4.98g
[root@centos8 ~]# vgdisplay 
  --- Volume group ---
  VG Name               testvg
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <19.97 GiB  #卷組大小20G
  PE Size               16.00 MiB   #塊大小為16M
  Total PE              1278
  Alloc PE / Size       0 / 0   
  Free  PE / Size       1278 / <19.97 GiB
  VG UUID               ICjCEw-pbWT-0jUt-f4hV-lDOJ-YSSq-o3tq5U

  
[root@centos8 ~]# lvcreate  -L 5G -n testlv testvg  #創(chuàng)建邏輯卷testlv,大小5G
  Logical volume "testlv" created.
[root@centos8 ~]# lvs
  LV     VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv testvg -wi-a----- 5.00g  

[root@centos8 ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/testvg/testlv
  LV Name                testlv
  VG Name                testvg
  LV UUID                aPZyRk-7n9N-P7ol-ZwJv-2LHI-aOm2-8tED5j
  LV Write Access        read/write
  LV Creation host, time centos8.neteagles.cn, 2020-12-06 19:54:00 +0800
  LV Status              available
  # open                 0
  LV Size                5.00 GiB
  Current LE             320
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

[root@centos8 ~]# mkfs.ext4 /dev/testvg/testlv      #創(chuàng)建邏輯卷文件系統(tǒng)
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 1310720 4k blocks and 327680 inodes
Filesystem UUID: 81a7eb1b-72ae-4d5c-9d0f-44a3daa14610
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

[root@centos8 ~]# mkdir /users
[root@centos8 ~]# mount /dev/testvg/testlv /users/  #掛載邏輯卷
[root@centos8 ~]# df -Th
Filesystem                Type      Size  Used Avail Use% Mounted on
devtmpfs                  devtmpfs  884M     0  884M   0% /dev
tmpfs                     tmpfs     901M     0  901M   0% /dev/shm
tmpfs                     tmpfs     901M  8.7M  892M   1% /run
tmpfs                     tmpfs     901M     0  901M   0% /sys/fs/cgroup
/dev/sda2                 xfs       100G  2.1G   98G   3% /
/dev/sda3                 xfs        50G  390M   50G   1% /data
/dev/sda1                 ext4      976M  135M  775M  15% /boot
tmpfs                     tmpfs     181M     0  181M   0% /run/user/0
/dev/mapper/testvg-testlv ext4      4.9G   20M  4.6G   1% /users    #已被掛載

2、新建用戶archlinux,需求其家目錄為/users/archlinux,而后su切換至archlinux用戶,復(fù)制/etc/pam.d目錄至自己的家目錄

[root@centos8 ~]# useradd -d /users/archlinux archlinux
[root@centos8 ~]# getent passwd archlinux
archlinux:x:1001:1001::/users/archlinux:/bin/bash
[root@centos8 ~]# su archlinux
[archlinux@centos8 root]$ cp -r /etc/pam.d ~
[archlinux@centos8 root]$ ll -a /users/archlinux/
total 28
drwx------ 3 archlinux archlinux 4096 Dec  6 19:57 .
drwxr-xr-x 4 root      root      4096 Dec  6 19:56 ..
-rw------- 1 archlinux archlinux   93 Dec  6 19:57 .bash_history
-rw-r--r-- 1 archlinux archlinux   18 Nov  9  2019 .bash_logout
-rw-r--r-- 1 archlinux archlinux  141 Nov  9  2019 .bash_profile
-rw-r--r-- 1 archlinux archlinux  312 Nov  9  2019 .bashrc
drwxr-xr-x 2 archlinux archlinux 4096 Dec  6 19:56 pam.d

3、擴展testlv至7G,需求archlinux用戶的文件不能丟失

[archlinux@centos8 root]$ exit
exit

[root@centos8 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  testvg   2   1   0 wz--n- <19.97g <14.97g #卷組可用空間為15G
[root@centos8 ~]#  lvextend -r -L +2G /dev/testvg/testlv 
  Size of logical volume testvg/testlv changed from 5.00 GiB (320 extents) to 7.00 GiB (448 extents).
  Logical volume testvg/testlv successfully resized.
resize2fs 1.45.4 (23-Sep-2019)
Filesystem at /dev/mapper/testvg-testlv is mounted on /users; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mapper/testvg-testlv is now 1835008 (4k) blocks long.

[root@centos8 ~]# lvs
  LV     VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv testvg -wi-ao---- 7.00g                                                    
[root@centos8 ~]# df -Th
Filesystem                Type      Size  Used Avail Use% Mounted on
devtmpfs                  devtmpfs  884M     0  884M   0% /dev
tmpfs                     tmpfs     901M     0  901M   0% /dev/shm
tmpfs                     tmpfs     901M  8.7M  892M   1% /run
tmpfs                     tmpfs     901M     0  901M   0% /sys/fs/cgroup
/dev/sda2                 xfs       100G  2.1G   98G   3% /
/dev/sda3                 xfs        50G  390M   50G   1% /data
/dev/sda1                 ext4      976M  135M  775M  15% /boot
tmpfs                     tmpfs     181M     0  181M   0% /run/user/0
/dev/mapper/testvg-testlv ext4      6.9G   23M  6.5G   1% /users

[root@centos8 ~]# ll -a /users/archlinux/
total 28
drwx------ 3 archlinux archlinux 4096 Dec  6 19:57 .
drwxr-xr-x 4 root      root      4096 Dec  6 19:56 ..
-rw------- 1 archlinux archlinux   93 Dec  6 19:57 .bash_history
-rw-r--r-- 1 archlinux archlinux   18 Nov  9  2019 .bash_logout
-rw-r--r-- 1 archlinux archlinux  141 Nov  9  2019 .bash_profile
-rw-r--r-- 1 archlinux archlinux  312 Nov  9  2019 .bashrc
drwxr-xr-x 2 archlinux archlinux 4096 Dec  6 19:56 pam.d    #數(shù)據(jù)還在

4、收縮testlv至3G,要求archlinux用戶的文件不能丟失

[root@centos8 ~]# umount /dev/testvg/testlv     #取消掛載
[root@centos8 ~]# fsck -f /dev/testvg/testlv    #檢查文件系統(tǒng)
fsck from util-linux 2.32.1
e2fsck 1.45.4 (23-Sep-2019)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/testvg-testlv: 40/458752 files (0.0% non-contiguous), 50972/1835008 blocks
[root@centos8 ~]# resize2fs /dev/testvg/testlv 3G   #縮減文件系統(tǒng)
resize2fs 1.45.4 (23-Sep-2019)
Resizing the filesystem on /dev/testvg/testlv to 786432 (4k) blocks.
The filesystem on /dev/testvg/testlv is now 786432 (4k) blocks long.
 
 [root@centos8 ~]# lvreduce -L 3G /dev/testvg/testlv    #縮減邏輯卷
  WARNING: Reducing active logical volume to 3.00 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce testvg/testlv? [y/n]: y
  Size of logical volume testvg/testlv changed from 7.00 GiB (448 extents) to 3.00 GiB (192 extents).
  Logical volume testvg/testlv successfully resized.
[root@centos8 ~]# mount /dev/testvg/testlv /users/  #掛載邏輯卷
[root@centos8 ~]# df -Th
Filesystem                Type      Size  Used Avail Use% Mounted on
devtmpfs                  devtmpfs  884M     0  884M   0% /dev
tmpfs                     tmpfs     901M     0  901M   0% /dev/shm
tmpfs                     tmpfs     901M  8.7M  892M   1% /run
tmpfs                     tmpfs     901M     0  901M   0% /sys/fs/cgroup
/dev/sda2                 xfs       100G  2.1G   98G   3% /
/dev/sda3                 xfs        50G  390M   50G   1% /data
/dev/sda1                 ext4      976M  135M  775M  15% /boot
tmpfs                     tmpfs     181M     0  181M   0% /run/user/0
/dev/mapper/testvg-testlv ext4      2.9G   16M  2.8G   1% /users    #現(xiàn)在已經(jīng)縮減至3G

[root@centos8 ~]# ll -a /users/archlinux/
total 28
drwx------ 3 archlinux archlinux 4096 Dec  6 19:57 .
drwxr-xr-x 4 root      root      4096 Dec  6 19:56 ..
-rw------- 1 archlinux archlinux   93 Dec  6 19:57 .bash_history
-rw-r--r-- 1 archlinux archlinux   18 Nov  9  2019 .bash_logout
-rw-r--r-- 1 archlinux archlinux  141 Nov  9  2019 .bash_profile
-rw-r--r-- 1 archlinux archlinux  312 Nov  9  2019 .bashrc
drwxr-xr-x 2 archlinux archlinux 4096 Dec  6 19:56 pam.d
#數(shù)據(jù)還在

5、對testlv創(chuàng)建快照,并嘗試基于快照備份數(shù)據(jù),驗證快照的功能

[root@centos8 ~]# lvs
  LV     VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv testvg -wi-ao---- 3.00g    #邏輯卷還有未使用空間
[root@centos8 ~]# lvcreate -s -L 1G -n testlv-snapshot -p r /dev/testvg/testlv 
  Logical volume "testlv-snapshot" created.
[root@centos8 ~]# lvs
  LV              VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv          testvg owi-aos--- 3.00g                                                    
  testlv-snapshot testvg sri-a-s--- 1.00g      testlv 0.01  

[root@centos8 ~]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/testvg/testlv
  LV Name                testlv
  VG Name                testvg
  LV UUID                aPZyRk-7n9N-P7ol-ZwJv-2LHI-aOm2-8tED5j
  LV Write Access        read/write
  LV Creation host, time centos8.neteagles.cn, 2020-12-06 19:54:00 +0800
  LV snapshot status     source of
                         testlv-snapshot [active]
  LV Status              available
  # open                 1
  LV Size                3.00 GiB
  Current LE             192
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
  --- Logical volume ---
  LV Path                /dev/testvg/testlv-snapshot
  LV Name                testlv-snapshot
  VG Name                testvg
  LV UUID                PvdE7T-kJCO-ogxX-bjZ3-jRbT-SwVn-z9KqJ9
  LV Write Access        read only
  LV Creation host, time centos8.neteagles.cn, 2020-12-06 20:12:33 +0800
  LV snapshot status     active destination for testlv
  LV Status              available
  # open                 0
  LV Size                3.00 GiB
  Current LE             192
  COW-table size         1.00 GiB
  COW-table LE           64
  Allocated to snapshot  0.01%
  Snapshot chunk size    4.00 KiB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:3

[root@centos8 ~]# mkdir /mnt/testlv-snapshot
[root@centos8 ~]# mount /dev/testvg/testlv-snapshot /mnt/testlv-snapshot/
mount: /mnt/testlv-snapshot: WARNING: device write-protected, mounted read-only.

[root@centos8 ~]# ls /mnt/testlv-snapshot/
archlinux  lost+found
[root@centos8 ~]# ls /users/
archlinux  lost+found
[root@centos8 ~]# ls /users/archlinux/
pam.d
[root@centos8 ~]# rm -rf /users/archlinux/pam.d/    #刪除邏輯卷中的牡蠣
[root@centos8 ~]# ls /users/archlinux/  #邏輯卷中已經(jīng)沒有了
[root@centos8 ~]# ls /mnt/testlv-snapshot/archlinux/
pam.d
#快照中還在

[root@centos8 ~]# rm -rf /mnt/testlv-snapshot/archlinux/pam.d/
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/runuser': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/polkit-1': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/systemd-user': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/passwd': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/password-auth': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/vmtoolsd': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/system-auth': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/vlock': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/runuser-l': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/sssd-shadowutils': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/su': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/postlogin': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/remote': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/sudo-i': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/fingerprint-auth': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/sshd': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/config-util': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/su-l': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/smartcard-auth': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/sudo': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/other': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/login': Read-only file system
rm: cannot remove '/mnt/testlv-snapshot/archlinux/pam.d/crond': Read-only file system
#快照中的文件不能刪除

[root@centos8 ~]# umount /dev/testvg/testlv #取消掛載邏輯卷
[root@centos8 ~]# umount /mnt/testlv-snapshot/  #取消掛載快照
[root@centos8 ~]# lvs
  LV              VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv          testvg owi-a-s--- 3.00g                                                    
  testlv-snapshot testvg sri-a-s--- 1.00g      testlv 0.01                                   
[root@centos8 ~]# lvconvert --merge /dev/testvg/testlv-snapshot     #合并快照
  Merging of volume testvg/testlv-snapshot started.
  testvg/testlv: Merged: 100.00%

[root@centos8 ~]# lvs
  LV     VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv testvg -wi-a----- 3.00g  #快照只是一次性的,還原過后就沒有了
  
[root@centos8 ~]# mount /dev/testvg/testlv /users/
    #掛載邏輯卷

[root@centos8 ~]# ll /users/
total 20
drwx------ 3 archlinux archlinux  4096 Dec  6 19:57 archlinux
drwx------ 2 root      root      16384 Dec  6 19:54 lost+found
[root@centos8 ~]# ll /users/archlinux/
total 4
drwxr-xr-x 2 archlinux archlinux 4096 Dec  6 19:56 pam.d
#還原成做快照時的文件了

6.刪除邏輯卷、卷組、物理卷

[root@centos8 ~]# lvs
  LV     VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv testvg -wi-ao---- 3.00g                                                    
[root@centos8 ~]# umount /dev/testvg/testlv #取消邏輯卷掛載
[root@centos8 ~]# lvremove /dev/testvg/testlv   #刪除邏輯卷
Do you really want to remove active logical volume testvg/testlv? [y/n]: y
  Logical volume "testlv" successfully removed
[root@centos8 ~]# lvs
[root@centos8 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  testvg   2   0   0 wz--n- <19.97g <19.97g
[root@centos8 ~]# vgremove testvg   #刪除卷組
  Volume group "testvg" successfully removed
[root@centos8 ~]# vgs
[root@centos8 ~]# pvs
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sdb      lvm2 ---  15.00g 15.00g
  /dev/sdc      lvm2 ---   5.00g  5.00g

[root@centos8 ~]# pvremove /dev/sd{b,c} #刪除邏輯卷
  Labels on physical volume "/dev/sdb" successfully wiped.
  Labels on physical volume "/dev/sdc" successfully wiped.
[root@centos8 ~]# pvs
[root@centos8 ~]# lvblk
-bash: lvblk: command not found
[root@centos8 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk 
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0  100G  0 part /
├─sda3   8:3    0   50G  0 part /data
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0    4G  0 part [SWAP]
sdb      8:16   0   15G  0 disk 
sdc      8:32   0    5G  0 disk 
sr0     11:0    1  7.7G  0 rom  
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容