Codis is a distributed Redis solution, for upper-level applications, there is no obvious difference between connecting to Codis Proxy and connecting to native Redis Server, which can be used like a single-machine Redis, and the Codis bottom will handle Forwarding, non-stop data migration, and so on, all the things behind, for the front of the client is transparent, you can simply think behind the connection is a memory unlimited Redis service.
The Codis consists of four parts:
Codis Proxy (codis-proxy)
Codis Manager (codis-config)
Codis Redis (codis-server)
ZooKeeper
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7D/FE/wKiom1b0seLBzXEGAADhv2xnT8o838.png "title=" 25057421_1438525059sfj6.png "alt=" Wkiom1b0selbzxegaadhv2xnt8o838.png "/>
One, install zookeeper
Installing the Java Environment
ZooKeeper requires the JAVA environment to run and requires more than JAVA6 versions to
Download from the official website and set the JAVA environment variables.
Yum-y Install Java-1.7.0-openjdk-devel
Jave-version Display version
Installing zookeeper
wget http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
Tar zxvf zookeeper-3.4.6.tar.gz
MV Zookeeper-3.4.6/usr/local/zookeeper
Mkdir-p/data/zookeeper/{data,logs}
CP zoo_sample.cfg ZOO.CFG Configuration zoo.cfg
Vim/usr/local/zookeeper/conf/zoo.cfg
ticktime=2000
Initlimit=5
synclimit=2
Datadir=/data/zookeeper/data
#dataLogDir =/data/zookeeper/logs
clientport=2181
server.1=zookeeper-1:2888:3888
Set myID
Under the directory specified by the DataDir that we configured, create a myID file with a number that identifies the current host, the conf/zoo.cfg in the server.x configured in the file, and the number in the myID file.
[Email protected] ~]# echo 1 >/data/zookeeper/data/myid
Start Zookeeper
Boot order zookeeper-1>zookeeper-2>zookeeper-3
[[email protected] zookeeper]# zkserver.sh start
JMX enabled by default
Using config:/usr/local/zookeeper/bin/. /conf/zoo.cfg
Starting zookeeper ... STARTED
[Email protected] zookeeper]# zkserver.sh status
JMX enabled by default
Using config:/usr/local/zookeeper/bin/. /conf/zoo.cfg
Mode:leader
You can see that the first start is leader, and the other two are follower
Set boot up
Vim/etc/rc.local
/usr/local/zookeeper/bin/zkserver.sh start
Setting environment variables
Vim/etc/profile
Export Zookeeperpath=/usr/local/zookeeper
Export Goroot=/usr/local/go
Export Codispath=/usr/local/codis
Export path= $PATH: $GOROOT/bin: $ZOOKEEPERPATH/bin: $CODISPATH/bin
Source/etc/profile
Second, install Codis cluster
1, install Go
Setting environment variables
Vim/etc/profile
Export Goroot=/usr/local/go
Export Codispath=/usr/local/codis
Export path= $PATH: $GOROOT/bin: $CODISPATH/bin
Source/etc/profile
Download and install Go
cd/usr/local/
wget http://golangtc.com/static/go/go1.3.3.linux-amd64.tar.gz
If you can't download it, you can try to download the tar package manually
TAR-ZXVF go1.3.3.linux-amd64.tar.gz Go version
Go version go1.3.3 linux/amd64
2, installation dependent environment
Yum Groupinstall "Development Tools"
3, install Codis
Yum install-y git
Before installing the Go_path path, I set it to/usr/local/go_path by default, and before downloading we need to set up a bin directory in advance of Go_path.
Go get-u-D Github.com/codislabs/codis
Clone a window to monitor Codis download progress: tcpdump-i eth0 host github.com IP address
Switch to$GOPATH/src/github.com/CodisLabs/codis
Directory Executionmake
command to compile the code and execute themake gotest
run the test.
After all instructions are executed, the Codis-config, Codis-proxy, codis-server Three executables are generated within the Bin folder. In addition, the Bin/assets folder is the front-end resource required for Codis-config Dashboard HTTP service and needs to be placed in the same folder as Codis-config
After the installation is complete, the Redis configuration directory is:
/usr/local/go_path/src/github.com/codislabs/codis/extern/under
Redis configuration information see the Redis configuration of the previous blog
Configure profile information for Config.ini in Coids as required
Add with the-c parameter to make the Config.ini profile address codis-config-c: /config.ini Server add 1 172.16.12.26:6380 salverdashboard_addr=0.0.0.0:18087zk=172.16.12.26:2181
Start Dashboard
Codis-config Dashboard &
Initialize it. Solt can only be used for the first time installation
Codis-config Slot Init
Start Codis
Codis-server/etc/redis/redis_6380.conf
Codis-server/etc/redis/redis_6381.conf
Add Redis Server Group
Each server group exists as a Redis server set, only one master is allowed, multiple slave can be used, and the group ID only supports integers greater than or equal to 1
$ bin/codis-config server -h usage: codis-config server list codis-config server add <group_id> <redis_addr> <role> codis-config server remove <group_id> <redis_addr> codis-config server promote <group_id> <redis_addr> codis-config Server add-group <group_id> codis-config server remove-group <group_id> Add group a master one from codis-confiG server add 1 localhost:6380 master codis-config server add 1 localhost:6381 salver enter: in the browser Entry Interface Verification
This article is from the "years, the Allure" blog, please be sure to keep this source http://alca0126.blog.51cto.com/7826974/1757904
Codis-server cluster installation and deployment