Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >PyQt5 动画类--跳舞的火柴人

PyQt5 动画类--跳舞的火柴人

作者头像
用户6021899
发布于 2019-11-14 09:08:36
发布于 2019-11-14 09:08:36
1.7K00
代码可运行
举报
运行总次数:0
代码可运行

PyQt5.QtCore中的 QPropertyAnimation可以实现动画功能。

下面第一个例子通过将一个QLabel对象移动和放大来实现简单的动画:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
import sysfrom PyQt5.QtCore import QPropertyAnimation, QRect, QEasingCurvefrom PyQt5 import QtGuifrom PyQt5.QtWidgets import QApplication, QWidget, QLabel
class AnimationDemo(QWidget):    def __init__(self):        super().__init__()        self.resize(800, 800)        self.label = QLabel('Move', self)        pixmap = QtGui.QPixmap('sight.jpg')        self.label.setPixmap(pixmap)        self.label.setGeometry(0, 0, 300, 300)        self.animation = QPropertyAnimation(self.label, b'geometry')         # 实例化一个动画对象          # 参数1  动画要操作的对象          # 参数2  要改变的属性     geometry位置和大小                    #注意:字节类型                    #pos---位置动画---QPoint                    #size---大小动画---QSize                    #geometry----位置+大小动画----QRect                    #windowOpacity---窗口的透明度(0.0是透明的    1.0是不透明)        self.animation.setDuration(5000)  # 设置动画持续时间。单位毫秒        self.animation.setStartValue(QRect(0, 0, 300, 300))  #动画开始时的位置和大小        self.animation.setEndValue(QRect(500, 500, 500, 500))  #动画结束时的位置和大小        #self.animation.setEasingCurve(QEasingCurve.InBounce) #设置缓和曲线        self.animation.setLoopCount(-1)  #设置循环次数            #-1  无限循环            #0  不循环            #正数   循环次数                self.animation.start()#动画开始        if __name__ == "__main__":    app = QApplication(sys.argv)    demo = AnimationDemo()    demo.show()    sys.exit(app.exec_())

第二个例子来自PyQt4官方demo(现已升级为PyQt5版本)。代码实现了一个火柴人,他开心时可以跳跃、可以舞蹈,不开心时可以躺地上……

代码有点复杂:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#!/usr/bin/env python################################################################################# Copyright (C) 2010 Riverbank Computing Limited.## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).## All rights reserved.

