热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

重新初始化RAC的OCR盘和Votedisk盘,修复RAC系统

假设我们的RAC环境中OCR磁盘和votedisk磁盘全部被破坏,并且都没有备份,那么我们该如何恢复我们的RAC环境。最近简单的办法就是重新初始化我们的ocr盘和votedisk盘

假设我们的RAC环境中OCR磁盘和votedisk磁盘全部被破坏,并且都没有备份,那么我们该如何恢复我们的RAC环境。
最近简单的办法就是重新初始化我们的ocr盘和votedisk盘,把集群中的所有相关资源重新注册到OCR磁盘和votedisk磁盘中。

1.停掉所有节点的Clusterware Stack

[root@rac3 bin]# ./crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.



[root@rac4 bin]# ./crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

2.为安全期间,我们先备份一下ocr和votedisk

为防止我们的实验失败,我们先备份一下ocr盘和votedisk盘。
当然,在正式的RAC环境中是不会不备份ocr盘和votedisk盘,我们模拟的也是一种极端情况。

[root@rac3 bin]# ./crsctl query css votedisk
 0.     0    /dev/raw/raw2

located 1 votedisk(s).
[root@rac3 bin]# dd if=/dev/raw/raw2 of=/home/oracle/votedisk.bak
208864+0 records in
208864+0 records out


