Ariston Darmayuda


Everytime I generate the snapshot always show this error on replication monitor:

Error messages:

Executed as user: toshiba\snapshot_agent. The replication agent encountered a failure. See the previous job step history message or Replication Monitor for more information. The step failed.

Then I go to SQL Server Agent tree and view Job Activity monitor, an got some steps, like this:


1. Snapshot agent startup message => Success

Message : Executed as user: NT AUTHORITY\SYSTEM. The step succeeded.
2. Run Agent => Success
Message : The replication agent has been successfully started. See the Replication Monitor for more information.
3. Run Agent => Success
Message :
2006-03-03 07:33:42.68 --------------------------------------
2006-03-03 07:33:42.68 -Publisher TOSHIBA\SQLSERVER2005
2006-03-03 07:33:42.70 -PublisherDB TestMobile
2006-03-03 07:33:42.70 -Publication TestMobile
2006-03-03 07:33:42.70 -ReplicationType 2
2006-03-03 07:33:42.70 -Distributor TOSHIBA\SQLSERVER2005
2006-03-03 07:33:42.70 -DistributorSecurityMode 1
2006-03-03 07:33:42.70 -XJOBID 0x836332D54395C041BA25A79AF6878769
2006-03-03 07:33:42.70 --------------------------------------
2006-03-03 07:33:42.70 Connecting to Distributor 'TOSHIBA\SQLSERVER2005'
2006-03-03 07:33:43.01 The replication agent had encountered an exception.
2006-03-03 07:33:43.01 Source: Replication
2006-03-03 07:33:43.01 Exception Type: Microsoft.SqlServer.Replication.ReplicationAgentSqlException
2006-03-03 07:33:43.01 Exception Message: You do not have sufficient permission to run this command. Contact your system administrator.
2006-03-03 07:33:43.01 Message Code: 14260
2006-03-03 07:33:43.01
4. Run Agent => Failed
Message : Executed as user: toshiba\snapshot_agent. The replication agent encountered a failure. See the previous job step history message or Replication Monitor for more information. The step failed.
5. Detect nonlogged agent shutdown.
Message : Executed as user: NT AUTHORITY\SYSTEM. Replication-Replication Snapshot Subsystem: agent TOSHIBA\SQLSERVER2005-TestMobile-TestMobile-4 failed. Executed as user: toshiba\snapshot_agent. The replication agent encountered a failure. See the previous job step history message or Replication Monitor for more information. The step failed. [SQLSTATE 42000] (Error 14151). The step failed.

PS: I use SQL Server 2005 Standard Edition on Windows 2003 Data Center Edition SP1. And authentication I use administrator. I follow the steps on tutorial how to sync with sql mobile.

I hope this information help.

Regrads,
Ariston D.

Thank you




Re: when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.

Raymond Mak


Hi Ariston,

Please review the following SQL Server 2005 Books Online topic for the privilege level required to run the snapshot agent:

http://msdn2.microsoft.com/en-us/library/ms151868(SQL.90).aspx

If you are still having problems running the snapshot agent after granting the necessary privileges to the toshiba\snapshot_agent account as prescribed by the article above, please run the snapshot agent from the command line with -OutputVerboseLevel 2 to get extended error information on the operation that the snapshot agent is failing on.

-Raymond






Re: when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.

Ariston Darmayuda

Ok, that resolve the problem. The resolve are first I change the snapshot folder (by default SQL Server put the snapshot on "Repl" forlder at SQL Server folder), but I put on difference folder. Second it seem that my snapshot agent user have not permission to write on the snapshot folder. For example I have custom snapshot folder on "C:\snapshot" so I must set permission for snapshot agent to be able write on that folder. But came new problem that the snapshot agent still can not write on that folder so create snapshot became failed.

I change the member of for snapshot agent from users into administrators, and now I can create subscription. But I don't want the snapshot agent become administrators because maybe later it will make problem for me because this user have administrator priviledge.

I hope this clear. How to make the snapshot agent have permission to write into a folder

Thanks.






Re: when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.

Raymond Mak

I am probably missing something here but all you really need to do is to grant R\W access of the snapshot folder to snapshot agent account (which I asssume is toshiba\snapshot_agent) I would suggest that you use runas to make sure that the toshiba\snapshot_agent account indeed has access to the snapshot folder. If you are still having trouble, post the error obfuscated message here so we can have a closer look.