import mathfrom PyQt5 import QtCore, QtWidgets, QtGuiimport stickman_qrc
class Node(QtWidgets.QGraphicsObject):    positionChanged = QtCore.pyqtSignal()    def __init__(self, pos, parent=None):        super().__init__(parent)        self.m_dragging = False        self.setPos(pos)        self.setFlag(QtWidgets.QGraphicsItem.ItemSendsGeometryChanges)    def boundingRect(self):        return QtCore.QRectF(-6.0, -6.0, 12.0, 12.0)    def paint(self, painter, option, widget):        painter.setPen(QtCore.Qt.white)        painter.drawEllipse(QtCore.QPointF(0.0, 0.0), 5.0, 5.0)    def itemChange(self, change, value):        if change == QtWidgets.QGraphicsItem.ItemPositionChange:            self.positionChanged.emit()        return super(Node, self).itemChange(change, value)    def mousePressEvent(self, event):        self.m_dragging = True    def mouseMoveEvent(self, event):        if self.m_dragging:            self.setPos(self.mapToParent(event.pos()))    def mouseReleaseEvent(self, event):        self.m_dragging = False
Coords = (    # Head: 0    (0.0, -150.0),    # Body pentagon, top->bottom, left->right: 1 - 5    (0.0, -100.0),    (-50.0, -50.0),    (50.0, -50.0),    (-25.0, 50.0),    (25.0, 50.0),    # Right arm: 6 - 7    (-100.0, 0.0),    (-125.0, 50.0),    # Left arm: 8 - 9    (100.0, 0.0),    (125.0, 50.0),    # Lower body: 10 - 11    (-35.0, 75.0),    (35.0, 75.0),    # Right leg: 12 - 13    (-25.0, 200.0),    (-30.0, 300.0),    # Left leg: 14 - 15    (25.0, 200.0),    (30.0, 300.0))
Bones = (    # Neck.    (0, 1),    # Body.    (1, 2),    (1, 3),    (1, 4),    (1, 5),    (2, 3),    (2, 4),    (2, 5),    (3, 4),    (3, 5),    (4, 5),    # Right arm.    (2, 6),    (6, 7),    # Left arm.    (3, 8),    (8, 9),    # Lower body.    (4, 10),    (4, 11),    (5, 10),    (5, 11),    (10, 11),    # Right leg.    (10, 12),    (12, 13),    # Left leg.    (11, 14),    (14, 15))
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释 
* class StickMan(QtWidgets.QGraphicsObject):    def __init__(self):        super().__init__()        self.m_sticks = True        self.m_isDead = False        self.m_pixmap = QtGui.QPixmap('images/head.png')        self.m_penColor = QtGui.QColor(QtCore.Qt.white)        self.m_fillColor = QtGui.QColor(QtCore.Qt.black)        # Set up start position of limbs.        self.m_nodes = []        for x, y in Coords:            node = Node(QtCore.QPointF(x, y), self)            node.positionChanged.connect(self.childPositionChanged)            self.m_nodes.append(node)        self.m_perfectBoneLengths = []        for n1, n2 in Bones:            node1 = self.m_nodes[n1]            node2 = self.m_nodes[n2]            dist = node1.pos() - node2.pos()            self.m_perfectBoneLengths.append(math.hypot(dist.x(), dist.y()))        self.startTimer(10)    def childPositionChanged(self):        self.prepareGeometryChange()    def setDrawSticks(self, on):        self.m_sticks = on        for node in self.m_nodes:            node.setVisible(on)    def drawSticks(self):        return self.m_sticks    def boundingRect(self):        # Account for head radius of 50.0 plus pen which is 5.0.        return self.childrenBoundingRect().adjusted(-55.0, -55.0, 55.0, 55.0)    def nodeCount(self):        return len(self.m_nodes)    def node(self, idx):        if idx >= 0 and idx < len(self.m_nodes):            return self.m_nodes[idx]        return None    def timerEvent(self, e):        self.update()    def stabilize(self):        threshold = 0.001        for i, (n1, n2) in enumerate(Bones):            node1 = self.m_nodes[n1]            node2 = self.m_nodes[n2]            pos1 = node1.pos()            pos2 = node2.pos()            dist = pos1 - pos2            length = math.hypot(dist.x(), dist.y())            diff = (length - self.m_perfectBoneLengths[i]) / length            p = dist * (0.5 * diff)            if p.x() > threshold and p.y() > threshold:                pos1 -= p                pos2 += p                node1.setPos(pos1)                node2.setPos(pos2)    def posFor(self, idx):        return self.m_nodes[idx].pos()    @QtCore.pyqtProperty(QtGui.QColor)    def penColor(self):        return QtGui.QColor(self.m_penColor)    @penColor.setter    def penColor(self, color):        self.m_penColor = QtGui.QColor(color)    @QtCore.pyqtProperty(QtGui.QColor)    def fillColor(self):        return QtGui.QColor(self.m_fillColor)    @fillColor.setter    def fillColor(self, color):        self.m_fillColor = QtGui.QColor(color)    @QtCore.pyqtProperty(bool)    def isDead(self):        return self.m_isDead    @isDead.setter    def isDead(self, isDead):        self.m_isDead = isDead    def paint(self, painter, option, widget):        self.stabilize()               if self.m_sticks:            painter.setPen(QtCore.Qt.white)            for n1, n2 in Bones:                node1 = self.m_nodes[n1]                node2 = self.m_nodes[n2]                painter.drawLine(node1.pos(), node2.pos())        else:            # First bone is neck and will be used for head.            path = QtGui.QPainterPath()            path.moveTo(self.posFor(0))            path.lineTo(self.posFor(1))            # Right arm.            path.lineTo(self.posFor(2))            path.lineTo(self.posFor(6))            path.lineTo(self.posFor(7))            # Left arm.            path.moveTo(self.posFor(3))            path.lineTo(self.posFor(8))            path.lineTo(self.posFor(9))            # Body.            path.moveTo(self.posFor(2))            path.lineTo(self.posFor(4))            path.lineTo(self.posFor(10))            path.lineTo(self.posFor(11))            path.lineTo(self.posFor(5))            path.lineTo(self.posFor(3))            path.lineTo(self.posFor(1))            # Right leg.            path.moveTo(self.posFor(10))            path.lineTo(self.posFor(12))            path.lineTo(self.posFor(13))            # Left leg.            path.moveTo(self.posFor(11))            path.lineTo(self.posFor(14))            path.lineTo(self.posFor(15))            painter.setPen(QtGui.QPen(self.m_penColor, 5.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap))            painter.drawPath(path)            n1, n2 = Bones[0]            node1 = self.m_nodes[n1]            node2 = self.m_nodes[n2]            dist = node2.pos() - node1.pos()            sinAngle = dist.x() / math.hypot(dist.x(), dist.y())            angle = math.degrees(math.asin(sinAngle))            headPos = node1.pos()            painter.translate(headPos)            painter.rotate(-angle)            painter.setBrush(self.m_fillColor)            painter.drawEllipse(QtCore.QPointF(0, 0), 50.0, 50.0)            painter.setBrush(self.m_penColor)            painter.setPen(QtGui.QPen(self.m_penColor, 2.5, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap))            # Eyes.            if self.m_isDead:                painter.drawLine(-30.0, -30.0, -20.0, -20.0)                painter.drawLine(-20.0, -30.0, -30.0, -20.0)                painter.drawLine(20.0, -30.0, 30.0, -20.0)                painter.drawLine(30.0, -30.0, 20.0, -20.0)            else:                painter.drawChord(QtCore.QRectF(-30.0, -30.0, 25.0, 70.0), 30.0 * 16, 120.0 * 16)                painter.drawChord(QtCore.QRectF(5.0, -30.0, 25.0, 70.0), 30.0 * 16, 120.0 * 16)            # Mouth.            if self.m_isDead:                painter.drawLine(-28.0, 2.0, 29.0, 2.0)            else:                painter.setBrush(QtGui.QColor(128, 0, 64 ))                painter.drawChord(QtCore.QRectF(-28.0, 2.0 - 55.0 / 2.0, 57.0, 55.0), 0.0, -180.0 * 16)            # Pupils.            if not self.m_isDead:                painter.setPen(QtGui.QPen(self.m_fillColor, 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap))                painter.setBrush(self.m_fillColor)                painter.drawEllipse(QtCore.QPointF(-12.0, -25.0), 5.0, 5.0)                painter.drawEllipse(QtCore.QPointF(22.0, -25.0), 5.0, 5.0)
*/
class GraphicsView(QtWidgets.QGraphicsView):    keyPressed = QtCore.pyqtSignal(int)    def keyPressEvent(self, e):        if e.key() == QtCore.Qt.Key_Escape:            self.close()        self.keyPressed.emit(QtCore.Qt.Key(e.key()))
class Frame(object):       def __init__(self):        self.m_nodePositions = []    def nodeCount(self):        return len(self.m_nodePositions)    def setNodeCount(self, nodeCount):        while nodeCount > len(self.m_nodePositions):            self.m_nodePositions.append(QtCore.QPointF())        while nodeCount < len(self.m_nodePositions):            self.m_nodePositions.pop()    def nodePos(self, idx):        return QtCore.QPointF(self.m_nodePositions[idx])    def setNodePos(self, idx, pos):        self.m_nodePositions[idx] = QtCore.QPointF(pos)
class Animation(object):    def __init__(self):        self.m_currentFrame = 0        self.m_frames = [Frame()]        self.m_name = ''    def setTotalFrames(self, totalFrames):        while len(self.m_frames) < totalFrames:            self.m_frames.append(Frame())        while totalFrames < len(self.m_frames):            self.m_frames.pop()    def totalFrames(self):        return len(self.m_frames)    def setCurrentFrame(self, currentFrame):        self.m_currentFrame = max(min(currentFrame, self.totalFrames() - 1), 0)    def currentFrame(self):        return self.m_currentFrame    def setNodeCount(self, nodeCount):        frame = self.m_frames[self.m_currentFrame]        frame.setNodeCount(nodeCount)    def nodeCount(self):        frame = self.m_frames[self.m_currentFrame]        return frame.nodeCount()    def setNodePos(self, idx, pos):        frame = self.m_frames[self.m_currentFrame]        frame.setNodePos(idx, pos)    def nodePos(self, idx):        frame = self.m_frames[self.m_currentFrame]        return frame.nodePos(idx)    def name(self):        return self.m_name    def setName(self, name):        self.m_name = name    def save(self, device):        stream = QtCore.QDataStream(device)        stream.writeQString(self.m_name)        stream.writeInt(len(self.m_frames))        for frame in self.m_frames:            stream.writeInt(frame.nodeCount())            for i in range(frame.nodeCount()):                stream << frame.nodePos(i)    def load(self, device):        self.m_frames = []        stream = QtCore.QDataStream(device)        self.m_name = stream.readQString()        frameCount = stream.readInt()        for i in range(frameCount):            nodeCount = stream.readInt()            frame = Frame()            frame.setNodeCount(nodeCount)            for j in range(nodeCount):                pos = QtCore.QPointF()                stream >> pos                frame.setNodePos(j, pos)            self.m_frames.append(frame)
class KeyPressTransition(QtCore.QSignalTransition):    def __init__(self, receiver, key, target=None):        super(KeyPressTransition, self).__init__(receiver.keyPressed)        self.m_key = key        if target is not None:            self.setTargetState(target)    def eventTest(self, e):        if super(KeyPressTransition, self).eventTest(e):            key = e.arguments()[0]            return key == self.m_key        return False
class LightningStrikesTransition(QtCore.QEventTransition):    def __init__(self, target):        super().__init__()        self.setEventSource(self)        self.setEventType(QtCore.QEvent.Timer)        self.setTargetState(target)        QtCore.qsrand(QtCore.QDateTime.currentDateTime().toTime_t())        self.startTimer(1000)    def eventTest(self, e):        return (super(LightningStrikesTransition, self).eventTest(e) and                (QtCore.qrand() % 50) == 0)
class LifeCycle(object):    def __init__(self, stickMan, keyReceiver):        self.m_stickMan = stickMan        self.m_keyReceiver = keyReceiver        # Create animation group to be used for all transitions.        self.m_animationGroup = QtCore.QParallelAnimationGroup()        stickManNodeCount = self.m_stickMan.nodeCount()        self._pas = []        for i in range(stickManNodeCount):            pa = QtCore.QPropertyAnimation(self.m_stickMan.node(i), b'pos')            self._pas.append(pa)            self.m_animationGroup.addAnimation(pa)                   # Set up intial state graph.        self.m_machine = QtCore.QStateMachine()        self.m_machine.addDefaultAnimation(self.m_animationGroup)        self.m_alive = QtCore.QState(self.m_machine)        self.m_alive.setObjectName('alive')        # Make it blink when lightning strikes before entering dead animation.        lightningBlink = QtCore.QState(self.m_machine)        lightningBlink.assignProperty(self.m_stickMan.scene(),'backgroundBrush', QtCore.Qt.white)        lightningBlink.assignProperty(self.m_stickMan, 'penColor',QtCore.Qt.black)        lightningBlink.assignProperty(self.m_stickMan, 'fillColor',QtCore.Qt.white)        lightningBlink.assignProperty(self.m_stickMan, 'isDead', True)        timer = QtCore.QTimer(lightningBlink)        timer.setSingleShot(True)        timer.setInterval(100)        lightningBlink.entered.connect(timer.start)        lightningBlink.exited.connect(timer.stop)        self.m_dead = QtCore.QState(self.m_machine)        self.m_dead.assignProperty(self.m_stickMan.scene(), 'backgroundBrush',QtCore.Qt.black)        self.m_dead.assignProperty(self.m_stickMan, 'penColor',QtCore.Qt.white)        self.m_dead.assignProperty(self.m_stickMan, 'fillColor',QtCore.Qt.black)        self.m_dead.setObjectName('dead')        # Idle state (sets no properties).        self.m_idle = QtCore.QState(self.m_alive)        self.m_idle.setObjectName('idle')        self.m_alive.setInitialState(self.m_idle)        # Lightning strikes at random.        self.m_alive.addTransition(LightningStrikesTransition(lightningBlink))        lightningBlink.addTransition(timer.timeout, self.m_dead)        self.m_machine.setInitialState(self.m_alive)
    def setDeathAnimation(self, fileName):        deathAnimation = self.makeState(self.m_dead, fileName)        self.m_dead.setInitialState(deathAnimation)    def start(self):        self.m_machine.start()    def addActivity(self, fileName, key):        state = self.makeState(self.m_alive, fileName)        self.m_alive.addTransition(KeyPressTransition(self.m_keyReceiver, key, state))    def makeState(self, parentState, animationFileName):        topLevel = QtCore.QState(parentState)        animation = Animation()        file = QtCore.QFile(animationFileName)        if file.open(QtCore.QIODevice.ReadOnly):            animation.load(file)        frameCount = animation.totalFrames()        previousState = None        for i in range(frameCount):            animation.setCurrentFrame(i)            frameState = QtCore.QState(topLevel)            nodeCount = animation.nodeCount()            for j in range(nodeCount):                frameState.assignProperty(self.m_stickMan.node(j), b'pos',                        animation.nodePos(j))            frameState.setObjectName('frame %d' % i)            if previousState is None:                topLevel.setInitialState(frameState)            else:                previousState.addTransition(previousState.propertiesAssigned,                        frameState)            previousState = frameState        previousState.addTransition(previousState.propertiesAssigned,                topLevel.initialState())        return topLevel
if __name__ == '__main__':    import sys    app = QtWidgets.QApplication(sys.argv)    stickMan = StickMan()    stickMan.setDrawSticks(False)    textItem = QtWidgets.QGraphicsTextItem()    textItem.setHtml("<font color=\"white\"><b>Stickman</b>"        "<p>"        "Tell the stickman what to do!"        "</p>"        "<p><i>"        "<li>Press <font color=\"purple\">J</font> to make the stickman jump.</li>"        "<li>Press <font color=\"purple\">D</font> to make the stickman dance.</li>"        "<li>Press <font color=\"purple\">C</font> to make him chill out.</li>"        "<li>When you are done, press <font color=\"purple\">Escape</font>.</li>"        "</i></p>"        "<p>If he is unlucky, the stickman will get struck by lightning, and never jump, dance or chill out again."        "</p></font>")    w = textItem.boundingRect().width()    stickManBoundingRect = stickMan.mapToScene(stickMan.boundingRect()).boundingRect()    textItem.setPos(-w / 2.0, stickManBoundingRect.bottom() + 25.0)    scene = QtWidgets.QGraphicsScene()    scene.addItem(stickMan)    scene.addItem(textItem)    scene.setBackgroundBrush(QtCore.Qt.black)    view = GraphicsView()    view.setRenderHints(QtGui.QPainter.Antialiasing)    view.setTransformationAnchor(QtWidgets.QGraphicsView.NoAnchor)    view.setScene(scene)    view.show()    view.setFocus()       # Make enough room in the scene for stickman to jump and die.    sceneRect = scene.sceneRect()    view.resize(sceneRect.width() + 100, sceneRect.height() + 100)    view.setSceneRect(sceneRect)    cycle = LifeCycle(stickMan, view)    cycle.setDeathAnimation(':/animations/dead')    cycle.addActivity(':/animations/jumping', QtCore.Qt.Key_J)    cycle.addActivity(':/animations/dancing', QtCore.Qt.Key_D)    cycle.addActivity(':/animations/chilling', QtCore.Qt.Key_C)    cycle.start()        sys.exit(app.exec_())
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2019-11-11,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Python可视化编程机器学习OpenCV 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
​【腾讯云ES】自建ES集群在线融合迁移原理解析及操作指南
随着腾讯云ES集群稳定性越来越高、产品体验越来越好。有越来越多的外部客户希望将自建的ES集群迁移到腾讯云上来。本文将介绍一种腾讯云ES在业界独有的业务不停服无感知的迁移方案--在线融合迁移方案。本方案目前已经迁移了上百套客户自建ES集群上云。下面将结合我们在给客户迁移过程中总结出的宝贵经验,来详细介绍下在线融合迁移技术方案的基本原理、核心优势、迁移步骤和注意事项。
吴容
2022/12/09
2.6K0
​【腾讯云ES】自建ES集群在线融合迁移原理解析及操作指南
ES CCR同步最佳实践
1. 如图,首先在follower集群建立两个集群的远程连接(连接的节点只添加一个也会发现所有seed nodes)
沈小翊
2023/11/08
6791
跨集群复制 Cross-cluster replication(CCR)
跨集群复制(CCR)功能支持将远程集群中的索引复制到本地集群,可以在一些常见的生产用例中使用此功能:
南非骆驼说大数据
2020/10/26
3.3K0
Elasticsearch跨集群复制(CCR)之腾讯云ES跨地域容灾
腾讯云ES目前已经提供了多可用区部署,即支持同地域跨机房的高可用容灾方案,满足了绝大多数客户的需求。但是依然会有部分客户希望进一步提升容灾级别,能够做到跨地域容灾。随着腾讯云ES双网卡功能的发布,使得跨地域容灾成为可能。接下来我将介绍下腾讯云ES实现跨地域容灾的详细步骤。
吴容
2020/08/18
5.3K3
Elasticsearch跨集群复制(CCR)之腾讯云ES跨地域容灾
自建ES集群迁移至腾讯云ES的几种方案介绍
随着腾讯云Elasticsearch产品功能越来越丰富、产品体验越来越好。越来越多的客户将自建的ES集群或者部署在其他云厂商的 ES 集群迁移到腾讯云上来。为了更加方便快捷地帮助客户完成集群迁移工作,下面简单介绍下可提供的两种迁移方案,离线迁移和在线迁移。
吴容
2020/07/28
4.3K0
自建ES集群迁移至腾讯云ES的几种方案介绍
ElasticSearch高级功能:Cross Cluster Replication实战
ElasticSearch在platinum版本中,推出了Cross Cluster Replication特性(以下简称CCR),也即跨集群远程复制。
一枚hammer
2020/06/02
3.3K0
ElasticSearch高级功能:Cross Cluster Replication实战
腾讯云ES如何通过Reindex实现跨集群数据拷贝<上>
在前面的生产实践中,我们经常会用reindex命令去拷贝复制索引文档,但是除了此功能,reindex还能实现跨集群复制索引,今天我们来试试这个功能.我将以自建集群与云上集群为标准,互相使用Reindex,来实现数据的跨越拷贝。拓扑如下:
南非骆驼说大数据
2020/12/24
3.7K0
Elasticsearch数据在线迁移方案
本文描述问题及解决方法同样适用于 腾讯云 Elasticsearch Service(ES)。
岳涛
2023/08/31
1K0
Elasticsearch数据在线迁移方案
E往无前 | 腾讯云大数据 ElasticSearch 高级功能:Cross Cluster Replication实战
Elasticsearch在platinum版本中,推出了Cross Cluster Replication特性(以下简称CCR),也即跨集群远程复制。
腾讯QQ大数据
2023/07/26
3600
E往无前 | 腾讯云大数据 ElasticSearch 高级功能:Cross Cluster Replication实战
Elasticsearch 在线融合过程中Kibana无法访问处理过程
前几天,在给客户做在线迁移的时候,突然出现了Kibana无法访问,浏览器,返回报错500.如下图所示:
南非骆驼说大数据
2021/04/09
3.1K1
中间件PaaS层组件容灾方案及实践
当下,随着数字化技术不断深入,愈来愈多企业将核心业务搬到线上。业务系统高可用、可扩展、容灾能力决定企业系统的连续性,中间件作为构建企业核心系统的重要组成部分,其高可用容灾能力也将决定应用系统的。本文结合腾讯云中间件各PaaS产品的容灾能力及实践,以一个行业头部客户业务容灾实践举例,来展开说明基于腾讯云中间件PaaS层相关产品的实践。
邓愉悦
2021/05/31
4.5K12
在线不停服迁移自建ES集群至腾讯云ES
在之前的文章Elasticsearch跨集群数据迁移之离线迁移中,我们介绍了如何在离线场景下把自建的ES集群或者在其它云厂商购买的ES集群迁移至腾讯云的ES, 但是如果在迁移过程中业务不能中断或者不能够暂停写操作,就必须采用其它的方案进行迁移。2020年5月份,腾讯云ES上线的新版本中,对集群节点所在的网络进行了优化,使得集群节点能够反向访问到用户VPC下的ip,因此采用集群融合的方式可以实现在线不停服地迁移自建ES集群至腾讯云ES。
bellen
2020/05/22
4.5K1
在线不停服迁移自建ES集群至腾讯云ES
Elasticsearch跨集群复制(CCR)之腾讯云ES跨地域容灾
腾讯云ES目前已经提供了多可用区部署,即支持同地域跨机房的高可用容灾方案,满足了绝大多数客户的需求。但是依然会有部分客户希望进一步提升容灾级别,能够做到跨地域容灾。随着腾讯云ES双网卡功能的发布,使得跨地域容灾成为可能。接下来我将介绍下腾讯云ES实现跨地域容灾的详细步骤。
腾讯云大数据
2021/01/08
3.9K0
Elasticsearch跨集群复制(CCR)之腾讯云ES跨地域容灾
如何在腾讯云上开启ES集群的跨进群复制功能(CCR)
腾讯云是Elastic在中国主要的云厂商合作伙伴,在腾讯云上也有提供Elasticsearch的SaaS服务。其名称为Elasticsearch Service(ES)。以下是腾讯云上的产品介绍:
点火三周
2020/12/08
7.2K0
腾讯云Elasticsearch跨集群复制原理及最佳实践
跨集群复制即CCR,是一种能够实现数据迁移、数据备份、降低访问延迟的高可用解决方案。跨集群复制采用的是一个主备的架构模型。在主集群中创建一系列leader索引,在备集群中通过主动Pull方式复制数据到follower索引中,且follower索引为只读索引。
吴容
2021/11/20
4.8K0
腾讯云Elasticsearch跨集群复制原理及最佳实践
Kibana 看不到监控数据,怎么办?
问题描述:客户反馈其Kibana的stack monitor功能无法正常展示,报错如下:
南非骆驼说大数据
2021/03/02
2.4K1
elasticsearch CCR CCS互信配置
export ES_JAVA_HOME=/data/es8/cluster1/node1/jdk
周银辉
2024/06/27
2901
腾讯云 Elasticsearch 运维篇(十二)API访问ES集群
上一章节,我们通过腾讯云控制台快速搭建了一个ES集群,通过Kibana我们在公网能进行安全的访问。同时,我们在Kibana里边针对不同的索引需求新建了不同的账户进行登录测试。往往实际情况是我们在腾讯云上有多台主机,多个集群,我们需要通过内网去访问和操作ES集群,所以,今天来讲讲这个问题。
南非骆驼说大数据
2020/02/21
4.5K0
腾讯云Elasticsearch Watcher 功能之 Webhook实践
Elasticsearch 的商业包 x-pack 给我们提供了很多高阶功能,其中有一个非常重要的用来检测日志是否异常并及时发送警报信息的功能,我们称这个功能为Watcher for alert.
南非骆驼说大数据
2020/12/03
3.4K1
腾讯云Elasticsearch Watcher 功能之 Webhook实践
腾讯云 Elasticsearch 实战篇(二十二) ES6.8权限使用配置
在前面的章节中我们讲了开源架构ELK、腾讯云Elasticsearch产品系列。我们也知道了,在构建腾讯云ES集群的时候,我们选择的6.8.2白金版具备充分的安全的机制来保证数据和访问的安全。那么,它到底是如何实现的呢?我们今天就来简单聊聊这个问题:
南非骆驼说大数据
2020/03/01
4.2K0
推荐阅读
相关推荐
​【腾讯云ES】自建ES集群在线融合迁移原理解析及操作指南
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验