Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Two ways to realize database persistence

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report