Software management mechanism:
The installation of software under Linux can be roughly divided into the following types:
1.Binary installation (simplest installation) 2.rpm Program installation (suffix:*.rpm) 3.yum Source installation (essentially rpm Install, it's just rpm It's just an installation method) 4.Source installation
Binary installation:
Binary format software under Linux refers to the relevant software compiled on various platforms first, and then compressed and packaged. During installation, you only need to decompress or execute the installation executable. This software distribution format is similar to windows system. The reason for this is to protect the source code program from external disclosure and protect intellectual property rights, The advantage of binary software package is that it is easy to install, but the disadvantage is that it lacks flexibility. The corresponding software package is installed on the corresponding platform, and the software cannot run without this environment.
Binary packages provide many types of packaging methods, the most common of which is our package in RPM format and * tar.gz/.gz/.bz2 and other forms of binary software packages. The last one is the binary software package that provides the installer for installation
Installation * tar.gz and bz2 binary package:
The installation of software packages in this format is actually a simple decompression process. According to different software packaging formats, we can use the corresponding decompression command to decompress them Installation:.tar.gz--->tar -zxvf .bz2----->tar -jxvf Uninstall: if there is only software in a single directory after decompression, you can directly delete the corresponding software directory. For files scattered in multiple directories after decompression, you need to manually delete the directories one by one
Packages that provide the installer:
This kind of software package provides the corresponding installation script or installation wizard. You only need to unzip this kind of software package after downloading it, and then enter the installation directory to find a similar one setup,install,install.sh Such executable files can be run, and then the corresponding settings are made according to the prompts (such as installation path, parameter setting, etc.), and then the installation is completed automatically The uninstallation of this kind of software also provides corresponding uninstallation script or uninstallation wizard. You can complete the software uninstallation according to the prompt
rpm installation:
The rpm package also becomes a binary package
rpm is the abbreviation of redhat package manager (redhat package management tool). Although this file format is marked with the logo of redhat, its original design concept is open. Now, Linux distribution versions including redhat, centos and suse are adopted, which can be regarded as a recognized industry standard. The installation of rpm files in Linux system is very simple
Common parameters of rpm:
i: Install application( install) vh: Display installation progress( verbose hash) u: Upgrade package( update) qa: Displays all installed packages( query all) e: Uninstall application( erase) Note: if other software packages have dependencies, a prompt will be generated during uninstallation, which can be used--nodeps Forced unloading
yum (yellowdog updater modified): package management tool
1.rpm The installation of is actually linux Standard installation in, but rpm There is a very troublesome place, that is, you need to manually manage the installation package. In addition rpm It cannot automatically solve the lack of dependency. When installing the software, if this program needs to rely on other programs, each dependent program needs to be installed manually 2.yum It perfectly solves such a problem yum Installation. You don't need to care about what programs this package depends on, yum It will automatically help you install dependent components 3.yum The essence of is still rpm Installation of, yum It is only managed automatically. We don't need to rely on manual management
Benefits of using yum:
1. Automatically resolve software package dependencies
2. Facilitate software package upgrade
yum It is a management tool for installing software online, so you need to download the software through the network yum The self-contained image is a foreign address, which is slow. Therefore, in the process of using it, we often need to replace it with a domestic source Common domestic sources: http://mirrors.aliyun.com Alibaba's source http://mirrors.ustc.edu.cn The source of China University of science and technology
Query: yum list Query the list of all available packages yum search keyword Search all keyword related packages on the server yum info keyword Find package name Installation: yum -y install Package name Upgrade: yum -y update Package name Note: if you do not add a package name, upgrade all, including the kernel. You must add a package name to upgrade a single software package. Use caution to upgrade all yum check update Uninstall: yum -y remove Package name other: yum clean all Clear cache and old packages yum repolist View currently available yum source yum deplist httpd List all dependent packages of a package
Source code compilation and installation:
Since the Linux operating system is open source, most of the software installed on it is also open source software, such as apache,tomcat,php and other software. Open source software provides the way of source download and source installation;
Advantages of source code installation:
1.Users can customize the functions of the software and install the required modules. Unnecessary functions do not need to be installed 2.Users can also choose the way of installation to facilitate management 3.It is also convenient to uninstall the software. You only need to delete the corresponding installation directory 4.It can integrate with the server platform to the greatest extent, and the efficiency is slightly higher than other methods 5.No, windows The so-called registry theory
Disadvantages of source code installation:
1.The installation is cumbersome and needs to be configured by yourself 2.Installation is time-consuming, and you need to compile the source code yourself 3.Installation is error prone and difficult to solve
Installation steps:
The source code installation software generally consists of the following steps: Download and unzip the source code, analyze the installation platform environment (ifconfigure), and compile the installation software (make, make install)
Clone: (it can copy a new machine exactly the same, which saves a lot of time compared with the original way of creating virtual machine)
Actions after cloning:
1. Modify ip address:
vi /etc/sysconfig/network-scripts/ifcfg-ens32
2. Modify host name:
vi /etc/hostname
3. Modify the domain name mapping file:
vi /etc/hosts
4. Use nat mode to realize LAN communication between two virtual machines
5. Process of operating the new Linux system:
1.Change host name temporary+permanent 2.Check whether the network card is started 3.close networkManager Network management service 4.Turn off firewall 5.change ip address 6.Change host name and mapping relationship 7.Using the remote connection tool( finalshell)Connect
scp command:
scp file Remote user name@remote server ip:/catalogue (There must be no space between colon and directory) If you copy a directory, you need to add-r option use root user Example: scp -r /opt/jdk root@haha02:/opt/jdk ~: Host Directory of the current user
ssh password free login:
Function: convenient switching between nodes Example: ssh node2 Implementation process of secret free login: 1.Generate a pair of keys on the first machine: public key and private key 1.ssh -keygen -t rsa 2.Under the host directory of the current user.ssh There are two more files in the directory -rw-------. 1 root root 1679 6 June 24-16:51 id_rsa -rw-r--r--. 1 root root 397 6 June 24-16:51 id_rsa.pub 3.Copy the public key to the machine to log in without secret ssh-copy-id root@haha02 ssh-copy-id root@haha03 4.Verify whether you can log in without secret ssh root@haha02
Secret free login principle:
1.haha01 generate ssh-keygen -t rsa Generate public and private keys 2.ssh-copy-id root@haha02 Copy public key to haha02 In fact, the public key content is appended to authrized_keys 3.When requested, haha01 towards haha02 Send connection request with host, ip Address and other information 4.haha02 When you receive a request, look in the authorization file haha01 After finding the public key, randomly generate a string, encrypt it with the public key, and send it to haha01 5.haha01 After receiving the ciphertext, decrypt it with the private key and return the decryption result to haha02 6.haha02 After decryption, compare it with the previous string. If it is the same, the login is successful
schematic diagram:
[the external link image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-hK8Wm6Sc-1624699380032)(C:\Users326\Desktop\dayHomework\QQ screenshot 20210624175437.png)]
Timer crontab:
Introduction to crontab:
1.Linux In, periodic tasks are generally performed by cron This daemon is used to process (a daemon is a special process running in the background to execute specific system tasks. Many daemons start when the system boots and run until the system is shut down, while others start only when needed and end automatically when the task is completed). It is a linux The scheduled task execution tool under can run jobs without human intervention 2.cron Read one or more configuration files that contain the command line and its invocation time 3.cron The configuration file for is called crontab,yes cron table Abbreviation of
cron Services: service crond start Start service service crond stop Shut down service service crond restart Restart service service crond relaod service crond reload service crond status View service status
cron profile location:
/var/spool/cron/ This shows that each user is stored in this directory, including root of crontab Tasks, each task and the name of the creator, such as tom Built crontab The file corresponding to the task is/var/spool/cron/tom Generally, there is only one user at most crontab file
crontab command format:
Function: used to generate cron Required by the process crontab file Format: crontab [-u username] -e
File content format:
The format is as follows: * * * * * user-name command to be executed It consists of six parts: Time sharing day month week command to run Resolution: minute: What minute of an hour[0~59] hour: What hour of the day[0~23] day: Which day of the month[1~12] week: Which day of the week[0~6] 0 On behalf of Sunday commands: Commands executed Notes for writing: 1.All cannot be empty and must be filled in. If you don't know, use wildcards*Represents any time 2.Each time field can specify multiple values, and discontinuous values are used,Interval, for continuous values-interval 3.The command should give an absolute path 4.The user must have the permission to run the corresponding command or program 5.*/num Representation frequency
Time synchronization:
In the actual production environment, many software or tasks have strict requirements on whether the time on the cluster is consistent. Some require that the time difference on all machines in the cluster should not be more than 10 minutes, and some require that the time difference on all machines should not be more than 30 seconds, which involves the problem of time synchronization
1. Time to synchronize the network:
1.1 synchronization time:
Synchronization time, need to use ntpdate Command, if not available yum install use utpdate Synchronize the time of the time server on the network, for example: time.windows.com,ntp.aliyun.com ntpdate -u ntp.aliyun.com
1.2 timing synchronization
Time synchronization can be made into a scheduled task to synchronize the network time at regular intervals
2. Custom time server:
If the cluster is not networked, you can set up a time server by yourself, so that all machines in the cluster can synchronize with the time server in the LAN
1.Select a machine in the cluster as the time server, for example haha01 2.Make sure the machine is installed ntp.x86_64 3.ensure ntpd Service operation: sudo service ntpd start Startup and self startup: chkconfig ntpd on 4.Configure the corresponding file: vi /etc/ntp.conf 5.Others shall be installed ntpdate.*86_64 6.Other machines to use root Define timer
If the cluster is not networked, you can set up a time server by yourself, so that all machines in the cluster can synchronize with the time server in the LAN
1.Select a machine in the cluster as the time server, for example haha01 2.Make sure the machine is installed ntp.x86_64 3.ensure ntpd Service operation: sudo service ntpd start Startup and self startup: chkconfig ntpd on 4.Configure the corresponding file: vi /etc/ntp.conf 5.Others shall be installed ntpdate.*86_64 6.Other machines to use root Define timer