在Debian上设置SQL Server的数据库复制,可以按照以下步骤进行:
首先,确保安装了必要的软件包,包括sqlcmd和mssql-tools。
sudo apt-get update sudo apt-get install -y mssql-tools unixodbc-dev 确保SQL Server的网络配置允许远程连接。
编辑/etc/sqlserver/sqlserver.conf文件,确保以下配置项正确:
[Network] TcpPort = 1433 然后重启SQL Server服务:
sudo systemctl restart mssql-server 在发布服务器上创建一个发布。
sqlcmd连接到发布服务器。USE [master] GO EXEC sp_addpublication @publication = N'YourPublicationName', @description = N'Transactional publication of object', @repl_freq = N'continuous', @status = N'active', @allow_push = N'true', @allow_pull = N'true', @allow_subscription_copy = N'true', @snapshot_in_defaultfolder = N'true', @compress_snapshot = N'true', @ftp_port = N'21', @allow_web_sync = N'true', @independent_agent = N'true', @immediate_sync = N'true', @allow_subscription_backup = N'true', @add_to_active_directory = N'false', @repl_type = N'transactional' GO 添加要复制的表。
USE [YourPublicationName] GO EXEC sp_addarticle @publication = N'YourPublicationName', @article = N'YourTableName', @source_object = N'YourTableName', @type = N'logbased', @description = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509F, @identityrangemanagementoption = N'manual', @destination_owner = N'', @destination_table = N'YourTableName', @status = 24, @vertical_partition = N'false', @ins_cmd = N'CALL sp_MSins_YourTableName', @del_cmd = N'CALL sp_MSdel_YourTableName', @upd_cmd = N'CALL sp_MSupd_YourTableName' GO 在订阅服务器上创建一个订阅。
USE [master] GO EXEC sp_addsubscription @publication = N'YourPublicationName', @subscriber = N'SubscriberServerName', @destination_db = N'DestinationDatabaseName', @subscription_type = N'Push', @sync_type = N'automatic', @article = N'all', @update_mode = N'read only', @subscriber_type = 0 GO 初始化订阅以复制现有数据。
USE [master] GO EXEC sp_startpublication_snapshot @publication = N'YourPublicationName' GO EXEC sp_helpsubscription @publication = N'YourPublicationName' 通过以上步骤,你应该能够在Debian上成功设置SQL Server的数据库复制。如果有任何问题,请参考SQL Server官方文档或寻求专业帮助。