redis哨兵

【0】redis的主从数据库实现, 参见: redis的主从数据库复制功能

1)redis的主从数据库的作用: 在一主多从的redis系统中, 从数据库起到了 数据冗余备份和读写分离的作用;

2)redis2.8提供的哨兵: 用来实现自动化的系统监控和故障恢复功能;


【1】启动哨兵进程

1)编辑哨兵启动配置文件

在redis_home 目录添加 redis-sentinel.conf 文件, 并修改 其监控的主数据库信息, 如下:

sentinel monitor mymaster 192.168.186.100 6379 1 

其中, mymaster是监控的主数据库的名称,可以自定义,将其与 192.168.186.100 绑定即可; 6379 端口号; 1 表示最低通过票数;

(该conf文件, 在文末会贴出)

2)启动哨兵, 

[pacoson@localhost redis-4.0.8]$ redis-sentinel sentinel.conf 
3256:X 09 Mar 07:46:54.108 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
3256:X 09 Mar 07:46:54.108 # Redis version=4.0.8, bits=32, commit=00000000, modified=0, pid=3256, just started
3256:X 09 Mar 07:46:54.108 # Configuration loaded
3256:X 09 Mar 07:46:54.111 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
3256:X 09 Mar 07:46:54.111 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
3256:X 09 Mar 07:46:54.111 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
3256:X 09 Mar 07:46:54.113 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now._._                                                  _.-``__ ''-._                                             _.-``    `.  `_.  ''-._           Redis 4.0.8 (00000000/0) 32 bit.-`` .-```.  ```\/    _.,_ ''-._                                   (    '      ,       .-`  | `,    )     Running in sentinel mode|`-._`-...-` __...-.``-._|'` _.-'|     Port: 26379|    `-._   `._    /     _.-'    |     PID: 3256`-._    `-._  `-./  _.-'    _.-'                                   |`-._`-._    `-.__.-'    _.-'_.-'|                                  |    `-._`-._        _.-'_.-'    |           http://redis.io        `-._    `-._`-.__.-'_.-'    _.-'                                   |`-._`-._    `-.__.-'    _.-'_.-'|                                  |    `-._`-._        _.-'_.-'    |                                  `-._    `-._`-.__.-'_.-'    _.-'                                   `-._    `-.__.-'    _.-'                                       `-._        _.-'                                           `-.__.-'                                               3256:X 09 Mar 07:46:54.115 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3256:X 09 Mar 07:46:54.142 # Sentinel ID is 285f3e0832faf2c4c94a7ce89c2011fe76beb797
3256:X 09 Mar 07:46:54.142 # +monitor master mymaster 192.168.186.100 6379 quorum 1
3256:X 09 Mar 07:46:54.147 * +slave slave 192.168.186.100:6380 192.168.186.100 6380 @ mymaster 192.168.186.100 6379
3256:X 09 Mar 07:46:54.151 * +slave slave 192.168.186.100:6381 192.168.186.100 6381 @ mymaster 192.168.186.100 6379
【说明】

1)最后4行的启动日志非常重要:

哨兵编号;

+monitor: 哨兵监控的主数据库名称及其 ip地址, 端口号等; 

+slave: 表示新发现了 从数据库, 显然哨兵发现了两个从数据库; 


【3】停止主数据库的服务器

[pacoson@localhost redis-4.0.8]$ ps -ef |grep redis
pacoson   2112     1  0 06:23 ?        00:00:17 redis-server 192.168.186.100:6379
pacoson   2557  1931  0 06:25 pts/0    00:00:00 redis-cli -h 192.168.186.100
pacoson   2908  2533  0 07:23 pts/1    00:00:08 redis-server *:6380                                                        
pacoson   2913  2854  0 07:23 pts/5    00:00:08 redis-server *:6381                                                        
pacoson   2918  2662  0 07:23 pts/2    00:00:00 redis-cli -h 192.168.186.100 -p 6380
pacoson   2920  2793  0 07:24 pts/4    00:00:00 redis-cli -h 192.168.186.100 -p 6381
pacoson   3256  2733  1 07:46 pts/3    00:00:06 redis-sentinel *:26379 [sentinel]
pacoson   3314  3270  1 07:55 pts/7    00:00:00 grep redis
[pacoson@localhost redis-4.0.8]$ kill 2112
[pacoson@localhost redis-4.0.8]$ kill 2112
-bash: kill: (2112) - 没有那个进程
[pacoson@localhost redis-4.0.8]$ ps -ef |grep redis
pacoson   2908  2533  0 07:23 pts/1    00:00:08 redis-server *:6380                                                        
pacoson   2913  2854  0 07:23 pts/5    00:00:08 redis-server *:6381                                                        
pacoson   2918  2662  0 07:23 pts/2    00:00:00 redis-cli -h 192.168.186.100 -p 6380
pacoson   2920  2793  0 07:24 pts/4    00:00:00 redis-cli -h 192.168.186.100 -p 6381
pacoson   3256  2733  1 07:46 pts/3    00:00:07 redis-sentinel *:26379 [sentinel]
pacoson   3317  3270  0 07:56 pts/7    00:00:00 grep redis
[pacoson@localhost redis-4.0.8]$ 

