Redis cluster construction and redislive monitoring and deployment
redis cluster construction and monitoring environment
Achieve a cluster of 3 masters and 3 slaves. Single machine IP: 192.168.40.128
Basic cluster construction
Simple download
Via
wget http://download.redis.io/releases/redis-4.0.10.tar.gz
Unzip
tar zxvf redis-4.0.10.tar.gz
Specify the installation path, switch to root user and execute
make && make PREFIX=/usr/ local/redis install
, there may be a problem of insufficient permissions, sudo will also report an error, use root directly to operate.
Install compilation tools
sudo apt-get update
-
sudo apt-get install gcc
sudo apt-get install make
sudo apt-get install tcl
#Create the redis cluster folder
Because it is /usr, So always operate under root permissions
##cd /usr/local/redis
mkdir cluster
cd cluster
mkdir 7000 7001 7002 7003 7004 7005
Modify the configuration fileCopy the config file in redis conf to six folders, and modify the following content
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Startup script
cd / home/ubuntu/redis-4.0.10/
touch start.link.sh
For easy operation, create a script
- Modify the startup script to
1 2 3 4 5 6 7 8 9 10 |
|
Cluster startup
- The associated program is written in ruby. So to set up rudy's operating environment, you need to install rudbygem
sudo apt-get install ruby rubygems -y
- gem install redis, running here will feel very slow, you need to wait patiently, in the redis installation directory, src folder redis-trib.rb
- run
redis-trib. rb create --replicas 1 192.168.40.128:7000 192.168.40.128:7001 192.168.40.128:7002 192.168.40.128:7003 192.168.40.128:7004 192.168.40.12 8:7005
, check whether the configured information is correct, there is no direct Just yes.
[OK] All 16384 slots covered.means the group connection is started successfully.
Node check, restart Check the cluster running status: use the command
./redis-trib.rb check 192.168.40.128:7000, check the status of the cluster
Performance test Comes with the test tool redis-benchmark
redis-benchmark - h 192.168.40.128 -p 6379 -c 100 -n 100000
100 concurrent connections, 100000 requests, detect the performance of the redis server whose host is localhost and the port is 6379.
redis-benchmark -h 192.168.40.128 -p 6379 -q -d 100
Test the performance of accessing data packets with a size of 100 bytes.
redis-benchmark -t set,lpush -n 100000 -q
Only test the performance of certain operations.
redis-benchmark -n 100000 -q script load "redis.call('set','foo','bar')"
Only test some Performance of numerical access.
Cluster password settingNo password is required for the initial cluster establishment. After the startup is completed, first check whether the configuration file of each node has read and write permissions. If There is no read and write permissions. You need to modify the read and write permissions by chmod. Connect each node separately for settings through
1 2 3 4 |
|
If you find that the connection cannot be reached after restarting, modify the startup script redis-.sh line 99 and configure Startup script password startup
@r = Redis.new(:host => @info[:host], :port => @info[:port], :timeout => 60,:password => "yangfan@1995")
Code test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
*集群连接测试
*/
@Test
public
void testJedisCluster() {
Set<HostAndPort> nodes =
new
LinkedHashSet<>();
//所有主机节点ip和端口
nodes.add(
new
HostAndPort(
"192.168.40.128"
, 7000));
nodes.add(
new
HostAndPort(
"192.168.40.128"
, 7001));
nodes.add(
new
HostAndPort(
"192.168.40.128"
, 7002));
nodes.add(
new
HostAndPort(
"192.168.40.128"
, 7003));
nodes.add(
new
HostAndPort(
"192.168.40.128"
, 7004));
nodes.add(
new
HostAndPort(
"192.168.40.128"
, 7005));
//没有密码
//JedisCluster cluster = new JedisCluster(nodes);
//添加密码调用
JedisCluster cluster =
new
JedisCluster(nodes, 5000, 5000, 10,
"yangfan@1995"
,
new
GenericObjectPoolConfig());
//cluster.zadd("test_1", String.valueOf(""),"id_2");
System.out.println(cluster.zscore(
"test_1"
,
"id_1"
));
try
{
cluster.close();
}
catch
(IOException e) {
e.printStackTrace();
}
}
Copy after login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
The relationship between master-slave mode, sentry, and cluster
- The master-slave mode specifies the replication and persistence relationship, and the master-slave backup relationship.
- Sentinel: When the master database encounters an exception and interrupts the service, developers can manually method to select a slave database to upgrade to the master database so that the system can continue to provide services. It is mainly a detection tool to solve the problem of manual switching of master-slave relationship during master-slave replication, and can automatically switch master-slave.
使用哨兵,redis每个实例也是全量存储,每个redis存储的内容都是完整的数据,浪费内存且有木桶效应。为了最大化利用内存,可以采用集群,就是分布式存储。即每台redis存储不同的内容,共有16384个slot。每个redis分得一些slot,hash_slot = crc16(key) mod 16384 找到对应slot,键是可用键,如果有{}则取{}内的作为可用键,否则整个键是可用键集群至少需要3主3从,且每个实例使用不同的配置文件,主从不用配置,集群会自己选。
监控部署
RedisLive搭建部署
运行环境部署
git clone https://github.com/kumarnitin/RedisLive.git
下载redislive,解压缩unzip -o -d /home/ubuntu/ RedisLive-master.zip
进入src文件夹,复制example文件,编辑
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"RedisServers"
:
[
{
"server"
:
"192.168.40.128"
,
"port"
: 7000,
"password"
:
"yangfan@1995"
},
//...多个监听
],
"DataStoreType"
:
"redis"
,
"RedisStatsServer"
:
//存储的redis监听接口
{
"server"
:
"127.0.0.1"
,
"port"
: 6379
},
"SqliteStatsStore"
:
{
"path"
:
"/home/ubuntu/redis-4.0.10/working/redislive.db"
//进行存储的文件
} }
Copy after loginubuntu@ubuntu:~/redis-4.0.10$ mkdir pid
ubuntu@ubuntu:~/redis-4.0.10$ mkdir log
ubuntu@ubuntu:~/redis-4.0.10$ mkdir working
//保存aof,rdb,node-config文件。RedisLive分为两部分,其中一部分为监控脚本,另一部分为web服务,所以需要分别启动。`./redis-monitor.py
--duration=120`./redis-live.py
redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException: No reachable node in cluster redis node的redis.conf 绑定ip设置为指定的redis节点ip,启动集群时只用指定ip启动,不使用192.168.40.128
connect refuse 关闭防火墙
No module named redis
查看python位置
which python
先备份
sudo cp /usr/bin/python /usr/bin/python_cp
删除
sudo rm /usr/bin/python
默认设置成python3.5,创建链接
sudo ln -s /usr/bin/python3.5 /usr/bin/python
Q&A
相关推荐:
The above is the detailed content of Redis cluster construction and redislive monitoring and deployment. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Perfect Number in Java. Here we discuss the Definition, How to check Perfect number in Java?, examples with code implementation.

Guide to Weka in Java. Here we discuss the Introduction, how to use weka java, the type of platform, and advantages with examples.

Guide to Smith Number in Java. Here we discuss the Definition, How to check smith number in Java? example with code implementation.

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

Guide to TimeStamp to Date in Java. Here we also discuss the introduction and how to convert timestamp to date in java along with examples.

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.
