一:monogdb 的replica sets中,每一个成员,都有很多属性。
官方文档请点我
二:votes和priority
这两个属性都可以primary有关系。replica sets中primary是很重要的成员,所有的write操作,都要从primary进入。
primary是通过选举产生的,选举的过程中需要投票。
votes表示成员拥有的票数。
priority表示成员的权重。
两个属性默认值都是1。
priority的值越大,就越可能获得多数成员的votes数。
最终获得votes数量超过半数的成员,成为primary。
这就是两个属性和primary的关系。
三:注意
votes的值一般是0或者1。如果设置超过1,可能会出现很多问题。
因为选举primary,必须要求成员获得半数的votes,如果某成员的votes设置过大,超过半数,且改成员挂了。那么replica sets将不能选出primary,这是很危险的。
Sql最早的版本是由IBM开发,它最初的被叫做Sequel,在20世纪70年代早期作为System R项目的一部分。Sequel语言一直发展至今,其名称已经变为SQL(结构化查询语言)。Sql已经很明显的确立了自己作为标准的关系数据库语言的地位。
Sql语言包括一下几个部分:
l 数据定义语言(Data-Definition Language,DDL):SQL DDL提供定义关系模式、删除关系以及修改关系模式的命令。
l 数据操纵语言(Data-Manipulation Language,DML)SQL DML提供从数据库查询信息,以及在数据库中插入元组、删除元组、修改元组的能力。
l 完整性(integrity):SQL DDL包括定义完整性约束的命令,保存在数据库中的数据必须满足所定义的完整性月火速。破坏完整性约束的更新是不允许的。
l 视图定义(view definition) :SQL DDL包括定义视图的命令。
l 事务控制(transaction control):SQL 包括定义事务的开始和结束的命令
l 嵌入式SQL和动态SQL(embedded SQL and dynamic SQL):嵌入式和动态SQL定义SQL语言如何嵌入到通用编程语言中。
l 授权(authorization):SQL DDL 包括定义对关系和视图的访问权限的命令。
Sql数据定义DDL不仅能够定义关系,还可以定义每个 每个关系的信息:
l 每个关系的模式
l 每个属性的取值类型
l 完整性约束
l 每个关系维护的索引集合
l 每个关系的安全性和权限信息
l 每个关系在磁盘上的物理存储结构
基本类型:Char(n):固定长度的字符串,用户指定长度n,全称character
Varchar(n):可变长度字符串,用户指定最大长度n,等价于全称character varying。
Int:整型,全称integer
Smallint:小整数类型。
Numeric(p,d):定点数,精度由用户指定,这个数有p位数字,其中有d位在小数点右边
Real,double precision:浮点数与双精度浮点数,精度与机器相关。
Float(n):精度至少为n位的浮点数。
基本模式定义:用create table 定义sql关系:
Create table department
(
dept_name varchar(20),
building varchar(15),
budget numeric(12,2),
primary key(dept_name)
);
Primary key(A),声明属性A构成关系的主码。主码属性必须非空且唯一,也就是说没有一个元组在主码属性上取空值,关系中也没有两个元组在所有主码属性上取值相同。虽然主码的声明是可选的,但为每个关系指定一个主码通常会更好。
Foreign key(A1,A2,A3…..) references:
Foreign key 声明表示关系中任意元组在属性(A1,A2…)上的取值必须对应与关系s中某元组在主码属性上的值。
Not null:一个属性上的not null 约束表明在该属性上不允许空值。
一个新创建的关系最初是空的,可以用insert 命令将数据加载到关系中。
Insert into instructor values(10211,’Smith’,’Biology’,6600);
值的顺序应该遵循对应属性在关系模式中列出的顺序。
用delete命令删除元组:
Delete from student;
将删除student的所有元组。
如果要从sql数据库中去掉一个关系,我们使用drop table 命令
Drop talbe r;
不仅删除r的所有元组,还删除了关系模式;
我们用alter table 命令为已有关系增加属性。关系中的所有元组在新属性上的取值将被设为null
Add a Node to Oracle RAC 11gR2(11.2.0.3) on Oracle Linux 6
This guide shows how to remove a node from an existing 11gR2 Oracle RAC cluster. It is assumed that the node in question is available and is not part of a GNS/Grid Plug and Play cluster. In other words, the database
is considered to be "Administrator-Managed". Also, the database software is non-shared. This guide uses a 3-node cluster running Oracle Linux 6.3 (x64). The three nodes are "node1", "node2", and "node3",we will be removing "node3" from the cluster.
Delete Node from Cluster
"Unpin" node
"Unpin" the node – in our case "node3" – from all nodes that are to remain in the cluster; in this case, "node1" and "node2". Specify the node you plan on deleting in the command and do so on each remaining node
in the cluster.
[root@node1 ~]# /u01/app/11.2.0/grid/bin/crsctl unpin css -n node3 CRS-4667: Node node3 successfully unpinned.
[root@node2 ~]# /u01/app/11.2.0/grid/bin/crsctl unpin css -n node3 CRS-4667: Node node3 successfully unpinned.
The node we are removing houses an instance – "zhongwc3" – which is part of a RAC database – "zhongwc".
Remove the "zhongwc3" instance from the "zhongwc" database using "dbca" in "Silent Mode"
[oracle@node1 ~]$ dbca -silent -deleteInstance -nodeList node3 -gdbName zhongwc -instanceName zhongwc3 -sysDBAUserName sys -sysDBAPassword oracle Deleting instance 1% complete 2% complete 6% complete 13% complete 20% complete 26% complete 33% complete 40% complete 46% complete 53% complete 60% complete 66% complete Completing instance management. 100% complete Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/zhongwc.log" for further details.
In this case, we ran the command as "oracle" on "zhongwc1". Afterwards, the database should only show 2 threads and the configuration of the database should show "zhongwc1" and "zhongwc2" as its only instances.
[oracle@node1 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Sat Jan 5 15:20:12 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'; Session altered. SQL> col host_name format a11 SQL> set line 300 SQL> select INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS,ACTIVE_STATE,INSTANCE_ROLE,DATABASE_STATUS from gv$INSTANCE; INSTANCE_NAME HOST_NAME VERSION STARTUP_TIME STATUS ACTIVE_ST INSTANCE_ROLE DATABASE_STATUS ---------------- ----------- ----------------- ------------------- ------------ --------- ------------------ ----------------- zhongwc1 node1 11.2.0.3.0 2013-01-05 09:53:24 OPEN NORMAL PRIMARY_INSTANCE ACTIVE zhongwc2 node2 11.2.0.3.0 2013-01-04 17:34:40 OPEN NORMAL PRIMARY_INSTANCE ACTIVE
[oracle@node1 ~]$ srvctl config database -d zhongwc -v Database unique name: zhongwc Database name: zhongwc Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1 Oracle user: oracle Spfile: +DATADG/zhongwc/spfilezhongwc.ora Domain: Start options: open Stop options: immediate Database role: PRIMARY Management policy: AUTOMATIC Server pools: zhongwc Database instances: zhongwc1,zhongwc2 Disk Groups: DATADG,FRADG Mount point paths: Services: Type: RAC Database is administrator managed
In this step, the Oracle RAC database software will be removed from the node that will be deleted. Additionally, the inventories of the remaining nodes will be updated to reflect the removal of the node’s Oracle RAC database software home, etc.
Any listener running on "node3" will need to be stopped.
[oracle@node3 ~]$ srvctl disable listener -n node3 [oracle@node3 ~]$ srvctl stop listener -n node3
Update inventory on "node3"
[oracle@node3 bin]$ ./runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={node3}" -local Starting Oracle Universal Installer... Checking swap space: must be greater than 500 MB. Actual 3930 MB Passed The inventory pointer is located at /etc/oraInst.loc The inventory is located at /u01/app/oraInventory 'UpdateNodeList' was successful.
Remove the RAC Database Software from "node3"
[oracle@node3 ~]$ cd $ORACLE_HOME/deinstall [oracle@node3 deinstall]$ ./deinstall -local Checking for required files and bootstrapping ... Please wait ... Location of logs /u01/app/oraInventory/logs/ ############ ORACLE DEINSTALL & DECONFIG TOOL START ############ ######################### CHECK OPERATION START ######################### ## [START] Install check configuration ## Checking for existence of the Oracle home location /u01/app/oracle/product/11.2.0/dbhome_1 Oracle Home type selected for deinstall is: Oracle Real Application Cluster Database Oracle Base selected for deinstall is: /u01/app/oracle Checking for existence of central inventory location /u01/app/oraInventory Checking for existence of the Oracle Grid Infrastructure home /u01/app/11.2.0/grid The following nodes are part of this cluster: node3 Checking for sufficient temp space availability on node(s) : 'node3' ## [END] Install check configuration ## Network Configuration check config START Network de-configuration trace file location: /u01/app/oraInventory/logs/netdc_check2013-01-05_03-34-48-PM.log Network Configuration check config END Database Check Configuration START Database de-configuration trace file location: /u01/app/oraInventory/logs/databasedc_check2013-01-05_03-34-56-PM.log Database Check Configuration END Enterprise Manager Configuration Assistant START EMCA de-configuration trace file location: /u01/app/oraInventory/logs/emcadc_check2013-01-05_03-35-03-PM.log Enterprise Manager Configuration Assistant END Oracle Configuration Manager check START OCM check log file location : /u01/app/oraInventory/logs//ocm_check3913.log Oracle Configuration Manager check END ######################### CHECK OPERATION END ######################### ####################### CHECK OPERATION SUMMARY ####################### Oracle Grid Infrastructure Home is: /u01/app/11.2.0/grid The cluster node(s) on which the Oracle home deinstallation will be performed are:node3 Since -local option has been specified, the Oracle home will be deinstalled only on the local node, 'node3', and the global configuration will be removed. Oracle Home selected for deinstall is: /u01/app/oracle/product/11.2.0/dbhome_1 Inventory Location where the Oracle home registered is: /u01/app/oraInventory The option -local will not modify any database configuration for this Oracle home. No Enterprise Manager configuration to be updated for any database(s) No Enterprise Manager ASM targets to update No Enterprise Manager listener targets to migrate Checking the config status for CCR Oracle Home exists with CCR directory, but CCR is not configured CCR check is finished Do you want to continue (y - yes, n - no)? [n]: y A log of this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2013-01-05_03-34-20-PM.out' Any error messages from this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2013-01-05_03-34-20-PM.err' ######################## CLEAN OPERATION START ######################## Enterprise Manager Configuration Assistant START EMCA de-configuration trace file location: /u01/app/oraInventory/logs/emcadc_clean2013-01-05_03-35-03-PM.log Updating Enterprise Manager ASM targets (if any) Updating Enterprise Manager listener targets (if any) Enterprise Manager Configuration Assistant END Database de-configuration trace file location: /u01/app/oraInventory/logs/databasedc_clean2013-01-05_03-35-33-PM.log Network Configuration clean config START