【4】等待大约30秒后(可配置), 哨兵进程输出如下内容:

3256:X 09 Mar 07:46:54.115 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3256:X 09 Mar 07:46:54.142 # Sentinel ID is 285f3e0832faf2c4c94a7ce89c2011fe76beb797
3256:X 09 Mar 07:46:54.142 # +monitor master mymaster 192.168.186.100 6379 quorum 1
3256:X 09 Mar 07:46:54.147 * +slave slave 192.168.186.100:6380 192.168.186.100 6380 @ mymaster 192.168.186.100 6379
3256:X 09 Mar 07:46:54.151 * +slave slave 192.168.186.100:6381 192.168.186.100 6381 @ mymaster 192.168.186.100 6379
// A:主服务器停止后, 哨兵进程的监控日志 
3256:X 09 Mar 07:56:49.816 # +sdown master mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:49.816 # +odown master mymaster 192.168.186.100 6379 #quorum 1/1
3256:X 09 Mar 07:56:49.816 # +new-epoch 1
// B: 哨兵尝试挑选一个从数据库升级为主数据库,即进行故障恢复;
3256:X 09 Mar 07:56:49.816 # +try-failover master mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:49.841 # +vote-for-leader 285f3e0832faf2c4c94a7ce89c2011fe76beb797 1
3256:X 09 Mar 07:56:49.841 # +elected-leader master mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:49.841 # +failover-state-select-slave master mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:49.896 # +selected-slave slave 192.168.186.100:6380 192.168.186.100 6380 @ mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:49.896 * +failover-state-send-slaveof-noone slave 192.168.186.100:6380 192.168.186.100 6380 @ mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:49.973 * +failover-state-wait-promotion slave 192.168.186.100:6380 192.168.186.100 6380 @ mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:50.814 # +promoted-slave slave 192.168.186.100:6380 192.168.186.100 6380 @ mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:50.814 # +failover-state-reconf-slaves master mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:50.886 * +slave-reconf-sent slave 192.168.186.100:6381 192.168.186.100 6381 @ mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:51.685 * +slave-reconf-inprog slave 192.168.186.100:6381 192.168.186.100 6381 @ mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:52.754 * +slave-reconf-done slave 192.168.186.100:6381 192.168.186.100 6381 @ mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:52.817 # +failover-end master mymaster 192.168.186.100 6379
3256:X 09 Mar 07:56:52.817 # +switch-master mymaster 192.168.186.100 6379 192.168.186.100 6380
3256:X 09 Mar 07:56:52.817 * +slave slave 192.168.186.100:6381 192.168.186.100 6381 @ mymaster 192.168.186.100 6380
3256:X 09 Mar 07:56:52.818 * +slave slave 192.168.186.100:6379 192.168.186.100 6379 @ mymaster 192.168.186.100 6380
3256:X 09 Mar 07:57:22.857 # +sdown slave 192.168.186.100:6379 192.168.186.100 6379 @ mymaster 192.168.186.100 6380
【说明】

1)+sdown:表示哨兵主观认为主数据库服务停止了;

2)+odown:表示哨兵客观认为主数据库服务停止了;

3)此时哨兵开始执行故障恢复, 挑选一个从数据库, 将其升级为 主数据库, 输出如下内容:

+try-failover: 表示哨兵开始进行故障恢复;

+failover-end:表示哨兵完成故障恢复, 过程复杂, 包括领头哨兵选择,备选从数据库的选择等;

【4.1】关注最后4条输出:

