Redis is the remote dictionary service. It is an open source log-type Key-Value database written in ANSI C language, supports the network, can be memory-based and persistent, and provides APIs in multiple languages.
Several methods of importing and exporting redis data:
1. redis-dump method
#redis-dump安装 yum install ruby rubygems ruby-devel -y gem sources --add http://gems.ruby-china.com/ --remove https://rubygems.org/ [root@docker ~]# gem sources -l *** CURRENT SOURCES *** http://gems.ruby-china.com/ #确定只剩这一个 [root@docker ~]# curl -L get.rvm.io | bash -s stable
gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB 再执行一遍: [root@docker ~]# source /etc/profile.d/rvm.sh [root@docker ~]# rvm -v rvm 1.29.8 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
List known ruby packages and install them:
[root@docker ~]# rvm list known [root@docker ~]# rvm install 2.4
Install redis-dump
gem install redis-dump -V
Import and export
redis-dump导出 [root@ ~]# redis-dump -u :password@172.20.0.1:6379 > 172.20.0.1.json redis-load导入 [root@ ~]# cat 172.20.0.1.json | redis-load -u :password@172.20.0.2:6379
2. AOF import method
## 3. RDB file migration method
1. Original redis serverLog in to the redis server, and then connect to redis through the redis client. The command is as follows:[root@ ~]# redis-cli 127.0.0.1:6379>
127.0.0.1:6379> CONFIG GET dir "dir" "/var/lib/redis" 127.0.0.1:6379>
save 900 1 #At least 1 within 900 seconds The key is changed, make a backup save 300 10 #At least 300 keys have been changed within 300 seconds, make a backupsave 60 10000 #At least 10,000 keys have been changed within 60 seconds, BackupWe can directly back up the data at this time through save. The command is as follows:
[root@ ~]# redis-cli 127.0.0.1:6379> save #数据备份 127.0.0.1:6379> #退出
service redis stop #停止redis服务
service redis start #启动redis服务
redis tutorial column on the PHP Chinese website.
The above is the detailed content of redis data import and export. For more information, please follow other related articles on the PHP Chinese website!