[root@rac3 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       : 1887132889
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

[root@rac3 bin]# ./ocrconfig -export /home/oracle/ocr.bak

3.我们先破坏一下ocr和votedisk

[root@rac3 bin]# dd if=/dev/zero of=/dev/raw/raw1 bs=1M count=100
100+0 records in
100+0 records out
[root@rac3 bin]# dd if=/dev/zero of=/dev/raw/raw1 bs=1M count=130
dd: writing `/dev/raw/raw1: No space left on device
102+0 records in
101+0 records out
[root@rac3 bin]# dd if=/dev/zero of=/dev/raw/raw2 bs=1M count=130   
dd: writing `/dev/raw/raw2: No space left on device
102+0 records in
101+0 records out

现在ocr和votedisk已经被我们破坏,目前我们的RAC肯定是启不来了。

现在我们就利用重建的方式重新把信息注册到ocr和votedisk中去。

4.分别在每个节点上执行$CRS_HOME/install/rootdele.sh

[root@rac3 install]# ./rootdelete.sh 
Shutting down Oracle Cluster Ready Services (CRS):
OCR initialization failed with invalid format: PROC-22: The OCR backend has an invalid format
Shutdown has begun. The daemons should exit soon.
Checking to see if Oracle CRS stack is down...
Oracle CRS stack is not running.
Oracle CRS stack is down now.
Removing script for Oracle Cluster Ready services
Updating ocr file for downgrade
Cleaning up SCR settings in /etc/oracle/scls_scr
[root@rac4 install]# ./rootdelete.sh 
Shutting down Oracle Cluster Ready Services (CRS):
OCR initialization failed with invalid format: PROC-22: The OCR backend has an invalid format
Shutdown has begun. The daemons should exit soon.
Checking to see if Oracle CRS stack is down...
Oracle CRS stack is not running.
Oracle CRS stack is down now.
Removing script for Oracle Cluster Ready services
Updating ocr file for downgrade
Cleaning up SCR settings in /etc/oracle/scls_scr

5.在任意一个节点上执行脚本$CRS_HOME/install/rootdeinstall.sh

只需要一个节点上执行即可

[root@rac3 install]# ./rootdeinstall.sh 
Removing contents from OCR mirror device
2560+0 records in
2560+0 records out
Removing contents from OCR device
2560+0 records in
2560+0 records out

6.在和步骤5同一个节点上执行$CRS_HOME/root.sh脚本

[root@rac3 crs_1]# ./root.sh
WARNING: directory /opt/ora10g/product/10.2.0 is not owned by root
WARNING: directory /opt/ora10g/product is not owned by root
WARNING: directory /opt/ora10g is not owned by root
WARNING: directory /opt is not owned by root
Checking to see if Oracle CRS stack is already configured

Setting the permissions on OCR backup directory
Setting up NS directories
Oracle Cluster Registry configuration upgraded successfully
WARNING: directory /opt/ora10g/product/10.2.0 is not owned by root
WARNING: directory /opt/ora10g/product is not owned by root
WARNING: directory /opt/ora10g is not owned by root
WARNING: directory /opt is not owned by root
Successfully accumulated necessary OCR keys.
Using ports: CSS=49895 CRS=49896 EVMC=49898 and EVMR=49897.
node :  <private interconnect name> 
node 1: rac3 rac3-priv rac3
node 2: rac4 rac4-priv rac4
Creating OCR keys for user root, privgrp root..
Operation successful.
Now formatting voting device: /dev/raw/raw2
Format of 1 voting devices complete.
Startup will be queued to init within 90 seconds.
Adding daemons to inittab
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
        rac3
CSS is inactive on these nodes.
        rac4
Local node checking complete.
Run root.sh on remaining nodes to start CRS daemons.

7.在其他节点执行$CRS_HOME/root.sh脚本,注意最后一个节点的输出

[root@rac4 crs_1]# ./root.sh 
WARNING: directory /opt/ora10g/product/10.2.0 is not owned by root
WARNING: directory /opt/ora10g/product is not owned by root
WARNING: directory /opt/ora10g is not owned by root
WARNING: directory /opt is not owned by root
Checking to see if Oracle CRS stack is already configured

Current Oracle Cluster Registry mirror location /dev/raw/raw7 in /etc/oracle/ocr.loc and ‘‘ does not match
Update either /etc/oracle/ocr.loc to use ‘‘ or variable CRS_OCR_LOCATIONS in rootconfig.sh with /dev/raw/raw7 then rerun rootconfig.sh

发现有报错,报错信息应该是ocr mirror location和当前不匹配,这是之前我们试验ocr转移位置时留下的(/dev/raw/raw7),
/etc/oracle/ocr.loc文件里我们已经ocrmirrorconfig_loc参数注释掉了,系统怎么还能看得到那??

http://www.cnblogs.com/myrunning/p/4253696.html

[root@rac4 oracle]# cat ocr.loc 
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8 
ocrconfig_loc=/dev/raw/raw1
#ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false

我们把/etc/oracle/ocr.loc文件的"#ocrmirrorconfig_loc=/dev/raw/raw7" 去掉,重新执行$CRS_HOME/root.sh

[root@rac4 oracle]# cat ocr.loc 
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8 
ocrconfig_loc=/dev/raw/raw1
local_only=false

去掉"#ocrmirrorconfig_loc=/dev/raw/raw7",重新执行$CRS_HOME/root.sh,发现问题解决:

[root@rac4 crs_1]# ./root.sh 
WARNING: directory /opt/ora10g/product/10.2.0 is not owned by root
WARNING: directory /opt/ora10g/product is not owned by root
WARNING: directory /opt/ora10g is not owned by root
WARNING: directory /opt is not owned by root
Checking to see if Oracle CRS stack is already configured

Setting the permissions on OCR backup directory
Setting up NS directories
Oracle Cluster Registry configuration upgraded successfully
WARNING: directory /opt/ora10g/product/10.2.0 is not owned by root
WARNING: directory /opt/ora10g/product is not owned by root
WARNING: directory /opt/ora10g is not owned by root
WARNING: directory /opt is not owned by root
clscfg: EXISTING configuration version 3 detected.
clscfg: version 3 is 10G Release 2.
Successfully accumulated necessary OCR keys.
Using ports: CSS=49895 CRS=49896 EVMC=49898 and EVMR=49897.
node :  <private interconnect name> 
node 1: rac3 rac3-priv rac3
node 2: rac4 rac4-priv rac4
clscfg: Arguments check out successfully.

NO KEYS WERE WRITTEN. Supply -force parameter to override.
-force is destructive and will destroy any previous cluster
configuration.
Oracle Cluster Registry for cluster has already been initialized
Startup will be queued to init within 90 seconds.
Adding daemons to inittab
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
        rac3
        rac4
CSS is active on all nodes.
Waiting for the Oracle CRSD and EVMD to start
Oracle CRS stack installed and running under init(1M)
Running vipca(silent) for configuring nodeapps
The given interface(s), "eth0" is not public. Public interfaces should be used to configure virtual IPs.

发现问题,由于"eth0" is not public.vipca没有执行成功,这需要我们手动地在这个节点上执行vipca

8.重新执行vipca命令

执行vipca报出Error 0(Native: listNetInterfaces:[3])错误,如图:

技术分享

这是因为我们需要重新设置一下RAC的公共网络及私有网络:

技术分享

使用root用户重新手动执行vipca:

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

9.验证ONS/GSD/VIP有没有正常注册到集群中

[oracle@rac4 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4  

10.使用netca命令重新配置监听

使用netca命令配置监听,该命令会自动把Listener注册到Clusterware中。

使用oracle用户手动执行netca命令:

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享


确认一下我们刚刚配置的Listener有没有注册到监听中:

[oracle@rac4 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4  

可以看到至此,我们把listener、ons、gsd、vip都已经注册到ocr中了,下一步还需要把ASM、数据库注册到ocr中我们的实验就完成了。

11.把ASM注册到OCR中

[oracle@rac3 ~]$ srvctl add asm -n rac3 -i +ASM1 -o /opt/ora10g/product/10.2.0/db_1
[oracle@rac3 ~]$ srvctl add asm -n rac4 -i +ASM2 -o /opt/ora10g/product/10.2.0/db_1  
[oracle@rac3 ~]$ 
[oracle@rac3 ~]$ srvctl config asm -n rac3
+ASM1 /opt/ora10g/product/10.2.0/db_1
[oracle@rac3 ~]$ srvctl config asm -n rac4
+ASM2 /opt/ora10g/product/10.2.0/db_1

12.启动ASM验证

[oracle@rac3 ~]$ srvctl start asm -n rac3
[oracle@rac3 ~]$ srvctl start asm -n rac4
[oracle@rac3 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3        
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....SM2.asm application    ONLINE    ONLINE    rac4        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4   

通过上面的输出可以看出ASM已经成功启动,启动的时候可以关注一下asm的启动日志,方便有错误的时候即使发现问题:

[oracle@rac3 bdump]$ pwd
/opt/ora10g/admin/+ASM/bdump
[oracle@rac3 bdump]$ tail -f alert_+ASM1.log

13.把数据库注册到OCR中

[oracle@rac3 ~]$ srvctl add database -d racdb -o $ORACLE_HOME
[oracle@rac3 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3        
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....SM2.asm application    ONLINE    ONLINE    rac4        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4        
ora.racdb.db   application    OFFLINE   OFFLINE               

14.把实例注册到OCR中

[oracle@rac3 ~]$ srvctl add instance -d racdb -n rac3 -i racdb1
[oracle@rac3 ~]$ srvctl add instance -d racdb -n rac4 -i racdb2
[oracle@rac3 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3        
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....SM2.asm application    ONLINE    ONLINE    rac4        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4        
ora.racdb.db   application    OFFLINE   OFFLINE               
ora....b1.inst application    OFFLINE   OFFLINE               
ora....b2.inst application    OFFLINE   OFFLINE    

15.修改实例和ASM实例的依赖关系

[oracle@rac3 ~]$ srvctl modify instance -d racdb -i racdb1 -s +ASM1
[oracle@rac3 ~]$ srvctl modify instance -d racdb -i racdb2 -s +ASM2 
[oracle@rac3 ~]$ 

16.启动数据库进行验证

[oracle@rac3 ~]$ srvctl start database -d racdb
[oracle@rac3 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3        
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....SM2.asm application    ONLINE    ONLINE    rac4        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4        
ora.racdb.db   application    ONLINE    ONLINE    rac3        
ora....b1.inst application    ONLINE    ONLINE    rac3        
ora....b2.inst application    ONLINE    ONLINE    rac4   

现在可以看到我们注册到CRS中的数据已经正常启动了

[oracle@rac3 ~]$ sqlplus /as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jan 29 12:47:02 2015

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> col name for a50
SQL> select * from v$dbfile;

     FILE# NAME
---------- --------------------------------------------------
         4 +DATA/racdb/datafile/users.259.845203503
         3 +DATA/racdb/datafile/sysaux.257.845203501
         2 +DATA/racdb/datafile/undotbs1.258.845203501
         1 +DATA/racdb/datafile/system.256.845203499
         5 +DATA/racdb/datafile/undotbs2.264.845203661
         6 +DATA/racdb/datafile/rlst.268.852657465

6 rows selected.

SQL> 


17.手动添加service到ocr中

[oracle@rac3 ~]$ srvctl add service -d racdb -s racdbservice -r racdb1 -a racdb2 -P BASIC
[oracle@rac3 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3        
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....SM2.asm application    ONLINE    ONLINE    rac4        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4        
ora.racdb.db   application    ONLINE    ONLINE    rac3        
ora....b1.inst application    ONLINE    ONLINE    rac3        
ora....b2.inst application    ONLINE    ONLINE    rac4        
ora....vice.cs application    OFFLINE   OFFLINE               
ora....db1.srv application    OFFLINE   OFFLINE    
[oracle@rac3 ~]$ srvctl start service -d racdb
[oracle@rac3 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3        
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....SM2.asm application    ONLINE    ONLINE    rac4        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4        
ora.racdb.db   application    ONLINE    ONLINE    rac3        
ora....b1.inst application    ONLINE    ONLINE    rac3        
ora....b2.inst application    ONLINE    ONLINE    rac4        
ora....vice.cs application    ONLINE    ONLINE    rac3        
ora....db1.srv application    ONLINE    ONLINE    rac3  

至此,我们已经正确的重新初始化了我们的OCR盘和VoteDisk盘,并且没有用到备份。

重新初始化RAC的OCR盘和Votedisk盘,修复RAC系统


推荐阅读
  • 在分析和解决 Keepalived VIP 漂移故障的过程中,我们发现主备节点配置如下:主节点 IP 为 172.16.30.31,备份节点 IP 为 172.16.30.32,虚拟 IP 为 172.16.30.10。故障表现为监控系统显示 Keepalived 主节点状态异常,导致 VIP 漂移到备份节点。通过详细检查配置文件和日志,我们发现主节点上的 Keepalived 进程未能正常运行,最终通过优化配置和重启服务解决了该问题。此外,我们还增加了健康检查机制,以提高系统的稳定性和可靠性。 ... [详细]
  • 使用Jsoup解析并遍历HTML文档时,该库能够高效地生成一个清晰、规范的解析树,即使源HTML文档存在格式问题。Jsoup具备强大的容错能力,能够处理多种异常情况,如未闭合的标签等,确保解析结果的准确性和完整性。 ... [详细]
  • 在使用Eclipse进行调试时,如果遇到未解析的断点(unresolved breakpoint)并显示“未加载符号表,请使用‘file’命令加载目标文件以进行调试”的错误提示,这通常是因为调试器未能正确加载符号表。解决此问题的方法是通过GDB的`file`命令手动加载目标文件,以便调试器能够识别和解析断点。具体操作为在GDB命令行中输入 `(gdb) file `。这一步骤确保了调试环境能够正确访问和解析程序中的符号信息,从而实现有效的调试。 ... [详细]
  • 在 LeetCode 的“有效回文串 II”问题中,给定一个非空字符串 `s`,允许删除最多一个字符。本篇深入解析了如何判断删除一个字符后,字符串是否能成为回文串,并提出了高效的优化算法。通过详细的分析和代码实现,本文提供了多种解决方案,帮助读者更好地理解和应用这一算法。 ... [详细]
  • 本项目通过Python编程实现了一个简单的汇率转换器v1.02。主要内容包括:1. Python的基本语法元素:(1)缩进:用于表示代码的层次结构,是Python中定义程序框架的唯一方式;(2)注释:提供开发者说明信息,不参与实际运行,通常每个代码块添加一个注释;(3)常量和变量:用于存储和操作数据,是程序执行过程中的重要组成部分。此外,项目还涉及了函数定义、用户输入处理和异常捕获等高级特性,以确保程序的健壮性和易用性。 ... [详细]
  • 本文详细解析了Autofac在高级应用场景中的具体实现,特别是如何通过注册泛型接口的类来优化依赖注入。示例代码展示了如何使用 `builder.RegisterAssemblyTypes` 方法,结合 `typeof(IEventHandler).Assembly` 和 `Where` 过滤条件,动态注册所有符合条件的类,从而简化配置并提高代码的可维护性。此外,文章还探讨了这一方法在复杂系统中的实际应用及其优势。 ... [详细]
  • 浏览器作为我们日常不可或缺的软件工具,其背后的运作机制却鲜为人知。本文将深入探讨浏览器内核及其版本的演变历程,帮助读者更好地理解这一关键技术组件,揭示其内部运作的奥秘。 ... [详细]
  • 深入解析:Synchronized 关键字在 Java 中对 int 和 Integer 对象的作用与影响
    深入探讨了 `Synchronized` 关键字在 Java 中对 `int` 和 `Integer` 对象的影响。尽管初看此题似乎简单,但其实质在于理解对象的概念。根据《Java编程思想》第二章的观点,一切皆为对象。本文详细分析了 `Synchronized` 关键字在不同数据类型上的作用机制,特别是对基本数据类型 `int` 和包装类 `Integer` 的区别处理,帮助读者深入理解 Java 中的同步机制及其在多线程环境中的应用。 ... [详细]
  • 虚函数表指针vptr的功能测试与分析
    类的虚函数调用依赖于虚函数表来实现。虚函数表是由编译器自动生成的一段内存区域,用于存储包含虚函数的类中每个虚函数的入口地址。这些入口地址本质上是指针类型,从而使得动态绑定成为可能。本文对虚函数表指针(vptr)的功能进行了详细的测试与分析,探讨了其在多态性和继承机制中的作用及其性能影响。 ... [详细]
  • 二分查找算法详解与应用分析:本文深入探讨了二分查找算法的实现细节及其在实际问题中的应用。通过定义 `binary_search` 函数,详细介绍了算法的逻辑流程,包括初始化上下界、循环条件以及中间值的计算方法。此外,还讨论了该算法的时间复杂度和空间复杂度,并提供了多个应用场景示例,帮助读者更好地理解和掌握这一高效查找技术。 ... [详细]
  • 在 Android 开发中,`android:exported` 属性用于控制组件(如 Activity、Service、BroadcastReceiver 和 ContentProvider)是否可以被其他应用组件访问或与其交互。若将此属性设为 `true`,则允许外部应用调用或与之交互;反之,若设为 `false`,则仅限于同一应用内的组件进行访问。这一属性对于确保应用的安全性和隐私保护至关重要。 ... [详细]
  • 系统数据实体验证异常:多个实体验证失败的错误处理与分析
    在使用MVC和EF框架进行数据保存时,遇到了 `System.Data.Entity.Validation.DbEntityValidationException` 错误,表明存在一个或多个实体验证失败的情况。本文详细分析了该错误的成因,并提出了有效的处理方法,包括检查实体属性的约束条件、调试日志的使用以及优化数据验证逻辑,以确保数据的一致性和完整性。 ... [详细]
  • MySQL的查询执行流程涉及多个关键组件,包括连接器、查询缓存、分析器和优化器。在服务层,连接器负责建立与客户端的连接,查询缓存用于存储和检索常用查询结果,以提高性能。分析器则解析SQL语句,生成语法树,而优化器负责选择最优的查询执行计划。这一流程确保了MySQL能够高效地处理各种复杂的查询请求。 ... [详细]
  • 装饰者模式(Decorator):一种灵活的对象结构设计模式
    装饰者模式(Decorator)是一种灵活的对象结构设计模式,旨在为单个对象动态地添加功能,而无需修改原有类的结构。通过封装对象并提供额外的行为,装饰者模式比传统的继承方式更加灵活和可扩展。例如,可以在运行时为特定对象添加边框或滚动条等特性,而不会影响其他对象。这种模式特别适用于需要在不同情况下动态组合功能的场景。 ... [详细]
  • 在 iOS 开发中,经常会遇到 `@(YES)`、`@[firstViewController]` 以及 `@{@a:@b}` 这样的语法糖。这些简化的写法分别用于初始化布尔值、数组和字典对象,能够显著提高代码的可读性和编写效率。例如,`@(YES)` 可以快速创建一个布尔值对象,`@[firstViewController]` 则用于创建包含单个元素的数组,而 `@{@a:@b}` 则用于创建键值对字典。理解这些语法糖的使用方法,有助于开发者更加高效地进行编码。 ... [详细]
author-avatar
k172ausoreor_878
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有