3256:X 09 Mar 07:56:52.817 # +switch-master mymaster 192.168.186.100 6379 192.168.186.100 6380
3256:X 09 Mar 07:56:52.817 * +slave slave 192.168.186.100:6381 192.168.186.100 6381 @ mymaster 192.168.186.100 6380
3256:X 09 Mar 07:56:52.818 * +slave slave 192.168.186.100:6379 192.168.186.100 6379 @ mymaster 192.168.186.100 6380
3256:X 09 Mar 07:57:22.857 # +sdown slave 192.168.186.100:6379 192.168.186.100 6379 @ mymaster 192.168.186.100 6380
 【说明】 

1) +switch-master: 表示主数据库从 6379 端口迁移到 6380 端口上了;即 6380端口上的redis 服务升级为 主数据库;

2)+slave :列出了两个新的从数据库, 包括 6381 和 6379;

3)为什么 6379 还会被当做从数据库呢?  因为停止服务的实例有可能会在之后的某个时间恢复服务,恢复服务后,该数据库将作为 6380主数据库的从数据库;

【5】故障恢复后, 可以info replication 检查6380 和 6381 上的复制信息;

192.168.186.100:6380> info replication
# Replication
role:master // 主数据库 
connected_slaves:1
slave0:ip=192.168.186.100,port=6381,state=online,offset=89055,lag=0
master_replid:4327aef198c3c958e0d8a23414ccb69498cca6f2
master_replid2:28c0673df46b0bceda233e58a7a3cd9ae9d5b2e6
master_repl_offset:89200
second_repl_offset:43056
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:43
repl_backlog_histlen:89158
192.168.186.100:6380> 
192.168.186.100:6381> info replication
# Replication
role:slave // 从数据库 
master_host:192.168.186.100
master_port:6380
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_repl_offset:90098
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:4327aef198c3c958e0d8a23414ccb69498cca6f2
master_replid2:28c0673df46b0bceda233e58a7a3cd9ae9d5b2e6
master_repl_offset:90098
second_repl_offset:43056
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:211
repl_backlog_histlen:89888
192.168.186.100:6381> 

【6】将 6379 上的服务重新启动; 并查看其 复制信息, 如下:

redis-server redis.conf

1)启动后, 哨兵进程打印日志如下:

3256:X 09 Mar 08:09:55.694 # -sdown slave 192.168.186.100:6379 192.168.186.100 6379 @ mymaster 192.168.186.100 6380
3256:X 09 Mar 08:10:05.693 * +convert-to-slave slave 192.168.186.100:6379 192.168.186.100 6379 @ mymaster 192.168.186.100 6380
2) 客户端连接 6379 数据库,并打印复制信息, 

192.168.186.100:6379> info replication
# Replication
role:slave // 从数据库
master_host:192.168.186.100
master_port:6380  // 主数据库端口为 6380 
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_repl_offset:103858
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:4327aef198c3c958e0d8a23414ccb69498cca6f2
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:103858
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:100141
repl_backlog_histlen:3718
192.168.186.100:6379> 


【7】6379 启动后, 再次查看 6380 的 复制信息, 如下:

192.168.186.100:6380> info replication
# Replication
role:master // 主数据库
connected_slaves:2 // 附带2个从 数据库 6381 和 6379 
slave0:ip=192.168.186.100,port=6381,state=online,offset=110813,lag=0
slave1:ip=192.168.186.100,port=6379,state=online,offset=110813,lag=0
master_replid:4327aef198c3c958e0d8a23414ccb69498cca6f2
master_replid2:28c0673df46b0bceda233e58a7a3cd9ae9d5b2e6
master_repl_offset:110813
second_repl_offset:43056
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:43
repl_backlog_histlen:110771
192.168.186.100:6380> 

【总结】以上过程演示了,当集群中的主数据库 down 掉后, 从数据库升级为主数据库的过程,即6379成功恢复服务;


【补充】sentinel.conf 文件

