Using codis to realize Redis distributed cluster management

1, Understanding of Redis
codis is a distributed redis solution. For the upper application, there is no obvious difference between connecting to the redis proxy and connecting to the native Redis Server (some commands are not supported). The upper application can be used as a stand-alone redis. The lower layer of codis will handle the request forwarding, non-stop data migration and other work. For all the things behind, for the front The client side of is transparent. It can be simply considered that the connection behind is a redis service with unlimited memory. Of course, the official 3.0 of redis released a stable version some time ago. 3.0 supports the clustering function. The implementation principle of codis is similar to the clustering function of 3.0.

2, Architecture implementation

go installation

Experimental environment:
server:172.25.23.2 

[root@server2 redis]# tar go1.8.linux-amd64.tar.gz
[root@server2 redis]# tar zxf go1.8.linux-amd64.tar.gz -C /usr/local/
[root@server2 redis]# cd
[root@server2 ~]# vim .bash_profile 
[root@server2 ~]# source .bash_profile 
[root@server2 ~]# go env
[root@server2 ~]# go env GOPATH
/root/go #Executed environment directory
[root@server2 redis]# mkdir -p go/src/github.com/CodisLabs[root@server2 redis]# unzip codis-release3.2.zip -d go/src/github.com/CodisLabs
[root@server2 redis]# cd go/src/github.com/CodisLabs/codis-release3.2/
[root@server2 codis-release3.2]# ls
admin    deploy      extern           pkg        version
ansible  doc         Godeps           README.md  wandoujia_license.txt
cmd      Dockerfile  Makefile         scripts
config   example     MIT-LICENSE.txt  vendor
[root@server2 codis-release3.2]# cd ..
[root@server2 CodisLabs]# ls
codis-release3.2
[root@server2 CodisLabs]# mv codis-release3.2/ codis
[root@server2 CodisLabs]# cd codis/
[root@server2 codis]# pwd
/root/redis/go/src/github.com/CodisLabs/codis
[root@server2 codis]# yum install -y git autoconf gcc 
[root@server2 codis]make



[root@server2 codis]# ./admin/codis-dashboard-admin.sh start
/root/redis/go/src/github.com/CodisLabs/codis/admin/../config/dashboard.toml
starting codis-dashboard ... 
[root@server2 codis]# ./admin/codis-proxy-admin.sh start
/root/redis/go/src/github.com/CodisLabs/codis/admin/../config/proxy.toml
starting codis-proxy ... 
[root@server2 codis]# ./admin/codis-server-admin.sh start
/root/redis/go/src/github.com/CodisLabs/codis/admin/../config/redis.conf
starting codis-server ... 
[root@server2 codis]# ./admin/codis-fe-admin.sh start

starting codis-fe ... 

[root@server2 codis]# cd config/
[root@server2 config]# ls
dashboard.toml  proxy.toml  redis.conf  sentinel.conf
[root@server2 config]# grep -v ^# redis.conf  > redis1.conf 
[root@server2 config]# vim redis1.conf 
[root@server2 config]# grep -v ^# redis.conf  > redis2.conf 
[root@server2 config]# grep -v ^# redis.conf  > redis3.conf 
[root@server2 config]# grep -v ^# redis.conf  > redis4.conf 
[root@server2 config]# cd ..
[root@server2 codis]# ./bin/codis-server 
8824:C 12 Aug 23:39:34.887 # Warning: no config file specified, using the default config. In order to specify a config file use ./bin/codis-server /path/to/redis.conf
8824:M 12 Aug 23:39:34.888 * Increased maximum number of open files to 10032 (it was originally set to 1024).
8824:M 12 Aug 23:39:34.888 # Creating Server TCP listening socket *:6379: bind: Address already in use
[root@server2 codis]# ./bin/codis-server config/redis1.conf 
[root@server2 codis]# ./bin/codis-server config/redis2.conf 
[root@server2 codis]# ./bin/codis-server config/redis3.conf 
[root@server2 codis]# cd bin/
[root@server2 bin]# ./redis-cli -p 19000
127.0.0.1:19000> set hello world



Testing:

[root@server2 bin]# ./redis-cli -p 19000
127.0.0.1:19000> get hello
"world"
127.0.0.1:19000> get iii
"www"




Tags: Redis github Linux vim

Posted on Sun, 05 Jan 2020 19:32:52 -0800 by suma237