{"rsdb":{"rid":"157262","subhead":"","postdate":"0","aid":"117973","fid":"57","uid":"1","topic":"1","content":"

SQL Server AlwaysOn \u53ef\u7528\u6027\u7ec4\u526f\u672c\u662f\u5141\u8bb8\u53ea\u8bfb\u7684\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e0d\u53ef\u8bfb\u3002
<\/span><\/p>

\u5176\u4e2d\u526f\u672c\u7684\u53ef\u8bfb\u6027\u6709\u51e0\u4e2a\u9009\u9879\uff1a<\/span><\/p>

NO \uff1a \u4e0d\u53ef\u8fde\u63a5\u5230\u526f\u672c\u6570\u636e\u5e93\uff0c\u56e0\u6b64\u4e5f\u4e0d\u53ef\u8bfb\u3002\u9ed8\u8ba4\u8bbe\u7f6e\u3002<\/span><\/strong><\/p>

Read-intent only\uff1a\u53ea\u6709\u9650\u5b9a \u201cread-only\u201d \u65f6\u624d\u80fd\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u4f46\u53ea\u8bfb\u3002<\/span><\/strong><\/p>

Yes\uff1a\u6240\u6709\u8fde\u63a5\u90fd\u6709\u53ef\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u4f46\u53ea\u8bfb\u3002<\/span><\/strong><\/p>

\"\"<\/p>

\u5982\u679c\u8bbe\u7f6e\u4e3a \u201cRead-intent only\u201d<\/strong> \uff0c\u5ba2\u6237\u7aef\u67e5\u8be2\u8be5\u6570\u636e\u5e93\u5bf9\u8c61\u65f6\u63d0\u793a\u4ee5\u4e0b\u9519\u8bef\uff1a<\/span><\/p>

Msg 976, Level 14, State 1, Line 1
The target database, 'TestDB', 
is participating in an availability group and is currently not accessible for queries. 
Either data movement is suspended or the availability replica is not enabled for read access. 
To allow read-only access to this and other databases in the availability group, 
enable read access to one or more secondary availability replicas in the group.  
For more information, see the ALTER AVAILABILITY GROUP statement in SQL Server Books Online.<\/span><\/p>

\u82e5\u8bbe\u7f6e\u4e3a \u201cRead-intent only\u201d<\/strong>\uff0c\u53c8\u6253\u7b97\u53ef\u8bfb\u526f\u672c\u6570\u636e\u5e93\u6570\u636e\uff0c\u5ba2\u6237\u7aef\u8fde\u63a5\u8bbe\u7f6e\u5982\u4e0b\uff1a<\/span><\/p>

\u8fde\u63a5\u65f6\u52a0\u4e0a ReadOnly \u53c2\u6570\uff1a ApplicationIntent=ReadOnly<\/span><\/span><\/p>

\"\"<\/p>

\u5176\u4ed6\u7a0b\u5e8f\u8fde\u63a5\u8bbe\u7f6e\u5982\uff1aApplicationIntent=readonly<\/strong><\/span><\/p>

("Driver={SQL Server Native Client 11.0};server=AGListener;Database=dbname;trusted_connection=yes;ApplicationIntent=readonly\u201d)  <\/span><\/span><\/p>


\u4f7f\u7528 sqlcmd \u5de5\u5177\u8fde\u63a5\u9700\u8981\u8bbe\u7f6e\u53c2\u6570 \u201c-K\u201d<\/span><\/p>

sqlcmd -SAGListener -E -dDBName -Kreadonly  <\/span><\/span><\/p>

\u82e5\u90fd\u5141\u8bb8\u53ea\u8bfb\uff0c\u9009\u62e9 \u201cYes\u201d \u5373\u53ef\u66f4\u6539\uff0c\u6216\u4f7f\u7528\u547d\u4ee4\u66f4\u6539\uff1a<\/span><\/p>

\u53c2\u8003\uff1a<\/strong><\/p>

\u5c06\u8fde\u63a5\u5b57\u7b26\u4e32\u5173\u952e\u5b57\u7528\u4e8e SQL Server Native Client<\/a><\/p>

onnect to SQL Server AlwaysOn replica with SSMS when Readable Secondary is set to Read-intent only<\/a><\/p>","orderid":"0","title":"SQL Server AlwaysOn \u53ef\u7528\u6027\u7ec4\u526f\u672c\u53ea\u8bfb\u8bbe\u7f6e","smalltitle":"","mid":"0","fname":"\u6570\u636e\u5e93\u7f16\u7a0b","special_id":"0","bak_id":"0","info":"0","hits":"1418","pages":"1","comments":"0","posttime":"2017-05-27 17:36:02","list":"1495877762","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"SQL<\/A> Server<\/A> AlwaysOn<\/A> \u53ef\u7528<\/A> \u526f\u672c<\/A> \u53ea\u8bfb<\/A> \u8bbe\u7f6e<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"218.17.197.194","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"SQL Server AlwaysOn \u53ef\u7528\u6027\u7ec4\u526f\u672c\u53ea\u8bfb\u8bbe\u7f6e","lastview":"1713468567","digg_num":"2415","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}