# Example sentinel.conf# *** IMPORTANT ***
#
# By default Sentinel will not be reachable from interfaces different than
# localhost, either use the 'bind' directive to bind to a list of network
# interfaces, or disable protected mode with "protected-mode no" by
# adding it to this configuration file.
#
# Before doing that MAKE SURE the instance is protected from the outside
# world via firewalling or other means.
#
# For example you may use one of the following:
#
# bind 127.0.0.1 192.168.1.1
#
# protected-mode no# port <sentinel-port>
# The port that this sentinel instance will run on
port 26379# sentinel announce-ip <ip>
# sentinel announce-port <port>
#
# The above two configuration directives are useful in environments where,
# because of NAT, Sentinel is reachable from outside via a non-local address.
#
# When announce-ip is provided, the Sentinel will claim the specified IP address
# in HELLO messages used to gossip its presence, instead of auto-detecting the
# local address as it usually does.
#
# Similarly when announce-port is provided and is valid and non-zero, Sentinel
# will announce the specified TCP port.
#
# The two options don't need to be used together, if only announce-ip is
# provided, the Sentinel will announce the specified IP and the server port
# as specified by the "port" option. If only announce-port is provided, the
# Sentinel will announce the auto-detected local IP and the specified port.
#
# Example:
#
# sentinel announce-ip 1.2.3.4# dir <working-directory>
# Every long running process should have a well-defined working directory.
# For Redis Sentinel to chdir to /tmp at startup is the simplest thing
# for the process to don't interfere with administrative tasks such as
# unmounting filesystems.
dir "/tmp"# sentinel monitor <master-name> <ip> <redis-port> <quorum>
#
# Tells Sentinel to monitor this master, and to consider it in O_DOWN
# (Objectively Down) state only if at least <quorum> sentinels agree.
#
# Note that whatever is the ODOWN quorum, a Sentinel will require to
# be elected by the majority of the known Sentinels in order to
# start a failover, so no failover can be performed in minority.
#
# Slaves are auto-discovered, so you don't need to specify slaves in
# any way. Sentinel itself will rewrite this configuration file adding
# the slaves using additional configuration options.
# Also note that the configuration file is rewritten when a
# slave is promoted to master.
#
# Note: master name should not include special characters or spaces.
# The valid charset is A-z 0-9 and the three characters ".-_".
sentinel myid 285f3e0832faf2c4c94a7ce89c2011fe76beb797# sentinel auth-pass <master-name> <password>
#
# Set the password to use to authenticate with the master and slaves.
# Useful if there is a password set in the Redis instances to monitor.
#
# Note that the master password is also used for slaves, so it is not
# possible to set a different password in masters and slaves instances
# if you want to be able to monitor these instances with Sentinel.
#
# However you can have Redis instances without the authentication enabled
# mixed with Redis instances requiring the authentication (as long as the
# password set is the same for all the instances requiring the password) as
# the AUTH command will have no effect in Redis instances with authentication
# switched off.
#
# Example:
#
# sentinel auth-pass mymaster MySUPER--secret-0123passw0rd# sentinel down-after-milliseconds <master-name> <milliseconds>
#
# Number of milliseconds the master (or any attached slave or sentinel) should
# be unreachable (as in, not acceptable reply to PING, continuously, for the
# specified period) in order to consider it in S_DOWN state (Subjectively
# Down).
#
# Default is 30 seconds.
sentinel monitor mymaster 192.168.186.100 6379 1  // highlight# sentinel parallel-syncs <master-name> <numslaves>
#
# How many slaves we can reconfigure to point to the new slave simultaneously
# during the failover. Use a low number if you use the slaves to serve query
# to avoid that all the slaves will be unreachable at about the same
# time while performing the synchronization with the master.
sentinel config-epoch mymaster 0# sentinel failover-timeout <master-name> <milliseconds>
#
# Specifies the failover timeout in milliseconds. It is used in many ways:
#
# - The time needed to re-start a failover after a previous failover was
#   already tried against the same master by a given Sentinel, is two
#   times the failover timeout.
#
# - The time needed for a slave replicating to a wrong master according
#   to a Sentinel current configuration, to be forced to replicate
#   with the right master, is exactly the failover timeout (counting since
#   the moment a Sentinel detected the misconfiguration).
#
# - The time needed to cancel a failover that is already in progress but
#   did not produced any configuration change (SLAVEOF NO ONE yet not
#   acknowledged by the promoted slave).
#
# - The maximum time a failover in progress waits for all the slaves to be
#   reconfigured as slaves of the new master. However even after this time
#   the slaves will be reconfigured by the Sentinels anyway, but not with
#   the exact parallel-syncs progression as specified.
#
# Default is 3 minutes.
sentinel leader-epoch mymaster 0# SCRIPTS EXECUTION
#
# sentinel notification-script and sentinel reconfig-script are used in order
# to configure scripts that are called to notify the system administrator
# or to reconfigure clients after a failover. The scripts are executed
# with the following rules for error handling:
#
# If script exits with "1" the execution is retried later (up to a maximum
# number of times currently set to 10).
#
# If script exits with "2" (or an higher value) the script execution is
# not retried.
#
# If script terminates because it receives a signal the behavior is the same
# as exit code 1.
#
# A script has a maximum running time of 60 seconds. After this limit is
# reached the script is terminated with a SIGKILL and the execution retried.# NOTIFICATION SCRIPT
#
# sentinel notification-script <master-name> <script-path>
#
# Call the specified notification script for any sentinel event that is
# generated in the WARNING level (for instance -sdown, -odown, and so forth).
# This script should notify the system administrator via email, SMS, or any
# other messaging system, that there is something wrong with the monitored
# Redis systems.
#
# The script is called with just two arguments: the first is the event type
# and the second the event description.
#
# The script must exist and be executable in order for sentinel to start if
# this option is provided.
#
# Example:
#
# sentinel notification-script mymaster /var/redis/notify.sh# CLIENTS RECONFIGURATION SCRIPT
#
# sentinel client-reconfig-script <master-name> <script-path>
#
# When the master changed because of a failover a script can be called in
# order to perform application-specific tasks to notify the clients that the
# configuration has changed and the master is at a different address.
#
# The following arguments are passed to the script:
#
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
#
# <state> is currently always "failover"
# <role> is either "leader" or "observer"
#
# The arguments from-ip, from-port, to-ip, to-port are used to communicate
# the old address of the master and the new address of the elected slave
# (now a master).
#
# This script should be resistant to multiple invocations.
#
# Example:
#
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh# Generated by CONFIG REWRITE
maxclients 4064
maxmemory 3gb
sentinel known-slave mymaster 192.168.186.100 6381
sentinel known-slave mymaster 192.168.186.100 6380
sentinel current-epoch 0


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

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

