In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Features of the package manager
We know that the source code of the program written and provided by the programmer has to be converted to the target binary format before it can be run on the computer, but users need to compile and install it manually before they can use it on the platform. it is difficult for ordinary users. Therefore, in order to reduce the difficulty for ordinary users to use the application, programmers can provide program files that have been compiled in a specific environment while providing the source code, as long as the user's platform environment is the same as the programmer's platform environment. it can be used by decompressing the binary format files provided by the programmer without having to compile and install it manually.
A compiled program consists of binary programs, library files, configuration files and help manuals, and the function of the package manager is to package the compiled application files (binary programs, library files, configuration files, help files, etc.) into one or more package files, so as to more easily realize the package installation, upgrade, uninstall and query and other management operations.
two。 The conversion process from source code to package
3. Overview of rpm package Manager
Rpm is a method of managing software packages proposed by Redhat for its operating system RHEL. The full name of rpm was originally RedHat Package Manager. Later, due to the convenience of the rpm package manager and the various commercial strategies adopted by Redhat, rpm has become an industrial standard, and other systems can use rpm for reference, so the full name of rpm was later changed to: RPM Package Manager. As long as the rpm package manager is installed on the system, as long as the package files that conform to the rpm standard can be installed, upgraded, uninstalled and queried more easily.
4. Why use rpm?
One of Linux's philosophies is that "a program does only one thing and does it well." Therefore, Linux often uses many single-function programs to accomplish complex tasks, the most common example is the use of pipe commands. The problem caused by the singleness of each program function is the great dependence between the program files, which is a problem that needs to be solved. In addition, programs with various functions should be installed, and the paths and files generated by each program during installation are different, which will bring great annoyance to uninstall a program, extremely inconvenient to manage, as well as the management of the version of the program. The above problems can be solved by installing the rpm package manager on Linux. The RPM package manager can package compiled application composition files into one or limited rpm packages, each of which records the dependencies of the current package. Once the package is installed, rpm tracks the installation path of its individual files (including temporary files generated when the program is running). The rpm package manager realizes the management of the rpm package in this way, and the management of the package is nothing more than installation, upgrade, uninstallation, query and so on.
5. Components of the package manager
The package manager consists of two parts: the package manifest and the database:
(1) composition list of packages (each program is implemented separately):
① file list
Scripts that run when ② installs or uninstalls
(2) Database (shared by all rpm packages):
Name and version of the ① package
② dependency relationship
③ feature description
File path and check code information of each file generated by ④ installation
6. Rpm package naming format
The rpm package can be divided into the main package and the subpackage (the subpackage of the main package), and the subpackage serves as a functional supplement to the main package. The naming format of the rpm main package is: name-VERSION-release.arch.rpm. The various parts are explained as follows:
Name: program name
VERSION: version
VERSION consists of three parts:
① major: the major version number of the program
② minor: the minor version number of the program
③ release: revision number of the program
Release [.os] .arch: represents the release number of the rpm package
① release [.os]: rpm version + operating system
② arch:archetecture, supported hardware architecture. Common hardware architectures include i386, x64 (amd64), ppc, noarch (supporting any architecture), etc.
The schematic diagram of each component is as follows:
For example, zsh-5.0.2-25.el7.x86_64.rpm represents: the major version number of the zsh package is 5, the minor version number is 0, the revision number is 25, the supported operating system is RHEL 7 (CentOS 7), and the supported hardware architecture is x86x64.
For subpackages, the naming format is:
Name-function-VERSION-release.arch.rpm
Common function are: devel, utils (tool program), libs,...
7. The way to get the package
How do I get the rpm package?
(1) CD-ROM of the system distribution or official file server (or mirror site)
Common mirror sites such as:
Http://mirrors.aliyun.com
Http://mirrors.sohu.com
Http://mirrors.163.com
(2) the official site of the project
(3) third-party organizations
(a) EPEL
(B) search engines
Http://pkgs.org
Http://rpmfind.net
Http://rpm.pbone.net
...
(4) make your own rpm package.
Recommendation: check its legitimacy (source legitimacy, package integrity)
8. Rpm Command Management package on CentOS system
8.1. Installation
Syntax format:
Rpm {- I |-- install} [install-options] PACKAGE_FILE...
Common command options:
-v:verbose to output detailed process information
-vv:very verbose to output more detailed process information
Installation options (install-options):
-h:hash marks outputs the progress bar; the hash marker is #, and each # indicates 2% progress
-- test: test installation, check and report dependency and conflict information, etc.; equivalent to dry run
-- nodeps: ignore dependencies and are not recommended
-- replacepkgs: reinstall
-- noscripts: specifies that the script does not run
-- nosignature: do not check the package signature information, that is, do not check the source validity of the package
-- nodigest: do not check package integrity information
Usage:
Rpm-ivh PACKAGE_FILE...
Note: rpm can have its own script.
There are up to four types of scripts: (--noscripts can specify not to run these four types of scripts)
Preinstall: script that runs before the installation process starts,% pre;--nopre can specify not to run
Postinstall: script that runs after the installation process is complete,% post;--nopost can specify not to run
Preuninstall: the uninstall process actually starts to execute the script that was run before,% preun;--nopreun can specify not to run
Postuninstall: script that runs after the uninstall process is complete,% postun;--nopostun can specify not to run
Command demonstration:
To install zsh, first mount the CD:
[root@osyunwei ~] # mkdir / media/cdrom [root@osyunwei ~] # mount / dev/sr0 / media/cdrommount: block device / dev/sr0 is write-protected, mounting read-only
Download zsh with rpm:
[root@osyunwei ~] # cd / media/cdrom/Packages/ [root@osyunwei Packages] # rpm-ivh zsh-4.3.11-4.el6.centos.2.x86_64.rpm Preparing... # [100%] 1:zsh #
8.2. Upgrade
Syntax format:
Rpm {- U |-- upgrade} [install-options] PACKAGE_FILE...
Rpm {- F |-- freshen} [install-options] PACKAGE_FILE...
Common options:
-U: upgrade or install
-F: upgrade
-v: same as "installation"
-vv: same as "install".
Installation options (install-options):
-- oldpackage: downgrade-- > some programs encounter incompatibility after upgrading and need to be downgraded at this time
-- force: force upgrade-- > this option may be used when upgrading some programs that cause dependency problems
Other installation options are the same as "install".
Usage:
Rpm-Uvh PACKAGE_FILE...
Rpm-Fvh PACKAGE_FILE...
Note:
(1) Linux supports the coexistence of multiple kernel versions, so do not upgrade the kernel, as this may lead to "rollback". It is recommended to install a new version of the kernel directly.
(2) if the configuration file of an original package has been modified after installation, the same configuration file provided by the new version of the program will not overwrite the original version of the configuration file during the upgrade, but will be provided after renaming (FILENAME.rpmnew) the new version of the configuration file.
Command demonstration:
View the currently installed version of zsh:
[root@osyunwei] # rpm-Q zshzsh-4.3.11-4.el6.centos.2.x86_64
Download the zsh-5.0.2-25.el7_3.1.x86_64.rpm package from NetEase's mirror site:
[root@osyunwei ~] # wget http://mirrors.163.com/centos/7/updates/x86_64/Packages/zsh-5.0.225.el7_3.1.x86_64.rpm
Upgrade zsh with rpm:
[root@osyunwei] # rpm-Uvh zsh-5.0.2-25.el7_3.1.x86_64.rpm warning: zsh-5.0.2-25.el7_3.1.x86_64.rpm: Header V3 RSA/SHA256 Signature Key ID f4a80eb5: NOKEYerror: Failed dependencies:libc.so.6 (GLIBC_2.14) (64bit) is needed by zsh-5.0.2-25.el7_3.1.x86_64libc.so.6 (GLIBC_2.15) (64bit) is needed by zsh-5.0.2-25.el7_3.1.x86_64
It was found that there was a dependency that could not be upgraded.
To force an upgrade at this point, use the-- nodeps option:
[root@osyunwei] # rpm-Uvh-- nodeps zsh-5.0.2-25.el7_3.1.x86_64.rpmwarning: zsh-5.0.2-25.el7_3.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... # [100%] 1:zsh #
Note: the program may not work properly after ignoring dependency upgrade!
Then downgrade zsh:
[root@osyunwei ~] # cd / media/cdrom/Packages/ [root@osyunwei Packages] # rpm-Uvh-- oldpackage zsh-4.3.11-4.el6.centos.2.x86_64.rpm Preparing... # [100%] 1:zsh #
8.3. Unloading
Syntax format:
Rpm {- e |-- erase} [--allmatches] [--nodeps] [--test] PACKAGE_NAME...
Uninstall option (erase options):
-- allmatches: uninstalls all versions of packages that match the specified name
-- nodeps: ignore dependencies
-- test: test uninstall, dry run mode.
Usage:
Rpm-e PACKAGE_NAME
Command demonstration:
Uninstall the installed zsh package:
[root@osyunwei] # rpm-e zsh
If there is no display, it means that the uninstall is successful!
8.4. Query
Syntax format:
Rpm {- Q |-- query} [select-options] [query-options]
[select-options]:
PACKAGE_NAME: query whether the specified package is installed and its version
-a,-- all: query all installed packages
-f,-- file FILE: query which package installation generates the specified file
-p,-- package PACKAGE_FILE: used to perform query operations on packages that are not installed
-- whatprovides CAPABILITY: query which package provides the specified CAPABILITY
-- whatrequires CAPABILITY: queries which package the specified CAPABILITY is dependent on.
[query-options]:
-- changelog: query the changelog of the rpm package
-I,-- info: information about the package, version number, size, package group to which it belongs, etc.
-l,-- list: a list of all files generated by the package installation
-c,-- configfiles: query the configuration file provided by the specified package
-d,-- docfiles: query the documents provided by the specified package
-- provides: lists all CAPABILITY provided by the specified package
-R,-- requires: query the dependencies of the specified package
-- scripts: view the script snippet that comes with the package.
Usage:
Rpm-qi PACKAGE
Rpm-qf FILE
Rpm-qc PACKAGE
Rpm-qd PACKAGE
Rpm-qpi PACKAGE_FILE
Rpm-apl PACKAGE_FILE
Rpm-qpc PACKAGE_FILE
With so many options listed, let's give an example.
(1) check whether zsh has been installed:
[root@osyunwei ~] # rpm-qa | grep'^ zsh'zsh-4.3.11-4.el6.centos.2.x86_64 / / shows that zsh; is installed or: [root@osyunwei ~] # rpm-Q zshzsh-4.3.11-4.el6.centos.2.x86_64 / / shows that zsh is installed
(2) which package installs and generates the query / etc/fstab:
[root@osyunwei] # rpm-qf / etc/fstab setup-2.8.14-20.el6_4.1.noarch
(3) list all the files generated by installing httpd:
[root@osyunwei ~] # rpm-ql httpd
(4) list the dependencies of the httpd package:
[root@osyunwei] # rpm-qR httpd/bin/bash / bin/sh. (omitted). Libz.so.1 () (64bit) rpmlib (CompressedFileNames)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.