shardingsphere-proxy 实现postgresql的分库分表

news2024/10/7 6:40:03

1、docker 安装zookeeper

1、拉取镜像

docker pull zookeeper

2、运行容器

docker run -d -e TZ="Asia/Shanghai"  -p 2181:2181 -v /home/sunyuhua/docker/zookeeper:/data --name zookeeper --restart always zookeeper

3、查看容器是不是运行成功

docker exec -it zookeeper bash

./bin/zkCli.sh

2、docker 安装 shardingsphere-proxy

1、获取镜像中的配置

docker run -d --name tmp --entrypoint=bash apache/shardingsphere-proxy

docker cp tmp:/opt/shardingsphere-proxy/conf /home/sunyuhua/docker/shardingsphere-proxy/conf

docker rm tmp

2、启动shardingsphere-proxy

docker run -d -v /home/sunyuhua/docker/shardingsphere-proxy/conf:/opt/shardingsphere-proxy/conf -v /home/sunyuhua/docker/shardingsphere-proxy/ext-lib:/opt/shardingsphere-proxy/ext-lib -v /home/sunyuhua/docker/shardingsphere-proxy/logs:/opt/shardingsphere-proxy/logs -p3307:3307  --name sharding-proxy  --restart always  --network sharding-network  apache/shardingsphere-proxy

3、检查shardingsphere-proxy是否启动成功

docker logs sharding-proxy

3、docker 安装 postgresql13

1、拉取镜像

docker pull postgres:13

2、运行镜像

docker run -d --name postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres  -v /home/sunyuhua/docker/postgresql/data:/var/lib/postgresql/data -v /etc/localtime:/etc/localtime --restart=always  -p 5432:5432 postgres:13

3、进入docker容器检查是否成功

docker exec -it postgres /bin/bash

4、创建查询用户,并赋值权限

psql -U postgres


CREATE ROLE sa WITH SUPERUSER LOGIN PASSWORD 'boKYLXIERWnzB0gX';


grant all PRIVILEGES on database postgres to sa;

grant all PRIVILEGES on all tables in schema public TO sa;

ALTER ROLE sa CREATEROLE SUPERUSER;

4、准备数据库的表结构

CREATE DATABASE demo_ds_0;

\c demo_ds_0;

CREATE TABLE t_order_0 (
  order_id BIGINT NOT NULL,
  user_id BIGINT NOT NULL,
  total_money INT NOT NULL,
  PRIMARY KEY (order_id)
);

CREATE INDEX idx_user_id_0 ON t_order_0 (user_id);


CREATE TABLE t_order_1 (
  order_id BIGINT NOT NULL,
  user_id BIGINT NOT NULL,
  total_money INT NOT NULL,
  PRIMARY KEY (order_id)
);

CREATE INDEX idx_user_id_1 ON t_order_1 (user_id);



CREATE TABLE t_order_item_0 (
  order_item_id BIGINT NOT NULL,
  order_id BIGINT NOT NULL,
  user_id BIGINT NOT NULL,
  money INT NOT NULL,
  PRIMARY KEY (order_item_id)
);

CREATE INDEX idx_order_id_0 ON t_order_item_0 (order_id);
CREATE INDEX idx_user_id_0 ON t_order_item_0 (user_id);



CREATE TABLE t_order_item_1 (
  order_item_id BIGINT NOT NULL,
  order_id BIGINT NOT NULL,
  user_id BIGINT NOT NULL,
  money INT NOT NULL,
  PRIMARY KEY (order_item_id)
);

CREATE INDEX idx_order_id_1 ON t_order_item_1 (order_id);
CREATE INDEX idx_user_id_1 ON t_order_item_1 (user_id);


CREATE DATABASE demo_ds_1;

\c demo_ds_1;

CREATE TABLE t_order_0 (
  order_id BIGINT NOT NULL,
  user_id BIGINT NOT NULL,
  total_money INT NOT NULL,
  PRIMARY KEY (order_id)
);

CREATE INDEX idx_user_id_0 ON t_order_0 (user_id);


CREATE TABLE t_order_1 (
  order_id BIGINT NOT NULL,
  user_id BIGINT NOT NULL,
  total_money INT NOT NULL,
  PRIMARY KEY (order_id)
);

