• redis集群安装多端口多实例部署


    目标(本文达成的结果,配对关系可能会变):

    先在131上进行操作

    1.下载redis

    http://download.redis.io/releases/redis-5.0.2.tar.gz

    2.解压

    [testapp@k8s-node2 ~]$ mkdir redis

    [testapp@k8s-node2 ~]$ cd redis 

    上传文件

    [testapp@k8s-node2 ~/redis]$ tar -zxvf redis-5.0.2.tar.gz

    3.修改/usr/local/bin/权限

    su - root

    chmod 777 /usr/local/bin/

    su - testapap

    建立文件夹

    [testapp@k8s-node2 ~/redis]$ mkdir redis_cluster
    
    [testapp@k8s-node2 ~/redis]$ mkdir logs
    
    [testapp@k8s-node2 ~/redis]$ touch logs/redis_run.logs
    
    [testapp@k8s-node2 ~/redis]$ cp /redis-5.0.2/redis.conf .
    [testapp@k8s-node1 ~/redis]$ ll
    总用量 1908
    drwxrwxr-x 2 testapp testapp      77 8月  14 17:00 logs
    drwxrwxr-x 6 testapp testapp     309 11月 22 2018 redis-5.0.2
    -rw-rw-r-- 1 testapp testapp 1952989 8月  14 15:33 redis-5.0.2.tar.gz
    drwxrwxr-x 2 testapp testapp     268 8月  14 18:56 redis_cluster

    [testapp@k8s-node1 ~/redis]$ pwd
    /home/ap/testapp/redis

     

    4.修改配置文件

    port 6380 //端口(从节点使用6381端口)

    #bind 127.0.0.1 //需要注释掉该配置

    daemonize yes //redis后台运行

    logfile “/home/ap/testapp/redis/logs/redis_run.log”//配置redis日志路径

    pidfile /home/ap/testapp/redis/redis_cluster/redis_6380.pid //redis的进程文件

    appendonly yes //aof日志开启 有需要就开启,它会每次写操作都记录一条日志 

    dir /home/ap/testapp/redis/redis_cluster/ //数据库备份的文件放置的路径

    Protected-mode no //是否开启保护模式

    cluster-enabled yes //开启集群 把注释#去掉

    cluster-config-file /home/ap/testappl/redis/redis_cluster/nodes_6380.conf //集群的配置

    cluster-node-timeout 15000 //请求超时 默认15秒,可自行设置

    5.安装

    cd redis-5.0.2

    make && make install

    6.启动

    /home/ap/testapp/redis/redis-5.0.2/src/redis-server /home/ap/testapp/redis/redis_cluster/redis.conf

     ps -ef | grep redis

    7.关闭防墙

    systemctl status firewalld //查看防火墙状态
    systemctl is-enabled firewalld //查看开机是否启动防火墙服务
    systemctl stop firewalld //关闭防火墙
    systemctl disable firewalld //禁用防火墙(系统启动时不启动防火墙服务)

     8.组成集群

    关闭6380

    /home/ap/testapp/software/redis/redis-5.0.2/src/redis-cli -c -p 6380 shutdown

    配置集群conf

    cp redis.conf redis6380.conf

    cp redis.conf redis6381.conf ##并更改内容中6380 为6381

    cp redis.conf redis6382.conf ##并更改内容中6380 为6382

    rm redis.conf 

    依次启动6380 6381 6382

    /home/ap/testapp/redis/redis-5.0.2/src/redis-server /home/ap/testapp/redis/redis_cluster/redis6380.conf

    /home/ap/testapp/redis/redis-5.0.2/src/redis-server /home/ap/testapp/redis/redis_cluster/redis6381.conf

     /home/ap/testapp/redis/redis-5.0.2/src/redis-server /home/ap/testapp/redis/redis_cluster/redis6382.conf

    再在192.168.111.132重复1--8

    组成集群

    /home/ap/testapp/software/redis/redis-5.0.2/src/redis-cli --cluster create 192.168.111.131:6380 192.168.111.131:6381 192.168.111.131:6382 192.168.111.132:6380 192.168.111.132:6381 192.168.111.132:6382 --cluster-replicas 1

    [testapp@k8s-node1 ~/redis/redis_cluster]$ /home/ap/testapp/redis/redis-5.0.2/src/redis-cli --cluster create  192.168.111.131:6380 192.168.111.131:6381 192.168.111.131:6382 192.168.111.132:6380 192.168.111.132:6381 192.168.111.132:6382 --cluster-replicas 1
    >>> Performing hash slots allocation on 6 nodes...
    Master[0] -> Slots 0 - 5460
    Master[1] -> Slots 5461 - 10922
    Master[2] -> Slots 10923 - 16383
    Adding replica 192.168.111.132:6381 to 192.168.111.131:6380
    Adding replica 192.168.111.131:6382 to 192.168.111.132:6380
    Adding replica 192.168.111.132:6382 to 192.168.111.131:6381
    M: 078d0050ee8502ac2e21fd26b63924d5fca1c384 192.168.111.131:6380
       slots:[0-5460] (5461 slots) master
    M: f1b97d85a94a309b9c67e6b50104cc2e6c2be6b3 192.168.111.131:6381
       slots:[10923-16383] (5461 slots) master
    S: c8952a45cf7019bb1dfd8f8e029dc3415d65b214 192.168.111.131:6382
       replicates a799a7cf8c7a14bbc72f7411322895e0ff3d4952
    M: a799a7cf8c7a14bbc72f7411322895e0ff3d4952 192.168.111.132:6380
       slots:[5461-10922] (5462 slots) master
    S: 301acfbb7929a0416911f892efadfad8a5bf38f9 192.168.111.132:6381
       replicates 078d0050ee8502ac2e21fd26b63924d5fca1c384
    S: b56997d7fbbe5df8257733c3ad017edbeb4bdaff 192.168.111.132:6382
       replicates f1b97d85a94a309b9c67e6b50104cc2e6c2be6b3
    Can I set the above configuration? (type 'yes' to accept): yes ##输入yes
    >>> Nodes configuration updated
    >>> Assign a different config epoch to each node
    >>> Sending CLUSTER MEET messages to join the cluster
    Waiting for the cluster to join
    ......
    >>> Performing Cluster Check (using node 192.168.111.131:6380)
    M: 078d0050ee8502ac2e21fd26b63924d5fca1c384 192.168.111.131:6380
       slots:[0-5460] (5461 slots) master
       1 additional replica(s)
    S: b56997d7fbbe5df8257733c3ad017edbeb4bdaff 192.168.111.132:6382
       slots: (0 slots) slave
       replicates f1b97d85a94a309b9c67e6b50104cc2e6c2be6b3
    S: c8952a45cf7019bb1dfd8f8e029dc3415d65b214 192.168.111.131:6382
       slots: (0 slots) slave
       replicates a799a7cf8c7a14bbc72f7411322895e0ff3d4952
    M: a799a7cf8c7a14bbc72f7411322895e0ff3d4952 192.168.111.132:6380
       slots:[5461-10922] (5462 slots) master
       1 additional replica(s)
    M: f1b97d85a94a309b9c67e6b50104cc2e6c2be6b3 192.168.111.131:6381
       slots:[10923-16383] (5461 slots) master
       1 additional replica(s)
    S: 301acfbb7929a0416911f892efadfad8a5bf38f9 192.168.111.132:6381
       slots: (0 slots) slave
       replicates 078d0050ee8502ac2e21fd26b63924d5fca1c384
    [OK] All nodes agree about slots configuration.
    >>> Check for open slots...
    >>> Check slots coverage...
    [OK] All 16384 slots covered.
    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ 

    成功搞定

    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ ll
    总用量 228
    -rw-rw-r-- 1 testapp testapp    92 8月  14 18:56 appendonly.aof
    -rw-r--r-- 1 testapp testapp   175 8月  14 18:56 dump.rdb
    -rw-rw-r-- 1 testapp testapp   957 8月  14 18:55 flushCluster.sh
    -rw-r--r-- 1 testapp testapp   817 8月  14 18:56 nodes-6380.conf
    -rw-r--r-- 1 testapp testapp   817 8月  14 18:56 nodes-6381.conf
    -rw-r--r-- 1 testapp testapp   817 8月  14 18:56 nodes-6382.conf
    -rw-rw-r-- 1 testapp testapp 62340 8月  14 18:30 redis6380.conf
    -rw-rw-r-- 1 testapp testapp     6 8月  14 18:55 redis_6380.pid
    -rw-rw-r-- 1 testapp testapp 62344 8月  14 16:57 redis6381.conf
    -rw-rw-r-- 1 testapp testapp     6 8月  14 18:55 redis_6381.pid
    -rw-rw-r-- 1 testapp testapp 62344 8月  14 16:59 redis6382.conf
    -rw-rw-r-- 1 testapp testapp     6 8月  14 18:55 redis_6382.pid
    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ pwd
    /home/ap/testapp/software/redis/redis_cluster
    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ 

    如果失败(重试时报Node xxx is not empty)可以用下面脚本来清除后再试

    [testapp@k8s-node1 ~/redis/redis_cluster]$ cat flushCluster.sh 
    ##判断参数
    if [ $# -eq 0 ]
    then
        echo -e "usage: sh $0 ip 
    exit!!" 
        exit
    fi
    
    ##删除文件
    rm /home/ap/testapp/redis/redis_cluster/appendonly.aof /home/ap/testapp/redis/redis_cluster/dump.rdb /home/ap/testapp/redis/redis_cluster/nodes-*.conf
    echo "remove appendonly.aof dump.rdb nodes-*.conf,but will be re-created once restart done"
    
    
    ##清除redsi库
    
    for port in 6380 6381 6382
    do 
    
    ##清除redsi库
    /home/ap/testapp/redis/redis-5.0.2/src/redis-cli -c -h $1 -p ${port} <<EOF 2>/dev/null
    flushdb
    cluster reset
    exit
    /
    EOF
    
    echo "reflushdb redis $1:$port finished"
    ##关闭服务
    /home/ap/testapp/redis/redis-5.0.2/src/redis-cli -c -p ${port} shutdown
    echo "shut down redis service on  $1:$port finished"
    
    ##启动服务
    /home/ap/testapp/redis/redis-5.0.2/src/redis-server /home/ap/testapp/redis/redis_cluster/redis${port}.conf
    echo "start redis service on  $1:$port finished"
    done
    
    echo "all port restart finished"

    9.为集群中的每一个节点设置密码

    编写批量启动脚本

    [testapp@k8s-node1 ~/redis/redis_cluster]$ pwd
    /home/ap/testapp/redis/redis_cluster
    [testapp@k8s-node1 ~/redis/redis_cluster]$ ll
    总用量 236
    -rw-rw-r-- 1 testapp testapp    92 8月  14 18:56 appendonly.aof
    -rw-r--r-- 1 testapp testapp   175 8月  14 18:56 dump.rdb
    -rw-rw-r-- 1 testapp testapp   957 8月  14 18:55 flushCluster.sh
    -rw-r--r-- 1 testapp testapp   817 8月  14 18:56 nodes-6380.conf
    -rw-r--r-- 1 testapp testapp   817 8月  14 18:56 nodes-6381.conf
    -rw-r--r-- 1 testapp testapp   817 8月  14 18:56 nodes-6382.conf
    -rw-rw-r-- 1 testapp testapp 62340 8月  14 18:30 redis6380.conf
    -rw-rw-r-- 1 testapp testapp     6 8月  14 18:55 redis_6380.pid
    -rw-rw-r-- 1 testapp testapp 62344 8月  14 16:57 redis6381.conf
    -rw-rw-r-- 1 testapp testapp     6 8月  14 18:55 redis_6381.pid
    -rw-rw-r-- 1 testapp testapp 62344 8月  14 16:59 redis6382.conf
    -rw-rw-r-- 1 testapp testapp     6 8月  14 18:55 redis_6382.pid
    -rw-rw-r-- 1 testapp testapp   337 8月  14 19:30 startAll.sh
    -rw-rw-r-- 1 testapp testapp   220 8月  14 19:31 stopAll.sh
    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ cat startAll.sh 
    /home/ap/testapp/software/redis/redis-5.0.2/src/redis-server /home/ap/testapp/redis/redis_cluster/redis6380.conf
    /home/ap/testapp/software/redis/redis-5.0.2/src/redis-server /home/ap/testapp/redis/redis_cluster/redis6381.conf
    /home/ap/testapp/software/redis/redis-5.0.2/src/redis-server /home/ap/testapp/redis/redis_cluster/redis6382.conf
    
    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ cat stopAll.sh 
    /home/ap/testapp/redis/redis-5.0.2/src/redis-cli -c -p 6380 shutdown
    /home/ap/testapp/redis/redis-5.0.2/src/redis-cli -c -p 6381 shutdown
    /home/ap/testapp/redis/redis-5.0.2/src/redis-cli -c -p 6382 shutdown
    
    [testapp@k8s-node1 ~/redis/redis_cluster]$ 

     修改每个redis638*.conf

     masterauth <master-password>  改为  masterauth test@123

    requirepass foobared   改为 requirepass test@123

    一向比较懒的我

    [testapp@k8s-node2 ~/redis/redis_cluster]$  sed 's/# masterauth <master-password>/masterauth test@123/g' redis638*.conf|grep test@123 ##尝试修改,并显示结果
    masterauth test@123
    masterauth test@123
    masterauth test@123
    [testapp@k8s-node2 ~/software/redis/redis_cluster]$  sed -i 's/# masterauth <master-password>/masterauth test@123/g' redis638*.conf  ##加-i表示真正修改源文件

    同理

    [testapp@k8s-node2 ~/redis/redis_cluster]$  sed  's/# requirepass foobared/requirepass test@123/g' redis638*.conf|grep test@123
    masterauth test@123
    requirepass test@123
    masterauth test@123
    requirepass test@123
    masterauth test@123
    requirepass test@123
    [testapp@k8s-node2 ~/redis/redis_cluster]$  sed  -i 's/# requirepass foobared/requirepass test@123/g' redis638*.conf

    验证

    [testapp@k8s-node2 ~/software/redis/redis_cluster]$ grep test@123 redis638*.conf
    redis6380.conf:masterauth test@123
    redis6380.conf:requirepass test@123
    redis6381.conf:masterauth test@123
    redis6381.conf:requirepass test@123
    redis6382.conf:masterauth test@123
    redis6382.conf:requirepass test@123

    然后重启

    sh stopAll.sh

    sh startAll.sh

    [testapp@k8s-node2 ~/redis/redis_cluster]$ sh stopAll.sh 
    [testapp@k8s-node2 ~/redis/redis_cluster]$ sh startAll.sh 
    [testapp@k8s-node2 ~/redis/redis_cluster]$ ps -ef|grep redis
    testapp   28886      1  0 20:01 ?        00:00:00 /home/ap/testapp/redis/redis-5.0.2/src/redis-server *:6380 [cluster]
    testapp   28891      1  0 20:01 ?        00:00:00 /home/ap/testapp/redis/redis-5.0.2/src/redis-server *:6381 [cluster]
    testapp   28896      1  0 20:01 ?        00:00:00 /home/ap/testapp/redis/redis-5.0.2/src/redis-server *:6382 [cluster]
    testapp   28904  27515  0 20:01 pts/0    00:00:00 grep --color=auto redis
    [testapp@k8s-node2 ~/software/redis/redis_cluster]$ pwd
    /home/ap/testapp/software/redis/redis_cluster
    [testapp@k8s-node2 ~/software/redis/redis_cluster]$ 

    验证,不输入密码,报NOAUTH Authentication required

    9.1集群相关信息查看

    9.1.1集群状态

    redis-cli -h ip -p 9379 -a password cluster info
    9.1.2.集群节点信息
    redis-cli -h ip -p 9379 -a password cluster nodes
    9.1.3.节点内存、cpu、key数量等信息(每个节点都需查看)
    redis-cli -h ip -p 9379 -a password info
    9.1.4.从redis集群中查看key(只需要连接master节点查看)
    a.查看该节点的所有key
    redis-cli -h ip -p 9379 -a password keys *
    b.查看key的value值
    redis-cli -h ip -p 9379 -a password -c get key
    c.查看key值得有效期
    redis-cli -h ip -p 9379 -a password -c ttl key

    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ /home/ap/testapp/software/redis/redis-5.0.2/src/redis-cli -c -h 192.168.111.131 -p 6380  cluster info ##查看集群信息
    NOAUTH Authentication required.
    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ /home/ap/testapp/software/redis/redis-5.0.2/src/redis-cli -c -h 192.168.111.131 -p 6380 -a test@123 cluster info
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    cluster_state:ok
    cluster_slots_assigned:16384
    cluster_slots_ok:16384
    cluster_slots_pfail:0
    cluster_slots_fail:0
    cluster_known_nodes:6
    cluster_size:3
    cluster_current_epoch:6
    cluster_my_epoch:1
    cluster_stats_messages_ping_sent:638
    cluster_stats_messages_pong_sent:498
    cluster_stats_messages_sent:1136
    cluster_stats_messages_ping_received:498
    cluster_stats_messages_pong_received:525
    cluster_stats_messages_received:1023
    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ /home/ap/testapp/software/redis/redis-5.0.2/src/redis-cli -c -h 192.168.111.131 -p 6380 -a test@123 cluster nodes ##查看集群结点信息
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    301acfbb7929a0416911f892efadfad8a5bf38f9 192.168.111.132:6381@16381 slave 078d0050ee8502ac2e21fd26b63924d5fca1c384 0 1565784658000 5 connected
    b56997d7fbbe5df8257733c3ad017edbeb4bdaff 192.168.111.132:6382@16382 slave f1b97d85a94a309b9c67e6b50104cc2e6c2be6b3 0 1565784659541 6 connected
    f1b97d85a94a309b9c67e6b50104cc2e6c2be6b3 192.168.111.131:6381@16381 master - 0 1565784656518 2 connected 10923-16383
    078d0050ee8502ac2e21fd26b63924d5fca1c384 192.168.111.131:6380@16380 myself,master - 0 1565784657000 1 connected 0-5460
    c8952a45cf7019bb1dfd8f8e029dc3415d65b214 192.168.111.131:6382@16382 slave a799a7cf8c7a14bbc72f7411322895e0ff3d4952 0 1565784658534 4 connected
    a799a7cf8c7a14bbc72f7411322895e0ff3d4952 192.168.111.132:6380@16380 master - 0 1565784660549 4 connected 5461-10922
    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ 
    [testapp@k8s-node1 ~/software/redis/redis_cluster]$ /home/ap/testapp/software/redis/redis-5.0.2/src/redis-cli -c -h 192.168.111.131 -p 6380 -a test@123 info ##查看节点节点内存、cpu、key数量等信息
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    # Server
    redis_version:5.0.2
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:c55a3c91ae2e868
    redis_mode:cluster
    os:Linux 3.10.0-957.el7.x86_64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    atomicvar_api:atomic-builtin
    gcc_version:4.8.5
    process_id:21623
    run_id:bde9ca1163e34126efb47de9ee76c589dd979b89
    tcp_port:6380
    uptime_in_seconds:665
    uptime_in_days:0
    hz:10
    configured_hz:10
    lru_clock:5503626
    executable:/home/ap/testapp/software/redis/redis-5.0.2/src/redis-server
    config_file:/home/ap/testapp/software/redis/redis_cluster/redis6380.conf
    
    # Clients
    connected_clients:2
    client_recent_max_input_buffer:2
    client_recent_max_output_buffer:0
    blocked_clients:0
    
    # Memory
    used_memory:2395096
    used_memory_human:2.28M
    used_memory_rss:8044544
    used_memory_rss_human:7.67M
    used_memory_peak:2395096
    used_memory_peak_human:2.28M
    used_memory_peak_perc:100.05%
    used_memory_overhead:2316538
    used_memory_startup:1184448
    used_memory_dataset:78558
    used_memory_dataset_perc:6.49%
    allocator_allocated:2488720
    allocator_active:2715648
    allocator_resident:6713344
    total_system_memory:1019797504
    total_system_memory_human:972.55M
    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.09
    allocator_frag_bytes:226928
    allocator_rss_ratio:2.47
    allocator_rss_bytes:3997696
    rss_overhead_ratio:1.20
    rss_overhead_bytes:1331200
    mem_fragmentation_ratio:3.45
    mem_fragmentation_bytes:5712592
    mem_not_counted_for_evict:0
    mem_replication_backlog:1048576
    mem_clients_slaves:16914
    mem_clients_normal:66600
    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:1565784065
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:0
    rdb_current_bgsave_time_sec:-1
    rdb_last_cow_size:4390912
    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:92
    aof_base_size:92
    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:19
    total_commands_processed:652
    instantaneous_ops_per_sec:0
    total_net_input_bytes:25411
    total_net_output_bytes:4547
    instantaneous_input_kbps:0.02
    instantaneous_output_kbps:0.00
    rejected_connections:0
    sync_full:1
    sync_partial_ok:0
    sync_partial_err:1
    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:98873
    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:1
    slave0:ip=192.168.111.132,port=6381,state=online,offset=896,lag=1
    master_replid:bb5feffa6c709a7daac8fe92e722e85f067da375
    master_replid2:0000000000000000000000000000000000000000
    master_repl_offset:896
    second_repl_offset:-1
    repl_backlog_active:1
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:1
    repl_backlog_histlen:896
    
    # CPU
    used_cpu_sys:1.147768
    used_cpu_user:0.126526
    used_cpu_sys_children:0.085297
    used_cpu_user_children:0.000000
    
    # Cluster
    cluster_enabled:1
    
    # Keyspace

    9.2 redis.config配置

    查看文件中生效配置,即非空非注释行

    [testapp@k8s-node2 ~/redis/redis_cluster]$ grep -v "^#" redis6380.conf|grep -v "^$"
    protected-mode no
    port 6380
    tcp-backlog 511
    timeout 0
    tcp-keepalive 300
    daemonize yes
    supervised no
    pidfile /home/ap/testapp/redis/redis_cluster/redis_6380.pid
    loglevel notice
    logfile "/home/ap/testapp/redis/logs/redis_run.log"
    databases 16
    always-show-logo yes
    save 900 1
    save 300 10
    save 60 10000
    stop-writes-on-bgsave-error yes
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    dir /home/ap/testapp/redis/redis_cluster
    masterauth test@123
    replica-serve-stale-data yes
    replica-read-only yes
    repl-diskless-sync no
    repl-diskless-sync-delay 5
    repl-disable-tcp-nodelay no
    replica-priority 100
    requirepass test@123
    lazyfree-lazy-eviction no
    lazyfree-lazy-expire no
    lazyfree-lazy-server-del no
    replica-lazy-flush no
    appendonly yes
    appendfilename "appendonly.aof"
    appendfsync everysec
    no-appendfsync-on-rewrite no
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    aof-load-truncated yes
    aof-use-rdb-preamble yes
    lua-time-limit 5000
    cluster-enabled yes
    cluster-config-file /home/ap/testapp/redis/redis_cluster/nodes-6380.conf
    cluster-node-timeout 15000
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    latency-monitor-threshold 0
    notify-keyspace-events ""
    hash-max-ziplist-entries 512
    hash-max-ziplist-value 64
    list-max-ziplist-size -2
    list-compress-depth 0
    set-max-intset-entries 512
    zset-max-ziplist-entries 128
    zset-max-ziplist-value 64
    hll-sparse-max-bytes 3000
    stream-node-max-bytes 4096
    stream-node-max-entries 100
    activerehashing yes
    client-output-buffer-limit normal 0 0 0
    client-output-buffer-limit replica 256mb 64mb 60
    client-output-buffer-limit pubsub 32mb 8mb 60
    hz 10
    dynamic-hz yes
    aof-rewrite-incremental-fsync yes
    rdb-save-incremental-fsync yes
    [testapp@k8s-node2 ~/redis/redis_cluster]$ 

     9.3持久化相关的配置

    rdb快照模式

    save 900 1
    save 300 10
    save 60 10000
    stop-writes-on-bgsave-error yes
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    rdb-save-incremental-fsync yes

    AOF增量日志模式
    appendonly yes
    appendfilename "appendonly.aof"
    appendfsync everysec
    no-appendfsync-on-rewrite no
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    aof-load-truncated yes
    aof-use-rdb-preamble yes
    aof-rewrite-incremental-fsync yes
     

    10 集群使用

    192.168.111.132:6380中加入keyhello值
    [testapp@k8s-node1 ~/redis/redis_cluster]$ /home/ap/testapp/redis/redis-5.0.2/src/redis-cli -c -h 192.168.111.131 -p 6380 -a test@123
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    192.168.111.131:6380> set keyhello valueworld
    -> Redirected to slot [8118] located at 192.168.111.132:6380
    OK
    192.168.111.132:6380> keys *
    1) "keyhello"
    192.168.111.132:6380> exit
    192.168.111.131:6381加入keyhello131-6381
    [testapp@k8s-node2 ~/redis/redis_cluster]$ /home/ap/testapp/redis/redis-5.0.2/src/redis-cli -c -h 192.168.111.131 -p 6381 -a test@123
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    192.168.111.131:6381> keys *
    (empty list or set)
    192.168.111.131:6381> set keyhello1316381 worldhaha
    -> Redirected to slot [3527] located at 192.168.111.131:6380
    OK
    192.168.111.131:6380> keys
    (error) ERR wrong number of arguments for 'keys' command
    192.168.111.131:6380> keys *
    1) "keyhello1316381"
    192.168.111.131:6380> exit
    [testapp@k8s-node2 ~/software/redis/redis_cluster]$ 

    客户端查看

    11 问题及解决

    https://blog.csdn.net/wenwen360360/article/details/70162169 

    Linux安装redis时报gcc:未找到命令错误

    https://blog.csdn.net/weixin_38109191/article/details/81531086

    tar解压出错:gzip: stdin: unexpected end of file的解决

    Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    install: 无法创建普通文件"/usr/local/bin/redis-server": 权限不够
    make[1]: *** [install] 错误 1
    make[1]: 离开目录“/home/ap/testapp/software/redis/redis-5.0.2/src”
    make: *** [install] 错误 2
    [testapp@k8s-node1 ~/software/redis/redis-5.0.2]$ ll

    [testapp@k8s-node1 /usr/local]$ su - root
    密码:
    上一次登录:三 8月 14 15:10:59 CST 2019pts/0 上
    [root@k8s-node1 ~]# chmod 777 -R /usr/local/bin/
    [root@k8s-node1 ~]# 

    [ERR] Node xxx is not empty. Either the node already knows other no...

    https://blog.csdn.net/xianzhixianzhixian/article/details/82777767

  • 相关阅读:
    Python基础之初始编码
    Excel图表编辑---表格移动,样式修改
    Python基础之Python的变量、常量
    刷题62. Unique Paths
    刷题56. Merge Intervals
    刷题55. Jump Game
    刷题53. Maximum Subarray
    刷题49. Group Anagrams
    刷题48. Rotate Image
    刷题46. Permutations
  • 原文地址:https://www.cnblogs.com/pu20065226/p/11352118.html
Copyright © 2020-2023  润新知