其实我在今年的开发者大会中专门对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用户下
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
# set the workspace
arcpy.env.workspace = 'Database Connections/admin.sde'
# set a variable for the workspace
workspace = arcpy.env.workspace
# get a list of connected users.
userList = arcpy.ListUsers("Database Connections/admin.sde")
# get a list of usernames of users currently connected and make email addresses
emailList = [u.Name + "@yourcompany.com" for user in arcpy.ListUsers("Database Connections/admin.sde")]
# take the email list and use it to send an email to connected users.
SERVER = "mailserver.yourcompany.com"
FROM = "SDE Admin "
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."
# Prepare actual message
MESSAGE = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, MSG)
# Send the mail
server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO, MESSAGE)
server.quit()
#block new connections to the database.
arcpy.AcceptConnections('Database Connections/admin.sde', False)
# wait 15 minutes
time.sleep(900)
#disconnect all users from the database.
arcpy.DisconnectUser('Database Connections/admin.sde', "ALL")
# Get a list of versions to pass into the ReconcileVersions tool.
versionList = arcpy.ListVersions('Database Connections/admin.sde')
# Execute the ReconcileVersions tool.
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")
# Run the compress tool.
arcpy.Compress_management('Database Connections/admin.sde')
#Allow the database to begin accepting connections again
arcpy.AcceptConnections('Database Connections/admin.sde', True)
#Get a list of datasets owned by the admin user
# Get the user name for the workspace
# this assumes you are using database authentication.
# OS authentication connection files do not have a 'user' property.
userName = arcpy.Describe(arcpy.env.workspace).connectionProperties.user
# Get a list of all the datasets the user has access to.
# First, get all the stand alone tables, feature classes and rasters.
dataList = arcpy.ListTables('*.' + userName + '.*') + arcpy.ListFeatureClasses('*.' + userName + '.*') + arcpy.ListRasters('*.' + userName + '.*')
# Next, for feature datasets get all of the featureclasses
# from the list and add them to the master list.
for dataset in arcpy.ListDatasets('*.' + userName + '.*'):
dataList += arcpy.ListFeatureClasses(feature_dataset=dataset)
# pass in the list of datasets owned by the admin to the rebuild indexes and analyze datasets tools
# Note: to use the "SYSTEM" option the user must be an administrator.
arcpy.RebuildIndexes_management(workspace, "SYSTEM", dataList, "ALL")
arcpy.AnalyzeDatasets_management(workspace, "SYSTEM", dataList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE")
以下的压缩代码仅供参考,适用于ArcGIS9.2/9.3
# This script is designed to compress an SDE Geodatabase and then
# loop through and analyze the statistics ofeach feature dataset, feature class and table.
# It is designed to log the entire process to a text file and
# if there are any errors during the process the script will email a specified address.
# Created by Mike Long - [email protected]
# Last Modified on 7/16/09
# Import system, Geoprocessing, time and email modules
import sys, string, os, arcgisscripting, time, smtplib
# Set the date.
Date = time.strftime("%m-%d-%Y", time.localtime())
# Set the time.
Time = time.strftime("%I:%M:%S %p", time.localtime())
# Create the Geoprocessor object
gp = arcgisscripting.create()
gp.CheckProduct("ArcEditor") # Checks the license level.
gp.SetProduct("arceditor") # Sets the license level.
print "Process started at " + str(Date) + " " + str(Time) + "." + "\n"
# Set up the log file.
LogFile = file('C:\\PythonScripts\\Analyze\\GIS-' + Date + '.txt', 'w') #Creates a log file with todays date.
output = open('C:\\PythonScripts\\Analyze\\GIS-' + Date + '.txt', 'w') #Path to log file.
output.write(str("Process started at " + str(Date) + " " + str(Time) + "." + "\n")) # Write the start time to the log file.
# Load required toolboxes (This shouldn't need to be changed unless ArcGIS was
# installed to a different location)
gp.AddToolbox("F:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
try:
# Compress the database
print "Begining Compress..." + "\n"
gp.toolbox = "management"
# For this script to work it will need the full path to the .sde connection file.
gp.compress("C:\\Documents and Settings\\mlong\\Application Data\\ESRI\\ArcCatalog\\[email protected]")
print gp.GetMessages() + "\n"
output.write(gp.GetMessages()+ "\n")
except:
#Sets up the email parameters
From = "Geoprocessor"
To = ["[email protected]"] # This is the email address that will receive any errors.
Date = time.ctime(time.time())
Subject = "Error Compressing the GIS Database"
Text = gp.GetMessages()
#Format mail message
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') # This needs to be set to your email server.
#Send Email
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:
# Loop through and analyze all Feature datasets
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()
# Loop through and analyze all the Feature classes
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()
# Loop through and analyze all the Tables.
# The if-else statements set the script to skip over Multi-Versioned Views.
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())
#Sets up the email parameters
From = "Geoprocessor"
To = ["[email protected]"]
Date = time.ctime(time.time())
Subject = "Error Analyzing the GIS Database"
Text = gp.GetMessages()
#Format mail message
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')
#Send Email
rCode = s.sendmail(From, To, mMessage)
s.quit()
if rCode:
print 'Error Sending Message'
else:
print 'Message sent sucessfully'
# Sets the Date & Time since the script started.
Date = time.strftime("%m-%d-%Y", time.localtime())# Set the date.
Time = time.strftime("%I:%M:%S %p", time.localtime()) # Set the time.
output.write(str("Process completed at " + str(Date) + " " + str(Time) + "." + "\n")) # Write the start time to the log file.
output.close() # Closes the log file.
print "Process completed at " + str(Date) + " " + str(Time) + "."
Esri 相关系列文章:
-------------------------------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
-------------------------------------------------------------------------------------------------------