在lua方案里碰到了在redis集群中执行多键操作,Key要在同一slot的限制。
经查资料,说是要避免 Max redirect exception
,节点会因为某些场景发生阻塞(阻塞时间大于 clutser-node-timeout),被判断下线。
想来在多键命令执行时,节点是阻塞的,如果不做单slot限制,键槽所分布的节点都会受到阻塞的影响。
在lua方案里碰到了在redis集群中执行多键操作,Key要在同一slot的限制。
经查资料,说是要避免 Max redirect exception
,节点会因为某些场景发生阻塞(阻塞时间大于 clutser-node-timeout),被判断下线。
想来在多键命令执行时,节点是阻塞的,如果不做单slot限制,键槽所分布的节点都会受到阻塞的影响。
Lua 脚本功能是 Reids的一大亮点, 通过内嵌对 Lua 环境的支持,
Redis 解决了长久以来不能高效地处理 CAS (check-and-set) 命令的缺点。
并且可以通过组合使用多个命令, 轻松实现以前很难实现或者不能高效实现的模式。
该抢购方案基于Lua脚本,实际项目中可根据需要扩展命令。
why redis-cluster use 16384 slots? #2576
【原创】为什么Redis集群有16384个槽
看到这位博主的文章,感觉redis作者的考量很有意思。
打开集群的头文件,看了一下数据结构,不出所料是16384个槽
https://github.com/antirez/redis/blob/6.0.0/src/cluster.h
1 | /*----------------------------------------------------------------------------- |
1 | /\bsys_.*?\b/ |
match words begin with sys_
, as short as possible.
1 | find --name "*.xml" . |
If you search directly under a foldergrep -r
—recursive may more suitable.
1 | tr "[:lower:]" "[:upper:]" |
1 | awk '!a[$0]++{print}' |
when current line not show in below, print it.
1 | find -name "*.xml" | xargs grep -iohP '\bsys_.*?\b' | tr "[:lower:]" "[:upper:]" | awk '!a[$0]++{print}' |
Simple demonstration of segment-level locking caused by concurrency in an Oracle database
reprint:简单演示 Oracle 数据库并发导致段级锁(表级锁)
https://www.cnblogs.com/liuning8023/archive/2013/03/20/2971946.html
本文简单演示并发导致的行级锁。并发是两个以上的用户对同样的数据进行修改(包括插入、删除和修改)。锁的产生是因为并发。没有并发,就没有锁。并发的产生是因为系统需要,系统需要是因为用户需要。
This article briefly demonstrates row-level locking caused by concurrency. Concurrency is when two or more users make changes (including inserts, deletes, and modifications) to the same data. Locks occur because of concurrency. No concurrency, no locking. Concurrency occurs because the system needs it, and the system needs it because the user needs it.
Env/Componet | Description | Description |
---|---|---|
System | CentOS 7.3 | http://archive.kernel.org/centos-vault/7.3.1611/isos/x86_64/CentOS-7-x86_64-DVD-1611.iso |
Go | 1.11.4 | https://prometheus.io/download/#prometheus |
Prometheus | 2.6.0 | https://golang.org/dl/ |
Grafana | 5.4.2 | https://dl.grafana.com/oss/release/grafana-5.4.2-1.x86_64.rpm |
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
this pack may not necessaryyum install libffi-devel -y
1 | wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz |
python3.7 locate in /usr/local/bin
in default
we need to change default python2.7 to python3.7
1 | # backup |
modify pip
1
2
3
4# backup
mv /usr/bin/pip /usr/bin/pip.bak
# soft link
ln -s /usr/local/bin/pip3 /usr/bin/pip
yum
settingyum
not support python3, so we need point to python2 manually.
vi /usr/libexec/urlgrabber-ext-down
vi /usr/bin/yum
modify the first line to #! /usr/bin/python2.7
when npm install
error happen
check whether the web problem or the node version problem.
1 | node --version |
https://stackoverflow.com/questions/32791657/node-gyp-rebuild-build-error-make-failed-npm-install
https://segmentfault.com/q/1010000009734734
https://blog.csdn.net/weixin_38190050/article/details/99644735
brew install python3
origin | path |
---|---|
default(2.7) | /System/Library/Frameworks/Python.framework/Versions/2.7 |
brew(2.7/3.x) | /usr/local/Cellar/python |
pkg(3.x) | /Library/Frameworks/Python.framework/Versions/3.x |
vi ~/.bash_profile
1 | # Setting PATH for Python 2.7 |
vi ~/.bashrc
1 | alias python2='/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7' |
source ~/.bash_profile
source ~/.bashrc
1 | docker pull redislabs/redisearch:latest |
1 | <dependencies> |
Initializing the client with JedisPool:1
Client client = new Client("testing", "localhost", 6379);
Initializing the client with JedisSentinelPool:1
2
3
4
5
6
7
8
9
10private static final String MASTER_NAME = "mymaster";
private static final Set<String> sentinels;
static {
sentinels = new HashSet();
sentinels.add("localhost:7000");
sentinels.add("localhost:7001");
sentinels.add("localhost:7002");
}
...
Client client = new Client("testung", MASTER_NAME, sentinels);
1 | // Create schema |
1 | // Create document |
1 | // actual search |
1 | // aggregation query |
https://github.com/RediSearch/RediSearch
https://github.com/RediSearch/JRediSearch
git clone https://github.com/BurningBright/minishowcase
https://github.com/BurningBright/minishowcase