Get the App
SLTechnology News&Howtos  ›  Database  › 

Two ways to realize database persistence

Shulou Source: shulou.com Published: 2022-06-01 22:40:30 11月07日 Update

Persistent storage of the data in the database service can not only do data backup, but also facilitate data transmission.

At present, there are two main ways to implement it:

one。 Create a snapshot

Mysql Snapshot

Mysql dump tool, you can export data to a .sql file, through this sql file, you can do data recovery.

$mysqldump-h xxx-uroot-p databasename > ~ / data_backup/database.sql

Rdb of Redis

The save/bgsave instruction is sent under the redis client, and the rdb file is created. The default file name is dump.rdb

127.0.0.1 6379 > save127.0.0.1:6379 > bgsave

Notice how to quickly find the dump.rdb location

1. Use the config command

127.0.0.1 var/lib/redis 6379 > CONFIG GET dir1) "dir" 2) "/ var/lib/redis"

two。 Through the redis.conf configuration file, find the working directory dir configuration

How to find the redis.conf file quickly? Use the info server command when the client is connected

127.0.0.1 6379 > info server# Serverredis_version:5.0.3redis_git_sha1:00000000redis_git_dirty:0redis_build_id:23238c6957772153redis_mode:standaloneos:Linux 5.0.0-32-generic x86_64arch_bits:64multiplexing_api:epollatomicvar_api:atomic-builtingcc_version:8.3.0process_id:855run_id:8b009f0b92e3d738e49ab03fdad7766dbb3988c2tcp_port:6379uptime_in_seconds:402219uptime_in_days:4hz:10configured_hz:10lru_clock:15054015executable:/usr/bin/redis -serverconfig_file:/etc/redis/redis.conf

Or

$redis-cli-p 6379 info server | grep config_fileconfig_file:/etc/redis/ redis.confs II. Record write log (inset/update/delete)

Binlog of Mysql

Aof of Redis

Tags: Data files commands customers clients snapshots configurations databases methods creation location backup tools situations instructions data transfer data backup data recovery logs directories Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL Shulou Technology Xiaomi Shulou Tech Info