GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc:modify tutorial_en · coder-java-caicai/codis@ce49783

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc
    • tutorial_en.md
    • tutorial_zh.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/tutorial_en.md‎

Copy file name to clipboardExpand all lines: doc/tutorial_en.md
+135-108Lines changed: 135 additions & 108 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2,176 +2,203 @@
22

33
Codes is a distributed Redis solution, there is no obvious difference between connecting to a Codis proxy and an original Redis server(?), top layer application can connect to Codis as normal standalone Redis, Codis will forward low layer requests. Hot data migration and all things in the shadow are transparent to client. Simply treat Coids as a Redis service with unlimited RAM.
44

5-
Codis has four parts:
6-
* Codis Proxy(proxy)
7-
* Codis manager(cconfig)
8-
* Codis Redis
9-
* ZooKeeper
105

11-
`codis-proxy` is the proxy service of client connections, `codis-proxy` is a Redis protocol implementation, perform as an original Redis(just like Twemproxy). You can deploy multiple `codis-proxy` for one business, `codis-proxy` is none-stateful.
6+
Codis 3.x consists of the following components:
127

13-
`codis-config` is the configuration to for Codis, support actions like add/remove Redis node, add/remove Proxy node and start data migaration, etc. `codis-config` has a built-in http server which can start a dashboard for user to monitor the status of Codis cluster in browser.
8+
* ** Codis Server **: based on redis-3.2.8 branch development. Added additional data structures to support slot-related operations and data migration instructions. Specific changes can refer to the document [redis changes] (redis_change_zh.md).
149

15-
`codis-server` is a branch of Redis maintain by Codis project, based on 2.8.13, add support for slot and atomic data migration. `codis-proxy` and `codis-config` can only work properly with this specific version of Redis.
10+
* ** Codis Proxy **: is the proxy service of client connections. Codis Proxy Implements Redis Protocol. In addition to some commands do not support ([unsupported command list] (unsupported_cmds.md)).
1611

17-
Codis depend on ZooKeeper to store data routing table and meta data of `codis-proxy` node, `codis-config` actions will go through ZooKeeper, then synchronize up to alive `codis-proxy`.
12+
    + For the same product cluster, you can deploy multiple codis-proxy instances at the same time;
13+
    + Different codis-proxy by codis-dashboard to ensure state synchronization.
1814

19-
Codis support namespace, configs of products with different name won’t be conflict.
15+
* ** Codis Dashboard **: cluster management tools, support codis-proxy, codis-server add, delete, slot migrate(sync/async), and other operations. When a cluster state changes, the codis-dashboard maintains the consistency of all codis-proxy states under the cluster.
2016

21-
## Build codis-proxy & codis-config
17+
    + For the same product cluster, the same time codis-dashboard can only have 0 or 1;
18+
    + All changes to the cluster must be done via codis-dashboard.
2219

20+
* ** Codis Admin **: Command-line tool for cluster management.
2321