CREATE INDEX idx_user_id_1 ON t_order_1 (user_id);



CREATE TABLE t_order_item_0 (
  order_item_id BIGINT NOT NULL,
  order_id BIGINT NOT NULL,
  user_id BIGINT NOT NULL,
  money INT NOT NULL,
  PRIMARY KEY (order_item_id)
);

CREATE INDEX idx_order_id_0 ON t_order_item_0 (order_id);
CREATE INDEX idx_user_id_0 ON t_order_item_0 (user_id);



CREATE TABLE t_order_item_1 (
  order_item_id BIGINT NOT NULL,
  order_id BIGINT NOT NULL,
  user_id BIGINT NOT NULL,
  money INT NOT NULL,
  PRIMARY KEY (order_item_id)
);

CREATE INDEX idx_order_id_1 ON t_order_item_1 (order_id);
CREATE INDEX idx_user_id_1 ON t_order_item_1 (user_id);


5、配置shardingsphere-proxy分库分表的策略

修改server.xml文件,文件地址:/home/sunyuhua/docker/shardingsphere-proxy/conf

mode:
  type: Cluster
  repository:
    type: ZooKeeper
    props:
      namespace: governance_ds
      server-lists: host.docker.internal:2181
      retryIntervalMilliseconds: 500
      timeToLiveSeconds: 60
      maxRetries: 3
      operationTimeoutMilliseconds: 500
#  overwrite: false
#
rules:
  - !AUTHORITY
    users:
      - root@%:root
      - sharding@:sharding
    provider:
      type: ALL_PRIVILEGES_PERMITTED
#  - !TRANSACTION
#    defaultType: XA
#    providerType: Atomikos

props:
#  max-connections-size-per-query: 1
#  kernel-executor-size: 16  # Infinite by default.
#  proxy-frontend-flush-threshold: 128  # The default value is 128.
#  proxy-opentracing-enabled: false
#  proxy-hint-enabled: false
  sql-show: true
#  check-table-metadata-enabled: false
#  show-process-list-enabled: false
#    # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
#    # The default value is -1, which means set the minimum value for different JDBC drivers.
#  proxy-backend-query-fetch-size: -1
#  check-duplicate-table-enabled: false
#  sql-comment-parse-enabled: false
#  proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
#    # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
#    # if client connections are more than proxy-frontend-netty-executor-size, especially executing slow SQL.
#  proxy-backend-executor-suitable: OLAP
#  proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
#  sql-federation-enabled: false

修改config-sharding.yaml 文件,文件地址/home/sunyuhua/docker/shardingsphere-proxy/conf



schemaName: sharding_db_postgres

dataSources:
 ds_0:
   url: jdbc:postgresql://host.docker.internal:5432/demo_ds_0
   username: sa
   password: boKYLXIERWnzB0gX
   connectionTimeoutMilliseconds: 30000
   idleTimeoutMilliseconds: 60000
   maxLifetimeMilliseconds: 1800000
   maxPoolSize: 50
   minPoolSize: 1
 ds_1:
   url: jdbc:postgresql://host.docker.internal:5432/demo_ds_1
   username: sa
   password: boKYLXIERWnzB0gX
   connectionTimeoutMilliseconds: 30000
   idleTimeoutMilliseconds: 60000
   maxLifetimeMilliseconds: 1800000
   maxPoolSize: 50
   minPoolSize: 1

rules:
- !SHARDING
 tables:
   t_order:
     actualDataNodes: ds_${0..1}.t_order_${0..1}
     tableStrategy:
       standard:
         shardingColumn: order_id
         shardingAlgorithmName: t_order_inline
     keyGenerateStrategy:
         column: order_id
         keyGeneratorName: snowflake
   t_order_item:
     actualDataNodes: ds_${0..1}.t_order_item_${0..1}
     tableStrategy:
       standard:
         shardingColumn: order_id
         shardingAlgorithmName: t_order_item_inline
     keyGenerateStrategy:
       column: order_item_id
       keyGeneratorName: snowflake
 bindingTables:
   - t_order,t_order_item
 defaultDatabaseStrategy:
   standard:
     shardingColumn: user_id
     shardingAlgorithmName: database_inline
 defaultTableStrategy:
   none:
 
 shardingAlgorithms:
   database_inline:
     type: INLINE
     props:
       algorithm-expression: ds_${user_id % 2}
   t_order_inline:
     type: INLINE
     props:
       algorithm-expression: t_order_${order_id % 2}
   t_order_item_inline:
     type: INLINE
     props:
       algorithm-expression: t_order_item_${order_id % 2}
 
 keyGenerators:
   snowflake:
     type: SNOWFLAKE
     props:
       worker-id: 123

