Category: Database

Redis选主

Replica election and promotion Replica election and promotion is handled by replica nodes, with the help of master nodes that vote for the replica to promote. A replica election happens when a master is in FAIL state from the point of view of at least one of its replicas that has the prerequisites in order to become […]

单机使用Docker搭建Redis各种实例

docker run 运行单节点 使用指定docker网络,暴露容器6379端口到主机6379端口 将指定的配置文件映射到容器内指定路径 将主机目录映射到容器内redis默认数据目录 设置redis-server运行时加载指定配置文件 使用docker-compose运行主从+哨兵实例 /etc/localtime:/etc/localtime:ro 使容器实例时间与主机时间同步 容器数据目录挂载到主机指定目录 由于示例这里没有指定主从redis的配置文件,在运行命令command处指定 每个哨兵使用 sentinel配置文件示例 protected-mode yes 设置为yes时,如果没有使用bind命令绑定指定ip,并且也没有设置密码,则只接受本地连接请求 port 26381 这里使用自定义端口,默认是26379,即20000+6379 sentinel monitor <master-group-name> <ip> <port> <quorum> 指定哨兵要监控的主节点组名称,这里可以随意设置,但监控通过节点所有哨兵必须使用同一个主节点组名称 ip和port是要监控的主节点ip和端口 quorum用来检测和确认失败,上面配置2表示只要有2个哨兵确认主节点失联,即可将该节点标记为故障并且如果条件允许的话,最终会启动故障转移流程 sentinel auth-pass docker-redis-master master_password 设置主节点密码,如果有才需要 requirepass sentinel_password 设置哨兵密码 sentinel monitor <master-group-name> <ip> <port> <quorum> sentinel monitor mymaster 127.0.0.1 6379 2  This config is used to tell […]

Redis cluster 官方文档(选摘)

Redis cluster tutorial This tutorial tries to provide information about the availability and consistency characteristics of Redis Cluster from the point of view of the final user, stated in a simple to understand way. Note this tutorial requires Redis version 3.0 or higher. Redis Cluster 101 Redis Cluster provides a way to run a Redis […]

What are database NULL fields for?

纠结着生日字段要不要允许NULL值,搜索了一下Stack Overflow刚好有问题讨论到,然后决定还是允许NULL了,不然就要使用一个特殊的值来表示,感觉并不好。 以下是转自Stack Overflow的问题,数据库中为什么使用NULL值? It is useful to mark “unknown” or missing values. For instance, if you’re storing people, and one of the fields is their birthday, you could allow it to be NULL to signify “We don’t know when he was born”. This is in contrast to having non-nullable fields where, for the same type of […]

What’s New in Connector/J 8.0?

https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-whats-new.html Note Connector/J 8.0 was formerly known as Connector/J 6.0; see Changes in MySQL Connector/J 8.0.7 for an explanation of the version number change. This section describes differences between Connector/J 8.0 and Connector/J 5.1. Here is a summary of major new features of Connector/J 8.0 (for details on the differences between the Connector/J 5.1 and 8.0 and […]

Windows 10下安装PostgreSQL 14

下载地址: https://www.postgresql.org/download/windows/ 285M左右,下载后安装在D盘,安装到最后时,出现以下提示: 百度了一下,尝试修改locale为中国香港还是有问题,点击安装文件右键选择使用管理员执行也不行,后面卸载掉,重新正常双击安装,database locale选了开头的C选项后,意外可以了。 Maven依赖: <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> </dependency> 驱动类名: org.postgresql.Driver 连接URL示例: jdbc:postgresql://localhost:5432/postgres 官网14版本文档: https://www.postgresql.org/docs/14/index.html