Codis3.1 Installation Documentation

Source: Internet
Author: User
Tags install go etcd redis server
This is a creation in Article, where the information may have evolved or changed.

I. BASIC information

1. Codis Cluster architecture


Image

2. Environmental information

operating system: MacOS 10.12.3

Codis Version: 3.1

Go language version: 1.8.1

ETCD version: 3.2.0-rc.0

Ii. Deployment of Codis

1. Install Go

Download Address : HTTPS://GOLANG.ORG/DL

Mac:
Select go1.8.1.darwin-amd64.pkg to download and install

Windows:
Select Go1.8.1.windows-amd64.msi to download and install

Linux:
Select go1.8.1.linux-386.tar.gz or go1.8.1.linux-amd64.tar.gz download (download the corresponding version based on the number of operating system bits)
Unzip to the/usr/local path and set the environment variable

//解压到/usr/local路径tar -C /usr/local/ -xzf go1.8.1.linux-amd64.tar.gz
#设置环境变量export GOROOT=/usr/local/goexport PATH=$PATH:$GOROOT/binexport GOPATH=/usr/local/gopath

2, Installation GODEP

go env GOPATH $GOPATHgo get -u github.com/tools/godep && which godep $GOPATH/bin/godep

3, installation Etcd

mkdir -p $GOPATH/src/github.com/coreoscd $GOPATH/src/github.com/coreosgit clone https://github.com/coreos/etcd.gitcd etcd./build
#设置环境变量export PATH=$PATH:$GOPATH/src/github.com/coreos/etcd/bin

4, Installation Codis

#下载Codis源代码mkdir -p $GOPATH/src/github.com/CodisLabscd $_ && git clone https://github.com/CodisLabs/codis.git -b release3.1
#编译Codis源代码cd $GOPATH/src/github.com/CodisLabs/codismake

5. Start Codis Service

Note: The following command needs to specify the configuration file and log path, I have configured, download the configuration file, specific profile description Please see the official documentation

1. Start ETCD

#启动的端口为2379etcd --listen-client-urls 'http://0.0.0.0:2379' --advertise-client-urls 'http://0.0.0.0:2379' &

Description: Provides external storage for cluster status

2. Start Codis-dashboard

./bin/codis-dashboard --config=conf/dashboard-18080.toml --log=conf/dashboard-18080.log --log-level=WARN &

Description: Cluster management tools, support Codis-proxy, codis-server Add, delete, and according to the migration and other operations
Parameter description:--config Specify the configuration file path--log Specify the log file path

Configuration file Description:

Parameters Description Example
Coordinator_name External storage type, accept Zookeeper/etcd "Etcd"
Coordinator_addr External storage Address "127.0.0.1:2379"
Product_Name Cluster name, which satisfies the regular\w[\w\.\-]* "Demo-test"
Product_auth Cluster password, default is empty "123"
Admin_addr RESTful API Ports "0.0.0.0:18080"

3. Start Codis-fe

./bin/codis-fe --log=conf/fe.log --log-level=WARN --etcd=127.0.0.1:2379 --listen=0.0.0.0:8080 &

Description: Cluster Management interface
Parameter description:--log Specify the log file path--etcd Specify the external storage address--listen Specify the management interface access address

4. Start Codis-server

./bin/codis-server --include conf/redis-16379.conf &./bin/codis-server --include conf/redis-17379.conf &

Description: Based on redis-3.2.8 branch development
Parameter description:--include Specify the configuration file path

Configuration file Description:

Parameters Description Example
Port Listening port "16379"
Save DB file save path, empty is Codis home directory ""
Dbfilename DB file name "16379.rdb"
Requirepass Login Password "123"

5. Start Codis-proxy

./bin/codis-proxy --config=conf/proxy-19000.toml --log=conf/proxy-19000.log --etcd 127.0.0.1:2379 --log-level=WARN &

Description: The Redis Proxy service that the client connects to implements the Redis protocol. Except for some commands not supported (list of unsupported commands), there is no difference between the performance and the native Redis
Parameter description:--config Specify the configuration file path--log Specify the log file path--etcd Specify the external storage address

Configuration file Description:

Parameters Description Example
product_name cluster name, reference dashboard parameter description demo-test
product_auth cluster password, default is empty 123
proto_type Redis Port type, accept Tcp/tcp4/tcp6/unix/unixpacket TCP4
admin_addr restful API port 0.0.0.0:11080
proxy_addr redis port address or path 0.0.0.0:19000
proxy_datacenter data center address, codis-server need to specify address localhost

6. High Availability (HA) service

Description: Two Select one, also can not choose, the tool will be detected when master hangs off the active application of master-slave switching strategy, to promote a single slave to become the new master

1. Start codis-ha (optional components)

./bin/codis-ha --log=conf/ha.log --log-level=WARN --dashboard=127.0.0.1:18080 &

Description: Codis's own master-slave switch tool
Parameter Description:--log Specifies the log file path--dashboard Specifies which dashboard service to target

2. Start Codis-sentinel (optional components)

./bin/codis-server conf/sentinel-26379.conf --sentinel &./bin/codis-server conf/sentinel-26380.conf --sentinel &./bin/codis-server conf/sentinel-26381.conf --sentinel &

Description: Refer to Redis Sentinel mechanism and usage for specific switching mechanism
Parameter description:--sentinel starts in Sentinel mode

Third, Codis management interface

Browser Access http://127.0.0.1:8080 Open the Admin interface

1. Add a group


Image

2. Add Redis Server


Image

3. Add Sentinel


Image

4. Initialize Slots


Image

Note: The new cluster slot state is offline, so we need to initialize it (assign 1024 slots to each group), and the fastest way to initialize is done with the rebalance all slots button provided by Fe, as shown in this button, We quickly completed the construction of a cluster.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.