반응형

# 시나리오

운영 중간에 데이터가 모두 지워 (flushall)

 

#운영 상태 확인 (AOF 활성화 되어 있는지 체크)

 

127.0.0.1:6379> config get append*

1) "appendfsync"

2) "everysec"

3) "appendonly"

4) "yes"

127.0.0.1:6379> exit

[root@localhost redis-stable]# ls

00-RELEASENOTES  appendonly.aof  BUGS  CONTRIBUTING  COPYING  deps  dump.rdb  INSTALL  Makefile  MANIFESTO  README.md  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src 

 

# KEY 생성

 

127.0.0.1:6379> set test1 value1

OK

127.0.0.1:6379> get test1

"value1"

 

127.0.0.1:6379> select 1

OK

127.0.0.1:6379[1]> keys *

(empty list or set)

127.0.0.1:6379[1]> set DB1 value1

OK

 

# 데이터 삭제

 

127.0.0.1:6379[1]> flushall

29652:M 20 Dec 00:17:26.880 * DB saved on disk

OK

 

127.0.0.1:6379[1]> select 1

OK

127.0.0.1:6379[1]> keys *

(empty list or set)

 

127.0.0.1:6379[1]> select 0

OK

127.0.0.1:6379> keys *

(empty list or set)

 

 

# 레디스 종료

 

[root@localhost redis-stable]# stop

29652:M 20 Dec 00:18:00.271 # User requested shutdown...

29652:M 20 Dec 00:18:00.271 * Calling fsync() on the AOF file.

29652:M 20 Dec 00:18:00.346 * Saving the final RDB snapshot before exiting.

29652:M 20 Dec 00:18:00.413 * DB saved on disk

29652:M 20 Dec 00:18:00.413 * Removing the pid file.

29652:M 20 Dec 00:18:00.413 # Redis is now ready to exit, bye bye...

[1]+  Done                    /root/redis-stable/src/redis-server /root/redis-stable/redis.conf

 

 

# AOF 파일 편집

 

[root@localhost redis-stable]# cat appendonly.aof

*2

$6

SELECT

$1

0

*3

$3

set

$5

test1

$6

value1

*2

$6

SELECT

$1

1

*3

$3

set

$3

DB1

$6

value1

*1

$8

flushall    <-- 명령어 삭제 저장

 

 

#레디스 기동

 

[root@localhost redis-stable]# start

[1] 29703

[root@localhost redis-stable]# 29703:C 20 Dec 00:18:55.170 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

29703:C 20 Dec 00:18:55.170 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=29703, just started

29703:C 20 Dec 00:18:55.170 # Configuration loaded

29703:M 20 Dec 00:18:55.171 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._

           _.-``__ ''-._

      _.-``    `.  `_.  ''-._           Redis 4.0.6 (00000000/0) 64 bit

  .-`` .-```.  ```\/    _.,_ ''-._

 (    '      ,       .-`  | `,    )     Running in standalone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 29703

  `-._    `-._  `-./  _.-'    _.-'

 |`-._`-._    `-.__.-'    _.-'_.-'|

 |    `-._`-._        _.-'_.-'    |           http://redis.io

  `-._    `-._`-.__.-'_.-'    _.-'

 |`-._`-._    `-.__.-'    _.-'_.-'|

 |    `-._`-._        _.-'_.-'    |

  `-._    `-._`-.__.-'_.-'    _.-'

      `-._    `-.__.-'    _.-'

          `-._        _.-'

              `-.__.-'

 

29703:M 20 Dec 00:18:55.174 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

29703:M 20 Dec 00:18:55.174 # Server initialized

29703:M 20 Dec 00:18:55.174 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

29703:M 20 Dec 00:18:55.174 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

29703:M 20 Dec 00:18:55.174 # !!! Warning: short read while loading the AOF file !!!

29703:M 20 Dec 00:18:55.174 # !!! Truncating the AOF at offset 116 !!!

29703:M 20 Dec 00:18:55.174 # AOF loaded anyway because aof-load-truncated is enabled

29703:M 20 Dec 00:18:55.174 * DB loaded from append only file: 0.000 seconds

29703:M 20 Dec 00:18:55.174 * Ready to accept connections

 

[root@localhost redis-stable]# redis

127.0.0.1:6379> keys *

1) "test1"

127.0.0.1:6379> get test1

"value1"

 

127.0.0.1:6379> select 1

OK

127.0.0.1:6379[1]> keys *

1) "DB1"

127.0.0.1:6379[1]> get DB1

"value1"


반응형

+ Recent posts