重新启动shardingsphere

docker restart sharding-proxy

检查shardingsphere-proxy是不是启动

docker logs sharding-proxy

或者查看日志

 /opt/shardingsphere-proxy/logs/stdout.log

[INFO ] 2023-06-28 05:46:54.015 [main-SendThread(host.docker.internal:2181)] org.apache.zookeeper.ClientCnxn - Session establishment complete on server host.docker.internal/192.168.65.2:2181, session id = 0x100000045ca0001, negotiated timeout = 40000
[INFO ] 2023-06-28 05:46:54.024 [main-EventThread] o.a.c.f.state.ConnectionStateManager - State change: CONNECTED
[INFO ] 2023-06-28 05:46:54.052 [main-EventThread] o.a.c.framework.imps.EnsembleTracker - New config event received: {}
[INFO ] 2023-06-28 05:46:54.052 [main-EventThread] o.a.c.framework.imps.EnsembleTracker - New config event received: {}
Thanks for using Atomikos! Evaluate http://www.atomikos.com/Main/ExtremeTransactions for advanced features and professional support
or register at http://www.atomikos.com/Main/RegisterYourDownload to disable this message and receive FREE tips & advice
[INFO ] 2023-06-28 05:46:56.075 [main] o.apache.curator.utils.Compatibility - Using org.apache.zookeeper.server.quorum.MultipleAddresses
[INFO ] 2023-06-28 05:46:56.093 [main] o.a.s.p.i.BootstrapInitializer - Database name is `MySQL`, version is `5.7.42-log`
[INFO ] 2023-06-28 05:46:56.283 [main] o.a.s.p.frontend.ShardingSphereProxy - ShardingSphere-Proxy start success

6、插入和查询数据,检查分库分表策略是不是生效

在这里插入图片描述

7、检查物理库是不是已经插入成功

在这里插入图片描述

常见错误

1、postgresql 客户端DBeaver 出现进行 SSL 连线时发生错误。 解决办法:降低shardingsphere-proxy到5.2.1版本即可

[ERROR] 2023-06-30 07:28:39.479 [epollEventLoopGroup-3-3] o.a.s.p.f.n.FrontendChannelInboundHandler - Exception occur: 
java.lang.IndexOutOfBoundsException: readerIndex(1) + length(4) exceeds writerIndex(1): PooledSlicedByteBuf(ridx: 1, widx: 1, cap: 1/1, unwrapped: PooledUnsafeDirectByteBuf(ridx: 4, widx: 8, cap: 2048))
        at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1442)
        at io.netty.buffer.AbstractByteBuf.readIntLE(AbstractByteBuf.java:817)
        at org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload.readInt4(MySQLPacketPayload.java:115)
        at org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakeResponse41Packet.<init>(MySQLHandshakeResponse41Packet.java:56)
        at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authPhaseFastPath(MySQLAuthenticationEngine.java:86)
        at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authenticate(MySQLAuthenticationEngine.java:73)
        at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.authenticate(FrontendChannelInboundHandler.java:80)
        at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.channelRead(FrontendChannelInboundHandler.java:72)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311)
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
        at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)

2、DBeaver出现SQL 错误 [22023]: ERROR: No value specified for parameter 1. 解决方法:更换Navicat for postgresql