相关文章

Git安装及配置5分钟快速教程

转载自 Git安装及配置5分钟快速教程 Git是什么 Git是一款免费、开源的分布式版本控制系统&#xff0c;可以有效、高速的处理从很小到非常大的项目版本管理。 与常用的版本控制工具CVS、Subversion等不同的是它采用了分布式版本库的方式&#xff0c;不必服务器端软件支持&#x…

MySQL基础---增删改查语法

一、DDL-数据定义语言&#xff0c;操作数据库(CRUD)和表(CRUD) 1 创建数据库(指定字符集) create database 数据库名称 character set utf8; 数据库和表修改都是 Alter 查看都是show 删除都是drop2 创建表 create table 表名称(字段名 数据类型,字段名 数据类型,... ...字…

理解水平扩展和垂直扩展

转自&#xff1a; http://yunjiechao-163-com.iteye.com/blog/2126981 当一个开发人员提升计算机系统负荷时&#xff0c;通常会考虑两种方式垂直扩展和水平扩展。选用哪种策略主要依赖于要解决的问题 以及系统资源的限制。在这篇文章中我们将讲述这两种策略并讨论每种策越的…

JavaWeb核心常用API一览

1.核心知识点 2.常用API

Java中的宏变量,宏替换详解。

转载自 Java中的宏变量&#xff0c;宏替换详解。群友在微信群讨论的一个话题&#xff0c;有点意思&#xff0c;特拿出来分享一下。输出true false来看下面这段程序&#xff0c;和群友分享的大致一样。 public static void main(String[] args) {String hw "hello world&q…

eclipse如何设置js源文件编码

window -> preferences -> 输入 content type -> 然后在右侧栏点击 javascript source file&#xff0c; 然后default encoding 输入 gbk&#xff08;或者其他编码格式&#xff09;&#xff0c; 点击 update &#xff0c; 然后可以看见文件编码已经改变&#xff0c; 最…

SQL编程---存储过程和存储函数

1.基本概念 存储过程和函数是事先经过编译并存储在数据库中的一段 SQL 语句的集合。 2.存储过程和函数的好处 提高代码的复用性。减少数据在数据库和应用服务器之间的传输&#xff0c;提高效率。减少代码层面的业务处理。 3.创建和调用存储过程 <1>创建存储过程 创…

jvm 启动参数设置

-Xms256m -Xmx256m -XX:MaxPermSize64m 如果 jvm 启动失败&#xff0c; 说堆内存不够&#xff0c; 需要调小 初始堆和最大堆大小&#xff0c; 持久代大小&#xff1b; 第一行的参数是调节后的vm参数荔枝 &#xff1b;

类、变量、块、构造器、继承初始化顺序,终极解答

转载自 类、变量、块、构造器、继承初始化顺序&#xff0c;终极解答最近发现微信群里面有些群友在讨论类的初始化顺序&#xff0c;如类的静态变量、成员变量、静态代码块、非静态代码块、构造器&#xff0c;及继承父类时&#xff0c;它们的初始化顺序都是怎样的&#xff0c;下面…

