配置Zookeper
在整个的codis架构之中,codis-proxy将作为所有的codis-server的对外的代理,而在整个的处理之中,codis-proxy所保存的数据一定是所有的codis-server的信息,那么这些信息都会保存在zookeeper的组件里面,所以现在需要在"codis-proxy-60"的主机上配置zookeeper组件,现在的配置是在单机下进行。
1、将zookeeper-3.4.9.tar.gz上传到60环境中,进行解压
$ tar -zxvf zookeeper-3.4.9.tar.gz
2、设置环境变量
在/etc/profile文件中添加如下红色信息
ZOOKEEPER_HOME=/home/xm6f/dev/zookeeper-3.4.9 export PATH=$PATH:$JAVA_HOME/bin:$MYCAT_HOME/bin:$GOROOT/bin:$GOPATH/bin:$ZOOKEEPER_HOME/bin export ZOOKEEPER_HOME
3、建立zookeeper的数据保存路径
$ mkdir -p /usr/data/zookeeper
4、修改zookeeper配置文件
配置文件存放在$ZOOKEEPER_HOME/conf/目录下,将zoo_sample.cfd文件名称改为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=/usr/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
配置说明:
tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
5、启动zookeeper
当这些配置项配置好后,你现在就可以启动zookeeper了:
$ cd /home/xm6f/dev/zookeeper-3.4.9/bin/ $ ./zkServer.sh start $ netstat -anp|grep 2181 #查看zookeeper端口 $ lsof -i:2181 #查看某个端口是否被占用 $ ./zkServer.sh stop
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
2012-02-02 六、表查询一