Codis 集群搭建
Codis 集群搭建
1 安装go1.3.1 CentOS 7.0 安装go 1.3.1
1.1 下载go安装包 golang中国上下载 下载到Downloads下
1.2 解压 tar -zxf go1.3.1.linux-amd64.tar.gz -C /usr/local/
1.3 修改 etc/profile 文件在文件后加入 export的几行,在unset下面直接加,不要有空行
unset i
unset -f pathmunge
export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH
export GOPATH=/data/gopkg
1.4 然后执行 source /etc/profile 刷新配置文件
1.5 运行命令 go 测试go是否安装成功
1.6 在usr/local/go/test 下 运行 go run helloworld.go 测试
2 安装git yum -y install git
3 配置hosts文件 3个机器都是相同的配置
cd /etc
vi hosts
[will@weiguoyuan etc]$ more hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.64.4.57 weiguoyuan
10.64.4.95 weiguoyuan2
10.64.4.99 hemy
还需要配置windows下的hosts文件 否则在windows下的jodis客户端访问codis集群机器找不到主机名对应的ip
C:\Windows\System32\drivers\etc
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
10.64.4.57 weiguoyuan
10.64.4.95 weiguoyuan2
10.64.4.99 hemy
4 安装zookeeper 集群 3个机器上每个机器上都安装一个zookeeper
4.1 官网下载 下载到Downloads下
4.2 tar -xzf zookeeper.**.tar.gz -C /usr/local
4.3 cd /usr/local/zookeeper*/conf
4.4 cp zookeeper.cfg zoo.cfg
4.5 vi zoo.cfg(三个zookeeper的配置文件相同) 在尾部加上节点信息 (节点之前通信),
将dataDir=/tmp/zookeeper 修改为dataDir=/data/zookeeper 因为tmp目录在机器重启后会清空,所有权限的用户都可以修改
[will@weiguoyuan conf]$ more zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/data/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=10.64.4.57:2888:3888
server.2=10.64.4.95:2888:3888
server.3=10.64.4.99:2888:3888
4.6 配置zookeeper节点id
先启动3个机器的zookeeper zookeeper会自动生成/data/zookeeper文件夹
再设置节点的myid myid对应的zoo.cfg的server.ID比如192.168.253.128机器上的myid文件内容为1(3个机器分别生成123
echo "1" >/data/zookeeper/myid #3个机器上分别执行
echo "2" >/data/zookeeper/myid
echo "3" >/data/zookeeper/myid
4.7 启动zookeeper
cd /usr/local/zookeeper/bin
./zkServer.sh start
./zkServer.sh stop
./zkServer.sh status 查看节点状态有 leader,fellower
5 安装codis 编译 3个机器上都需安装
go get -d github.com/wandoulabs/codis
cd $GOPATH/src/github.com/wandoulabs/codis
./bootstrap.sh (这步比较慢 失败了可以重试)
make gotest
Codis 配置
1 官方文档 命令方式配置 https://github.com/wandoulabs/codis/blob/master/doc/tutorial_zh.md
2 编写脚本 脚本方式配置
2.1 配置config.ini 3个机器都得配置
cd /data/gopkg/src/github.com/wandoulabs/codis/sample
vi config.ini
[will@weiguoyuan sample]$ more config.ini
zk=10.64.4.57:2181,10.64.4.95:2181,10.64.4.99:2181 #zookeeper列表
product=test
proxy_id=proxy_1 #3个机器上分别是 proxy_1 proxy_2 proxy_3
net_timeout=5
dashboard_addr=weiguoyuan:18087
coordinator=zookeeper
2.2 配置 start_redis.sh 3个机器都要配置
cd /data/gopkg/src/github.com/wandoulabs/codis/sample
vi start_redis.sh
[will@weiguoyuan sample]$ more start_redis.sh
#!/bin/sh
nohup ../bin/codis-server ./redis_conf/6380.conf &> ./log/redis_6380.log &
nohup ../bin/codis-server ./redis_conf/6381.conf &> ./log/redis_6381.log &
nohup ../bin/codis-server ./redis_conf/6382.conf &> ./log/redis_6382.log &
nohup ../bin/codis-server ./redis_conf/6383.conf &> ./log/redis_6383.log &
echo "sleep 3s"
sleep 3
tail -n 30 ./log/redis_6380.log
tail -n 30 ./log/redis_6381.log
tail -n 30 ./log/redis_6382.log
tail -n 30 ./log/redis_6383.log
2.3 配置 add_group.sh 只需一个机器配置
cd /data/gopkg/src/github.com/wandoulabs/codis/sample
vi start_redis.sh
[will@weiguoyuan sample]$ more add_group.sh
#!/bin/sh
echo "add group 1 with a master(localhost:6381), Notice: do not use localhost when in produciton"
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 1 10.64.4.57:6380 master
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 1 10.64.4.95:6380 slave
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 1 10.64.4.99:6380 slave
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 2 10.64.4.57:6381 master
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 2 10.64.4.95:6381 slave
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 2 10.64.4.99:6381 slave
echo "add group 2 with a master(localhost:6382), Notice: do not use localhost when in produciton"
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 3 10.64.4.95:6382 master
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 3 10.64.4.57:6382 slave
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 3 10.64.4.99:6382 slave
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 4 10.64.4.99:6383 master
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 4 10.64.4.95:6383 slave
../bin/codis-config -c config.ini -L ./log/cconfig.log server add 4 10.64.4.57:6383 slave
2.4 配置 initslot.sh 只需一个机器配置
cd /data/gopkg/src/github.com/wandoulabs/codis/sample
vi initslot.sh
[will@weiguoyuan sample]$ more initslot.sh
#!/bin/sh
echo "slots initializing..."
../bin/codis-config -c config.ini slot init -f
echo "done"
echo "set slot ranges to server groups..."
../bin/codis-config -c config.ini slot range-set 0 255 1 online
../bin/codis-config -c config.ini slot range-set 256 511 2 online
../bin/codis-config -c config.ini slot range-set 512 767 3 online
../bin/codis-config -c config.ini slot range-set 768 1023 4 online
echo "done"
2.5 修改 start_proxy.sh 机器1 不用修改另外两个机器修改
cd /data/gopkg/src/github.com/wandoulabs/codis/sample
vi start_proxy.sh
[will@weiguoyuan sample]$ more start_proxy.sh
#!/bin/sh
echo "shut down proxy_1..."
../bin/codis-config -c config.ini proxy offline proxy_1 //修改这里
echo "done"
echo "start new proxy..."
nohup ../bin/codis-proxy --log-level info -c config.ini -L ./log/proxy.log --cpu=8 --addr=0.0.0.0:190
00 --http-addr=0.0.0.0:11000 &
echo "done"
echo "sleep 3s"
sleep 3
tail -n 30 ./log/proxy.log
2.6 修改 set_proxy_online.sh 机器1 不用修改另外两个机器修改
cd /data/gopkg/src/github.com/wandoulabs/codis/sample
vi set_proxy_online.sh
[will@weiguoyuan sample]$ more set_proxy_online.sh
#!/bin/sh
echo "set proxy_1 online"
../bin/codis-config -c config.ini proxy online proxy_1 #修改这里
echo "done"
Codis 集群启动
1 启动3个机器
2 关闭3个机器防火墙
CentOS防火墙分为2中 firewalld 和 iptables
如果是firewalld systemctl stop firewalld.service
如果是iptables systemctl stop iptables.service
3 启动3个机器的zookeeper
cd /usr/local/zookeeper/bin
./zkServer.sh start
4 在没有配置add_group.sh的两个机器上(机器2和3)
cd /data/gopkg/src/github.com/wandoulabs/codis/sample
./start_redis.sh
5 在配置add_group.sh的机器上(机器1) 上
cd /data/gopkg/src/github.com/wandoulabs/codis/sample
./startall.sh
6 在机器1上打开火狐浏览器 打开网址 http://localhost:18087/admin 可以看到节点 代理信息
7 在机器2和3上分别启动代理
cd /data/gopkg/src/github.com/wandoulabs/codis/sample
./start_proxy.sh
8 在机器1上浏览器http://localhost:18087/admin的代理信息中 设置proxy_2 proxy_3 online
9 可以通过windows上的jodis客户端访问Codis集群了
利用Asis2生成 Webservice服务
http://www.cnblogs.com/weixiaole/p/4372319.html
codis-ha
官方文档 https://github.com/ngaut/codis-ha
go get github.com/ngaut/codis-ha
cd codis-ha
go build
codis-ha --codis-config=localhost:18087 --productName=test
参考
http://navyaijm.blog.51cto.com/4647068/1637688
https://github.com/wandoulabs/codis/blob/master/doc/tutorial_zh.md
Codis 集群搭建的更多相关文章
- codis集群搭建笔记
一.安装Linux虚拟机 二.安装go运行环境 https://www.cnblogs.com/xmzncc/p/6218694.html wget http://mirrors.flysnow.or ...
- 实战Centos系统部署Codis集群服务
导读 Codis 是一个分布式 Redis 解决方案, 对于上层的应用来说, 连接到 Codis Proxy 和连接原生的 Redis Server 没有明显的区别 (不支持的命令列表), 上层应用可 ...
- 基于.NetCore的Redis5.0.3(最新版)快速入门、源码解析、集群搭建与SDK使用【原创】
1.[基础]redis能带给我们什么福利 Redis(Remote Dictionary Server)官网:https://redis.io/ Redis命令:https://redis.io/co ...
- Codis集群的搭建与使用
一.简介 Codis是一个分布式的Redis解决方案,对于上层的应用来说,连接Codis Proxy和连接原生的Redis Server没有明显的区别(不支持的命令列表),上层应用可以像使用单机的Re ...
- Codis集群的搭建
Codis集群的搭建与使用 一.简介 Codis是一个分布式的Redis解决方案,对于上层的应用来说,连接Codis Proxy和连接原生的Redis Server没有明显的区别(不支持的命令列表 ...
- 使用codis-admin搭建codis集群
目的 在Redis Codis 部署安装的文章中,介绍了通过fe在web上搭建codis的基本步骤和方法,也介绍了codis-admin的相关说明,为了更好的熟悉codis-admin的使用,本文将使 ...
- [Big Data - Codis] Codis集群的搭建与使用
一.简介 Codis是一个分布式的Redis解决方案,对于上层的应用来说,连接Codis Proxy和连接原生的Redis Server没有明显的区别(不支持的命令列表),上层应用可以像使用单机的Re ...
- codis+redis 集群搭建管理
Codis 是一个分布式 Redis 解决方案, 对于上层的应用来说, 连接到 Codis Proxy 和连接原生的 Redis Server 没有明显的区别 (不支持的命令列表), 上层应用可以像使 ...
- Linux服务器上搭建codis集群之——安装前环境准备
codis是redis的分布式集群模式,由豌豆荚开源,本文简单记录一下它的集群搭建方法. 首先介绍一下我的实验环境.三台配置相同的虚拟机, [root@test ~]# ip a|grep -w &q ...
随机推荐
- [整理]Linux压缩与解压缩命令整理。
一.压缩文件命令 1.*.Z compress 程序压缩的档案:2.*.bz2 bzip2 程序压缩的档案:3.*.gz gzip 程序压缩的档案:4.*.tar tar 程序打包的数据,并没有压缩过 ...
- C#基础学习文章导航
第一部分:入个门 C#入门篇-1:HelloWorld的类 C#入门篇-2:什么是变量 C#入门篇-3:数据类型及转换 C#入门篇-4:使用运算符 第二部分:流程控制语句 C#入门篇5-1:流程控制语 ...
- 注册并启动 Reporting Services SharePoint 服务
在安装 SharePoint 之前已安装 Reporting Services SharePoint 模式.所以Reporting Services SharePoint 是不能正常使用的. 安装完S ...
- spring mvc如何获取问号后的url参数
@RequestMapping(method=RequestMethod.GET) public ModelAndView allUsers(@RequestParam int page){ Mode ...
- 用Masonry实现键盘的收回和弹出
首先说几点:我一般将数值类型的约束用mas_equalTo,而相对于某个控件,或者某个控件的某个约束,我会使用equalTo,如:make.size.mas_equalTo(CGSizeMake(10 ...
- .NET C#使用微信公众号登录网站
适用于:本文适用于有一定微信开发基础的用户 引言:花了300大洋申请了微信公众平台后,发现不能使用微信公众号登录网站(非微信打开)获得微信帐号.仔细研究后才发现还要再花300大洋申请微信开放平台才能接 ...
- jsp和servlet的区别
servlet是服务器端的程序,动态生成html页面发到客户端,但是这样 程序里有许多out.println(),java和html语言混在一起很乱.所以 后来推出了jsp.其实jsp就是servle ...
- HDU 3265 扫描线(矩形面积并变形)
Posters Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- ARC 类型转换:显式转换 id 和 void *
http://blog.csdn.net/chinahaerbin/article/details/9471419 /* * ARC有效时三种类型转换: */ 1.__bridge ...
- 如何在滚动报表时保持标题可见 (Reporting Services)
From: https://msdn.microsoft.com/zh-cn/library/bb934257.aspx 对于跨多页的表或矩阵数据区域,可以控制滚动报表时是否始终显示包含列标题的初始行 ...