• Centos7 使用docker 安装redis


    1、拉取Redis镜像

    docker pull redis

    2、 这里可以查看一下自己是否下载成功:

    [root@localhost redis-6379]# docker images redis
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    redis               latest              df5748206578        32 hours ago        98.3MB

    3、 创建目录(宿主机)

    3.1 配置文件目录

    mkdir -p /root/docker/redis-6379/conf
    在该目录下放置redis.conf配置文件
    注:目录可以自定义
    

    3.2 数据目录

    mkdir -p /root/docker/redis-6379/data

    4、启动容器,加载配置文件并持久化数据

    docker run -d --privileged=true -p 6379:6379 --restart always -v /root/docker/redis-6379/conf/redis.conf:/etc/redis/redis.conf -v /root/docker/redis-6379/data:/data --name myredis redis redis-server /etc/redis/redis.conf --appendonly yes --requirepass "123456"

    4.1 涉及到的命令行参数

    -d                                                  -> 以守护进程的方式启动容器
    -p 6379:6379                                        -> 绑定宿主机端口
    --name myredis                                      -> 指定容器名称
    --restart always                                    -> 开机启动
    --privileged=true                                   -> 提升容器内权限
    -v /root/docker/redis-6379/conf:/etc/redis/redis.conf    -> 映射配置文件
    -v /root/docker/redis-6379/data:/data                    -> 映射数据目录
    redis-server /etc/redis/redis.conf --appendonly yes -> 在容器里执行redis-server命令,打开redis持久化
    
    --requirepass                                                 -> 密码

    5、查看启动镜像

    docker ps

    6、进入到容器

    [root@localhost redis-6379]# docker exec -it myredis redis-cli
    127.0.0.1:6379> info
    # Server
    redis_version:5.0.9
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:c781f6fafb441952
    redis_mode:standalone
    os:Linux 3.10.0-693.el7.x86_64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    atomicvar_api:atomic-builtin
    gcc_version:8.3.0
    process_id:1
    run_id:3ea7227ca4dc4f17935e5b382f86a0a6aa2abbd9
    tcp_port:6379
    uptime_in_seconds:1253
    uptime_in_days:0
    hz:10
    configured_hz:10
    lru_clock:10464647
    executable:/data/redis-server
    config_file:/etc/redis/redis.conf
    
    # Clients
    connected_clients:2
    client_recent_max_input_buffer:2
    client_recent_max_output_buffer:0
    blocked_clients:0
    
    # Memory
    used_memory:875120
    used_memory_human:854.61K
    used_memory_rss:11177984
    used_memory_rss_human:10.66M
    used_memory_peak:875120
    used_memory_peak_human:854.61K
    used_memory_peak_perc:100.12%
    used_memory_overhead:857928
    used_memory_startup:791312
    used_memory_dataset:17192
    used_memory_dataset_perc:20.51%
    allocator_allocated:1500440
    allocator_active:1806336
    allocator_resident:8699904
    total_system_memory:16650436608
    total_system_memory_human:15.51G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    used_memory_scripts:0
    used_memory_scripts_human:0B
    number_of_cached_scripts:0
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    allocator_frag_ratio:1.20
    allocator_frag_bytes:305896
    allocator_rss_ratio:4.82
    allocator_rss_bytes:6893568
    rss_overhead_ratio:1.28
    rss_overhead_bytes:2478080
    mem_fragmentation_ratio:13.42
    mem_fragmentation_bytes:10344864
    mem_not_counted_for_evict:0
    mem_replication_backlog:0
    mem_clients_slaves:0
    mem_clients_normal:66616
    mem_aof_buffer:0
    mem_allocator:jemalloc-5.1.0
    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:1587521698
    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:3
    total_commands_processed:35
    instantaneous_ops_per_sec:0
    total_net_input_bytes:992
    total_net_output_bytes:36972
    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:a0468cb6b4456287c809c15b0ea788f4348fe8b9
    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.971191
    used_cpu_user:1.097652
    used_cpu_sys_children:0.006025
    used_cpu_user_children:0.004464
    
    # Cluster
    cluster_enabled:0
    
    # Keyspace

    至此redis 安装完毕

  • 相关阅读:
    DOM基础
    9个实用的Javascript代码高亮脚本
    去掉超链接虚线框去掉chrome浏览器中input或textarea在得到焦点时出现黄色边框和取消可以拖动大小
    我的Gvim配置文件
    收集的一些有关UED的团队和个人博客
    JS函数:返回下一个元素节点而不是下一个节点
    分享一款图片导航效果 Animated Slideshow Navigation
    原生javascript写的Tab菜单(函数版)
    单个select语句实现MySQL查询统计次数
    mysql 语句case when
  • 原文地址:https://www.cnblogs.com/ningy1009/p/12750416.html
Copyright © 2020-2023  润新知