Redis集群做法的难点,百万并发客户端「实战」( 二 )
# chmod +x /usr/libexec/redis-shutdown# useradd -s /sbin/nologin redis# chown -R redis:redis /usr/local/redis# chown -R reids:redis /data/redis# yum install -y bash-completion--tt-darkmode-color: #999999;">192.168.30.128
# mkdir -p /data/redis # vim /usr/local/redis/redis.conf bind 192.168.30.128 #监听ip , 多个ip用空格分隔 daemonize yes #允许后台启动 logfile "/usr/local/redis/redis.log"#日志路径 dir /data/redis #数据库备份文件存放目录 masterauth 123456 #slave连接master密码 , master可省略 requirepass 123456 #设置master连接密码 , slave可省略 appendonly yes #在/data/redis/目录生成appendonly.aof文件 , 将每一次写操作请求都追加到appendonly.aof 文件中# echo 'vm.overcommit_memory=1' >> /etc/sysctl.conf # sysctl -p
192.168.30.129
# mkdir -p /data/redis # vim /usr/local/redis/redis.conf bind 192.168.30.129 daemonize yes logfile "/usr/local/redis/redis.log" dir /data/redis replicaof 192.168.30.128 6379 masterauth 123456 requirepass 123456 appendonly yes # echo 'vm.overcommit_memory=1' >> /etc/sysctl.conf# sysctl -p
192.168.30.130
# mkdir -p /data/redis# vim /usr/local/redis/redis.conf bind 192.168.30.130 daemonize yes logfile "/usr/local/redis/redis.log" dir /data/redis replicaof 192.168.30.128 6379 masterauth 123456 requirepass 123456 appendonly yes # echo 'vm.overcommit_memory=1' >> /etc/sysctl.conf # sysctl -p
# systemctl start redis
# redis-cli -h 192.168.30.128 -a 123456 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 192.168.30.128:6379> info replication # Replication role:master connected_slaves:2 slave0:ip=192.168.30.129,port=6379,state=online,offset=168,lag=1 slave1:ip=192.168.30.130,port=6379,state=online,offset=168,lag=1 master_replid:fb4941e02d5032ad74c6e2383211fc58963dbe90 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:168 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:168
# redis-cli -h 192.168.30.129 -a 123456 info replication Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. # Replication role:slave master_host:192.168.30.128 master_port:6379 master_link_status:up master_last_io_seconds_ago:1 master_sync_in_progress:0 slave_repl_offset:196 slave_priority:100 slave_read_only:1 connected_slaves:0 master_replid:fb4941e02d5032ad74c6e2383211fc58963dbe90 master_replid2:0000000000000000000000000000000000000000 master_repl_offset:196 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:196
数据演示
192.168.30.128:6379> keys *(empty list or set)192.168.30.128:6379> set key1 100OK192.168.30.128:6379> set key2 lzxOK192.168.30.128:6379> keys *1) "key1"2) "key2"123456789101112
【Redis集群做法的难点,百万并发客户端「实战」】
- 果粉有福了,苹果正式宣布新规,这个做法很库克
- 华为强行排除小米!而小米的做法却很亮眼!这次小米更有格局
- java 从零实现属于你的 redis 分布式锁
- HFL Redis_10_set类型底层存储数据结构
- 上海|全球科技集群100强发布,北京、上海、粤港三城跻身前十
- 为什么 Redis 单线程能支撑高并发?
- Redis流行的原因
- 摸方向盘就换挡、激光去污、磁悬浮雨刷,特斯拉尝试韭菜新做法
- 谁更有良心显而易见!关于手机屏幕,华为、OPPO做法差距明显
- C# Redis分布式锁 - 单节点