当前位置: 首页 > news >正文

Redis快速上手篇七(集群-一台虚拟机六个节点)

​​​​​​http://t.csdnimg.cn/S0NpK与上篇六个虚拟机配置基本一样有不懂可以看上篇配置实例 

集群搭建

        根据上篇文章,本篇只着重于小方面的配置差别

        配置集群一般不要设置密码

1.搭建一台虚拟机后再安装目录下新建文件夹 redis_cluster

2.在文件夹内创建六个文件夹,分别为7001 7002 7003 7004 7005 7006

3.将 redis.conf 拷贝到这六个目录中

echo ./7002 ./7003 ./7004 ./7005 ./7006 | xargs -n 1 cp -v /usr/local/bin/redis_cluster/7001/redis.conf

4.配置 redis7001.conf

vim redis7001.conf

这里我们并没有新建 redis7001.conf 文件 vim编辑不存在的文件会自动创建

引入的配置文件为安装目录下的 redis.conf 文件复制过来

cp usr/local/bin/redis.conf /usr/local/bin/redis_cluster

include /usr/local/bin/redis_cluster/redis.conf #引入配置文件
port 7001 #端口设置
pidfile "/var/run/redis_7001.pid" #存放进程ID防止启动多个进程副本
dbfilename "dump_7001.rdb" #持久化文件名称
dir "/usr/local/bin/redis_cluster" #持久化保存位置
logfile "/usr/local/bin/redis_cluster/redis_err_7001.log"
cluster-enabled yes    #开启集群
cluster-config-file nodes-7001.conf #节点名称
cluster-node-timeout 15000 #节点过期时间

5.分别对每个文件夹下的每个 .conf文件进行以上配置

        注意端口号

后续步骤与​​​​​​ http://t.csdnimg.cn/enij1文章中完全一致

需要注意运行时文件夹路径

一键启动与关闭脚本

#! /bin/bash
l=`ps -ef|grep -w redis|grep -v grep|wc -l`
if [ $l == 0 ]
thenecho "redis还没有启动,开始启动。。。。"/usr/local/bin/redis-server /usr/local/bin/redis_cluster/7001/redis.conf/usr/local/bin/redis-server /usr/local/bin/redis_cluster/7002/redis.conf/usr/local/bin/redis-server /usr/local/bin/redis_cluster/7003/redis.conf/usr/local/bin/redis-server /usr/local/bin/redis_cluster/7004/redis.conf/usr/local/bin/redis-server /usr/local/bin/redis_cluster/7005/redis.conf/usr/local/bin/redis-server /usr/local/bin/redis_cluster/7006/redis.confecho "启动成功。。。。。。。。。"
elseecho "redis已经启动,开始关闭******************************"/usr/local/bin/redis-cli -h 127.0.0.1 -p 7001 shutdown/usr/local/bin/redis-cli -h 127.0.0.1 -p 7002 shutdown/usr/local/bin/redis-cli -h 127.0.0.1 -p 7003 shutdown/usr/local/bin/redis-cli -h 127.0.0.1 -p 7004 shutdown/usr/local/bin/redis-cli -h 127.0.0.1 -p 7005 shutdown/usr/local/bin/redis-cli -h 127.0.0.1 -p 7006 shutdownecho "关闭成功****************************************"
fi

http://www.lryc.cn/news/211204.html

相关文章:

  • 社恐了怎么办?如何改变社交恐惧症?
  • HiQPdf Library for .NET - HTML to PDF Crack
  • ES6中Set集合
  • 论坛介绍 | COSCon'23 开源文化(GL)
  • 【httpd】 Apache http服务器目录显示不全解决
  • 笔记本电脑搜索不到wifi6 无线路由器信号
  • js获取input?
  • STM32 CAN使用
  • 安全和便捷:如何将运营商二要素API应用于实名制管理中
  • leetcode-二叉树
  • 【鸿蒙软件开发】ArkTS基础组件之TextTimer(文本显示计时)、TimePicker(时间选择)
  • pytorch 笔记:KLDivLoss
  • 父子项目打包发布至私仓库
  • 汽车网络安全--ECU的安全更新
  • NLP之搭建RNN神经网络
  • Android问题笔记四十三:JNI 开发如何快速定位崩溃问题
  • 机器学习 | 决策树算法
  • javascript中各种风骚的代码
  • el-tree横向纵向滚动条
  • STM32G030F6P6 芯片实验 (一)
  • Wpf 使用 Prism 实战开发Day01
  • 6G关键新兴技术- 智能超表面(RIS)技术演进
  • 【redhat9.2】搭建Discuz-X3.5网站
  • 算法篇 : 并查集
  • AM@微积分基本定理@微积分第二基本定理
  • goland常用快捷键
  • CSDN写文章时常见问题及技巧
  • JVM虚拟机详解
  • Go 怎么操作 OSS 阿里云对象存储
  • vue3 Suspense组件