在Domain Controller上安装all-in-one AX 2012 R2 Retail开发环境 -1
我们知道在生产环境下是不支持把所有东西都安装到一台机器(all-in-one)上去的,但是作为开发环境还是可行的。今天在具体安装过程中我个人碰到如下一个问题:
运行Retail Database Utitility (RetailDatabaseUtility.exe)创建storedb的时候报错: a store with the specified storeid could not be found
查看RetailDatabaseUtility.exe的日志文件 (通过在RetailDatabaseUtility.exe.Config配置文件修改SyncTracer=4 能够看到更加详细的信息)
RetailDatabaseUtility.exe.Config 文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Microsoft.Dynamics.Retail.Pos.DatabaseUtility.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings />
<system.diagnostics>
<switches>
<!-- 0-off, 1-error, 2-warn, 3-info, 4-verbose. -->
<add name="SyncTracer" value="4" />
</switches>
<trace autoflush="true">
<listeners>
<add name="FileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="RetailDatabaseUtility.log"/>
</listeners>
</trace>
</system.diagnostics>
接着在日志文件RetailDatabaseUtility.log中发现了如下具体错误
RetailDatabaseUtility.exe Error: 0 : EmbeddedInstall: CheckDatabase failed while configuring database access:System.Data.SqlClient.SqlException (0x80131904): Windows NT user or group 'CLIFFR2DC\POSUsers' not found. Check the name again.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.Dynamics.Retail.Pos.CreateDatabaseService.Utilites.CreateSqlLoginForWindowsUser(DbCommand dbCommand, String userName)
at Microsoft.Dynamics.Retail.Pos.CreateDatabaseService.EmbeddedInstall.ConfigureDatabaseAccessForUser(DbCommand dBCommand, String userName)
at Microsoft.Dynamics.Retail.Pos.CreateDatabaseService.EmbeddedInstall.CheckDatabase(String connectionString, String databasePhysicalFilePath, Boolean includeDemoData, String userGroupName)
ClientConnectionId:20668fd5-309d-482b-a9ae-d526998be000
RetailDatabaseUtility.exe Error: 0 : DBUtilityCore<ProvisionDatabasesForSynchronizationAsync>b__7: A store with the specified StoreId could not be found.
所以我们要先解决掉错误 “Windows NT user or group 'CLIFFR2DC\POSUsers' not found. Check the name again“
那么这个用户组'CLIFFR2DC\POSUsers‘是从哪里来的呢?其实POSUsers是在RetailDatabaseUtility.exe.Config 文件中通过DataBaseAccessUserGroup指定的:
<appSettings>
<add key="Test" value="value" />
<add key="OfflineServerName" value="cliffr2dc" />
<add key="OfflineDatabaseName" value="OfflinePOSDB" />
<add key="StoreServerName" value="CLIFFR2DC" />
<add key="StoreDatabaseName" value="StoreDB" />
<add key="StoreID" value="Store 1" />
<add key="TerminalID" value="0101" />
<add key="DataAreaID" value="ceu" />
<add key="DatabaseAccessUserGroup" value="POSUsers" />
<add key="CreateDBAccessUserGroup" value="True" />
<add key="PosExecutablePath" value="..\Retail POS\POS.exe" />
<add key="SyncServiceExecutablePath" value="..\Retail POS\RetailOffline\Microsoft.Dynamics.Retail.Offline.Service.exe" />
<add key="ConnectionStringTemplate" value="Integrated Security=SSPI;Persist Security Info=false;Pooling=true;TrustServerCertificate=true;Encrypt=TRUE" />
</appSettings>
也就是说在创建新的StoreDB时候会同时创建对应的SQL Login并赋予合适的SQL权限。通过分析代码我们看到如果DataBaseAccessUserGroup不是使用domain\alias的方式指定的,那么系统会使用本级机器名字构建( 因为店面系统可能不和总部HQ在同一Active Directory 范围内,所以这个UserGroup是本地的比建成整个AD Domain范围的试用面更广)。但Domain Controller上没有办法创建local user groups!
明白了上面的道理,,所以要想在DC上装POS系统那么解决办法就很简单了, 只要把DatabaseAccessUserGroup的值设为domain\alias的方式即可:
<appSettings>
<add key="Test" value="value" />
<add key="OfflineServerName" value="cliffr2dc" />
<add key="OfflineDatabaseName" value="OfflinePOSDB" />
<add key="StoreServerName" value="CLIFFR2DC" />
<add key="StoreDatabaseName" value="StoreDB" />
<add key="StoreID" value="Store 1" />
<add key="TerminalID" value="0101" />
<add key="DataAreaID" value="ceu" />
<add key="DatabaseAccessUserGroup" value="CliffR2\POSUsers" />
<add key="CreateDBAccessUserGroup" value="True" />
<add key="PosExecutablePath" value="..\Retail POS\POS.exe" />
<add key="SyncServiceExecutablePath" value="..\Retail POS\RetailOffline\Microsoft.Dynamics.Retail.Offline.Service.exe" />
<add key="ConnectionStringTemplate" value="Integrated Security=SSPI;Persist Security Info=false;Pooling=true;TrustServerCertificate=true;Encrypt=TRUE" />
</appSettings>
Cliff