250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- SpringBoot
- PostgreSQL
- Docker
- STS
- oracle
- MySQL
- Source
- MSSQL
- Open Source
- JavaScript
- ubuntu
- Spring Boot
- Exception
- 설정
- maven
- Tomcat
- 오픈소스
- jpa
- Core Java
- AJAX
- spring
- JDBC
- myBatis
- IntelliJ
- Thymeleaf
- 문서
- git
- Python
- Eclipse
- error
Archives
- Today
- Total
헤르메스 LIFE
[Redis] Docker에 Redis 설치하기 + 비밀번호 본문
728x90
Redis는 In Memory Key, Value 데이터 구조의 데이터를 저장할 수 있는 비정형 데이터 베이스입니다.
메모리 DB 이기때문에 속도가 빠르고, 영속성 및 다양한 데이터 구조와 같은 부가적인 기능을 지원하고 있어서, Key-Value DB 중 가장 인기가 좋습니다.
https://db-engines.com/en/ranking/key-value+store
Redis 최신버전 설치
Redis 7.0.5 버전을 설치하였습니다. ( info 명령 참조 )
Docker 설치
https://hermeslog.tistory.com/497?category=302346
Docker에 Redis 설치
? redis 다운로드
$>docker pull redis
Using default tag: latest
latest: Pulling from library/redis
a603fa5e3b41: Pull complete
77631c3ef092: Pull complete
ed3847cf62b8: Pull complete
261a8b530567: Pull complete
7d9005a8af6d: Pull complete
828da1afb5be: Pull complete
Digest: sha256:1e3207c292225b6dd21cb74d59255748a50e8f739dd983040df38fa913927cf1
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
? 다운로드된 Images 확인
$>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 3358aea34e8c 5 days ago 117MB
mysql latest d1dc36cf8d9e 9 months ago 519MB
postgres <none> e94a3bb61224 11 months ago 374MB
? redis-net 이라는 Docker Network를 생성한다.
$>docker network create redis-net
? Docker Redis 컨테이너 생성
? -d : 백그라운드 실행
? -p : 포트 포딩 - 6379번 포트로 들어온 내용은 6379번 포트로 포딩을 해주겟다는 내용
? -v : host 와 연결할 폴더 지정
? --name Container 이름을 설정해줍니다.
? docker exec -> run a command on an existing/running container
? docker run -> create a new container from an image, and run the command there
? --requirepass : Redis 비밀번호 설정
$>docker run --name redis_boot -p 6379:6379 --network redis-net -v redis_boot:/data -d redis redis-server --appendonly yes --requirepass "1234"
? docker에 설치된 컨테이너 목록 조회
? -a, --all: 컨테이너 모두 보기: 멈춘 컨테이너도 보여줍니다.
$>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
856611a265bf redis "docker-entrypoint.s…" 48 seconds ago Up 47 seconds 0.0.0.0:6379->6379/tcp redis_boot
? Docker Redis 컨테이너 접속방법 #1 - Docker의 Redis-Cli로 접속
? --rm : 실행할때, 컨테이너 id 가 존재하면 삭제후 run.
$>docker run -it --network redis-net --rm redis redis-cli -h redis_boot
? 권한 없음.
redis_boot:6379> ping
(error) NOAUTH Authentication required.
? 권한 없음.
redis_boot:6379> keys *
(error) NOAUTH Authentication required.
? 권한 접속
redis_boot:6379> auth 1234
OK
redis_boot:6379> ping
PONG
? keys 조회
redis_boot:6379> keys *
(empty array)
redis_boot:6379>
? Docker Redis 컨테이너 접속방법 #2
$>docker run -it --network redis-net --rm redis bash
root@a6ebaf9d585d:/data# redis-cli -h redis_boot
redis_boot:6379> keys *
redis_boot:6379> info
# Server
redis_version:7.0.5
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:aab17434977410f1
redis_mode:standalone
os:Linux 5.10.102.1-microsoft-standard-WSL2 x86_64
arch_bits:64
monotonic_clock:POSIX clock_gettime
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:10.2.1
process_id:1
process_supervised:no
run_id:fb2c9205c01316df82a7acca46e776b5c5a3d712
tcp_port:6379
server_time_usec:1669131102811681
uptime_in_seconds:104047
uptime_in_days:1
hz:10
configured_hz:10
lru_clock:8186718
executable:/data/redis-server
config_file:
io_threads_active:0
# Clients
connected_clients:1
cluster_connections:0
maxclients:10000
client_recent_max_input_buffer:8
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0
# Memory
used_memory:937896
used_memory_human:915.91K
used_memory_rss:13389824
used_memory_rss_human:12.77M
used_memory_peak:1114944
used_memory_peak_human:1.06M
used_memory_peak_perc:84.12%
used_memory_overhead:865040
used_memory_startup:863048
used_memory_dataset:72856
used_memory_dataset_perc:97.34%
allocator_allocated:947832
allocator_active:1228800
allocator_resident:5758976
total_system_memory:16470282240
total_system_memory_human:15.34G
used_memory_lua:31744
used_memory_vm_eval:31744
used_memory_lua_human:31.00K
used_memory_scripts_eval:0
number_of_cached_scripts:0
number_of_functions:0
number_of_libraries:0
used_memory_vm_functions:32768
used_memory_vm_total:64512
used_memory_vm_total_human:63.00K
used_memory_functions:184
used_memory_scripts:184
used_memory_scripts_human:184B
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.30
allocator_frag_bytes:280968
allocator_rss_ratio:4.69
allocator_rss_bytes:4530176
rss_overhead_ratio:2.33
rss_overhead_bytes:7630848
mem_fragmentation_ratio:14.63
mem_fragmentation_bytes:12474816
mem_not_counted_for_evict:8
mem_replication_backlog:0
mem_total_replication_buffers:0
mem_clients_slaves:0
mem_clients_normal:1800
mem_cluster_links:0
mem_aof_buffer:8
mem_allocator:jemalloc-5.2.1
active_defrag_running:0
lazyfree_pending_objects:0
lazyfreed_objects:0
# Persistence
loading:0
async_loading:0
current_cow_peak:0
current_cow_size:0
current_cow_size_age:0
current_fork_perc:0.00
current_save_keys_processed:0
current_save_keys_total:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1669027055
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_saves:0
rdb_last_cow_size:0
rdb_last_load_keys_expired:0
rdb_last_load_keys_loaded:0
aof_enabled:1
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_rewrites:0
aof_rewrites_consecutive_failures:0
aof_last_write_status:ok
aof_last_cow_size:0
module_fork_in_progress:0
module_fork_last_cow_size:0
aof_current_size:0
aof_base_size:0
aof_pending_rewrite:0
aof_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0
# Stats
total_connections_received:2
total_commands_processed:3
instantaneous_ops_per_sec:0
total_net_input_bytes:89
total_net_output_bytes:342736
total_net_repl_input_bytes:0
total_net_repl_output_bytes:0
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
instantaneous_input_repl_kbps:0.00
instantaneous_output_repl_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:1638
evicted_keys:0
evicted_clients:0
total_eviction_exceeded_time:0
current_eviction_exceeded_time:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
pubsubshard_channels:0
latest_fork_usec:0
total_forks:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
total_active_defrag_time:0
current_active_defrag_time:0
tracking_total_keys:0
tracking_total_items:0
tracking_total_prefixes:0
unexpected_error_replies:0
total_error_replies:0
dump_payload_sanitizations:0
total_reads_processed:5
total_writes_processed:7
io_threaded_reads_processed:0
io_threaded_writes_processed:0
reply_buffer_shrinks:2
reply_buffer_expands:0
# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:c62a336eed9e4f006700889a902dc06962af5d70
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:55.908705
used_cpu_user:55.048625
used_cpu_sys_children:0.000000
used_cpu_user_children:0.001235
used_cpu_sys_main_thread:55.899684
used_cpu_user_main_thread:55.054256
# Modules
# Errorstats
# Cluster
cluster_enabled:0
# Keyspace
비밀번호 설정 및 변경
? 접속
$> docker run -it --network redis-net --rm redis redis-cli -h redis_boot
? 비밀번호확인
edis_boot:6379> config get requirepass
(error) NOAUTH Authentication required.
? 비밀번호접속
redis_boot:6379> auth 1234
OK
? 비밀번호확인
redis_boot:6379> config get requirepass
1) "requirepass"
2) "1234"
? 비밀번호변경
redis_boot:6379> config set requirepass test
OK
redis_boot:6379> quit
? 재접속
$> docker run -it --network redis-net --rm redis redis-cli -h redis_boot
redis_boot:6379> auth test
OK
redis_boot:6379> keys *
(empty array)
redis_boot:6379> config get requirepass
1) "requirepass"
2) "test"
redis_boot:6379>
GUI Tools - RedisInsight
Redis 에서 만든 Tools 입니다.
https://redis.com/redis-enterprise/redis-insight/
설치 후 Tool을 오픈하면 아래와 같이 Docker 에 설치된 Redis 목록을 확인 할 수 있습니다.
https://hermeslog.tistory.com/737
728x90
'Spring Framework' 카테고리의 다른 글
[Log] Log4Jdbc 설정 (0) | 2024.02.23 |
---|---|
[SpringBoot] Docker에 PostgreSQL 설치 / 연결하기 (2) | 2024.02.04 |
[전자정부프레임워크] 샘플 프로젝트 생성 dev4.1 (0) | 2023.06.27 |
[전자정부프레임워크] 전자정부프레임워크 설치 (0) | 2023.06.22 |
[개발환경] Spring + Maven + MyBatis + PostgreSQL Upgrade (0) | 2023.05.23 |