Sql-Server

分配器未正確安裝。無法啟用數據庫進行發布

  • November 25, 2020

在我的一台伺服器中創建出版物的過程中,我不斷收到以下錯誤消息

分配器未正確安裝。無法啟用數據庫進行發布。

儘管我已經多次刪除並重新創建了分發器。

--==============================================================
-- replication - create publication - complete
-- marcelo miorelli
-- 06-Oct-2015
--==============================================================

select @@servername
select @@version
select @@spid
select @@servicename

--==============================================================
-- step 00 --  configuring the distributor
-- if there is already a distributor AND it is not healthy, 
-- you can have a look at the jobs related to this distributor and
-- MAYBE, if you need to get rid of it, run this step
-- generally you need to run this when adding a publication it says there is a problem with the distributor
--==============================================================

use master
go
sp_dropdistributor 
-- Could not drop the Distributor 'QG-V-SQL-TS\AIFS_DEVELOPMENT'. This Distributor has associated distribution databases.

EXEC sp_dropdistributor 
    @no_checks = 1
   ,@ignore_distributor = 1
GO

--==============================================================
-- step 01 --  configuring the distributor
-- tell this server who is the distributor and the admin password to connect there

-- create the distributor database
--==============================================================

use master
exec sp_adddistributor 
@distributor = N'the_same_server'
,@heartbeat_interval=10
,@password='#J4g4nn4th4_the_password#'

USE master
EXEC sp_adddistributiondb 
   @database = 'dist1', 
   @security_mode = 1;
GO

--==============================================================
-- check thing out before going ahead and create the publications
--==============================================================

USE master;  
go  

--Is the current server a Distributor?  
--Is the distribution database installed?  
--Are there other Publishers using this Distributor?  
EXEC sp_get_distributor  

--Is the current server a Distributor?  
SELECT is_distributor FROM sys.servers WHERE name='repl_distributor' AND data_source=@@servername;  

--Which databases on the Distributor are distribution databases?  
SELECT name FROM sys.databases WHERE is_distributor = 1  

--What are the Distributor and distribution database properties?  
EXEC sp_helpdistributor;  
EXEC sp_helpdistributiondb;  
EXEC sp_helpdistpublisher;  









--==============================================================
-- here you need to have a distributor in place

-- Enabling the replication database
-- the name of the database we want to replicate is COLAFinance
--==============================================================
use master
exec sp_get_distributor


use master
exec sp_replicationdboption @dbname = N'the_database_to_publish', 
                           @optname = N'publish', 
                           @value = N'true'
GO

有什麼遺漏嗎?有任何想法嗎?

我想我已經搞定了,我所做的很簡單

缺少對過程 sp_adddistpublisher的呼叫。

將發布伺服器配置為使用指定的分發數據庫。此儲存過程在任何數據庫上的分發伺服器上執行。請注意,儲存過程 sp_adddistributor (Transact-SQL) 和 sp_adddistributiondb (Transact-SQL) 必須在使用此儲存過程之前執行。

我已經在下面的腳本中添加了最後一個命令step01

--==============================================================
-- step 01 --  configuring the distributor
-- tell this server who is the distributor and the admin password to connect there

-- create the distributor database
--==============================================================

use master
exec sp_adddistributor 
@distributor = N'the_same_server'
,@heartbeat_interval=10
,@password='#J4g4nn4th4_the_password#'

USE master
EXEC sp_adddistributiondb 
   @database = 'dist1', 
   @security_mode = 1;
GO

exec sp_adddistpublisher @publisher = N'the_same_server', 
                        @distribution_db = N'dist1';
GO

我注意到現在當我呼叫以下過程時:

EXEC sp_get_distributor 

在此處輸入圖像描述

我看到了distribution db installed equals 列1,我之前應該注意到這個指示。

如果它有效,我將保留這個答案,否則我會相應地添加它。

引用自:https://dba.stackexchange.com/questions/182721