In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
First of all, the linux software package is incompatible with the package in windows, so to use programs on windows on linux, you need to use virtualization tools.
Library-level virtualization:
Linux: WinE
Windows: Cywin
There are many program development languages, which are divided into system-level development and application-level development.
System development language:
C, C++
C _ blank + program format:
Source code: program code in text format
Compiler development environment: compiler, header file, development library
Binary format: program code in text format-- > compiler-- > binary format (binary program, library file, configuration file, help file,)
Application-level development language:
Java/Python/perl/ruby/php/delphi/go
Java/python program format:
Source code: compiled into a format that can run on its virtual machine (jvm/pvm)
Development environment: compiler, development library
Binary format: program code-- > compiler-- > binary format (binary program, library file, configuration file, help file,)
Package Management:
Source code-- > target binary format-- > organized into one or a limited number of "package" files
Install, upgrade, uninstall, query, verify
The package manager is divided into:
Debian series: deb files, dpkg package manager
Redhat series: rpm files, rpm package manager
It's important to talk about the package management of the redhat series. "rpm package management" rpm is "Redhat Package Manager" and now is.
It means "RPM Package Manager".
There is a certain format for naming software packages.
Source code: name-VERSION.tar.gz
VERSION: major (major version number). Minor (minor version number). Release (release number)
Rpm package command format: name-VERSION-release.arch.rpm
VERSION::major,minor,release
Release.arch: the release number of the rpm package
Such as: bash-4.2.46-19.el7.x86_64.rpm
VERSION: major.minor.release
Release:release.OS
Common arch:
X86: i386, i486, i586, i686
X86_64: x64, x86_64, amd64powerpc: ppc
Platform independent: noarch
Packet classification and unpacking:
Application-VERSION-ARCH.rpm: main package
Application-devel-VERSION-ARCH.rpm: developing subpackages
Application-utils-VERSION-ARHC.rpm: other subpackages
Application-libs-VERSION-ARHC.rpm: other subpackages
View the library files that the binary depends on:
Ldd/PATH/TO/BINARY_FILE
Manage and view the library files loaded on this machine:
Ldconfig
/ sbin/ldconfig-p: displays all available library file names and file path mapping relationships that have been cached on this machine
Configuration file: / etc/ld.so.conf, / etc/ld.so.conf.d/*.conf
Cache file: / etc/ld.so.cache
When installing software packages, there may be dependencies between packages, or even circular dependencies. For example, to install package A, you need to install package B first, package B needs to install package C first, and package C needs to install package A first. This kind of cyclic dependency installation, if only step-by-step installation to solve the dependency, it will cost too much manpower and material resources, which requires the use of some front-end tools to automatically solve the dependency.
Resolve dependency package management tools:
Front-end tools for yum:rpm package manager
Apt-get:deb package Manager front-end tools
Zypper: rpm front-end management tool on suse
Dnf: Fedora 22 + rpm package Manager front-end management tool
Package Manager:
Function: package one or more package files from each component file of the compiled application, so as to easily and quickly realize the management operations such as installation, uninstallation, query, upgrade and verification of the package.
1. Composition of package files (unique to each package)
Files in the RPM package
RPM metadata, such as name, version, dependency, description, etc.
Scripts that run when installing or uninstalling
2. Database (public)
Package name and version
Dependency relationship
Function description
File path and check code information generated after package installation
...
Stored in / var/lib/rpm
Get the package
To install a package, you need to get the package first, and there are several more secure ways to get the package
(1) the CD-ROM of the system version or the official server
For example: CentOS image:
Https://www.centos.org/download/
Http://mirrors.aliyun.com
Http://mirrors.sohu.com
Http://mirrors.163.com
(2) official site of the project
(3) third-party organizations:
Fedora-EPEL:
Extra Packages for Enterprise Linux
Recommended by Rpmforge:RHEL, the package is very complete
Package search engine:
Http://pkgs.org
Http://rpmfind.net
Http://rpm.pbone.net
Https://sourceforge.net
④ made it himself.
When obtaining the package, you should pay attention to check its legitimacy: the source legitimacy, the integrity of the package.
After you get the package, you need to install or manage the package. Here's how to manage the rpm package:
Rmp package Management:
Rpm command
The rpm command management package on CentOS systems:
Installation, upgrade, uninstall, query, verification, database maintenance
Rpm command: rpm [options] [package_file]
Install:-iMager Musi install
Upgrade:-U _ Jing _ talk _ update _ M _ F,-- freshen
Uninstall:-eJing Musicerase
Query:-QMAT PULICULING
Check:-V,-- verify
Database maintenance:-- builddb,--initdb
Installation:
Rpm {- I |-- install} [install-options] PACKAGE_FILE...
Rpm-ivh PACKAGE_FILE
GENERAL OPTIONS:
-v:verbose, details
-vv: more detailed output
[install-options]:
-h: hash masks outputs progress bars; each # represents 2% progress
-- test: test installation, detect and report dependent inertial frames and collision messages, etc.
-- nodeps: ignore dependencies; not recommended
-- replacepkgs: reinstall
-- nosignature: do not check the validity of the source
-- nodigest: do not check package integrity
-- noscipts: do not execute package script fragments
For example, when you test and install the rpm package, you can see the dependencies required by the package:
When the package is installed, you will run some scripts to do some preparatory actions. Note: rpm can have its own scripts.
Four categories:-- noscripts (none of them are executed)
Preinstall: script that was run before the installation process started;% pre;-- nopre
Postinstall: script that runs after the installation process is complete;% post;-- nopost
Preuninstall: script that runs before the uninstall process actually starts;% preun;-- nopreun
Postuninstall: script run after the uninstall process is complete,% postun;-- nopostun
Upgrade:
Rpm {- U |-- upgrade} [install-options] PACKAGE_FILE...
-U: upgrade or install
Upgrade: upgrade if a legacy package is installed, or install if there is no legacy package
Rpm-Uvh PACKAGE_FILE...
Rpm {- F |-- freshen} [install-options] PACKAGE_FILE...
-F: upgrade
Freshen: upgrade if an old version of the package is installed; if no old version of the package exists, no upgrade will be performed
Rpm-Fvh PACKAGE_FILE...
-- oldpackage: downgrade installation
-- force: force upgrade
Note:
① does not upgrade the kernel; Linux supports the coexistence of multiple kernel versions, so you can install a new version of the kernel directly
② if the configuration file of an original package has been modified after installation, when upgrading, the same configuration file provided by the new version of the program will not overwrite the original version of the configuration file, but will be provided after renaming (FILENAME.rpmnew) the new version of the configuration file.
Example:
Uninstall:
Rpm {- e |-- erase} [--allmatches] [--nodeps] [--noscripts] [--test] PACKAGE_NAME...
[--allmatches]: uninstall all versions of packages that match the specified name
[--nodeps]: ignore dependencies
-- text: test uninstall only, dry run mode
When testing the uninstall, you can find that there is also a dependency during the uninstall.
Query:
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: query which package to install and generate the specified file
-pmam Murray package PACKAGE_FILE: used to execute queries on packages that are not installed
-- whatprovides CAPABILITY: query which package provides the specified CAPABILITY
-- whatrequires CAPABILITY: query which package the specified CAPABILITY is dependent on
Related usage:
[query-options]
-- changelog: query the changlog of the RPM package
-l,-- list: list of all files generated by the program installation
-I,-- info: information about the package, version number, size, package group to which it belongs, etc.
-c,-- configfiles: query the configuration file provided by the specified package
-d,-- docfiles: query the help documentation provided by the specified package
-- provides: lists all CAPABILITY that the specified package listens to
-R,-- requires: query the dependencies of the specified package
-- scripts: view the script snippets that come with the package
Rpm2cpio package files | cpio-itv: preview the files in the package
Rpm2cpio package file | cpio-id "* .conf": release the files in the package
When a file is damaged by misoperation and the program cannot be used, if the program is reinstalled directly, its configuration file will be overwritten, resulting in the loss of the previous configuration.
You can delete the damaged files, then use the rpm2cpio command to re-extract the specified files in the package, and then move the extracted files to the specified location for use; you can repair the program without overwriting other files.
Check:
Rpm {- V |-- verify} [select-options] [verify-options]
Displays the meaning represented by the characters:
S file Size differs
M Mode differs (includes permissions and file type)
5 digest (formerly MD5 sum) differs
D Device major/minor number mismatch
L readLink (2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs
P caPabilities differ
Package check:
Validity and integrity verification of package sources:
Integrity verification: SHA256
Verification of Source legitimacy: RSA
Public key encryption:
Symmetric encryption: encrypt and decrypt using the same key
Asymmetric encryption: keys are paired
Public key: public key, public owner
Secret key: private key, cannot be made public
Import the required public key:
Rpm--import / etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Available on the CentOS 7 distribution CD: RPM-GPG-KEY-CentOS-7
Rpm-K | checksigrpmfile checks the integrity and signature of the packet
Rpm-qagpg-pubkey* to view imported keys
[root@centos7 Packages] # rpm-K zsh-5.0.2-14.el7.x86_64.rpm zsh-5.0.2-14.el7.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
Rpm database
Database Reconstruction:
Rpm Manager database path: / var/lib/rpm
Query operation: through the database here
Get help:
CentOS6: man rpm
CentOS7: man rpmdb
Rpm {--initdb |-- rebuilddb}
Rpm {--initdb |-- rebuilddb} [- v] [--dbpath DIRECTORY] [--root DIRECTORY]
-- initdb: initializes the database. Currently, there is no database that can be implemented to create a new one. Currently, sometimes no operations are performed.
-- rebuilddb: rebuild, recreate by reading all packages that have been installed on the current system
Yum command
As mentioned earlier, when installing software packages, there may be dependencies between packages, and you need to use some front-end tools to automatically resolve the dependencies.
Resolve dependency package management tools:
Front-end tools for yum:rpm package manager
Apt-get:deb package Manager front-end tools
Zypper: rpm front-end management tool on suse
Dnf: Fedora 22 + rpm package Manager front-end management tool
Management tools in CentOS: yum, dnf
Here's how to use yum:
Yum: a front-end program for YellowdogUpdate Modifier;rpm that is used to resolve package-related dependencies and can be customized among multiple libraries
Bit package, an alternative tool for up2date
Yum repository: yum repo, which stores a large number of rpm packages and related metadata files for packages (placed under a specific directory repodata). The location of the repodata directory is where the repository should point.
The warehouse first needs to be a file server (the CD itself can also be used as a warehouse)
File server:
Ftp://
Http://
File:///
Configuration file for yum client:
/ etc/yum.conf: provide common configuration for all warehouses
Man yum.conf can view the details of yum.conf
/ etc/yum.repos.d/*.repo: provide configuration for warehouse execution
The definition of the warehouse point:
[repositoryID]
Name=Some name for this repository
Baseurl=url://path/to/repository
Enable= {1 | 0} (default is 1, that is, this warehouse is enabled)
Gpgcheck= {1 | 0} (default is 1, that is, enable key)
Gpgkey=URL (gpg key file)
Enablegroups= {1 | 0} (default is 1, that is, group management is enabled)
Faillovermethod= {roundrobin | priority} (when baseurl points to more than one, the default is: roundrobin, meaning random selection, priority: specify priority)
Cost= defaults to 1000
Example:
The custom repository points to:
[root@localhost ~] # cd / etc/yum.repos.d/ [root@localhost yum.repos.d] # vim base.repos [base] name=CentOS 7 baseurl= http://10.1.0.1/cobbler/ks_mirror/CentOS-7-x86_64/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7enabled=1
You can also use the mirrored CD as a repository:
First, you need to mount the CD:
[root@centos7 ~] # mount / dev/sr0 / mnt/cdrom/mount: / dev/sr0 is write-protected, mounting read-only
Then go to the / etc/yum.repos.d/ directory and change the CentOS-Base.repo file to a file that does not end with repo (making it unrecognizable and forbidding the use of this warehouse)
[root@centos7 ~] # cd / etc/yum.repos.d/ [root@centos7 yum.repos.d] # mv CentOS-Base.repo CentOS-Base.repo.bak
Edit the CentOS-Media.repo file
[root@centos7 yum.repos.d] # vim CentOS-Media.repo
[c7-media]
Name=CentOS-$releasever-Media
Baseurl= file:///mnt/cdrom
Gpgcheck=1
Enabled=1
Gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
This allows you to use the local warehouse!
Usage of the yum command:
Yum [options] [command] [package...]
Use the command to create a warehouse:
Such as:
Generate 172.16.0.1_cobbler_ks_mirror_CentOS-X-x86_64_.repo warehouse
Yum-config-manager-- add-repo= http://172.16.0.1/cobbler/ks_mirror/CentOS-X-x86_64/
Yum-config-manager-disable "warehouse name" disables the warehouse
Yum-config-manager-enable "warehouse name" enables the warehouse
Display a list of warehouses:
Repolist [all | enabled | disabled]
[root@localhost yum.repos.d] # yum repolist Loaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfilerepo id repo name statusBase CentOS 7 9007epel fedora-epel 8508repolist: 17515
Display the package:
Yum list [all | glob_exp1] [glob_exp2] [...]
Yum list {available | install | updates} [glob_exp1] [...]
Install the package:
Yum install package1 [package2] [...]
Yum reinstall package1 [package2] [...] (reinstall)
Upgrade package:
Yum update [package1] [package2] [...]
Yum downgrade package1 [package2] [...] (downgrade)
Check for available upgrades:
Yum check-update
Uninstall packages: (uninstall packages with dependencies)
Yum remove | erase package1 [package2] [...]
View the package infomation
Yum info [...]
See which package the specified feature (a file) is provided by:
Yum provides | whatprovides feature1 [feature2] [...]
Clean up the local cache:
Yum clean [packages | metadata | expire-cache | rpmdb | plugins | all]
Build the cache:
Yum makecache
Search for:
Yum search string1 [string2] [...]
Search for package name and summary information with specified keywords
View the capabilities on which the specified package depends
Yum deplist package1 [package2] [...]
View the history of yum things
History [info | list | packages-list | packages-info | summary | addon-info | redo | undo |
Rollback | new | sync | stats]
Yum history
Yum history info 6
Yum history undo 6
Install and upgrade local packages
* localinstall rpmfile1 [rpmfile2] [...]
(replace with install)
* localupdate rpmfile1 [rpmfile2] [...]
(replace with update)
Commands related to package group management:
Groupinstall group1 [group2] [...]
Groupupdate group1 [group2] [...]
Grouplist [hidden] [groupwildcard] [...]
Groupremove group1 [group2] [...]
Groupinfo group1 [...]
Command line options for yum:
-- nogpgcheck: gpgcheck is prohibited
-y: automatic answer is "yes"
-Q: silent mode
-- disablerepo=repoidglob: temporarily disable the repo specified here
-- enablerepo=repoidglob: temporarily enable the repo specified here
-- noplugins: disable all plug-ins
The variables available in the repo configuration file of yum:
$releasever: the major version number of the current OS release
$arch: platform, i386, 486, i486, 586, x86, 64, etc.
$basearch: basic platform; i386
$YUM0-$YUM9: custom variable
Such as: http://server/centos/$releasever/$basearch/
Create a yum repository:
Createrepo [options]
1. First, enter the directory where the package is stored, use the "createrpo. /" command to generate a repodata directory in the current directory, and then enter the directory to find and generate some files.
[root@localhost repo] # createrepo. / [root@localhost repo] # cd / etc/yum.repos.d/ [root@localhost yum.repos.d] # vim base.repo
Add the following lines:
[xen4centos] name=Xen 4 CentOS6baseurl= file:///yum/repo/gpgcheck=0
Use the yum repolist command to see that the warehouse has been generated
Compilation and installation of the package:
All of the above are binary rpm packages that have many advantages:
1. The package management system is simple and requires only a few commands to install, upgrade, query and uninstall the package.
2. Fast installation
But there are also many disadvantages:
1. You can't see the source code
2. Inflexible function selection
3. There is dependence.
The package that is compiled and installed is the source package, which can make up for these shortcomings.
Advantages of source package:
1. Freely choose the required functions
2. Open source. If you have enough ability, you can modify the source code.
3. The software is compiled and installed, so it is more suitable for your own system, more stable and more efficient.
4. Easy to uninstall
Disadvantages:
1. There are many steps in the installation process, especially when installing a large software collection, it is easy to make spelling mistakes.
2. the compilation time is long, and the installation time is longer than the binary package.
3. Because it is compiled and installed, it is difficult for beginners to scratch if they report an error during the installation process.
Package compilation and installation:
After Application-VERSION-release.src.rpm-- > installation, use the rpmbuild command to make the rpm package in binary format, and then install it
Source code-- > preprocessing-- > compilation (gcc)-- > assembly-- > link-- > execution
Source code organization format:
Multiple files: there are likely to be cross-file dependencies between the code in the file
C, C++:make (Project Manager, configure-- > Makefile.in-- > makefile)
Java: maven
C code compilation and installation three steps:
1 、. / configure:
(1) pass parameters through options to specify the enabled feature, installation path, etc. During execution, you will refer to the user's assignment and makefile.in file to generate makefile.
(2) check the external environment on which it depends
2. Make: build the application according to the makefile file
3. Make install: copy the file to the appropriate path
Development tools:
Autoconf: generate configure script
Automake: generate Makefile.in
Note: check INSTALL,README before installation
Access to source code of open source programs:
Official self-built site:
Apache.org (ASF)
Mariadb.org
...
Code hosting:
SourceForge.net
Github.com
Code.google.com
C _ blank + compiler: gcc (GNU C Complier)
Compile the C source code:
Premise: provide development tools and development environment
Development tools: make, gcc, etc.
Development environment: development libraries, header files
Glibc: standard library
Provide development components through "package groups"
CentOS 6: "Development Tools", "Server Platform Development"
Step 1: configure script
Options: specify installation location, specify enabled features
-- help: get the options it supports
Option classification:
Installation path setting:
-- prefix=/PATH: specify the default installation location. Default is / usr/local/.
-- sysconfdir=/PATH: configuration file installation location
System types: support for cross-compilation
Optional Features: optional featur
-- disable-FEATURE
-- enable-FEATURE [= ARG]
Optional Packages: optional package
-- with-PACKAGE [= ARG], dependent package
-- without-PACKAGE, disable dependencies
Step 2: make
Step 3: make install
Configuration after installation:
(1) Import the binary program directory into the PATH environment variable
Edit file / etc/profile.d/NAME.s
Export PATH=/PATH/TO/BIN:$PATH
(2) Import library file path
Edit / etc/ld.so.conf.d/NAME.conf
Add the directory where the new library file is located to this file
Have the system regenerate the cache:
Ldconfig [- v]
(3) Import header file
A link-based approach to:
Ln-sv
(4) Import help manual
Edit / etc/man.config | man_db.conf file
Add a MANPATH
Example: compile and install apache 2.2 and start this service
Yum install-y gccyum groupinstall-y "Development tools" yum groupinstall-y "Server Platform Development". / configure-prefix=/usr/local/apache2-sysconfdir=/etc/httpd2makemake install
Import the binary program directory into the PATH environment variable
Vim / etc/profile.d/httpd2.sh PATH=$PATH:/usr/local/apache2/bin
Import library file path
Vim / etc/ld.so.conf.d/httpd2.conf / usr/local/apache2/lib
Let the system regenerate the cache
Ldconfig-v
Import header file
Ln-sv / usr/local/apache2/include / usr/inclcude/httpd2.h
Import help manual
Vim / etc/man.config MANPATH / usr/local/apache2/man
Start the service
Apachectl start
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.