文章来源:https://www.cnblogs.com/hello-tl/p/9239474.html

1.添加镜像

# docker pull redis:4.0

2.在/data下新建文件夹redis,进入redis文件夹新建文件夹conf4.0

# mkdir /data
# mkdir /data/redis/conf4.0

3.创建并写入 redis.conf

# vim /data/redis/conf4.0/redis.conf
内容
bind 0.0.0.0
# 端口
port 6379
# 持久化
appendonly yes requirepass password

4.执行命令启动

# docker run -d -ti -p 6379:6379 --net docker_default \
-v /data/redis/conf4.0/redis.conf:/usr/local/etc/redis/redis.conf \
-v /data/redis/data:/data --restart always --name redis4.0 \
--sysctl net.core.somaxconn=1024 \
redis redis-server /usr/local/etc/redis/redis.conf

5.执行命令解说

1、-p是指启动的端口
2、第二行指定了配置的位置,命令指的是刚刚复制的配置,配置中有端口、密码等重要参数
3、第三行开始的是指定数据存储位置,--restart always是自动重启,--name redis4.0设置容器的名字为redis4.0
4、第四行设置tcp内核参数,默认512
5、启动镜像名和服务、配置(固定不能变)

6.简单操作

[root@localhost conf4.0]# docker run -it redis:4.0 redis-cli -h 172.17.0.1 -p 6379 -a password
172.17.0.1:6379> info
# Server
redis_version:4.0.10
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:5df2417984e896d3
redis_mode:standalone
os:Linux 3.10.0-862.3.3.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:6.3.0
process_id:1
run_id:facf14d5495779acb1e50c574d7479fd89c9dfe7
tcp_port:6379
uptime_in_seconds:527
uptime_in_days:0
hz:10
lru_clock:3506205
executable:/data/redis-server
config_file:/usr/local/etc/redis/redis.conf # Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0 # Memory
used_memory:849384
used_memory_human:829.48K
used_memory_rss:8159232
used_memory_rss_human:7.78M
used_memory_peak:849384
used_memory_peak_human:829.48K
used_memory_peak_perc:100.12%
used_memory_overhead:836150
used_memory_startup:786520
used_memory_dataset:13234
used_memory_dataset_perc:21.05%
total_system_memory:1910042624
total_system_memory_human:1.78G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:9.60
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0 # Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1530232334
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size: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_last_write_status:ok
aof_last_cow_size:0
aof_current_size:0
aof_base_size:0
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0 # Stats
total_connections_received:1
total_commands_processed:2
instantaneous_ops_per_sec:0
total_net_input_bytes:59
total_net_output_bytes:10168
instantaneous_input_kbps:0.00
instantaneous_output_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
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec: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 # Replication
role:master
connected_slaves:0
master_replid:42f75f1fc5e74d69b502af5af925870b8ffceaf6
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:0.44
used_cpu_user:0.17
used_cpu_sys_children:0.01
used_cpu_user_children:0.00 # Cluster
cluster_enabled:0 # Keyspace

文章来源:https://www.cnblogs.com/hello-tl/p/9239474.html

最新文章

  1. dede新建模型中自定义联动类别调用及修改方法
  2. CMS .NET 程序框架 从2.0/3.5升级到4.0 版本后 需要调整的地方
  3. List<T>的使用
  4. MS CRM 2011的自定义和开发(11)——插件(plugin)开发(一)
  5. Remove LUN from OCFS2
  6. sql脚本太大无法打开的解决办法
  7. DBCP数据源
  8. 关于Eclipse中的egit的常规使用和模板
  9. Android 支付宝接入时常见的问题
  10. SGU114-Telecasting station
  11. protobuf(Protocol Buffers)java初体验
  12. 程序猿进化 - 在拉钩子1024对APE节讲座计划
  13. Monkey源码分析之事件注入
  14. Angular 4 自定义组件封装遇见的一些事儿
  15. linux中时间命令详解
  16. NO.10: 在operator=中处理 "自我赋值"
  17. Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
  18. Thinkphp 关联模型
  19. [python] 初学python,级联菜单输出
  20. Shell脚本 | 一键获取安卓应用活动名

热门文章

  1. AFHTTPSessionManager下载文件 及下载中 进度条处理,进度条处理需要特别注意,要加载NSRunLoop 中
  2. redis集群模式
  3. netty与MQ使用心得
  4. Codeforces Round #396 (Div. 2) E
  5. 修正 FreeBSD 字体锯齿问题
  6. Springboot的static和templates
  7. 113 Path Sum II 路径总和 II
  8. C51 笔记
  9. 编译运行第一个Java程序——通过示例学习Java编程3
  10. 【转】HashMap 和 HashTable 到底哪不同 ?