[ERROR] 2023-06-30 08:47:23.424 [Connection-23-ThreadExecutor] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
org.postgresql.util.PSQLException: No value specified for parameter 1.
        at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:284)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:340)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:490)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:408)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:181)
        at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:133)
        at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
        at org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetadataExecutor$DefaultDatabaseMetadataExecutor.getSourceData(AbstractDatabaseMetadataExecutor.java:216)
        at org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetadataExecutor.execute(AbstractDatabaseMetadataExecutor.java:76)
        at org.apache.shardingsphere.proxy.backend.handler.admin.DatabaseAdminQueryBackendHandler.execute(DatabaseAdminQueryBackendHandler.java:56)
        at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.JDBCPortal.bind(JDBCPortal.java:113)
        at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.bind.PostgreSQLComBindExecutor.execute(PostgreSQLComBindExecutor.java:53)
        at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.PostgreSQLAggregatedCommandExecutor.execute(PostgreSQLAggregatedCommandExecutor.java:41)
        at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:111)
        at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/705986.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

threejs场景

个人博客地址: https://cxx001.gitee.io 前言 对象添加到场景里才能被渲染&#xff0c;场景是整个画面的容器。场景要显示任何东西&#xff0c;一般要有摄像机、光源、渲染对象。本章主要介绍场景类里常用的方法和属性&#xff0c;以及构建场景的基本组件。几何体和网格&…

从小白开始学习CAD(一)

什么是CAD ? CAD是计算机辅助设计&#xff08;Computer-Aided Design&#xff09;的缩写&#xff0c;它是一种利用计算机软件辅助进行设计和绘图的技术。 CAD是干什么的&#xff1f; CAD广泛应用于工程设计、建筑设计、产品设计等领域&#xff0c;可以提高设计效率、减少错误…

EthersV6之BigInt踩坑记录

起因&#xff1a;今天在调用合约的时候发现使用 BIgInt 丢了精度。看了下发现是自己的姿势不对&#xff0c;记录一下问题。 一、错误操作 const amountIn 2e24 const contract contract.function(BigInt(Number(2e24))为什么会这么写呢&#xff0c; 因为我们前端库升级到了 …

【C语言初阶(6)】猜数字游戏

文章目录 1. 游戏描述2. 代码结构2.1 菜单函数2.2 游戏函数2.3 主体函数 3. 代码实现 1. 游戏描述 电脑自动生成一个1-100以内的数字。我们输入一个我们猜的数字。如果我们猜的数字比电脑随机生成的数字大&#xff0c;那么输出&#xff08;猜大了&#xff09;&#xff0c;反之…

【MinIO异常】Storage reached its minimum free drive threshold 的解决方案

Storage reached its minimum free drive threshold 的解决方案 一、背景描述二、原因分析三、问题解决 一、背景描述 部署在Linux服务器上的MinIO服务器昨天使用的还正常&#xff0c;包含上传文件&#xff0c;下载文件&#xff0c;登录MinIO浏览器端&#xff0c;然而今天登录…

chatgpt赋能python:同一个python文件能同时运行多次吗?

同一个python文件能同时运行多次吗&#xff1f; Python作为一种高级编程语言&#xff0c;具有丰富的语法和功能。在编写Python程序时&#xff0c;我们常常需要考虑不同的需求。有时我们可能需要使用相同的python文件运行不同的程序&#xff0c;这时候很自然的问题就会出现&…

【机器学习】【期末复习】有关机器学习的简答题可供期末复习参考

本文为学校课程《机器学习》中老师给出的一些有关机器学习的简答题的详细解答&#xff0c;可供复习参考&#xff0c;基本答案全是正确的。 目录 什么是判别式模型和生成式模型&#xff0c;并且举例说明各自包含哪些典型的机器学习模型&#xff1f;L1 和 L2 的正则化的区别数据归…

Node.js 包管理器(Corepack)

目录 1、简介 2、启用Corepack 3、使用Node.js Corepack 4、配置包 5、升级全局版本 6、离线工作流 7、支持的包管理器 8、Node.js Corepack 拦截npm 9、Corepack 常用命令 1、简介 Corepack是一个实验性的工具&#xff0c;可以帮助管理包管理器的版本。它公开的二进制…

C#,数值计算——循环冗余校验和(CRC,Cyclic Redundancy Checksum)的计算方法与源代码

