Codis is an agent-based, high-performance Redis cluster solution, developed using the go language, and is now widely used in pea pods and other companies, including our company.
Codis is compared to common Redis cluster scenarios.
Image.png
In the construction, the individual feel that Redis cluster build up very easy, but redis-cluster no GUI management panel, in addition to query data found Redis-cluster client implementation Redis-cluster protocol is more troublesome.
While Codis is in use, it is like a normal connection to a Redis client, but codis some commands are not supported. Do it
Look at this official architecture diagram to help us understand the architecture of the CODIS and facilitate the operation of the latter
Image.png
Process
- If you compile and install Codis, install Codis-dependent libraries, the Golang libraries installed with Yum are in the/usr/lib/golang directory by default, so it's not a hassle to compile.
yum install golang -yyum install autoconf -y
- Download the source file and compile
cd /usr/lib/golangmkdir -p src/github.com/CodisLabscd src/github.com/CodisLabs/git clone https://github.com/CodisLabs/codis.git -b release3.2cd codismake
And then get the compiled files, no surprises can be compiled successfully, remember to install the Linux Developer Kit
Image.png
- Before running the command, take a look at what the Run command contains
In the config directory, there are configuration files that run several components that can be automatically generated using commands
codis-dashboard --default-config #生成codis-dashboard的默认配置文件codis-proxy --default-config #生成codis-proxy的默认配置文件
If you are familiar with distributed coordination components such as ZOOKEEPER,ETCD, the configuration files generated by both commands can be specified using zookeeper, or ETCD, Jodis is a CODIS-based Redis client.
Image.pngimage.png
Related shell script, look at the contents of the Admin directory, can understand, modify the next configuration file or something
- Running the cluster
./admin/codis-proxy-admin.sh start #dashboard提供REST API管理codis的集群./admin/codis-proxy-admin.sh start #codis代理,使用的时候连接的是codis-proxy./admin/codis-fe-admin.sh start #fe,用来提供GUI管理codis的
At this point, we have access to the Codis management interface, access to http://127.0.0.1:9090, this time Codis management panel is basically empty.
- Running a Redis server, like a regular Redis server, can set up slave and other related
./redis-server /etc/redis/redis_6379.conf # 记得设置redis绑定地址或者认证相关./redis-server /etc/redis/redis_6380.conf #这个设置为6379的slave
Set to slave for Redis, specify Slaveof 127.0.0.1:6379.
Working in the admin panel of Codis-fe
First add Codis-proxy
Image.png
Then add the Redis-group, you can add different groups, and then add servers to the group, note that Data Center and group, normally the first server added in each group is master , the next is slave, even if you add another master node, click the Green Repair button, the new master will become slave.
Image.png
- Test, pay attention to the above picture, I added two codis-proxy, and then 4 redis-server, we can do the test.
Image.png
- Connected to different codis-proxy above the data obtained is the same, so when we configure multiple proxies, where the proxy is hung off, it can be used normally, in addition, through the management interface, we can dynamically add redis-server.
Watch out.
It's not a hassle to set up a cluster and refer to the official documentation, and after completing a complete set of processes, remind some of the points that need to be noticed when building.
- Management panel, in the Management Codis-proxy section, you can see our command execution, command assigned to that host.
- After adding the new Redis-server, do not forget to migrate the slots, if the production environment migration slot to pay attention to the timing.
- Redis-proxy can configure different data-center, I think this can be specified when the client uses the tool.
Configure multiple proxies, connect different proxies to obtain the data are consistent, proxy proxy is more than Redis-master, the data on the back end of the redis-server is also fragmented storage.
If you have more than one redis-master configured, you can also say Redis-group, and each master stores part of the data.
At last
Paper on the end of the shallow, in the company generally has a dedicated operations to responsible for this part of the maintenance, to ensure high availability of relevant content. In addition to really set up after Cods, feel codis than redis-cluster use some, in addition to build a complex point, the concept of a little more, follow-up is very simple.
Reference
- Cluster Redis large scale production practice
- Codis Tutorials