本文讲述一下如何docker话360开源的持久化的redis,即pika

dockerfile

FROM centos:7
RUN yum -y update
ADD pika-linux-x86_64-v2.2.6.tar.bz2 /opt
RUN mv /opt/pika-linux-x86_64-v2.2.6 /opt/pika-v2.2.6
ENV PIKA  /opt/pika-v2.2.6
ENV PATH ${PIKA}/bin:${PATH}
WORKDIR ${PIKA}

由于官方的Dockerfile没有指定centos版本,直接用latest,导致build起来有些问题,不同版本的类库有的仓库里头没有,相对费劲,另外直接make出来的版本目测又2+G,没研究怎么去瘦身,于是干脆还是用二进制的版本了

运行

docker run --name "PIKA" --rm -v /pika-data/db:/opt/pika-v2.2.6/db -p 9221:9221 pika:v2.2.6 pika -c /opt/pika-v2.2.6/conf/pika.conf

测试

redis-cli -h localhost -p 9221
localhost:9221> info
# Server
pika_version:2.2.6
pika_git_sha:e646201f53c5584294bdb2dece7b073f0d0e69b2
pika_build_compile_date: Oct 11 2017
os:Linux 4.4.0-62-generic x86_64
arch_bits:64
process_id:1
tcp_port:9221
thread_num:1
sync_thread_num:6
uptime_in_seconds:145
uptime_in_days:1
config_file:conf/pika.conf

# Data
db_size:146428
db_size_human:0M
compression:snappy
used_memory:4128
used_memory_human:0M
db_memtable_usage:4128
db_tablereader_usage:0

# Log
log_size:71104
log_size_human:0M
safety_purge:none
expire_logs_days:7
expire_logs_nums:10
binlog_offset:0 0

# Clients
connected_clients:1

# Stats
total_connections_received:1
instantaneous_ops_per_sec:0
total_commands_processed:1
is_bgsaving:No, , 0
is_slots_reloading:No, , 0
is_scaning_keyspace:No
is_compact:No
compact_cron:
compact_interval:

# Replication(MASTER)
role:master
connected_slaves:0

# Keyspace
# Time:1970-01-01 08:00:00
kv keys:0
hash keys:0
list keys:0
zset keys:0
set keys:0
localhost:9221> set key1 hello
OK
localhost:9221> get key1
"hello"
localhost:9221> exit

doc


codecraft
11.9k 声望2k 粉丝

当一个代码的工匠回首往事时,不因虚度年华而悔恨,也不因碌碌无为而羞愧,这样,当他老的时候,可以很自豪告诉世人,我曾经将代码注入生命去打造互联网的浪潮之巅,那是个很疯狂的时代,我在一波波的浪潮上留下...