数据表触发器

1.概念 触发器就是在表数据发生变化的时候&#xff0c;自动触发的一些 SQL 操作,查询不影响表中的数据&#xff0c;所以没有触发器。类似于web监听器机制,监听对应表的增删改。 2.触发器分类 触发器类型OLD 触发器之前的效果NEW 触发器之后的效果INSERT 类型的触发器无&…

Linux NAT网络连接权威指南

【1】准备工作&#xff0c;写在前面 1.1&#xff09;检查服务&#xff08;cmd>>services.msc,我用的是VM&#xff09; 1.2&#xff09;确保Vmnet8 连接处于启动状态 获取ipv4&#xff08;ipv6&#xff09;地址 &#xff08;在网络连接不正确时&#xff0c;作参考之用&a…

事务的概述

1.基本概念 将一条或者多条SQL看成一个整体&#xff0c;要么同时执行成功要么同时执行失败&#xff0c;这就是事务。 事务举例&#xff1a; 张三给李四转账500元钱&#xff0c;需要让三账户的余额-500&#xff0c;李四的账户余额500&#xff0c;转账是一个连续的过程&#xf…

Spring Boot Debug调试

转载自 Spring Boot Debug调试 在使用maven插件执行spring-boot:run进行启动的时候&#xff0c;如果设置的断点进不去&#xff0c;要进行以下的设置。 1、添加jvm参数配置 在spring-boot的maven插件加上jvmArguments配置。 <project>...<build>...<plugins>…

centos磁盘安装与磁盘分区方案详解

转自&#xff1a; https://yq.aliyun.com/ziliao/56538 前几天自己研究了下几个linux系统&#xff0c;还是觉着centos要好一些。相对稳定点&#xff0c;起码桌面系统还是比 ubuntu 强安装centos并不难&#xff0c;安装方法多得是&#xff0c;像硬盘安装&#xff0c;U盘安装&…

存储过程内基础语法

学生表 1.定义变量及变量赋值方式 DELIMITER ; 分号前面必须要有一个空格 <1>DECLARE 变量名 数据类型 [DEFAULT 默认值]; 需求-- 定义一个int类型变量&#xff0c;并赋默认值为10 DELIMITER $$ CREATE PROCEDURE pro_test1() -- 没有; BEGIN-- 定义变量DECLARE nu…

nginx-配置基于ip或域名的虚拟主机

【0】README&#xff1a; nginx 可以配置多种类型的虚拟主机&#xff1a; 类型1&#xff09; 基于ip的虚拟主机&#xff1b; 类型2&#xff09;基于域名的虚拟主机&#xff1b; 类型3&#xff09;基于端口的虚拟主机&#xff1b; 【1】配置基于 ip 的虚拟主机的准备工作 …

Tomcat集群session复制与Oracle的坑

转载自 Tomcat集群session复制与Oracle的坑 问题描述 公司某个系统使用了tomcat自带的集群session复制功能&#xff0c;然后后报了一个oracle驱动包里面的连接不能被序列化的异常。 01-Nov-2017 16:45:26.653 SEVERE [https-jsse-nio-8443-exec-2] org.apache.catalina.ha.ses…

存储过程内基础语法---补充while循环

1.基础语法 while循环初始化语句;WHILE 条件判断语句 DO循环体语句;条件控制语句;END WHILE;2.举例 计算1~100之间的偶数和 【注&#xff1a;num只能numnum1 不能num,num1; 】 <1>存储过程内部查询 DELIMITER $CREATE PROCEDURE pro_test6() BEGIN-- 定义求和变量DE…

nginx停止,平滑重启命令

TERM, INT 快速关闭&#xff1b; QUIT 从容关闭&#xff1b; HUP 平滑重启&#xff0c;重新加载配置文件&#xff1b; USR1 重新打开日志文件&#xff0c;在切割日志时用途较大&#xff1b; USR2 平滑升级可执行程序&#xff1b; WINCH 从容关闭工作进程&#xff1b; 【荔…

IntelliJ IDEA Community(社区版)下载及安装自用版

IntelliJ IDEA Community&#xff08;社区版&#xff09;下载及安装自用版 估计是个开发都逃脱不了用IDEA的命运吧&#xff0c;这么好的软件&#xff0c;白嫖了好多年。感恩。 现在很多公司已经不让用商业版的破解版了&#xff0c;所以这里讲的是社区版。 区别&#xff1a; 商…