码迷,mamicode.com
首页 > 其他好文 > 详细

redis单节点及集群搭建

时间:2020-07-29 21:49:59      阅读:75      评论:0      收藏:0      [点我收藏+]

标签:单节点   lease   conf   redis   time   gcc   efi   搭建   eve   

1.redis是单线程,高性能的key/value内存数据,基于内存运行并支持持久化的NoSQL数据库

2.redis主要用来做缓存,但不仅仅是做缓存,例如:redis的计数器生成分布式唯一主键,redis实现分布式锁,队列,会话缓存

安装单节点redis

1、安装gcc套装:
yum install cpp
yum install binutils
yum install glibc
yum install glibc-kernheaders
yum install glibc-common
yum install glibc-devel
yum install gcc
yum install make

2、升级gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash

3、设置永久升级:
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

4、安装redis:
wget http://download.redis.io/releases/redis-6.0.3.tar.gz
tar xzf redis-6.0.3.tar.gz
cd redis-6.0.3
make
make  PREFIX=/usr/local/redis install

5、修改redis.conf以daemon运行
[root@VM-55fbfec9-2204-4954-90b1-67271ee7c4b0 bin]# grep  daemon redis.conf 
daemonize yes

6、启动redis
./redis-server redis.conf 
./redis-cli 
[root@VM-55fbfec9-2204-4954-90b1-67271ee7c4b0 bin]# redis-cli 
127.0.0.1:6379> ping
PONG

安装redis集群

#创建配置文件
[root@VM-55fbfec9-2204-4954-90b1-67271ee7c4b0 kconfig]# cat redis6380.conf 
include /usr/local/bin/kconfig/redis.conf
pidfile "/var/run/redis6380.pid"
port 6380
dbfilename "dump6380.rdb"
cluster-enabled yes
cluster-config-file node-6380.conf
cluster-node-timeout 15000

#启动6个实例
[root@VM-55fbfec9-2204-4954-90b1-67271ee7c4b0 kconfig]# ps -ef|grep redis
root      31911      1  0 11:10 ?        00:00:02 redis-server 127.0.0.1:6380 [cluster]
root      31938      1  0 11:10 ?        00:00:02 redis-server 127.0.0.1:6381 [cluster]
root      31974      1  0 11:10 ?        00:00:02 redis-server 127.0.0.1:6382 [cluster]
root      32012      1  0 11:10 ?        00:00:02 redis-server 127.0.0.1:6390 [cluster]
root      32050      1  0 11:10 ?        00:00:02 redis-server 127.0.0.1:6391 [cluster]
root      32062      1  0 11:11 ?        00:00:02 redis-server 127.0.0.1:6392 [cluster]

#创建集群
redis-cli --cluster create 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6390 127.0.0.1:6391 127.0.0.1:6392 --cluster-replicas 1

#查看集群状态
[root@VM-55fbfec9-2204-4954-90b1-67271ee7c4b0 kconfig]# redis-cli -c -p 6380
127.0.0.1:6380> cluster nodes
9467d8a87b935deb57875689fccd4a22f5b44209 127.0.0.1:6391@16391 slave e59e4511ef9e2816c1a1fe8c89c17f4f8de5ae53 0 1595778201000 3 connected
43bebe3e0646119264ae865e508dfa5bfcedef36 127.0.0.1:6392@16392 slave 9e90af4a5f76f6d007a3e002285307286d17f5a6 0 1595778203817 1 connected
3926c5da0c5f32a114242ba1a4649d564af960ef 127.0.0.1:6390@16390 slave 353af028076bff70ebb69f9e9fb6cc057a1302e4 0 1595778202000 2 connected
e59e4511ef9e2816c1a1fe8c89c17f4f8de5ae53 127.0.0.1:6382@16382 master - 0 1595778202814 3 connected 10923-16383
9e90af4a5f76f6d007a3e002285307286d17f5a6 127.0.0.1:6380@16380 myself,master - 0 1595778203000 1 connected 0-5460
353af028076bff70ebb69f9e9fb6cc057a1302e4 127.0.0.1:6381@16381 master - 0 1595778201000 2 connected 5461-10922

redis单节点及集群搭建

标签:单节点   lease   conf   redis   time   gcc   efi   搭建   eve   

原文地址:https://www.cnblogs.com/kolord/p/13399244.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!