1、主库生成RMAN备份注意:要运用backupascompressedbackupset,可以节省相当的空间run{allocatechannelc1devicetypedisk;backupascompressedbackupsetformat/u0
1、主库生成RMAN备份
注意:要运用backup as compressed backupset,可以节省相当的空间
run
{
allocate channel c1 device type disk;
backup as compressed backupset format ' /u01/rmanbak/nfs/bk_%U' database;
sql 'alter system archive log current';
release channel c1;
}
2、主库生成从库的控制文件
SQL> alter database create standby controlfile as '/tmp/control01.ctl';
Database altered.
3、主库生成的RMAN备份和控制文件放置到从库制定的位置
因为RMAN备份直接放置到了用从库建立了NFS上,香港服务器租用,所以无需额外的传输,但控制文件需要移动到备库的相应目录
[oracle@dgserver standby]$ mv /u01/rmanbak/nfs/control01.ctl control01.ctl
[oracle@dgserver standby]$ cp control01.ctl control03.ctl
[oracle@dgserver standby]$ cp control01.ctl control02.ctl
4、从库RMAN恢复
[oracle@dgserver standby]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Sun May 5 09:38:16 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: PRIMARY (DBID=1656746419, not open)
RMAN> run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
restore database;
switch datafile all;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=1479 devtype=DISK
allocated channel: c2
channel c2: sid=1478 devtype=DISK
allocated channel: c3
channel c3: sid=1477 devtype=DISK
allocated channel: c4
channel c4: sid=1476 devtype=DISK
Starting restore at 05-MAY-13
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oradata/standby/system.262.789583545
restoring datafile 00002 to /u01/oradata/standby/undotbs1.263.789583551
restoring datafile 00003 to /u01/oradata/standby/sysaux.264.789583551
restoring datafile 00004 to /u01/oradata/standby/undotbs2.266.789583557
restoring datafile 00005 to /u01/oradata/standby/users.267.789583559
restoring datafile 00006 to /u01/oradata/standby/inman_index.282.789655375
restoring datafile 00007 to /u01/oradata/standby/in_adcphcled_data.285.789655539
restoring datafile 00008 to /u01/oradata/standby/in_xian_index.286.789655615
restoring datafile 00009 to /u01/oradata/standby/in_xian_data.287.789655707
restoring datafile 00010 to /u01/oradata/standby/tbs_catalog.288.789655837
restoring datafile 00011 to /u01/oradata/standby/eport_index.291.789656023
restoring datafile 00012 to /u01/oradata/standby/in_man_index.292.789656085
restoring datafile 00013 to /u01/oradata/standby/in_suzhou_data.293.789656119
restoring datafile 00014 to /u01/oradata/standby/in_man_data.294.789656245
restoring datafile 00015 to /u01/oradata/standby/in_adcphc_index.295.789656363
restoring datafile 00016 to /u01/oradata/standby/auditadcphc.298.789656683
restoring datafile 00017 to /u01/oradata/standby/in_adcphc_data.299.789656797
restoring datafile 00018 to /u01/oradata/standby/eport_data.302.789657055
restoring datafile 00019 to /u01/oradata/standby/in_suzhou_index.303.789657231
restoring datafile 00020 to /u01/oradata/standby/in_suzhou_data.312.789659221
restoring datafile 00021 to /u01/oradata/standby/users.315.789661229
restoring datafile 00022 to /u01/oradata/standby/users.318.789661589
restoring datafile 00023 to /u01/oradata/standby/users.319.789661839
restoring datafile 00024 to +DATA/in_suzhou_data
restoring datafile 00025 to /u01/oradata/standby/in_suzhou_data
restoring datafile 00026 to /u01/oradata/standby/in_suzhou_data.9154.810742355
restoring datafile 00027 to /u01/oradata/standby/in_adcphc_data.9090.810742665
restoring datafile 00028 to /u01/oradata/standby/system_data
channel c1: reading from backup piece /u01/rmanbak/inc0_PRIMARY_sho8r312_1_1
ORA-19870: error reading backup piece /u01/rmanbak/inc0_PRIMARY_sho8r312_1_1
ORA-19505: failed to identify file "/u01/rmanbak/inc0_PRIMARY_sho8r312_1_1"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
failover to previous backup
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oradata/standby/system.262.789583545
restoring datafile 00002 to /u01/oradata/standby/undotbs1.263.789583551
restoring datafile 00003 to /u01/oradata/standby/sysaux.264.789583551
restoring datafile 00004 to /u01/oradata/standby/undotbs2.266.789583557
restoring datafile 00005 to /u01/oradata/standby/users.267.789583559
restoring datafile 00006 to /u01/oradata/standby/inman_index.282.789655375
restoring datafile 00007 to /u01/oradata/standby/in_adcphcled_data.285.789655539
restoring datafile 00008 to /u01/oradata/standby/in_xian_index.286.789655615
restoring datafile 00009 to /u01/oradata/standby/in_xian_data.287.789655707
restoring datafile 00010 to /u01/oradata/standby/tbs_catalog.288.789655837
restoring datafile 00011 to /u01/oradata/standby/eport_index.291.789656023
restoring datafile 00012 to /u01/oradata/standby/in_man_index.292.789656085
restoring datafile 00013 to /u01/oradata/standby/in_suzhou_data.293.789656119
restoring datafile 00014 to /u01/oradata/standby/in_man_data.294.789656245
restoring datafile 00015 to /u01/oradata/standby/in_adcphc_index.295.789656363
restoring datafile 00016 to /u01/oradata/standby/auditadcphc.298.789656683
restoring datafile 00017 to /u01/oradata/standby/in_adcphc_data.299.789656797
restoring datafile 00018 to /u01/oradata/standby/eport_data.302.789657055
restoring datafile 00019 to /u01/oradata/standby/in_suzhou_index.303.789657231
restoring datafile 00020 to /u01/oradata/standby/in_suzhou_data.312.789659221
restoring datafile 00021 to /u01/oradata/standby/users.315.789661229
restoring datafile 00022 to /u01/oradata/standby/users.318.789661589
restoring datafile 00023 to /u01/oradata/standby/users.319.789661839
restoring datafile 00024 to +DATA/in_suzhou_data
restoring datafile 00025 to /u01/oradata/standby/in_suzhou_data
restoring datafile 00026 to /u01/oradata/standby/in_suzhou_data.9154.810742355
restoring datafile 00027 to /u01/oradata/standby/in_adcphc_data.9090.810742665
restoring datafile 00028 to /u01/oradata/standby/system_data
channel c1: reading from backup piece /u01/rmanbak/nfs/bk_ppo8iqa9_1_1
ORA-19870: error reading backup piece /u01/rmanbak/nfs/bk_ppo8iqa9_1_1
ORA-19504: failed to create file "+DATA/in_suzhou_data"
ORA-17502: ksfdcre:3 Failed to create file +DATA/in_suzhou_data
ORA-15001: diskgroup "DATA" does not exist or is not mounted
ORA-15077: could not locate ASM instance serving a required diskgroup
ORA-29701: unable to connect to Cluster Manager
failover to previous backup
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oradata/standby/system.262.789583545
restoring datafile 00013 to /u01/oradata/standby/in_suzhou_data.293.789656119
restoring datafile 00017 to /u01/oradata/standby/in_adcphc_data.299.789656797
restoring datafile 00019 to /u01/oradata/standby/in_suzhou_index.303.789657231
restoring datafile 00020 to /u01/oradata/standby/in_suzhou_data.312.789659221
restoring datafile 00024 to +DATA/in_suzhou_data
restoring datafile 00025 to /u01/oradata/standby/in_suzhou_data
restoring datafile 00027 to /u01/oradata/standby/in_adcphc_data.9090.810742665
restoring datafile 00028 to /u01/oradata/standby/system_data
channel c1: reading from backup piece /u01/rmanbak/inc0_PRIMARY_nho86012_1_1
ORA-19870: error reading backup piece /u01/rmanbak/inc0_PRIMARY_nho86012_1_1
ORA-19505: failed to identify file "/u01/rmanbak/inc0_PRIMARY_nho86012_1_1"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
failover to previous backup
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00024 to +DATA/in_suzhou_data
channel c1: reading from backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1725_1_lto7pe31.bak
channel c2: starting datafile backupset restore
channel c2: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oradata/standby/system.262.789583545
channel c2: reading from backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1727_1_lvo7pe31.bak
channel c3: starting datafile backupset restore
channel c3: specifying datafile(s) to restore from backup set
restoring datafile 00017 to /u01/oradata/standby/in_adcphc_data.299.789656797
restoring datafile 00020 to /u01/oradata/standby/in_suzhou_data.312.789659221
restoring datafile 00025 to /u01/oradata/standby/in_suzhou_data
channel c3: reading from backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1724_1_lso7pe31.bak
channel c4: starting datafile backupset restore
channel c4: specifying datafile(s) to restore from backup set
restoring datafile 00013 to /u01/oradata/standby/in_suzhou_data.293.789656119
restoring datafile 00019 to /u01/oradata/standby/in_suzhou_index.303.789657231
restoring datafile 00027 to /u01/oradata/standby/in_adcphc_data.9090.810742665
restoring datafile 00028 to /u01/oradata/standby/system_data
channel c4: reading from backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1726_1_luo7pe31.bak
ORA-19870: error reading backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1726_1_luo7pe31.bak
ORA-19505: failed to identify file "/u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1726_1_luo7pe31.bak"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-19870: error reading backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1725_1_lto7pe31.bak
ORA-19505: failed to identify file "/u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1725_1_lto7pe31.bak"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-19870: error reading backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1727_1_lvo7pe31.bak
ORA-19505: failed to identify file "/u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1727_1_lvo7pe31.bak"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-19870: error reading backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1724_1_lso7pe31.bak
ORA-19505: failed to identify file "/u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1724_1_lso7pe31.bak"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
failover to previous backup
creating datafile fno=28 name=/u01/oradata/standby/system_data
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oradata/standby/system.262.789583545
restoring datafile 00013 to /u01/oradata/standby/in_suzhou_data.293.789656119
restoring datafile 00017 to /u01/oradata/standby/in_adcphc_data.299.789656797
restoring datafile 00019 to /u01/oradata/standby/in_suzhou_index.303.789657231
restoring datafile 00020 to /u01/oradata/standby/in_suzhou_data.312.789659221
restoring datafile 00025 to /u01/oradata/standby/in_suzhou_data
restoring datafile 00027 to /u01/oradata/standby/in_adcphc_data.9090.810742665
channel c1: reading from backup piece /u01/rmanbak/inc0_PRIMARY_0ro5s5gv_1_1
channel c2: starting datafile backupset restore
channel c2: specifying datafile(s) to restore from backup set
restoring datafile 00024 to +DATA/in_suzhou_data
channel c2: reading from backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1619_1_ijo6sfbj.bak
ORA-19870: error reading backup piece /u01/rmanbak/inc0_PRIMARY_0ro5s5gv_1_1
ORA-19505: failed to identify file "/u01/rmanbak/inc0_PRIMARY_0ro5s5gv_1_1"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-19870: error reading backup piece /u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1619_1_ijo6sfbj.bak
ORA-19505: failed to identify file "/u01/rmanbak/nfs/`date +2013%mPRIMARY`_full_PRIMARY_1619_1_ijo6sfbj.bak"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
failover to previous backup
creating datafile fno=1 name=/u01/oradata/standby/system.262.789583545
released channel: c1
released channel: c2
released channel: c3
released channel: c4
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/05/2013 12:06:01
ORA-01180: can not create datafile 1
ORA-01110: data file 1: '/u01/oradata/standby/system.262.789583545'
RMAN>
------------------------------------------------------------------------
因为从库不存在 +DATA目录,需要RENAME,重新执行RESTORE
------------------------------------------------------------------------
RMAN>
RMAN> run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
set newname for datafile 24 to '/u01/oradata/standby/in_suzhou_data.dbf';
restore database;
switch datafile all;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13>
allocated channel: c1
channel c1: sid=1479 devtype=DISK
allocated channel: c2
channel c2: sid=1478 devtype=DISK
allocated channel: c3
channel c3: sid=1477 devtype=DISK
allocated channel: c4
channel c4: sid=1476 devtype=DISK
executing command: SET NEWNAME
Starting restore at 05-MAY-13
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oradata/standby/system.262.789583545
restoring datafile 00002 to /u01/oradata/standby/undotbs1.263.789583551
restoring datafile 00003 to /u01/oradata/standby/sysaux.264.789583551
restoring datafile 00004 to /u01/oradata/standby/undotbs2.266.789583557
restoring datafile 00005 to /u01/oradata/standby/users.267.789583559
restoring datafile 00006 to /u01/oradata/standby/inman_index.282.789655375
restoring datafile 00007 to /u01/oradata/standby/in_adcphcled_data.285.789655539
restoring datafile 00008 to /u01/oradata/standby/in_xian_index.286.789655615
restoring datafile 00009 to /u01/oradata/standby/in_xian_data.287.789655707
restoring datafile 00010 to /u01/oradata/standby/tbs_catalog.288.789655837
restoring datafile 00011 to /u01/oradata/standby/eport_index.291.789656023
restoring datafile 00012 to /u01/oradata/standby/in_man_index.292.789656085
restoring datafile 00013 to /u01/oradata/standby/in_suzhou_data.293.789656119
restoring datafile 00014 to /u01/oradata/standby/in_man_data.294.789656245
restoring datafile 00015 to /u01/oradata/standby/in_adcphc_index.295.789656363
restoring datafile 00016 to /u01/oradata/standby/auditadcphc.298.789656683
restoring datafile 00017 to /u01/oradata/standby/in_adcphc_data.299.789656797
restoring datafile 00018 to /u01/oradata/standby/eport_data.302.789657055
restoring datafile 00019 to /u01/oradata/standby/in_suzhou_index.303.789657231
restoring datafile 00020 to /u01/oradata/standby/in_suzhou_data.312.789659221
restoring datafile 00021 to /u01/oradata/standby/users.315.789661229
restoring datafile 00022 to /u01/oradata/standby/users.318.789661589
restoring datafile 00023 to /u01/oradata/standby/users.319.789661839
restoring datafile 00024 to /u01/oradata/standby/in_suzhou_data.dbf
restoring datafile 00025 to /u01/oradata/standby/in_suzhou_data
restoring datafile 00026 to /u01/oradata/standby/in_suzhou_data.9154.810742355
restoring datafile 00027 to /u01/oradata/standby/in_adcphc_data.9090.810742665
restoring datafile 00028 to /u01/oradata/standby/system_data
channel c1: reading from backup piece /u01/rmanbak/inc0_PRIMARY_sho8r312_1_1
ORA-19870: error reading backup piece /u01/rmanbak/inc0_PRIMARY_sho8r312_1_1
ORA-19505: failed to identify file "/u01/rmanbak/inc0_PRIMARY_sho8r312_1_1"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
failover to previous backup
skipping datafile 2; already restored to file /u01/oradata/standby/undotbs1.263.789583551
skipping datafile 3; already restored to file /u01/oradata/standby/sysaux.264.789583551
skipping datafile 4; already restored to file /u01/oradata/standby/undotbs2.266.789583557
skipping datafile 5; already restored to file /u01/oradata/standby/users.267.789583559
skipping datafile 6; already restored to file /u01/oradata/standby/inman_index.282.789655375
skipping datafile 7; already restored to file /u01/oradata/standby/in_adcphcled_data.285.789655539
skipping datafile 8; already restored to file /u01/oradata/standby/in_xian_index.286.789655615
skipping datafile 9; already restored to file /u01/oradata/standby/in_xian_data.287.789655707
skipping datafile 10; already restored to file /u01/oradata/standby/tbs_catalog.288.789655837
skipping datafile 11; already restored to file /u01/oradata/standby/eport_index.291.789656023
skipping datafile 12; already restored to file /u01/oradata/standby/in_man_index.292.789656085
skipping datafile 14; already restored to file /u01/oradata/standby/in_man_data.294.789656245
skipping datafile 15; already restored to file /u01/oradata/standby/in_adcphc_index.295.789656363
skipping datafile 16; already restored to file /u01/oradata/standby/auditadcphc.298.789656683
skipping datafile 18; already restored to file /u01/oradata/standby/eport_data.302.789657055
skipping datafile 21; already restored to file /u01/oradata/standby/users.315.789661229
skipping datafile 22; already restored to file /u01/oradata/standby/users.318.789661589
skipping datafile 23; already restored to file /u01/oradata/standby/users.319.789661839
skipping datafile 26; already restored to file /u01/oradata/standby/in_suzhou_data.9154.810742355
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oradata/standby/system.262.789583545
restoring datafile 00013 to /u01/oradata/standby/in_suzhou_data.293.789656119
restoring datafile 00017 to /u01/oradata/standby/in_adcphc_data.299.789656797
restoring datafile 00019 to /u01/oradata/standby/in_suzhou_index.303.789657231
restoring datafile 00020 to /u01/oradata/standby/in_suzhou_data.312.789659221
restoring datafile 00024 to /u01/oradata/standby/in_suzhou_data.dbf
restoring datafile 00025 to /u01/oradata/standby/in_suzhou_data
restoring datafile 00027 to /u01/oradata/standby/in_adcphc_data.9090.810742665
restoring datafile 00028 to /u01/oradata/standby/system_data
channel c1: reading from backup piece /u01/rmanbak/nfs/bk_ppo8iqa9_1_1
channel c1: restored backup piece 1
piece handle=/u01/rmanbak/nfs/bk_ppo8iqa9_1_1 tag=TAG20130501T214233
channel c1: restore complete, elapsed time: 02:32:57
Finished restore at 05-MAY-13
datafile 24 switched to datafile copy
input datafile copy recid=29 stamp=814635208 filename=/u01/oradata/standby/in_suzhou_data.dbf
released channel: c1
released channel: c2
released channel: c3
released channel: c4
RMAN>
5、尝试应用日志
SQL> alter database recover managed standby database using current logfile disconnect from session;
alter database recover managed standby database using current logfile disconnect from session
*
ERROR at line 1:
ORA-38500: USING CURRENT LOGFILE option not available without stand
SQL> alter database add standby logfile group 10 ('/u01/oradata/standby/stand01.log') size 100m;
alter database add standby logfile group 11 ('/u01/oradata/standby/stand02.log') size 100m;
alter database add standby logfile group 12 ('/u01/oradata/standby/stand03.log') size 100m;
alter database add standby logfile group 13 ('/u01/oradata/standby/stand04.log') size 100m;
alter database add standby logfile group 14 ('/u01/oradata/standby/stand05.log') size 100m;
alter database add standby logfile group 15 ('/u01/oradata/standby/stand06.log') size 100m;
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL> SQL>
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL>
5、查看日志,已经正常应用了
root@dgserver standby]# cd /u01/app/oracle/admin/standby/bdump
[root@dgserver bdump]# tail -f *.log
Media Recovery Log /u01/archivelog/standby/arc_1_13753_789583539.dbf
Media Recovery Waiting for thread 2 sequence 17431
Fetching gap sequence in thread 2, gap sequence 17431-17530
FAL[client, MRP0]: Error 88 fetching archived redo log from PRIMARY
Sun May 05 20:09:26 CST 2013
Errors in file /u01/app/oracle/admin/standby/bdump/standby_mrp0_19416.trc:
ORA-00088: command cannot be executed by shared server
Sun May 05 20:09:27 CST 2013
RFS[2]: Archived Log: '/u01/archivelog/standby/arc_1_13769_789583539.dbf'
RFS[2]: Archived Log: '/u01/archivelog/standby/arc_1_13770_789583539.dbf'
Sun May 05 20:09:39 CST 2013
RFS[2]: Archived Log: '/u01/archivelog/standby/arc_1_13771_789583539.dbf'
Sun May 05 20:09:40 CST 2013
RFS[1]: Archived Log: '/u01/archivelog/standby/arc_2_17431_789583539.dbf'
RFS[1]: Archived Log: '/u01/archivelog/standby/arc_2_17432_789583539.dbf'
Sun May 05 20:09:49 CST 2013
RFS[2]: Archived Log: '/u01/archivelog/standby/arc_1_13772_789583539.dbf'
Sun May 05 20:09:55 CST 2013
RFS[1]: Archived Log: '/u01/archivelog/standby/arc_2_17433_789583539.dbf'
Sun May 05 20:09:56 CST 2013
Media Recovery Log /u01/archivelog/standby/arc_2_17431_789583539.dbf
本文出自 “麦地坞” 博客,请务必保留此出处
,香港虚拟主机,香港服务器
MySQL和SQLite的主要區別在於設計理念和使用場景:1.MySQL適用於大型應用和企業級解決方案,支持高性能和高並發;2.SQLite適合移動應用和桌面軟件,輕量級且易於嵌入。

