Redis 主从同步+哨兵
简介
通过使用 Redis 自带“主从同步+哨兵守护”功能提高Redis稳定性。
主从同步:保障数据主从数据实时同步。
哨兵:实时监控主redis如果故障,将从redis作为主使用。
环境:
- 系统:Centos7/Redhat7
- 服务:Redis4.0.11
- 服务器台数:1台(可多台)
- Redis服务数量:3个
- 192.168.1.100:6381(主)
- 192.168.1.100:6382(从)
- 192.168.1.100:6383(从)
Redis 主从同步
一、Redis主从同步搭建
1、解压缩包
tar -zxvf redis-4.0.11.tar.gz
2、移动到指定目录
mv redis-4.0.11 /usr/local/redis
3、移动到指定目录并编译安装
cd /usr/local/redis
make && make install
4、为每个Redis创建各自的目录
mkdir -p /usr/local/redis-ms/6381
mkdir -p /usr/local/redis-ms/6382
mkdir -p /usr/local/redis-ms/6383
5、将配置文件复制到创建目录下
cp /usr/local/redis/redis.conf /usr/local/redis-ms/6381/
cp /usr/local/redis/redis.conf /usr/local/redis-ms/6382/
cp /usr/local/redis/redis.conf /usr/local/redis-ms/6383/
6、redis 6381主 :修改如下配置参数
vim /usr/local/redis-ms/6381/redis.conf
# 任意ip都可以连接
bind 0.0.0.0
# 关闭保护,允许非本地连接
protected-mode no
# 端口号
port 6381
# 后台运行
daemonize yes
# 开启日志形式
appendonly yes
# 进程守护文件,就是存放该进程号相关信息的地方
pidfile "/var/run/redis_6381.pid"
# db等相关目录位置
dir /usr/local/redis-ms/6381/
# 缓存库数量
databases 50
# 设置redis密码
requirepass ""
# 设置主从复制密码
masterauth ""
7、redis 6382从 :修改如下配置参数
vim /usr/local/redis-ms/6382/redis.conf
# 任意ip都可以连接
bind 0.0.0.0
# 关闭保护,允许非本地连接
protected-mode no
# 端口号
port 6382
# 后台运行
daemonize yes
# 开启日志形式
appendonly yes
# 进程守护文件,就是存放该进程号相关信息的地方
pidfile "/var/run/redis_6382.pid"
# db等相关目录位置
dir /usr/local/redis-ms/6382/
# 缓存库数量
databases 50
# 设置redis密码
requirepass ""
# 设置主从复制密码
masterauth ""
# 主信息
slaveof 192.168.1.100 6381
8、redis 6383从 :修改如下配置参数
vim /usr/local/redis-ms/6383/redis.conf
# 任意ip都可以连接
bind 0.0.0.0
# 关闭保护,允许非本地连接
protected-mode no
# 端口号
port 6383
# 后台运行
daemonize yes
# 开启日志形式
appendonly yes
# 进程守护文件,就是存放该进程号相关信息的地方
pidfile "/var/run/redis_6383.pid"
# db等相关目录位置
dir /usr/local/redis-ms/6383/
# 缓存库数量
databases 50
# 设置redis密码
requirepass ""
# 设置主从复制密码
masterauth ""
# 主信息
slaveof 192.168.1.100 6381
9、启动
/usr/local/redis/src/redis-server /usr/local/redis-ms/6381/redis.conf
/usr/local/redis/src/redis-server /usr/local/redis-ms/6382/redis.conf
/usr/local/redis/src/redis-server /usr/local/redis-ms/6383/redis.conf
二、测试Redis主从同步
1、查看主从同步状态
/usr/local/redis/src/redis-cli -p 6381 -a 123456 info
# Server
redis_version:4.0.11
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:c471ec760376b22e
redis_mode:standalone
os:Linux 3.10.0-123.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.2
process_id:2788
run_id:3e7540f2dbcf55921c4e6bf5ac6de8f0c0d48625
tcp_port:6381
uptime_in_seconds:3196
uptime_in_days:0
hz:10
lru_clock:15365847
executable:/usr/local/redis/src/redis-server
config_file:/usr/local/redis-ms/6381/redis.conf # Clients
connected_clients:3
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0 # Memory
used_memory:1960456
used_memory_human:1.87M
used_memory_rss:10055680
used_memory_rss_human:9.59M
used_memory_peak:2001448
used_memory_peak_human:1.91M
used_memory_peak_perc:97.95%
used_memory_overhead:1935516
used_memory_startup:786632
used_memory_dataset:24940
used_memory_dataset_perc:2.12%
total_system_memory:499048448
total_system_memory_human:475.93M
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:5.13
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:1575644640
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:6475776
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:8507392
aof_current_size:113
aof_base_size:58
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:17
total_commands_processed:8041
instantaneous_ops_per_sec:2
total_net_input_bytes:402231
total_net_output_bytes:1561243
instantaneous_input_kbps:0.14
instantaneous_output_kbps:0.18
rejected_connections:0
sync_full:0
sync_partial_ok:1
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
evicted_keys:0
keyspace_hits:1
keyspace_misses:0
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:1179
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.1.100,port=6383,state=online,offset=224730,lag=1
master_replid:ca1e338e226a084983510088b89c15c556e7a945
master_replid2:f5f36c27bd86377158a1f2e85064f55924601b00
master_repl_offset:224871
second_repl_offset:22486
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:224871 # CPU
used_cpu_sys:2.09
used_cpu_user:1.02
used_cpu_sys_children:0.13
used_cpu_user_children:0.00 # Cluster
cluster_enabled:0 # Keyspace
db0:keys=1,expires=0,avg_ttl=0
redis状态
/usr/local/redis/src/redis-cli -p 6382 -a 123456 info
# Server
redis_version:4.0.11
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:c471ec760376b22e
redis_mode:standalone
os:Linux 3.10.0-123.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.2
process_id:2958
run_id:7907851a00ca97feba2e43c82112dda4ca8ba9b2
tcp_port:6382
uptime_in_seconds:70
uptime_in_days:0
hz:10
lru_clock:15366134
executable:/usr/local/redis/src/redis-server
config_file:/usr/local/redis-ms/6382/redis.conf # Clients
connected_clients:4
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0 # Memory
used_memory:1960496
used_memory_human:1.87M
used_memory_rss:10022912
used_memory_rss_human:9.56M
used_memory_peak:2042400
used_memory_peak_human:1.95M
used_memory_peak_perc:95.99%
used_memory_overhead:1935516
used_memory_startup:786632
used_memory_dataset:24980
used_memory_dataset_perc:2.13%
total_system_memory:499048448
total_system_memory_human:475.93M
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:5.11
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0 # Persistence
loading:0
rdb_changes_since_last_save:1
rdb_bgsave_in_progress:0
rdb_last_save_time:1575647152
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:0
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:8495104
aof_current_size:55
aof_base_size:55
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:5
total_commands_processed:161
instantaneous_ops_per_sec:2
total_net_input_bytes:11283
total_net_output_bytes:44463
instantaneous_input_kbps:0.19
instantaneous_output_kbps:0.23
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:1
pubsub_patterns:0
latest_fork_usec:806
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:slave
master_host:192.168.1.100
master_port:6381
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_repl_offset:4901
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:cdfb2756fa43e1d4dfce72986be98de38911dd38
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:4901
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:4901 # CPU
used_cpu_sys:0.05
used_cpu_user:0.01
used_cpu_sys_children:0.02
used_cpu_user_children:0.00 # Cluster
cluster_enabled:0 # Keyspace
db0:keys=1,expires=0,avg_ttl=0
redis状态
/usr/local/redis/src/redis-cli -p 6383 -a 123456 info
# Server
redis_version:4.0.11
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:c471ec760376b22e
redis_mode:standalone
os:Linux 3.10.0-123.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.2
process_id:2966
run_id:e345097b352029bbe43aeea0ed17a7c7c305ba90
tcp_port:6383
uptime_in_seconds:115
uptime_in_days:0
hz:10
lru_clock:15366180
executable:/usr/local/redis/src/redis-server
config_file:/usr/local/redis-ms/6383/redis.conf # Clients
connected_clients:4
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0 # Memory
used_memory:1960480
used_memory_human:1.87M
used_memory_rss:10027008
used_memory_rss_human:9.56M
used_memory_peak:1980560
used_memory_peak_human:1.89M
used_memory_peak_perc:98.99%
used_memory_overhead:1935516
used_memory_startup:786632
used_memory_dataset:24964
used_memory_dataset_perc:2.13%
total_system_memory:499048448
total_system_memory_human:475.93M
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:5.11
mem_allocator:jemalloc-4.0.3
active_defrag_running:0
lazyfree_pending_objects:0 # Persistence
loading:0
rdb_changes_since_last_save:1
rdb_bgsave_in_progress:0
rdb_last_save_time:1575647153
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:0
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:6397952
aof_current_size:55
aof_base_size:55
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:4
total_commands_processed:257
instantaneous_ops_per_sec:0
total_net_input_bytes:18203
total_net_output_bytes:65296
instantaneous_input_kbps:0.01
instantaneous_output_kbps:0.03
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:1
pubsub_patterns:0
latest_fork_usec:933
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:slave
master_host:192.168.1.100
master_port:6381
master_link_status:up
master_last_io_seconds_ago:1
master_sync_in_progress:0
slave_repl_offset:8073
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:cdfb2756fa43e1d4dfce72986be98de38911dd38
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:8073
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:8073 # CPU
used_cpu_sys:0.12
used_cpu_user:0.01
used_cpu_sys_children:0.01
used_cpu_user_children:0.00 # Cluster
cluster_enabled:0 # Keyspace
db0:keys=1,expires=0,avg_ttl=0
redis状态
2、进入主终端创建key
/usr/local/redis/src/redis-cli -p 6381 -a 123456 --raw
127.0.0.1:6381> set name 'xsk'
127.0.0.1:6381> get name
xsk
3、进入从终端查看同步状态
/usr/local/redis/src/redis-cli -p 6382 -a 123456 --raw
127.0.0.1:6381> get name
xsk
三、添加到系统服务
1、创建redis启动脚本存放目录
mkdir /usr/local/redis-ms/script
cd /usr/local/redis-ms/script/
2、创建启动脚本
vim ./start.sh
#!/bin/sh
/usr/local/redis/src/redis-server /usr/local/redis-ms/6381/redis.conf
/usr/local/redis/src/redis-server /usr/local/redis-ms/6382/redis.conf
/usr/local/redis/src/redis-server /usr/local/redis-ms/6383/redis.conf
3、创建停止脚本
vim ./stop.sh
#!/bin/sh
/usr/local/redis/src/redis-cli -p 6381 shutdown
/usr/local/redis/src/redis-cli -p 6382 shutdown
/usr/local/redis/src/redis-cli -p 6383 shutdown
4、创建重启脚本
vim ./restart.sh
#!/bin/sh
systemctl stop redis-ms
systemctl start redis-ms
5、赋值脚本权限
chmod 755 ./*
6、编写系统服务管理文件
vim /usr/lib/systemd/system/redis-ms.service
[Unit]
Description=redis-ms
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/redis-ms/script/start.sh
ExecStop=/usr/local/redis-ms/script/stop.sh
ExecReload=/usr/local/redis-ms/script/restart.sh
[Install]
WantedBy=multi-user.target
7、赋值权限
chmod 755 /usr/lib/systemd/system/redis-ms.service
8、重启服务并设置开机自启动
systemctl daemon-reload
systemctl enable redis-ms.service
systemctl restart redis-ms.service
Redis 哨兵
一、搭建哨兵
1、修改sentinel文件
vim /usr/local/redis/sentinel.conf
# 开启保护模式
protected-mode yes
# 任意IP都可链接
bind 0.0.0.0
# mymaster是Master的名称,192.168.0.100是Master的Ip。
# 1表示确认一个Master为O_DOWN最少需要多少个哨兵认可。
sentinel monitor mymaster 192.168.1.100 6381 1
# redis有登陆密码的话必须配置这项参数,设置密码
sentinel auth-pass mymaster 123456
# (默认30秒)指定Sentinel判定Master断线的时间。(单位为毫秒,判定为主观下线SDOWN)
sentinel down-after-milliseconds mymaster 10000
sentinel config-epoch redismaster 3
sentinel leader-epoch redismaster 3
2、启动
/usr/local/redis/src/redis-sentinel /usr/local/redis/sentinel.conf
二、添加系统服务
1、在执行脚本最下行添加命令
vim /usr/local/redis-ms/script/stop.sh
ps -aux | grep sentine |grep -v grep|awk '{print $2}'| xargs -I {} kill -9 {}
2、在执行脚本最下行添加命令
vim /usr/local/redis-ms/script/start.sh
nohup /usr/local/redis/src/redis-sentinel /usr/local/redis/sentinel.conf &
3、重启redis服务
systemctl daemon-reload
systemctl restart redis-ms.service
三、测试切换
1、关闭master后slave成为master
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.11 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in sentinel mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 26381
| `-._ `._ / _.-' | PID: 3032
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' 3032:X 07 Dec 00:20:49.244 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3032:X 07 Dec 00:20:49.244 # Sentinel ID is 4df58ef409ac6b52991173453736d113bd337f19
3032:X 07 Dec 00:20:49.244 # +monitor master mymaster 192.168.1.100 6381 quorum 1 3032:X 07 Dec 00:22:09.709 # +sdown master mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:09.709 # +odown master mymaster 192.168.1.100 6381 #quorum 1/1
3032:X 07 Dec 00:22:09.709 # +new-epoch 8
3032:X 07 Dec 00:22:09.709 # +try-failover master mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:09.710 # +vote-for-leader 4df58ef409ac6b52991173453736d113bd337f19 8
3032:X 07 Dec 00:22:09.710 # +elected-leader master mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:09.710 # +failover-state-select-slave master mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:09.811 # +selected-slave slave 192.168.1.100:6382 192.168.1.100 6382 @ mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:09.811 * +failover-state-send-slaveof-noone slave 192.168.1.100:6382 192.168.1.100 6382 @ mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:09.878 * +failover-state-wait-promotion slave 192.168.1.100:6382 192.168.1.100 6382 @ mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:10.585 # +promoted-slave slave 192.168.1.100:6382 192.168.1.100 6382 @ mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:10.585 # +failover-state-reconf-slaves master mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:10.661 * +slave-reconf-sent slave 192.168.1.100:6383 192.168.1.100 6383 @ mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:11.624 * +slave-reconf-inprog slave 192.168.1.100:6383 192.168.1.100 6383 @ mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:11.625 * +slave-reconf-done slave 192.168.1.100:6383 192.168.1.100 6383 @ mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:11.676 # +failover-end master mymaster 192.168.1.100 6381
3032:X 07 Dec 00:22:11.676 # +switch-master mymaster 192.168.1.100 6381 192.168.1.100 6382
3032:X 07 Dec 00:22:11.676 * +slave slave 192.168.1.100:6383 192.168.1.100 6383 @ mymaster 192.168.1.100 6382
3032:X 07 Dec 00:22:11.676 * +slave slave 192.168.1.100:6381 192.168.1.100 6381 @ mymaster 192.168.1.100 6382
3032:X 07 Dec 00:22:21.696 # +sdown slave 192.168.1.100:6381 192.168.1.100 6381 @ mymaster 192.168.1.100 6382
日志
Redis 主从同步+哨兵的更多相关文章
- redis 主从同步&哨兵模式&codis
主从同步 1.CPA原理 1. CPA原理是分布式存储理论的基石: C(一致性): A(可用性): P(分区容忍性); 2. 当主从网络无法连通时,修改操作无法同步到节点,所以“一致性”无法满足 ...
- 关于redis主从|哨兵|集群模式
关于redis主从.哨兵.集群的介绍网上很多,这里就不赘述了. 一.主从 通过持久化功能,Redis保证了即使在服务器重启的情况下也不会损失(或少量损失)数据,因为持久化会把内存中数据保存到硬盘上,重 ...
- redis主从同步故障切换及集群配置
一.redis是一中高性能的缓存数据库, 原理:1. 从服务器向主服务器发送 SYNC 命令.2. 接到 SYNC 命令的主服务器会调用BGSAVE 命令,创建一个 RDB 文件,并使用缓冲区记录接下 ...
- 自动配置redis主从和哨兵
redis shell 每次创建redis主从和哨兵服务,文件夹要复制好几个,配置文件改一大堆.繁琐还容易出错,就想通过shell脚本自动帮我配置好端口以及文件,下面就是脚本内容: redis-to ...
- redis主从|哨兵|集群模式
关于redis主从.哨兵.集群的介绍网上很多,这里就不赘述了. 一.主从 通过持久化功能,Redis保证了即使在服务器重启的情况下也不会损失(或少量损失)数据,因为持久化会把内存中数据保存到硬盘上,重 ...
- Redis 主从、哨兵Sentinel、Jedis
Redis 主从.哨兵Sentinel.Jedis 2017年02月15日 15:52:48 有且仅有 阅读数 6183 文章标签: redis主从sentineljedis 更多 分类专栏: 7/1 ...
- docker部署redis主从和哨兵
docker部署redis主从和哨兵 原文地址:https://www.jianshu.com/p/72ee9568c8ea 1主2从3哨兵 一.前期准备工作 1.电脑装有docker 2.假设本地i ...
- docker安装redis主从以及哨兵
docker安装redis主从以及哨兵 本文使用docker在四台机器上部署一主二从三哨兵的Redis主从结构. 服务器配置 192.168.102.128 主节点 centos7.5 192.168 ...
- Redis系列之(二):Redis主从同步,读写分离
1. Redis主从同步 Redis支持主从同步.数据可以从主服务器向任意数量的从服务器上同步,同步使用的是发布/订阅机制. 2. 配置主从同步 Mater Slave的模式,从Slave向Maste ...
随机推荐
- Spring Boot 启动以后然后再加载缓存数据 CommandLineRunner
实际应用中,我们会有在项目服务启动完成以后去加载一些数据或做一些事情(比如缓存)这样的需求. 为了解决这样的问题,Spring Boot 为我们提供了一个方法,通过实现接口 CommandLineRu ...
- Drools规则引擎-如果Fact对象参数为null如何处理
问题场景 在技术交流群(QQ:715840230)中有同学提出这样的问题: 往kiesession里面传入fact,如果不做输入检查fact里面有些字段可能是null值.但是如果在外面做输入检查,规则 ...
- MySQL UNION 查询
UNION 用来合并多个 SELECT 结果. 考察如下两个表: # t1 +----+---------+ | id | pattern | +----+---------+ | 1 | Divot ...
- C# QRBarCode
1. install-package barcode -v 4.0.2.2; 2. using IronBarCode; class Program { static void Main(string ...
- C# 判断(Excel)文件是否已经打开
using System.IO; using System.Runtime.InteropServices; [DllImport("kernel32.dll")] publi ...
- ASP.NET中WebService的创建和部署以及通过反射动态调用WebService
一.在ASP.NET中创建WebService 首先我们先创建一个ASP.NET Web 应用程序,此处我们以VS2017为例 点击新创建的项目,右键添加新建项,选择Web服务,输入名称后点击添加 这 ...
- ubuntu下查看本机IP地址
在终端输入: ifconfig -a 即可得解.出来的结果inet后就是你的ip地址
- Vue实战狗尾草博客管理平台第四章
本章主要内容如下: 填补上期的坑. iconfont仓库的关联,引入. 开发登录页面 填坑 上期中我们功能都已正常使用.但不知道有没有小伙伴测试过error页面,当访问地址不存在时,路由是否能正常挑战 ...
- bay——安装_RAC11g_LC_ASM方式_测试环境.txt
★★★____★☆★〓〓〓〓→VMware vSphere Client6.0 https://10.20.4.200/ 下载Vwmare IP:10.20.4.200-------账号:root-- ...
- [Go] golang实时监控日志文件的包tail
在linux中有一个tail命令,tail -f可以实时的监控文件新增加的内容,如果用代码实现这个逻辑,可以下载使用这个包go get github.com/hpcloud/tail/... 测试代码 ...