using System; namespace Legalsoft.Truffer { /// <summary> /// 循环冗余校验和 /// cyclic redundancy checksum /// </summary> public class Icrc { private uint jcrc { get; set; } private uint jfill { get; se…

【ISO26262】汽车功能安全第3部分:概念阶段

GB/T34590《道路车辆 功能安全》分为以下部分: 需要文档的朋友,可以和我联系! tommi_wei@163.com GB/T34590的本部分规定了车辆在概念阶段的要求: ———相关项定义; ———安全生命周期启动; ———危害分析和风险评估;及 ———功能安全概念。 危害事件分类 对于每一个…

多网口UDP发包无法收到回包排查与解决

最近几周几乎都是单休&#xff0c;加班很多&#xff0c;也遇到了很多未知的问题&#xff0c;杂事也多时间比较紧张&#xff0c;也没有多少空余来进行一些总结积累。这点让我很是怀念起几年前的日子&#xff0c;任务安排周期长&#xff0c;做技术纯粹又专心。 前几天遇到了一个…

chatgpt赋能python:如何将Python导入PyCharm

如何将Python导入PyCharm 介绍 PyCharm是一个非常流行的Python开发工具&#xff0c;它拥有许多强大的功能和插件&#xff0c;使开发人员能够更高效地编写Python代码。在本篇文章中&#xff0c;我们将介绍如何将Python导入PyCharm。 步骤 1. 安装PyCharm 首先&#xff0c;您…

jupyter-notebook:从记录点回复数据

使用jupyter进行记录数据分析思路时&#xff0c;有时候会莫名出现一些问题。比如这次遇到的保存并关闭之后&#xff0c;隔了一个晚上再次打开文件就成了空文件了&#xff0c;昨天写的分析都没有了&#xff0c;很头疼。解决方法&#xff1a;如果确定是保存了后&#xff0c;每一个…

32 linux 中物理页的 cow

前言 熟悉 linux 进程机制的人都知道 linux 中新建进程是以 fork exec 的形式创建的进程 fork 的时候复制了父进程的相关数据结构, 然后更新了待执行的 binary, 去执行 然后 父子进程之间 内存管理是 基于 copy on write 的 对于某块物理页, fork 之后内存设置为 只读…

JAVA3

文章目录 注释核心机制JVM的功能 优缺点优点缺点 注释 例子&#xff1a; 核心机制 JVM的功能 优缺点 优点 缺点

FreeRTOS入门(二)

目录 什么是RTOS? 嵌入式有哪些常见的RTOS&#xff1f; ✓ VxWorks&#xff08;开源收费&#xff09; ✓ UCOSII&III&#xff08;开源免费&#xff09; ✓ FreeRTOS&#xff08;开源免费&#xff09; ✓ RT_Thread(开源免费) ✓ AliOS(开源收费) ✓ LiteOS FreeR…

微信小程序canvas层级太高,与其他非原生组件层级冲突

官网已经提出新版本以支持同层渲染&#xff0c;但是实际项目中层级还是冲突的。 最后在文档中找到这样一段话&#xff0c;用真机打开&#xff0c;层级就正常了 。所以建议大家&#xff0c;多使用真机调试去测试&#xff01;&#xff01;&#xff01;&#xff01;

redis中常用的命令

1.关于对key操作的命令 keys *: 查看redis中所有的key exists key: 判断指定的key是否存在。存在返回1 否则返回0 del key: 删除指定的key expire key seconds: 为指定的key设置过期时间 2.关于库的命令 默认redis中存在16个库 select n: 选中库 n0~15 flushdb: 清空…

C++中的exec()函数

exec()函数在C中是一个进程控制函数&#xff0c;用于创建新进程执行其他程序或命令行指令。exec()函数可以替换当前进程的代码和数据&#xff0c;创建新的进程运行其他程序。exec()函数有多个版本&#xff0c;例如execl、execv、execle、execve等&#xff0c;根据不同的参数类型…

SAP 区分工单BOM物料是手工删除 还是 Teco后自动关闭需求

SAP 区分工单BOM物料是手工删除 还是 Teco后自动关闭需求 首先 resb表删除标识XLOEK 都为 ‘X’&#xff0c;无法通过其它字段直接区分 1先从前台界面区分 手工删除的&#xff0c;组件界面颜色正常&#xff0c;状态为-REL 删除 Teco自动关闭需求的&#xff0c;颜色不一样&am…