MySQL中的索引是數據庫表中一列或多列的有序結構,用於加速數據檢索。 1)索引通過減少掃描數據量提升查詢速度。 2)B-Tree索引利用平衡樹結構,適合範圍查詢和排序。 3)創建索引使用CREATEINDEX語句,如CREATEINDEXidx_customer_idONorders(customer_id)。 4)複合索引可優化多列查詢,如CREATEINDEXidx_customer_orderONorders(customer_id,order_date)。 5)使用EXPLAIN分析查詢計劃,避

在MySQL中使用事務可以確保數據一致性。 1)通過STARTTRANSACTION開始事務,執行SQL操作後用COMMIT提交或ROLLBACK回滾。 2)使用SAVEPOINT可以設置保存點,允許部分回滾。 3)性能優化建議包括縮短事務時間、避免大規模查詢和合理使用隔離級別。

選擇PostgreSQL而非MySQL的場景包括:1)需要復雜查詢和高級SQL功能,2)要求嚴格的數據完整性和ACID遵從性,3)需要高級空間功能,4)處理大數據集時需要高性能。 PostgreSQL在這些方面表現出色,適合需要復雜數據處理和高數據完整性的項目。

MySQL數據庫的安全可以通過以下措施實現:1.用戶權限管理:通過CREATEUSER和GRANT命令嚴格控制訪問權限。 2.加密傳輸:配置SSL/TLS確保數據傳輸安全。 3.數據庫備份和恢復:使用mysqldump或mysqlpump定期備份數據。 4.高級安全策略:使用防火牆限制訪問,並啟用審計日誌記錄操作。 5.性能優化與最佳實踐:通過索引和查詢優化以及定期維護兼顧安全和性能。

如何有效監控MySQL性能?使用mysqladmin、SHOWGLOBALSTATUS、PerconaMonitoringandManagement(PMM)和MySQLEnterpriseMonitor等工具。 1.使用mysqladmin查看連接數。 2.用SHOWGLOBALSTATUS查看查詢數。 3.PMM提供詳細性能數據和圖形化界面。 4.MySQLEnterpriseMonitor提供豐富的監控功能和報警機制。

MySQL和SQLServer的区别在于:1)MySQL是开源的,适用于Web和嵌入式系统,2)SQLServer是微软的商业产品,适用于企业级应用。两者在存储引擎、性能优化和应用场景上有显著差异,选择时需考虑项目规模和未来扩展性。

在需要高可用性、高級安全性和良好集成性的企業級應用場景下,應選擇SQLServer而不是MySQL。 1)SQLServer提供企業級功能,如高可用性和高級安全性。 2)它與微軟生態系統如VisualStudio和PowerBI緊密集成。 3)SQLServer在性能優化方面表現出色,支持內存優化表和列存儲索引。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3漢化版
中文版,非常好用

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

SublimeText3 Linux新版
SublimeText3 Linux最新版

WebStorm Mac版
好用的JavaScript開發工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),