首页 > 数据库 >redis自动化安装

redis自动化安装

时间:2024-01-18 10:24:07浏览次数:28  
标签:10.0 cli redis cluster 6380 自动化 0.51 安装

1.ruby脚本自动化安装

1.安装ruby开发环境
yum install rubygems -y

2.通过ruby包管理工具,安装操作redis的模块

gem sources --remove https://rubygems.org/
gem sources --remove http://mirrors.aliyun.com/rubygems/

gem sources -a https://mirrors.cloud.tencent.com/rubygems/

[root@db-51 ~]#gem sources -l
*** CURRENT SOURCES ***

https://mirrors.cloud.tencent.com/rubygems/

[root@db-51 ~]#gem install redis -v 3.3.3
Fetching: redis-3.3.3.gem (100%)
Successfully installed redis-3.3.3
Parsing documentation for redis-3.3.3
Installing ri documentation for redis-3.3.3
1 gem installed


2.清空redis环境
redis-cli -c -h 10.0.0.51 -p 6380 flushall
redis-cli -c -h 10.0.0.52 -p 6380 flushall
redis-cli -c -h 10.0.0.53 -p 6380 flushall

redis-cli  -h 10.0.0.51 -p 6380 cluster reset
redis-cli  -h 10.0.0.52 -p 6380 cluster reset
redis-cli  -h 10.0.0.53 -p 6380 cluster reset

redis-cli  -h 10.0.0.51 -p 6381 cluster reset
redis-cli  -h 10.0.0.52 -p 6381 cluster reset
redis-cli  -h 10.0.0.53 -p 6381 cluster reset

3.试试还能用吗redis-cluster
[root@db-51 ~]#redis-cli -c  -h 10.0.0.51 -p 6380 
10.0.0.51:6380> cluster info
cluster_state:fail

[root@db-51 ~]#redis-cli -c  -h 10.0.0.51 -p 6380 
10.0.0.51:6380> set name yuchao
(error) CLUSTERDOWN Hash slot not served




4.一键自动化部署redis集群
[root@db-51 ~]#
[root@db-51 ~]#/opt/redis/src/redis-trib.rb create --replicas 1 10.0.0.51:6380 10.0.0.52:6380 10.0.0.53:6380 10.0.0.51:6381 10.0.0.52:6381 10.0.0.53:6381
WARNING: redis-trib.rb is not longer available!
You should use redis-cli instead.

All commands and features belonging to redis-trib.rb have been moved
to redis-cli.
In order to use them you should call redis-cli with the --cluster
option followed by the subcommand name, arguments and options.

Use the following syntax:
redis-cli --cluster SUBCOMMAND [ARGUMENTS] [OPTIONS]

Example:
redis-cli --cluster create 10.0.0.51:6380 10.0.0.52:6380 10.0.0.53:6380 10.0.0.51:6381 10.0.0.52:6381 10.0.0.53:6381 --cluster-replicas 1

To get help about all subcommands, type:
redis-cli --cluster help


5.发现命令更新了,每一个节点自动分配一个slave
redis-cli --cluster create 10.0.0.51:6380 10.0.0.52:6380 10.0.0.53:6380 10.0.0.51:6381 10.0.0.52:6381 10.0.0.53:6381 --cluster-replicas 1

 

使用集群测试

[root@db-51 ~]#redis-cli -c -h 10.0.0.51 -p 6381
10.0.0.51:6381> dbsize
(integer) 0
10.0.0.51:6381> set name www.yuchaoit.cn
-> Redirected to slot [5798] located at 10.0.0.52:6380
OK
10.0.0.52:6380> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:4
cluster_stats_messages_ping_sent:3340
cluster_stats_messages_pong_sent:3224
cluster_stats_messages_meet_sent:5
cluster_stats_messages_sent:6569
cluster_stats_messages_ping_received:3224
cluster_stats_messages_pong_received:3342
cluster_stats_messages_received:6566
10.0.0.52:6380>

标签:10.0,cli,redis,cluster,6380,自动化,0.51,安装
From: https://www.cnblogs.com/sxy-blog/p/17971922

