Codis is a distributed Redis solution. For upper tier applications, there is no significant difference between connecting to Codis Proxy and connecting to native Redis Server( List of unsupported commands ), the upper layer application can be used like a stand-alone Redis. The bottom layer of Codis will handle request forwarding, non-stop data migration and other work. Everything behind is transparent to the front client. It can be simply considered that the rear connection is a Redis service with unlimited memory.
I Download and install source code
1. Install Go operating environment
download
go Download path: https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz codis Installation website: https://codeload.github.com/CodisLabs/codis/zip/release3.2
Unzip the compressed package to the user level program installation directory / usr/local
Add path to environment variable
Be careful to make the environment variables take effect
source .bash_profile
2.codis environment installation and deployment
Install codis in the go directory and create a new directory,
mkdir -p /usr/local/go/src/github.com/CodisLabs
Enter directory
cd /usr/local/go/src/github.com/CodisLabs
mv /root/codis-release3.2.zip . 32 ls 33 unzip codis-release3.2.zip 34 yum install -y unzip 35 unzip codis-release3.2.zip decompression 36 ls 37 mv codis-release3.2 codis 38 ls 39 yum install autoconf Installation dependency 40 yum install git -y make MALLOC=libc
3.codis startup
Start CODIS dashboard
Start CODIS proxy
Start CODIS server
Start CODIS Fe
57 ./admin/codis-dashboard-admin.sh start #Launch dashboard 58 cat log/codis-dashboard.log.2022-01-21 #view log 59 ./admin/codis-proxy-admin.sh start #Start CODIS proxy 60 cat log/codis-proxy.log.2022-01-21 61 ./admin/codis-server-admin.sh start # Start CODIS server 63 tail -n 100 /tmp/redis_6379.log 64 ./admin/codis-fe-admin.sh start # Start CODIS Fe 65 tail -n 100 log/codis-fe.log.2022-01-21
II Add group through fe
Access the cluster management page 172.25.24.9:9090 through fe add in the browser, select the newly built cluster CODIS demo, and you can see the started Proxy in the Proxy column. The group column is blank because the started Codis Server is not added to the cluster. Add NEW GROUP, enter 1, and then click NEW GROUP to add Codis Server, In the Add Server line, enter the Codis Server address 127.0.0.1:6379, add it to the NEW GROUP, and click Add Server. group
III Initialize slot through fe
The slot status of the new cluster is offline and needs to be initialized, that is, 1024 slots are allocated to each group. The fastest way to initialize is through the rebalance all slots button provided by fe. Click to complete the cluster construction.
IV. cluster configuration
1. Add two Redis instances
Add 6380 and 6381 Redis instances respectively.
cp config/redis.conf config/redis6380.conf cp config/redis.conf config/redis6381.conf
vim config/redis6380.conf /// 84 port 6380 150 pidfile /tmp/redis_6380.pid 163 logfile "/tmp/redis_6380.log" /// ./bin/codis-server ./config/redis6380.conf ##Start the new Redis instance
vim config/redis6381.conf /// 84 port 6381 150 pidfile /tmp/redis_6381.pid 163 logfile "/tmp/redis_6381.log" /// ./bin/codis-server ./config/redis6381.conf ##Start the new Redis instance
2. Add two instances in the browser
The default state just added is NO:ONE. Click the setting in the middle.
[note] after cluster management is enabled, only 6379 can be read and written, and the other two only have read permission