转载自:http://blog.csdn.net/linghe301/article/details/7777912
其实我在今年的开发者大会中专门对ArcGIS版本压缩做了一个详细的说明。为什么专门来说这个呢?其实现在对ArcGIS用户来说,他们在使用多用户版本操作时,发现性能慢一般都知道进行ArcGIS版本压缩,但是他们往往做的就是Compress操作,这样做是远远不够的,因为什么都不管只进行compress操作,不能彻底的进行压缩,也就是压缩的不彻底, 那么标准的ArcGIS版本压缩流程是什么样的呢?
首先说明,理想的版本压缩后是什么样子的
1:不能出错。(这像是废话)
2:增量表的数据为空
3:状态表和族系表一条记录也就是State_ID=0
相关的压缩流程,使用专门的管理员用户
1:断开其他所有用户的连接,阻止其他新用户连接
2:相关的子版本进行协调和提交
Python实现批量执行ArcGIS版本的协调和提交
http://blog.csdn.NET/linghe301/article/details/7777816
3:数据备份(这个和2可以互换顺序)
关于ArcGIS数据迁移方案的策略(备份也可以参考)
http://blog.csdn.net/linghe301/article/details/6330759
4:删除相关子版本(注意如果使用过同步复制,注意相关的隐藏子版本)
5:删除相关的锁信息
以Oracle 数据库为例sde用户下
- state_locks
- table_locks
- object_locks
- layer_locks
ArcGIS锁的介绍
6:进行版本压缩
ArcGIS版本压缩(Compress)报ORA-00001: unique constraint 的解决方法
http://blog.csdn.net/linghe301/article/details/7331992
ArcSDE版本压缩之前对UNDO表空间的设置
http://blog.csdn.net/linghe301/article/details/7335530
关于ArcSDE版本压缩(Compress)的再研究
http://blog.csdn.net/linghe301/article/details/6399036
7:创建子版本
一种快速批量创建子版本的方法
http://blog.csdn.net/linghe301/article/details/7329531
8:重建空间索引
怎么对ArcSDE数据库的要素类进行批量重建空间索引
http://blog.csdn.net/linghe301/article/details/7720871
9:进行统计分析
10:允许其他新用户连接
那么真正的压缩只有这样才能彻底压缩干净。
那么我们也可以使用python进行这样的操作,我没有经这些环节搞成一个现成可以用的脚本,以下的脚本文件仅供参考
- import arcpy, time, smtplib
-
-
- arcpy.env.workspace = 'Database Connections/admin.sde'
-
-
- workspace = arcpy.env.workspace
-
-
- userList = arcpy.ListUsers("Database Connections/admin.sde")
-
-
- emailList = [u.Name + "@yourcompany.com" for user in arcpy.ListUsers("Database Connections/admin.sde")]
-
-
- SERVER = "mailserver.yourcompany.com"
- FROM = "SDE Admin <python@yourcompany.com>"
- TO = emailList
- SUBJECT = "Maintenance is about to be performed"
- MSG = "Auto generated Message.\n\rServer maintenance will be performed in 15 minutes. Please log off."
-
-
- MESSAGE =
-
-
-
-
-
- % (FROM, ", ".join(TO), SUBJECT, MSG)
-
-
- server = smtplib.SMTP(SERVER)
- server.sendmail(FROM, TO, MESSAGE)
- server.quit()
-
-
- arcpy.AcceptConnections('Database Connections/admin.sde', False)
-
-
- time.sleep(900)
-
-
- arcpy.DisconnectUser('Database Connections/admin.sde', "ALL")
-
-
- versionList = arcpy.ListVersions('Database Connections/admin.sde')
-
-
- arcpy.ReconcileVersions_management('Database Connections/admin.sde', "ALL_VERSIONS", "sde.DEFAULT", versionList, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_TARGET_VERSION", "POST", "DELETE_VERSION", "c:/temp/reconcilelog.txt")
-
-
- arcpy.Compress_management('Database Connections/admin.sde')
-
-
- arcpy.AcceptConnections('Database Connections/admin.sde', True)
-
-
-
-
-
-
- userName = arcpy.Describe(arcpy.env.workspace).connectionProperties.user
-
-
-
- dataList = arcpy.ListTables('*.' + userName + '.*') + arcpy.ListFeatureClasses('*.' + userName + '.*') + arcpy.ListRasters('*.' + userName + '.*')
-
-
-
- for dataset in arcpy.ListDatasets('*.' + userName + '.*'):
- dataList += arcpy.ListFeatureClasses(feature_dataset=dataset)
-
-
-
- arcpy.RebuildIndexes_management(workspace, "SYSTEM", dataList, "ALL")
-
- arcpy.AnalyzeDatasets_management(workspace, "SYSTEM", dataList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE")
以下的压缩代码仅供参考,适用于ArcGIS9.2/9.3
-
-
-
-
-
-
-
-
- import sys, string, os, arcgisscripting, time, smtplib
-
-
- Date = time.strftime("%m-%d-%Y", time.localtime())
-
-
- Time = time.strftime("%I:%M:%S %p", time.localtime())
-
-
- gp = arcgisscripting.create()
-
- gp.CheckProduct("ArcEditor")
-
- gp.SetProduct("arceditor")
-
- print "Process started at " + str(Date) + " " + str(Time) + "." + "\n"
-
-
- LogFile = file('C:\\PythonScripts\\Analyze\\GIS-' + Date + '.txt', 'w')
- output = open('C:\\PythonScripts\\Analyze\\GIS-' + Date + '.txt', 'w')
- output.write(str("Process started at " + str(Date) + " " + str(Time) + "." + "\n"))
-
-
-
-
- gp.AddToolbox("F:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
-
- try:
-
- print "Begining Compress..." + "\n"
- gp.toolbox = "management"
-
- gp.compress("C:\\Documents and Settings\\mlong\\Application Data\\ESRI\\ArcCatalog\\SDE@GIS.sde")
- print gp.GetMessages() + "\n"
- output.write(gp.GetMessages()+ "\n")
-
- except:
-
-
- From = "Geoprocessor"
- To = ["your_email@domain.com"]
- Date = time.ctime(time.time())
- Subject = "Error Compressing the GIS Database"
- Text = gp.GetMessages()
-
-
- mMessage = ('From: %s\nTo: %s\nDate: %s\nSubject: %s\n%s\n' %
- (From, To, Date, Subject, Text))
- print 'Connecting to Server'
- s = smtplib.SMTP('machinename.domainname.com')
-
-
- rCode = s.sendmail(From, To, mMessage)
- s.quit()
-
- if rCode:
- print 'Error Sending Message'
- else:
- print 'Message sent sucessfully'
-
- analyzeworkspace = "C:\\Documents and Settings\\mlong\\Application Data\\ESRI\\ArcCatalog\\Model Connection.sde"
-
- try:
-
- gp.Workspace = analyzeworkspace
- FCList = gp.ListFeatureClasses ("*", "all")
- FC = FCList.Next()
- while FC:
- gp.Analyze_management(FC, "BUSINESS;FEATURE;ADDS;DELETES")
- print gp.GetMessages() + "\n"
- output.write(gp.GetMessages()+ "\n")
- FC = FCList.Next()
-
- gp.Workspace = analyzeworkspace
- FDList = gp.ListDatasets ("*", "all")
- FD = FDList.Next()
- while FD:
- gp.Analyze_management(FD, "BUSINESS;FEATURE;ADDS;DELETES")
- print gp.GetMessages() + "\n"
- output.write(gp.GetMessages())
- FD = FDList.Next()
-
-
- gp.Workspace = analyzeworkspace
- TBList = gp.ListTables ("*", "all")
- TB = TBList.Next()
- while TB:
- if '_MVVIEW' in TB:
- print "Skipping Multi-Versioned View"
- elif '_MVView' in TB:
- print "Skipping Multi-Versioned View"
- else:
- gp.Analyze_management(TB, "BUSINESS;FEATURE;ADDS;DELETES")
- print gp.GetMessages() + "\n"
- output.write(gp.GetMessages())
- TB = TBList.Next()
-
- except:
- print gp.GetMessages()
- output.write(gp.GetMessages())
-
-
-
- From = "Geoprocessor"
- To = ["your_email@domain.com"]
- Date = time.ctime(time.time())
- Subject = "Error Analyzing the GIS Database"
- Text = gp.GetMessages()
-
-
- mMessage = ('From: %s\nTo: %s\nDate: %s\nSubject: %s\n%s\n' %
- (From, To, Date, Subject, Text))
- print 'Connecting to Server'
- s = smtplib.SMTP('machinename.domainname.com')
-
-
- rCode = s.sendmail(From, To, mMessage)
- s.quit()
-
- if rCode:
- print 'Error Sending Message'
- else:
- print 'Message sent sucessfully'
-
-
- Date = time.strftime("%m-%d-%Y", time.localtime())
- Time = time.strftime("%I:%M:%S %p", time.localtime())
- output.write(str("Process completed at " + str(Date) + " " + str(Time) + "." + "\n"))
-
- output.close()
-
- print "Process completed at " + str(Date) + " " + str(Time) + "."
-