24-
* install go [see official doc](https://golang.org/doc/install)
25-
* set $GOPATH correctly and set PATH=$GOPATH/bin:$PATH to execute commands installed by `go get`
26-
* execute `go get -u -d github.com/CodisLabs/codis` to download codis
27-
* change directory to `$GOPATH/src/github.com/CodisLabs/codis` and execute `make` to compile, execute `make gotest` to run unit test
22+
    + Can be used to control the codis-proxy, codis-dashboard status, and access external storage.
2823

29-
Two executable file `codas-config` and `codis-proxy` should be generated in `codis/bin`(`bin/assets` is the resources for `codis-config` dashboard, should be placed at same directory with `codis-config`).
24+
* ** Codis FE **: cluster management Web Interface.
3025

31-
```
32-
cd sample
26+
    + Multiple cluster instances can share the same front-end display page;
27+
    + FE reads all cluster instances name from external storage.
3328

34-
$ bin/codis-config -h (master)
35-
usage: codis-config [-c <config_file>] [-L <log_file>] [--log-level=<loglevel>]
36-
<command> [<args>...]
37-
options:
38-
-c config file path, default: ./config.ini
39-
-L log output path, default: stdout
40-
--log-level=<loglevel> (debug < info (default) < warn < error < fatal)
29+
* ** Storage **: Provides external storage for cluster status, and saves cluster metadata.
4130

42-
commands:
43-
server redis group management
44-
slot slot management
45-
dashboard start dashboard
46-
action action management
47-
proxy proxy management
48-
```
31+
    + Provide the concept of Namespace, different clusters will be organized according to different product name;
32+
    + Currently only provides Zookeeper, Etcd, Fs three implementations, but provides an abstract interface can be self-expansion.
4933

50-
```
51-
$ bin/codis-proxy -h
5234

53-
usage: proxy [-c <config_file>] [-L <log_file>] [--log-level=<loglevel>] [--cpu=<cpu_num>] [--addr=<proxy_listen_addr>] [--http-addr=<debug_http_server_addr>]
35+
## Getting Codis
5436

55-
options:
56-
-c set config file
57-
-L set output log file, default is stdout
58-
--log-level=<loglevel> set log level: info, warn, error, debug [default: info]
59-
--cpu=<cpu_num> num of cpu cores that proxy can use
60-
--addr=<proxy_listen_addr> proxy listen address, example: 0.0.0.0:9000
61-
--http-addr=<debug_http_server_addr> debug vars http server
62-
```
37+
### Download Pre-built Release Binaries
6338

64-
## Deploy
39+
The easiest way to get codis is to use one of the pre-built release binaries which are available for OSX, Linux. Instructions for using these binaries are on the [GitHub releases page][github-release].
6540

66-
### Configuration file
67-
`codis-config` and `codis-proxy` will take `config.ini` in current directory by default without a specific `-c`.
41+
### Compile Source Code
6842

69-
See [config.ini](https://github.com/CodisLabs/codis/blob/master/config.ini)'s comments.
43+
For those wanting to try the very latest version, build the latest version of codis from the `master` branch. This first needs [*Go*](https://golang.org/) installed (version 1.7+ is required). All development occurs on `master`, including new features and bug fixes. Bug fixes are first targeted at `master` and subsequently ported to release branches.
7044

71-
### Workflow
72-
0. Execute `codis-config dashboard` , start dashboard.
73-
1. Execute `codis-config slot init` to initialize slots
74-
2. Starting and compiling a Codis Redis has no difference from a normal Redis Server
75-
3. Add Redis server group, each server group as a Redis server group, only one master is allowed while could have multiple slaves. Group id only support integer lager than 1.
7645

77-
```
78-
$ bin/codis-config server -h
79-
usage:
80-
codis-config server list
81-
codis-config server add <group_id> <redis_addr> <role>
82-
codis-config server remove <group_id> <redis_addr>
83-
codis-config server promote <group_id> <redis_addr>
84-
codis-config server add-group <group_id>
85-
codis-config server remove-group <group_id>
46+
#### 1. Install Go Environment [reference](https://golang.org/doc/install)
47+
48+
After the installation is complete, you can run the following command to detect:
49+
50+
```bash
51+
$ go version
52+
go version go1.7.3 linux/amd64
8653
```
8754

88-
For example: Add two server group with the ids of 1 and 2, each has two Redis instances, a master and a slave.
55+
#### 2. Set the compilation environment
8956

90-
First, add a group with id of 1 and assign a Redis master to it:
57+
Add `$GOPATH/bin` To `$PATH`,For Example:`PATH=$PATH:$GOPATH/bin`。
9158

92-
```
93-
$ bin/codis-config server add 1 localhost:6379 master
59+
```bash
60+
$ go env GOPATH
61+
/home/codis/gopath
9462
```
9563

96-
Second, assign a Redis slave to this group:
64+
#### 3. Download Codis Source Code
9765

98-
```
99-
$ bin/codis-config server add 1 localhost:6380 slave
66+
The Codis source code needs to be downloaded to `$GOPATH/src/github.com/CodisLabs/codis`:
67+
68+
```bash
69+
$ mkdir -p $GOPATH/src/github.com/CodisLabs
70+
$ cd $_ && git clone https://github.com/CodisLabs/codis.git -b release3.2
10071
```
10172

102-
Then the group with id of 2:
73+
#### 4. Compile Codis Source Code
10374

104-
```
105-
$ bin/codis-config server add 2 localhost:6479 master
106-
$ bin/codis-config server add 2 localhost:6480 slave
75+
* use make tool to compile:
76+
77+
```bash
78+
$ cd $GOPATH/src/github.com/CodisLabs/codis
79+
$ make
80+
make -j -C extern/redis-3.2.8/
81+
... ...
82+
go build -i -o bin/codis-dashboard ./cmd/dashboard
83+
go build -i -o bin/codis-proxy ./cmd/proxy
84+
go build -i -o bin/codis-admin ./cmd/admin
85+
go build -i -o bin/codis-fe ./cmd/fe
86+
87+
$ ls bin/
88+
total 69124
89+
drwxr-xr-x 4 codis codis 4096 Jan 4 14:55 assets
90+
-rwxr-xr-x 1 codis codis 17600752 Jan 4 14:55 codis-admin
91+
-rwxr-xr-x 1 codis codis 18416320 Jan 4 14:55 codis-dashboard
92+
-rwxr-xr-x 1 codis codis 9498040 Jan 4 14:55 codis-fe
93+
-rwxr-xr-x 1 codis codis 11057280 Jan 4 14:55 codis-proxy
94+
-rwxr-xr-x 1 codis codis 4234432 Jan 4 14:55 codis-server
95+
-rw-r--r-- 1 codis codis 148 Jan 4 14:55 version
96+
... ...
97+
98+
$ cat bin/version
99+
version = 2016-01-03 14:53:22 +0800 @51f06ae3b58a256a58f857f590430977638846a3
100+
compile = 2016-01-04 15:00:17 +0800 by go version go1.5.2 linux/amd64
107101
```
108102

109-
4. Config slot range of server group
103+
## 1. Running Codis Cluster
110104

111-
Codes implement data segmentation with Pre-sharding mechanism, 1024 slots will be segmented by default,a single key use following formula to determine which slot to resident, each slot has a server group id represents the server group which will provide service.
105+
Build a standalone codis cluster in 2 minutes,without any external component dependencies.
106+
The admin folder in the source code provides a series of scripts to quickly start, stop the codis components, improve the efficiency of operation and maintenance.
112107

108+
109+
### Start codis-dashboard
110+
Use codis-dashboard-admin.sh script to start dashboard and check the dashboard log to confirm whether there is an exception.
111+
```
112+
./admin/codis-dashboard-admin.sh start
113+
tail -100 ./log/codis-dashboard.log.2017-04-08
113114
```
114-
$ bin/codis-config slot -h
115-
usage:
116-
codis-config slot init
117-
codis-config slot info <slot_id>
118-
codis-config slot set <slot_id> <group_id> <status>
119-
codis-config slot range-set <slot_from> <slot_to> <group_id> <status>
120-
codis-config slot migrate <slot_from> <slot_to> <group_id> [--delay=<delay_time_in_ms>]
121115
```
116+
2017/04/08 15:16:57 fsclient.go:197: [INFO] fsclient - create /codis3/codis-demo/topom OK
117+
2017/04/08 15:16:57 main.go:140: [WARN] [0xc42025f7a0] dashboard is working ...
118+
2017/04/08 15:16:57 topom.go:424: [WARN] admin start service on [::]:18080
122119
123-
For exmaple, config server group 1 provide service for slot [0, 511], server group 2 provide service for slot [512, 1023]
120+
```
121+
122+
The default external storage Uses filesystem, the default data path is saved in /tmp/codis. If the startup fails, please check whether the current user has read/write access to the path.
124123

124+
125+
### Start codis-proxy
126+
Use codis-proxy-admin.sh script to start codis-proxy and check the proxy log to confirm whether there is an exception.
125127
```
126-
$ bin/codis-config slot range-set 0 511 1 online
127-
$ bin/codis-config slot range-set 512 1023 2 online
128+
./admin/codis-proxy-admin.sh start
129+
tail -100 ./log/codis-proxy.log.2017-04-08
128130
```
129131

130-
5. Start `codis-proxy`
132+
```
133+
2017/04/08 15:39:37 proxy.go:293: [WARN] [0xc4200df760] set sentinels = []
134+
2017/04/08 15:39:37 main.go:320: [WARN] rpc online proxy seems OK
135+
2017/04/08 15:39:38 main.go:210: [WARN] [0xc4200df760] proxy is working ...
136+
```
131137

138+
### Start codis-server
139+
Use codis-server-admin.sh script to start codis-server and check the redis log to confirm whether there is an exception.
132140
```
133-
bin/codis-proxy -c config.ini -L ./log/proxy.log --cpu=8 --addr=0.0.0.0:19000 --http-addr=0.0.0.0:11000
141+
./admin/codis-server-admin.sh start
142+
tail -100 /tmp/redis_6379.log
134143
```
135144

136-
`codas-proxy`’s status are now `offline`, put it `online` to provide service:
145+
```
146+
5706:M 08 Apr 16:04:11.748 * DB loaded from disk: 0.000 seconds
147+
5706:M 08 Apr 16:04:11.748 * The server is now ready to accept connections on port 6379
148+
```
149+
redis.conf pidfile,logfile default saves in the /tmp directory. If the startup fails, please check whether the current user has read/write access to the path.
137150

151+
### Start codis-fe
152+
Use codis-fe-admin.sh script to start codis-fe and check the redis log to confirm whether there is an exception.
153+
```
154+
./admin/codis-fe-admin.sh start
155+
tail -100 ./log/codis-fe.log.2017-04-08
138156
```
139-
bin/codis-config -c config.ini proxy online <proxy_name> <---- proxy id, e.g. proxy_1
157+
```
158+
2017/04/08 16:12:13 main.go:100: [WARN] set ncpu = 1
159+
2017/04/08 16:12:13 main.go:103: [WARN] set listen = 0.0.0.0:9090
160+
2017/04/08 16:12:13 main.go:115: [WARN] set assets = /home/codis/go/src/github.com/CodisLabs/codis/admin/../bin/assets
161+
2017/04/08 16:12:13 main.go:153: [WARN] set --filesystem = /tmp/codis
140162
```
141163

142-
6. Open http://localhost:18087/admin in browser
164+
### Add group by fe
143165

144-
Now you can achieve operations in browser. Enjoy!
166+
Please visit the cluster management web page(fe url:127.0.0.1:9090)
167+
Select the cluster(codis-demo) we have just built, in the Proxy column we can see that we have activated the Proxy,
168+
But the Group column is empty, because codis-server is not joined the cluster.
145169

146-
## Data Migration
170+
Add NEW GROUP
171+
In the `NEW GROUP` row, please input a number such as 1, and click NEWGROUP
147172

148-
Codis offers a reliable and transparent data migration mechanism, also it’s a killer feature which made Codis distinguished from other static distributed Redis solution, such as Twemproxy.
173+
Add Codis Server
149174

150-
The minimum data migration unit is `key`, we add some specific actions—such as `SLOTSMGRT`—to Codis to support migration based on `key`, which will send a random record of a slot to another Codis Redis instance each time, after the transportation is confirmed the original record will be removed from slot and return slot’s length. The action is atomically.
175+
In the `Add Server` row, please input the codis-server address we just started, add it to GROUP, and then click the Add Server button, as shown below
151176

152-
For example: migrate data in slot with ID from 0 to 511 to server group 2, `--delay` is the sleep duration after each transportation of record, which is used to limit speed, default value is 0.
177+
![addgroup](pictures/addgroup.jpg)
153178

154-
```
155-
$ bin/codis-config slot migrate 0 511 2 --delay=10
156-
```
179+
### Initialize slot by fe
180+
181+
The new cluster slot status is offline, so we need to initialize it (allocate 1024 slots to each group), and the fastest way to initialize a cluster is to click the `rebalance all slots` button provided by fe, as shown in the following figure.
157182

158-
Migration progress is reliable and transparent, data won’t vanish and top layer application won’t terminate service.
183+
![rebalance_slots](pictures/rebalance_slots.jpg)
159184

160-
Notice that migration task could be paused, but if there is a paused task, it must be fulfilled before another start(means only one migration task is allowed at the same time).
161185

162-
### Auto Rebalance
186+
## Quickly deploy the cluster by ansible
187+
188+
Use ansible to quickly deploy multiple clusters in standalone and multi-machine environment.
189+
The ansible folder contains the playbook for deploying the codis cluster, modifying the parameters in the groups_var / all file according to your own deployment environment, and modifying the hosts file to add the deployed environment IP.
190+
191+
Ansible installation is simple.Once Ansible is installed, there will be no daemons to start or keep running. You only need to install it on one machine and it can manage an entire fleet of remote machines from that central point.
192+
Ansible by default manages machines over the SSH protocol.
163193

164-
Codis support dynamic slots migration based on RAM usage to balance data distribution.
165-
166194
```
167-
$bin/codis-config slot rebalance
195+
git clone git://github.com/ansible/ansible.git -b stable-2.3
196+
cd ./ansible
197+
source ./hacking/env-setup
198+
cd $codis_dir/ansible
199+
ansible-playbook -i hosts site.yml
168200
```
169201

170-
Requirements:
171-
* all codis-server must set maxmemory.
172-
* All slots’ status should be `online`, namely no transportation task is running.
173-
* All server groups must have a master.
174-
175202

176203
##HA
177204

Collapse file

‎doc/tutorial_zh.md‎

Copy file name to clipboardExpand all lines: doc/tutorial_zh.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Codis 3.x 由以下组件组成:
7474

7575
```bash
7676
$ go version
77-
go version go1.5.2 linux/amd64
77+
go version go1.7.3 linux/amd64
7878
```
7979

8080
#### 2. 设置编译环境
@@ -94,7 +94,7 @@ Codis 源代码需要下载到 `$GOPATH/src/github.com/CodisLabs/codis`:
9494

9595
```bash
9696
$ mkdir -p $GOPATH/src/github.com/CodisLabs
97-
$ cd $_ && git clone https://github.com/CodisLabs/codis.git -b release3.1
97+
$ cd $_ && git clone https://github.com/CodisLabs/codis.git -b release3.2
9898
```
9999

100100
#### 4. 编译 Codis 源代码

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.