Ubuntu部署redis6.0集群
作者:互联网
root@redis:/data/redis-6# ll total 2452 drwxr-xr-x 8 root root 4096 Jun 18 18:00 ./ drwxr-xr-x 4 root root 4096 Jun 18 17:40 ../ -rw-r--r-- 1 root root 2476542 Jun 18 11:54 redis-6.2.6.tar.gz drwxrwxr-x 8 root root 4096 Jun 19 10:27 redis-6379/ drwxr-xr-x 8 root root 4096 Jun 19 10:27 redis-6380/ drwxr-xr-x 8 root root 4096 Jun 19 10:27 redis-6381/ drwxr-xr-x 8 root root 4096 Jun 19 10:27 redis-6382/ drwxr-xr-x 8 root root 4096 Jun 19 10:27 redis-6383/ drwxr-xr-x 8 root root 4096 Jun 19 10:27 redis-6384/
配置文件
bind 0.0.0.0 protected-mode yes port 6384 # 修改端口 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes pidfile /var/run/redis_6379.pid loglevel notice logfile "" databases 16 always-show-logo no set-proc-title yes proc-title-template "{title} {listen-addr} {server-mode}" save 3600 1 save 300 100 save 60 10000 stop-writes-on-bgsave-error no rdbcompression yes rdbchecksum yes dbfilename dump.rdb rdb-del-sync-files no dir ./ masterauth test123456 replica-serve-stale-data yes replica-read-only yes repl-diskless-sync no repl-diskless-sync-delay 30 repl-diskless-load disabled repl-ping-replica-period 10 repl-timeout 60 repl-disable-tcp-nodelay no repl-backlog-size 512mb repl-backlog-ttl 3600 replica-priority 100 acllog-max-len 128 requirepass test123456 maxclients 10000 maxmemory 4294967296 lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no replica-lazy-flush no lazyfree-lazy-user-del no lazyfree-lazy-user-flush no oom-score-adj no oom-score-adj-values 0 200 800 disable-thp yes 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 nodes-6379.conf cluster-node-timeout 15000 cluster-replica-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage no 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 jemalloc-bg-thread yes
启动
root@redis:/data/redis-6/redis-6379# redis-server redis.conf root@redis:/data/redis-6/redis-6379# cd ../redis-6380/ root@redis:/data/redis-6/redis-6380# redis-server redis.conf root@redis:/data/redis-6/redis-6380# cd ../redis-6381/ root@redis:/data/redis-6/redis-6381# redis-server redis.conf root@redis:/data/redis-6/redis-6381# cd ../redis-6382/ root@redis:/data/redis-6/redis-6382# redis-server redis.conf root@redis:/data/redis-6/redis-6382# cd ../redis-6383/ root@redis:/data/redis-6/redis-6383# redis-server redis.conf root@redis:/data/redis-6/redis-6383# cd ../redis-6384/ root@redis:/data/redis-6/redis-6384# redis-server redis.conf root@redis:/data/redis-6/redis-6384# netstat -ntpl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 1007/systemd-resolv tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1067/sshd: /usr/sbi tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 1569/sshd: root@pts tcp 0 0 0.0.0.0:16379 0.0.0.0:* LISTEN 2343/redis-server 0 tcp 0 0 0.0.0.0:16380 0.0.0.0:* LISTEN 2370/redis-server 0 tcp 0 0 0.0.0.0:16381 0.0.0.0:* LISTEN 2386/redis-server 0 tcp 0 0 0.0.0.0:16382 0.0.0.0:* LISTEN 2396/redis-server 0 tcp 0 0 0.0.0.0:16383 0.0.0.0:* LISTEN 2408/redis-server 0 tcp 0 0 0.0.0.0:16384 0.0.0.0:* LISTEN 2420/redis-server 0 tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 2343/redis-server 0 tcp 0 0 0.0.0.0:6380 0.0.0.0:* LISTEN 2370/redis-server 0 tcp 0 0 0.0.0.0:6381 0.0.0.0:* LISTEN 2386/redis-server 0 tcp 0 0 0.0.0.0:6382 0.0.0.0:* LISTEN 2396/redis-server 0 tcp 0 0 0.0.0.0:6383 0.0.0.0:* LISTEN 2408/redis-server 0 tcp 0 0 0.0.0.0:6384 0.0.0.0:* LISTEN 2420/redis-server 0 tcp6 0 0 :::22 :::* LISTEN 1067/sshd: /usr/sbi tcp6 0 0 ::1:6010 :::* LISTEN 1569/sshd: root@pts
创建集群
redis-cli -a test123456 --cluster create 172.25.0.132:6379 172.25.0.132:6380 172.25.0.132:6381 172.25.0.132:6382 172.25.0.132:6383 172.25.0.132:6384 --cluster-replicas 1
从节点设置主节点密码
[root@redis-s1 ~]# redis-cli -h 192.168.7.101 -p 6380 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.7.101:6380> CONFIG SET masterauth 123456
OK
查看集群节点
127.0.0.1:6384> cluster nodes bb35dbe6f97a7e5c1a1619a294d8501ffcf29831 172.25.0.132:6384@16384 myself,slave e802a611ccb02aa220c5a1e805c09284e345a342 0 1655695728000 3 connected 92d29c3e558896c33a2604850306bc74c1dcf3aa 172.25.0.132:6380@16380 master - 0 1655695730178 2 connected 5461-10922 e802a611ccb02aa220c5a1e805c09284e345a342 172.25.0.132:6381@16381 master - 0 1655695728109 3 connected 10923-16383 042ab78ca8bac057e7b6373f27f3974ea2353aab 172.25.0.132:6382@16382 slave 3cb5f6bfad64eeae4296d730654a7c5e12edac4a 0 1655695729000 1 connected 3cb5f6bfad64eeae4296d730654a7c5e12edac4a 172.25.0.132:6379@16379 master - 0 1655695726038 1 connected 0-5460 33d0a6147f9605be93357266df13016e1238f360 172.25.0.132:6383@16383 slave 92d29c3e558896c33a2604850306bc74c1dcf3aa 0 1655695729146 2 connected
测试
root@redis:/data/redis-6/redis-6384# redis-cli -p 6379 # 主写入 127.0.0.1:6379> auth test123456 OK 127.0.0.1:6379> set b 2 OK root@redis:/data/redis-6/redis-6384# redis-cli -p 6382 -c #从查看,-c表示集群模式 127.0.0.1:6382> auth test123456 OK
标签:redis6.0,0.0,redis,tcp,server,集群,Ubuntu,yes,root 来源: https://www.cnblogs.com/rtnb/p/16395947.html