diff --git a/source/_posts/Linux.md b/source/_posts/Linux.md index 0c674d4..274e6ff 100644 --- a/source/_posts/Linux.md +++ b/source/_posts/Linux.md @@ -596,8 +596,11 @@ cd mysql_install # 下载安装包 wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.41-1.el7.x86_64.rpm-bundle.tar tar -xvf mysql-5.7.41-1.el7.x86_64.rpm-bundle.tar + rpm -ivh mysql-community-common-5.7.41-1.el7.x86_64.rpm + rpm -ivh mysql-community-libs-5.7.41-1.el7.x86_64.rpm + rpm -ivh mysql-community-libs-compat-5.7.41-1.el7.x86_64.rpm # 如果出现以下错误 error: Failed dependencies: @@ -605,31 +608,40 @@ error: Failed dependencies: libcrypto.so.10(libcrypto.so.10)(64bit) is needed by mysql-community-libs-compat-5.7.41-1.el7.x86_64 libssl.so.10()(64bit) is needed by mysql-community-libs-compat-5.7.41-1.el7.x86_64 libssl.so.10(libssl.so.10)(64bit) is needed by mysql-community-libs-compat-5.7.41-1.el7.x86_64 +# 执行 dnf install -y https://repo.almalinux.org/almalinux/8/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-4.el8_6.x86_64.rpm + rpm -ivh mysql-community-devel-5.7.41-1.el7.x86_64.rpm # 如果出现以下错误 error: Failed dependencies: /usr/bin/pkg-config is needed by mysql-community-devel-5.7.41-1.el7.x86_64 +# 执行 dnf install openssl-devel -y + rpm -ivh mysql-community-client-5.7.41-1.el7.x86_64.rpm # 如果出现以下错误 错误:依赖检测失败: libncurses.so.5()(64bit) 被 mysql-community-client-5.7.41-1.el7.x86_64 需要 libtinfo.so.5()(64bit) 被 mysql-community-client-5.7.41-1.el7.x86_64 需要 +# 执行 dnf install libncurses* -y dnf install epel-release -y dnf install ncurses-compat-libs -y -# 再次执行 rpm -ivh mysql-community-client-5.7.41-1.el7.x86_64.rpm + rpm -ivh mysql-community-server-5.7.41-1.el7.x86_64.rpm # 如果出现以下提示 /usr/lib/tmpfiles.d/mysql.conf:23: Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly. +# 执行 vim /usr/lib/tmpfiles.d/mysql.conf # 将/var/run/mysqld 改为 /run/mysqld + # 如果出现以下提示 error: Failed dependencies: libcrypt.so.1()(64bit) is needed by mysql-community-server-5.7.41-1.el7.x86_64 libcrypt.so.1(GLIBC_2.2.5)(64bit) is needed by mysql-community-server-5.7.41-1.el7.x86_64 +# 执行 dnf install -y libxcrypt-compat + # 如果出现以下提示 error: Failed dependencies: /usr/bin/perl is needed by mysql-community-server-5.7.41-1.el7.x86_64 @@ -639,8 +651,9 @@ dnf install -y perl.x86_64 # 如果出现以下提示 error: Failed dependencies: net-tools is needed by mysql-community-server-5.7.41-1.el7.x86_64 +# 执行 dnf install net-tools -y -# 再次执行 rpm -ivh mysql-community-server-5.7.41-1.el7.x86_64.rpm + rpm -ivh mysql-community-embedded-compat-5.7.41-1.el7.x86_64.rpm ``` @@ -775,6 +788,108 @@ firewall-cmd --zone=public --add-port=3306/tcp --permanent ``` +## 查看硬盘空间 + +```shell +# 统计磁盘整体情况,包括磁盘大小,已使用,可用 +df -lh +# 查看根目录下文件夹大小 +du -sh /* +``` + +## 扩容 + +### LVM + +Orale VirtualBox + +![image-20240130093530200](Linux/image-20240130093530200.png) + +需要选择最后一个,因为前几个是之前的备份快照 + +![image-20240130093629718](Linux/image-20240130093629718.png) + +分配大小即可,只能增加不能缩小 + +查看现有分区大小 + +```shell +df -Th +``` + +![image-20240130093817210](Linux/image-20240130093817210.png) + +查看扩容后磁盘大小 + +```shell +lsblk +``` + +![image-20240130093857754](Linux/image-20240130093857754.png) + +创建分区 + +```shell +fdisk /dev/sda +``` + +![image-20240130093939297](Linux/image-20240130093939297.png) + +![image-20240130094105250](Linux/image-20240130094105250.png) + +刷新分区并创建物理卷 + +```shell +partprobe /dev/sda +pvcreate /dev/sda4 +``` + +![image-20240130094218593](Linux/image-20240130094218593.png) + +查看卷组名称,以及卷组使用情况 + +```shell +vgdisplay +``` + +![image-20240130094244545](Linux/image-20240130094244545.png) + +将物理卷扩展到卷组 + +```shell +vgextend rl /dev/sda4 +``` + +![image-20240130094253931](Linux/image-20240130094253931.png) + +查看当前逻辑卷的空间状态 + +```shell +lvdisplay +``` + +![image-20240130094329028](Linux/image-20240130094329028.png) + +将卷组中的空闲空间扩展到根分区逻辑卷 + +```shell +lvextend -l +100%FREE /dev/rl/root +``` + +![image-20240130094418379](Linux/image-20240130094418379.png) + +刷新根分区 + +```shell +xfs_growfs /dev/rl/root +``` + +![image-20240130094442884](Linux/image-20240130094442884.png) + +扩容成功 + +![image-20240130094540550](Linux/image-20240130094540550.png) + ## 分配Swap 查看分区大小 @@ -1083,15 +1198,6 @@ dnf install nodejs -y -## 查看硬盘空间 - -```shell -# 统计磁盘整体情况,包括磁盘大小,已使用,可用 -df -lh -# 查看根目录下文件夹大小 -du -sh /* -``` - ## 安装宝塔面板 ## 安装 Neofetch @@ -1334,3 +1440,50 @@ type=rpm-md dnf install --enablerepo=elasticsearch elasticsearch -y ``` +## 安装 Rsync + +```shell +dnf install rsync -y +``` + +### 配置 + +```shell +vim /etc/rsyncd.conf + +# /etc/rsyncd: configuration file for rsync daemon mode + +# See rsyncd.conf man page for more options. + +# configuration example: + +uid = root +gid = root +ignore errors +hosts allow = 10.0.3.0/24 +secrets file = /etc/rsyncd.secrets +# use chroot = yes +# max connections = 4 +# pid file = /var/run/rsyncd.pid +# exclude = lost+found/ +# transfer logging = yes +# timeout = 900 +# ignore nonreadable = yes +# dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 + +# [ftp] +# path = /home/ftp +# comment = ftp export area +# 同步模块名称 +[syncwspswwwroot] +# 服务器同步的路径 +path = /root/wwwroot +log file = /var/log/rsync.log +# 只读模式 不允许客户端向同步路径进行同步上传文件 +read only = yes + +[mysql_bakup] +path = /root/mysql_bakup +read only = yes +``` + diff --git a/source/_posts/Linux/image-20240130093530200.png b/source/_posts/Linux/image-20240130093530200.png new file mode 100644 index 0000000..7100160 Binary files /dev/null and b/source/_posts/Linux/image-20240130093530200.png differ diff --git a/source/_posts/Linux/image-20240130093629718.png b/source/_posts/Linux/image-20240130093629718.png new file mode 100644 index 0000000..47e6902 Binary files /dev/null and b/source/_posts/Linux/image-20240130093629718.png differ diff --git a/source/_posts/Linux/image-20240130093817210.png b/source/_posts/Linux/image-20240130093817210.png new file mode 100644 index 0000000..ccb6f98 Binary files /dev/null and b/source/_posts/Linux/image-20240130093817210.png differ diff --git a/source/_posts/Linux/image-20240130093857754.png b/source/_posts/Linux/image-20240130093857754.png new file mode 100644 index 0000000..5251314 Binary files /dev/null and b/source/_posts/Linux/image-20240130093857754.png differ diff --git a/source/_posts/Linux/image-20240130093939297.png b/source/_posts/Linux/image-20240130093939297.png new file mode 100644 index 0000000..3da0adc Binary files /dev/null and b/source/_posts/Linux/image-20240130093939297.png differ diff --git a/source/_posts/Linux/image-20240130094105250.png b/source/_posts/Linux/image-20240130094105250.png new file mode 100644 index 0000000..857438d Binary files /dev/null and b/source/_posts/Linux/image-20240130094105250.png differ diff --git a/source/_posts/Linux/image-20240130094218593.png b/source/_posts/Linux/image-20240130094218593.png new file mode 100644 index 0000000..3d837a1 Binary files /dev/null and b/source/_posts/Linux/image-20240130094218593.png differ diff --git a/source/_posts/Linux/image-20240130094244545.png b/source/_posts/Linux/image-20240130094244545.png new file mode 100644 index 0000000..e92db5b Binary files /dev/null and b/source/_posts/Linux/image-20240130094244545.png differ diff --git a/source/_posts/Linux/image-20240130094253931.png b/source/_posts/Linux/image-20240130094253931.png new file mode 100644 index 0000000..56046c9 Binary files /dev/null and b/source/_posts/Linux/image-20240130094253931.png differ diff --git a/source/_posts/Linux/image-20240130094329028.png b/source/_posts/Linux/image-20240130094329028.png new file mode 100644 index 0000000..0beea06 Binary files /dev/null and b/source/_posts/Linux/image-20240130094329028.png differ diff --git a/source/_posts/Linux/image-20240130094418379.png b/source/_posts/Linux/image-20240130094418379.png new file mode 100644 index 0000000..25f291c Binary files /dev/null and b/source/_posts/Linux/image-20240130094418379.png differ diff --git a/source/_posts/Linux/image-20240130094442884.png b/source/_posts/Linux/image-20240130094442884.png new file mode 100644 index 0000000..c301484 Binary files /dev/null and b/source/_posts/Linux/image-20240130094442884.png differ diff --git a/source/_posts/Linux/image-20240130094540550.png b/source/_posts/Linux/image-20240130094540550.png new file mode 100644 index 0000000..e96a5ad Binary files /dev/null and b/source/_posts/Linux/image-20240130094540550.png differ diff --git a/source/_posts/MySQL.md b/source/_posts/MySQL.md index 4c8c066..11d976c 100644 --- a/source/_posts/MySQL.md +++ b/source/_posts/MySQL.md @@ -68,7 +68,7 @@ mysqldump -uroot -p -B test > test.sql - MySQL 5.6、5.7,以下载并安装Percona XtraBackup 2.4.9为例 ```shell - wget https://downloads.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.9/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.9-1.el9.x86_64.rpm + wget https://downloads.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.29/binary/redhat/9/x86_64/percona-xtrabackup-24-2.4.29-1.el9.x86_64.rpm rpm -ivh percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm --nodeps --force ``` @@ -80,9 +80,136 @@ mysqldump -uroot -p -B test > test.sql rpm -ivh percona-xtrabackup-80-8.0.32-26.1.el7.x86_64.rpm --nodeps --force ``` +## 备份 + +#### 全量备份 + +```shell +innobackupex --user=root --password=123456 --host=127.0.0.1 ~/mysql_bakup/ + +#语法解释说明: +#--user=root 指定备份用户 +#--password=123456 指定备份用户密码 +#--host  指定主机 +#~/mysql_bakup/  指定备份目录 +``` + +执行命令后。可看到备份时间的文件夹 + +![image-20240130140632864](MySQL/image-20240130140632864.png) + +文件夹内容如下 + +![image-20240130140723465](MySQL/image-20240130140723465.png) + +#### 增量备份 + +```shell +innobackupex --user=root --password=123456 --host=127.0.0.1 --incremental ~/mysql_bakup/ --incremental-basedir=~/mysql_bakup/2024-01-30_14-03-42/ +``` + +![image-20240130151257100](MySQL/image-20240130151257100.png) + +增量备份需要使用参数--incremental指定需要备份到哪个目录,使用incremental-dir指定全备目录 + +查看备份数据 + +![image-20240130172206916](MySQL/image-20240130172206916.png) + ## 恢复 +#### 全量备份恢复 +```shell +# 停止目标服务器上的mysql +systemctl stop mysqld +``` + +![image-20240130142057208](MySQL/image-20240130142057208.png) + +同步服务器上的备份文件至本地 + +```shell +# 同步服务器上的备份文件夹至本地 +rsync -av root@10.0.3.3::mysql_bakup ~/mysql_bakup +``` + +![image-20240130142150299](MySQL/image-20240130142150299.png) + +创建本地数据目录备份 + +```shell +cp -r /var/lib/mysql /var/lib/mysqlbakup +``` + +合并数据日志,使数据文件处于一致性的状态 + +```shell +innobackupex --apply-log ~/mysql_bakup/2024-01-30_14-03-42/ +``` + +![image-20240130142410127](MySQL/image-20240130142410127.png) + +删除数据目录 + +```shell +rm -rf /var/lib/mysql +``` + +进行数据恢复 + +```shell +innobackupex --copy-back 2024-01-30_14-03-42/ +``` + +![image-20240130142551097](MySQL/image-20240130142551097.png) + +赋予权限 + +```shell +chown mysql:mysql /var/lib/mysql -R +``` + +临时关闭SELinux + +```she +setenforce 0 +``` + +永久关闭SELinux + +#### 增量备份恢复 + +```shell +# 停止目标服务器上的mysql +systemctl stop mysqld +``` + +![image-20240130142057208](MySQL/image-20240130142057208.png) + +删除数据目录 + +```shell +rm -rf /var/lib/mysql +``` + +合并全备数据目录,确保数据的一致性 + +```shell +innobackupex --apply-log --redo-only ~/mysql_bakup/2024-01-30_14-03-42/ +``` + +将增量备份数据合并到全备数据目录当中 + +```shell +innobackupex --apply-log --redo-only ~/mysql_bakup/2024-01-30_14-03-42/ --incremental-dir=~/mysql_bakup/2024-01-30_15-12-28/ +``` + +恢复数据 + +```shell +innobackupex --copy-back ~/mysql_bakup/2024-01-30_14-03-42/ +``` diff --git a/source/_posts/MySQL/image-20240130140632864.png b/source/_posts/MySQL/image-20240130140632864.png new file mode 100644 index 0000000..ad888f5 Binary files /dev/null and b/source/_posts/MySQL/image-20240130140632864.png differ diff --git a/source/_posts/MySQL/image-20240130140723465.png b/source/_posts/MySQL/image-20240130140723465.png new file mode 100644 index 0000000..8bd39fb Binary files /dev/null and b/source/_posts/MySQL/image-20240130140723465.png differ diff --git a/source/_posts/MySQL/image-20240130142057208.png b/source/_posts/MySQL/image-20240130142057208.png new file mode 100644 index 0000000..188d63d Binary files /dev/null and b/source/_posts/MySQL/image-20240130142057208.png differ diff --git a/source/_posts/MySQL/image-20240130142150299.png b/source/_posts/MySQL/image-20240130142150299.png new file mode 100644 index 0000000..248d917 Binary files /dev/null and b/source/_posts/MySQL/image-20240130142150299.png differ diff --git a/source/_posts/MySQL/image-20240130142408659.png b/source/_posts/MySQL/image-20240130142408659.png new file mode 100644 index 0000000..806f863 Binary files /dev/null and b/source/_posts/MySQL/image-20240130142408659.png differ diff --git a/source/_posts/MySQL/image-20240130142410127.png b/source/_posts/MySQL/image-20240130142410127.png new file mode 100644 index 0000000..806f863 Binary files /dev/null and b/source/_posts/MySQL/image-20240130142410127.png differ diff --git a/source/_posts/MySQL/image-20240130142551097.png b/source/_posts/MySQL/image-20240130142551097.png new file mode 100644 index 0000000..332678a Binary files /dev/null and b/source/_posts/MySQL/image-20240130142551097.png differ diff --git a/source/_posts/MySQL/image-20240130151257100.png b/source/_posts/MySQL/image-20240130151257100.png new file mode 100644 index 0000000..8ac8c36 Binary files /dev/null and b/source/_posts/MySQL/image-20240130151257100.png differ diff --git a/source/_posts/MySQL/image-20240130172202785.png b/source/_posts/MySQL/image-20240130172202785.png new file mode 100644 index 0000000..36eaa20 Binary files /dev/null and b/source/_posts/MySQL/image-20240130172202785.png differ diff --git a/source/_posts/MySQL/image-20240130172206916.png b/source/_posts/MySQL/image-20240130172206916.png new file mode 100644 index 0000000..36eaa20 Binary files /dev/null and b/source/_posts/MySQL/image-20240130172206916.png differ