-Raymond





Re: when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.

Ariston Darmayuda

I think I have resolve my problem by my self, but anyway thanks for reply, I hope this help to other person. My resolve is that change the snapshot_agent member of became member of SQL Server 2005 SQL Agent Users, and it works. But I don't know it safe or not to set a user to member of SQL Server 2005 SQL Agent Users

Thanks.





Re: when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.

MariJo

Hi Ariston,

i have a similiar problem.
I get the same error message, but i already gave the user and agent all the rights they need. As far as i think!

My question here is:
what if you run your code as a db_owner of the database and not as a admin
Is it then also working

Cause in my program its working as a sysadmin, but not when i execute as a simple "db_owner" of the database.
I use the MS SQL Server 2005.

Maybe you can help me out

Greetings,
MariJo




Re: when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.

jainmanishs

when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.
the log file generated is as follows

............................
............................
Flushing cabinet folder
The replication agent had encountered an exception.
Source: Replication
Exception Type: Microsoft.SqlServer.Replication.FciException
Exception Message: The replication agent had encountered a file compression (cabinet) library error while calling 'FCIDestroy()'.
Message Code: 4
what this error indicates .. i am not able to track what is mistake
pls let me konw asap

FOLLOWING IS THE CODE THAT I AM USING TO RUN SNAPSHOT AGENT

private static EReturnValue generateSnapshot()
{
if (!publisherConn.IsOpen)
{
return EReturnValue.Failure;
}
EReturnValue retVal = EReturnValue.Success;
SnapshotGenerationAgent agent=new SnapshotGenerationAgent();;

try
{
//SET THE STATUS EVENT
mPublicationStatusInfo = new StringBuilder(1024);//CAPACITY IS 1024
agent.Status += new AgentCore.StatusEventHandler(snapshotAgentStatus);
agent.Distributor = DistributorName;
agent.DistributorLogin = DBLogin;
agent.DistributorPassword = DBPassword;
agent.Publisher = PublisherName;
agent.PublisherLogin = DBLogin;
agent.PublisherPassword = DBPassword;
agent.PublisherDatabase = PublicationDatabaseName;
agent.ReplicationType = ReplicationType.Merge;
agent.Publication = PublicationName;

agent.GenerateSnapshot();
retVal = EReturnValue.Success;
}
catch (Exception ex)
{
#if debug
MessageBox.Show(ex.Message);
#endif
retVal = EReturnValue.Failure;
}
finally
{
writeStatusInfoInLogFile();
}
return retVal;
}






Manish









Re: when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.

MariJo

Hi,

i dont know about your error message.
My problem is still the agent security with its proxies.

When creating the publication by a User (db_owner), it only works when the User has db_owner rights for both, the publication and distribution database. But i dont want to grant this user account the db_owner rights for the system database 'distributionDb'. Thats i would like to solve it by impersonating and that process account for the agent.

I also created the windows account "repl_snapshot" just for the Snapshot Agent.
When creating the Snapshot agent for the publication, i also use the "impersonating ... process account", therefore the "repl_snapshot" account should excecute the snapshot creation, cause the agent is defined like this. When creating this snapshot agent to the publication: the proxy and credential are automatically created.
Next point is that i need to assign the account User1 (db_owner) to that proxy, right !
But then i get the message:
it starts the agent ... success
executing ... no rights again!

and then! Big problem ... nothing works anymore on that database. and then i need to use the sp_removedbreplication and create a new db. But this is another thing.

So i dont understand completely how to configure this proxy for this agent job. Cause i found out, that i need to assign the proxy to each agent job step, but i cant do that! cause when i open the agent job to assign the proxy to the steps: no steps are shown. But when starting the agent job over the context menu, i shows the three steps, sth like: start egent, execute, end.

Do you know sth about that

MariJo




Re: when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.

MariJo

hi,

Microsoft has a hotfix for it and its exactly for my error message ... i didnt try it ... but for sure im going to do it on monday Smile
http://support.microsoft.com/kb/938086

Will let you know if it works ...

MariJo





Re: when i run SnapshotGenerationAgent.GenerateSnapshot(), it fails.

MariJo

Its working with this hotifx!!!!
So, wait for SP3 or get this hotfix update if oyu really need it, but the hotfix is not fully tested and official.

Regards,
MariJo