相关文章

  • redis实战技巧
    1.分析key大小[root@db-51~]#redis-cli-h10.0.0.51-p6380--bigkeys#Scanningtheentirekeyspacetofindbiggestkeysaswellas#averagesizesperkeytype.Youcanuse-i0.1tosleep0.1sec#per100SCANcommands(notusuallyneeded).--------......
  • redis数据持久化篇
    为什么需要持久化Redis是个基于内存的数据库。那服务一旦宕机,内存中的数据将全部丢失。通常的解决方案是从后端数据库恢复这些数据,但后端数据库有性能瓶颈如果是大数据量的恢复,1、会对数据库带来巨大的压力,2、数据库的性能不如Redis。导致程序响应慢。所以对Redis来说,实现数......
  • redis安全篇
    redis被攻击,作为突破口,服务器惨遭毒手的事太常见了。大多数云服务器被攻击,都是redis,mongodb等数据库被入侵。因此修改端口,密码,以及注意bind运行地址,是必须。思考是否要暴露redis到公网。1.设置密码、端口配置[root@db-51~]#cat/opt/redis_6379/conf/redis_6379.confdae......
  • es安装分词插件elasticsearch-analysis-ik(elasticsearch-plugin方式安装)
    环境:OS:Centos7ES:6.8.5 1.查看当前的安装的插件[root@hadoop-slave1soft]#curl-uelastic:123456-XGET"http://192.168.1.63:19200/_cat/plugins?v&s=component&h=name,component,version,description&pretty"namecomponentversiondescription 2.将分......
  • 使用 Docker 安装 MongoDB 数据库
    byemanjusakafromhttps://www.emanjusaka.top/2024/01/docker-create-mongo-db彼岸花开可奈何本文欢迎分享与聚合,全文转载请留下原文地址。Docker安装命令dockerrun-d--namemongo--restart=always--privileged=true-p27017:27017-v/opt/doc/data:/data/dbmo......
  • Stirling-PDF docker安装
    有时候pdf文件需要处理,有个开源工具。https://github.com/Stirling-Tools/Stirling-PDF docker安装1、下载dockerpullfrooodle/s-pdf:latest2、安装dockerrun-d\-p8380:8080\-v/Users/xxxx/Documents/Stirling-PDF/data/:/usr/share/tesseract-ocr/4.......
  • 安装GPU版本Pytorch失败:torch.cuda.is_available()为False
    问题所在检查condalist发现,实际安装的Pytorch为CPU版本(虽然安装时明确指定了cuda版本):上图中可以看出,Pytorch的描述为:py3.9_cpu_0解决办法有可能是因为环境中存在一个叫“cpuonly”的包,导致无法安装GPU版本Pytorch:卸载掉它即可,卸载它时会自动将Pytorch更新为GPU版本:如果......
  • Git必知必会基础(02):Git安装、配置
     本系列汇总,请查看这里:https://www.cnblogs.com/uncleyong/p/10854115.html安装Git只有Windows系统需要手动安装Git软件, Linux和MacOS系统都自带Git(如果linux下想自己安装,参考:https://www.cnblogs.com/uncleyong/p/10767747.html)官网下载:https://git-scm.com/downloads......
  • 无涯教程-SQLite - 安装步骤
    SQLite以其出色的零配置功能而闻名,这意味着不需要复杂的设置或管理,本章将引导您完成在Windows,Linux和MacOSX上设置SQLite的过程。在Windows上安装步骤1-转到SQLite下载页面,并从Windows部分下载预编译的二进制文件。步骤2-下载sqlite-shell-win32-*.zip和sqlite-dll-win......
  • OpenCV安装与配置
    OpenCV安装与配置C++与OpenCV配置安装下载路径Releases-OpenCV添加Path环境变量的路径D:\OpenCV\opencv\build\x64\vc15\bin右击此电脑,选择属性,编辑环境变量设置的是dll文件的环境变量创建一个新的VisualStudioC++空项目尽量用英文路径测试代码#include<iostream......