home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / databases / sybase-faq / part3 < prev    next >
Encoding:
Internet Message Format  |  2004-04-21  |  22.6 KB

  1. Path: senator-bedfellow.mit.edu!dreaderd!not-for-mail
  2. Message-ID: <databases/sybase-faq/part3_1082468590@rtfm.mit.edu>
  3. Supersedes: <databases/sybase-faq/part3_1074677126@rtfm.mit.edu>
  4. Expires: 2 Aug 2004 13:43:10 GMT
  5. References: <databases/sybase-faq/part1_1082468590@rtfm.mit.edu>
  6. X-Last-Updated: 2003/03/02
  7. From: dowen@midsomer.org (David Owen)
  8. Newsgroups: comp.databases.sybase,comp.answers,news.answers
  9. Subject: Sybase FAQ: 3/19 - REP
  10. Reply-To: dowen@midsomer.org (David Owen)
  11. Followup-To: comp.databases.sybase
  12. Distribution: world
  13. Organization: Midsomer Consultants Inc.
  14. Approved: news-answers-request@MIT.EDU
  15. Keywords: FAQ, DATABASES, SYBASE, ASA, ASE, REP
  16. Originator: faqserv@penguin-lust.MIT.EDU
  17. Date: 20 Apr 2004 13:45:02 GMT
  18. Lines: 574
  19. NNTP-Posting-Host: penguin-lust.mit.edu
  20. X-Trace: 1082468702 senator-bedfellow.mit.edu 561 18.181.0.29
  21. Xref: senator-bedfellow.mit.edu comp.databases.sybase:106201 comp.answers:56947 news.answers:270287
  22.  
  23. Archive-name: databases/sybase-faq/part3
  24. URL: http://www.isug.com/Sybase_FAQ
  25. Version: 1.7
  26. Maintainer: David Owen
  27. Last-modified: 2003/03/02
  28. Posting-Frequency: posted every 3rd month
  29.    A how-to-find-the-FAQ article is posted on the intervening months.
  30.  
  31.                        Sybase Frequently Asked Questions                       
  32.  
  33.                                                                                
  34. Sybase FAQ Home PageAdaptive Server Enterprise FAQAdaptive Server Anywhere FAQ 
  35.                           Repserver FAQSearch the FAQ                          
  36.                                      [bar]                                     
  37.  
  38.                            Sybase Replication Server                           
  39.                                                                                
  40.  
  41.  
  42.         1.    Introduction to Replication Server
  43.         2.    Replication Server Administration
  44.         3.    Troubleshooting Replication Server
  45.         4.    Additional Information/Links
  46.        
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.                       Introduction to Replication Server                       
  82.                                                                                
  83.  
  84.  
  85.     1.1    Introduction
  86.     1.2    Replication Server Components
  87.     1.3    What is the Difference Between SQL Remote and Replication Server?
  88.    
  89.  
  90.  
  91. Thanks go to Manish I Shah for major help with this introduction. 
  92.  
  93. next prev ASE FAQ
  94.  
  95. -------------------------------------------------------------------------------
  96.  
  97. 1.1    Introduction
  98.  
  99. -------------------------------------------------------------------------------
  100.  
  101. What is Replication Server
  102.  
  103. Replication Server moves transactions (insert, updates and deletes) at the
  104. table level from a source dataserver to one or more destination dataservers. 
  105. The dataserver could be ASE or other major DBMS flavour (including DB2,
  106. Informix, Oracle). The source and destinations need not be of the same type.
  107.  
  108. What can it do ?
  109.  
  110.   * Move data from one source to another.
  111.   * Move only a subset of data from source to destination. So, you can  
  112.     subscribe  to a subset of data, or a subset of the columns, in the source
  113.     table, e.g. select * from clients where state =  NY 
  114.   * Manipulation/transformation of data when moving from source to destination.
  115.     E.g. it can map data from a data-type in DB2 to an equivalent in Sybase.*
  116.   * Provide a warm-standby system.  Can be incorporated with Open Switch to
  117.     provide a fairly seamless fail-over environment.
  118.   * Merge data from several source databases into one destination database
  119.     (could be for a warehouse type environment for example).
  120.   * Move data through a complicated network down to branch offices, say, only
  121.     sending the relevant data to each branch.
  122.  
  123. (* This is one of Sybase replication's real strengths, the ability to define
  124. function string classes which allow the conversion of statements from one SQL
  125. dialect to match the dialect of the destination machine.  Ed)
  126.  
  127. How soon does the data move
  128.  
  129. The data moves asynchronously. The time it takes to reach the destination
  130. depends on the size of your transaction, level of activity in that particular
  131. database (a database as in Sybase systems), the length of the chain (one or
  132. more replication servers that the transaction has to pass through to reach the
  133. destination), the thickness of pipe (network), how busy your replication server
  134. is etc. Usually, on a LAN, for small transactions, this is about a second.
  135.  
  136. Back to top
  137.  
  138. -------------------------------------------------------------------------------
  139.  
  140. 1.2    Replication Server Components
  141.  
  142. -------------------------------------------------------------------------------
  143.  
  144. Basic
  145.  
  146. Primary Dataserver
  147.  
  148. The source of data where client applications enter/delete and modify data.  As
  149. mentioned before, this need not be ASE, it can be Microsoft SQL Server, Oracle,
  150. DB2, Informix.  (I know that I should get a complete list.)
  151.  
  152. Replication Agent/Log Transfer Manager
  153.  
  154. Log Transfer Manager (LTM) is a separate program/process which reads
  155. transaction log from the source server and transfers them to the replication
  156. server for further processing. With ASE 11.5, this has become part of ASE and
  157. is now called the Replication Agent.  However, you still need to use an LTM for
  158. non-ASE sources.  I imagine there is a version of LTM for each kind of source
  159. (DB2, Informix, Oracle etc).  When replication is active, you see one
  160. connection per each replicated database in the source dataserver (sp_who).
  161.  
  162. Replication Server (s)
  163.  
  164. The replication server is an Open Server/Open Client application.  The server
  165. part receives transactions being sent by either the source ASE or the source
  166. LTM.  The client part sends these transactions to the target server which could
  167. be another replication server or the final dataserver.  As far as I know, the
  168. server does not include the client component of any of the other DBMSes out of
  169. the box.
  170.  
  171. Replicate (target) Dataserver
  172.  
  173. Server in which the final replication server (in the queue) will repeat the
  174. transaction done on the primary. You will see a connection, one for each target
  175. database, in the target dataserver when the replication server is actively
  176. transferring data (when idle, the replication server disconnects or fades out
  177. in replication terminology).
  178.  
  179. Back to top
  180.  
  181. -------------------------------------------------------------------------------
  182.  
  183. 1.3    What is the Difference Between Replication Server and SQL Remote?
  184.  
  185. -------------------------------------------------------------------------------
  186.  
  187. Both SQL Remote and Replication Server perform replication.  SQL Remote was
  188. originally part of the Adaptive Server Anywhere tool kit and is intended for
  189. intermittent replication.  (The classic example is that of a salesman
  190. connecting on a daily basis to upload sales and download new prices and
  191. inventory.)  Replication Server is intended for near real-time replication
  192. scenarios.
  193.  
  194. Back to top
  195.  
  196. -------------------------------------------------------------------------------
  197.  
  198. next prev ASE FAQ
  199.  
  200.                        Replication Server Administration                       
  201.                                                                                
  202.  
  203.  
  204.     2.1    How can I improve throughput?
  205.     2.2    Where should I install replication server?
  206.     2.3    Using large raw partitions with Replication Server on Unix.
  207.     2.4    How to replicate col = col + 1
  208.     2.5    What is the difference between an LTMs an a RepAgent?
  209.     2.6    Which Should I choose, RepAgent or LTM?
  210.    
  211. next prev ASE FAQ
  212.  
  213. -------------------------------------------------------------------------------
  214.  
  215. 2.1    How can I improve throughput?
  216.  
  217. -------------------------------------------------------------------------------
  218.  
  219. Check the Obvious
  220.  
  221. First, ensure that you are only replicating those parts of the system that need
  222. to be replicated.  Some of this is obvious.  Don't replicate any table that
  223. does not need to be replicated.  Check that you are only replicating the
  224. columns you need.  Replication is very sophisticated and will allow you to
  225. replicate both a subset of the columns as well as a subset of the rows.
  226.  
  227. Replicate Minimum Columns
  228.  
  229. Once the replication is set up and synchronised, it is only necessary to
  230. replicate those parts of the primary system that actually change.  You are only
  231. replicating those rows and columns that need to be replicated, but you only
  232. need to replicate the actual changes.  Check that each replication definition
  233. is defined using the clause:
  234.  
  235. create replication definition rep_def_name
  236. with primary...
  237. ...
  238. replicate minimal columns
  239.  
  240. Second Replication Server
  241.  
  242. This might be appropriate in a simple environment on systems with spare cycles
  243. and limited space on the network.  When Sybase replicates from a primary to a
  244. replicate using only one replication server the data is transferred across the
  245. network uncompressed.  However, the communication between two replication
  246. servers is compressed.  By installing a second replication server it is
  247. possible to dramatically reduce the bandwidth needed to replicate your data.
  248.  
  249. Dedicated Network Card
  250.  
  251. Obviously, if replication is sharing the same network resources that all of the
  252. clients are using, there is the possibility for a bottleneck if the network
  253. bandwidth is close to saturation.  If a second replication server is not going
  254. to cut it since you already have one or there are no spare cycles, then a
  255. second network card may be the answer.
  256.  
  257. First, you will need to configure ASE to listen on two network connections. 
  258. This is relatively straightforward.  There is no change to the client
  259. configuration.  They all continue to talk to Sybase using the same connection. 
  260. When defining the replication server, ensure that the interfaces/sql.ini entry
  261. that it uses only has the second connection in it.  This may involve some
  262. jiggery pokery with environment variables, but should be possible, even on NT! 
  263. You need to be a little careful with network configuration.  Sybase will
  264. communicate with the two servers on the correct address, but if the underlying
  265. operating system believes that both clients and repserver can be serviced by
  266. the same card, then it will use the first card that it comes to.  So, if you
  267. had the situation that all of the clients, ASE and the replication server were
  268. on 192.168.1.0, and the host running ASE had two cards onto this same segment,
  269. then it would choose to route all packets through the first card.  OK, so this
  270. is a very simplistic error to correct, but similar things can happen with more
  271. convoluted and, superficially, better thought out configurations. 
  272.  
  273. +---------+                                +-----------+   +-----------+
  274. |         |--> NE(1) --> All Clients...    |           |   |           |
  275. | Primary |                                | repserver |   | replicate |
  276. |         |--> NE(2) --------------------->|           |-->|           |
  277. |         |                                |           |   |           |
  278. +---------+                                +-----------+   +-----------+
  279.  
  280. So, configure NE(1) to be on 192.168.1.0, say, and NE(2) to be on 192.168.2.0
  281. and all should be well.  OK, so my character art is not perfect, but I think
  282. that you get the gist!
  283.  
  284. No Network Card
  285.  
  286. If RepServer resides on the same physical machine as either the primary or the
  287. replicate, it is possible to use the localhost or loopback network device.  The
  288. loopback device is a network interface that connects back to itself without
  289. going through the network interface card.  It is almost always uses the IP
  290. address 127.0.0.1.  So, by applying the technique described above, but instead
  291. of using a dedicated network card, you use the loopback device.  Obviously, the
  292. two servers have to be on the same physical machine or it won't work! 
  293.  
  294. Back to top
  295.  
  296. -------------------------------------------------------------------------------
  297.  
  298. 2.2    Where should I install replication server?
  299.  
  300. -------------------------------------------------------------------------------
  301.  
  302. A seemingly trivial question, but one that can cause novices a bit of worry.
  303.  
  304. There are three answers: on the primary machine, on the replicate machine or on
  305. a completely separate machine.  There is no right answer, and if you are doing
  306. an initial install it probably pays to consider the future, consider the
  307. proposed configuration and have a look at the load on the available machines.
  308.  
  309. It is probably fair to say that replication is not power hungry but neither is
  310. it free.  If the primary is only just about coping with its current load, then
  311. it might be as well looking into hosting it on another machine.  The argument
  312. applies to the replicate.  If you think that network bandwidth may be an issue,
  313. and you may have to add a second replication server, you may be better off
  314. starting with repserver running on the primary.  It is marginally easier to add
  315. a repserver to an existing configuration if the first repserver is on the
  316. primary.
  317.  
  318. Remember that a production replication server on Unix will require raw devices
  319. for the stable devices and that these can be more than 2GB in size.  If you are
  320. restricted in the number of raw partitions you have available on a particular
  321. machine, then this may have a bearing.  See Q2.3. 
  322.  
  323. Installing replication server on its own machine will, of course, introduce all
  324. sorts of problems of its own, as well as answering some.  The load on the
  325. primary or the replicate is reduced considerably, but you are definitely going
  326. to add some load to the network.  Remember that ASE->Rep and Rep->ASE is
  327. uncompressed.  It is only Rep->Rep that is compressed.
  328.  
  329. Back to top
  330.  
  331. -------------------------------------------------------------------------------
  332.  
  333. 2.3    Using large raw partitions with Replication Server on Unix.
  334.  
  335. -------------------------------------------------------------------------------
  336.  
  337. It is a good practice with production installations of Replication Server on
  338. Unix that you use raw partitions for the stable devices.  This is for just the
  339. same reason that production ASE's use raw partitions.  Raw devices can be a
  340. maximum of 2GB with replication server up to release 11.5.  (I have not checked
  341. 12.)
  342.  
  343. In order to utilise a raw partition that is greater than 2GB in size you can do
  344. the following (remember all of the cautionary warnings about trying this sort
  345. of stuff out in development first!):
  346.  
  347. add partition firstpartition on '/dev/rdsk/c0t0d0s0' with size 2024
  348. go
  349. add partition secondpartition on '/dev/rdsk/c0t0d0s0' with size 2024
  350. starting at 2048
  351. go
  352.  
  353. Notice that the initial partition is sized at 2024MB and not 2048.  I have not
  354. found this in the documentation, but replication certainly seems to have a
  355. problem allocating a full 2GB.  Interestingly, do the same operation through
  356. Rep Server Manager and Sybase central caused no problems at all.
  357.  
  358. Back to top
  359.  
  360. -------------------------------------------------------------------------------
  361.  
  362. 2.4    How to replicate col = col + 1
  363.  
  364. -------------------------------------------------------------------------------
  365.  
  366. Firstly.  While the rule that you never update a primary key may be a
  367. philosophical choice in a non-replicated system, it is an architectural
  368. requirement of a replicated system.
  369.  
  370. If you use simple data replication, and your primary table is:
  371.  
  372. id
  373. ---
  374. 1
  375. 2
  376. 3
  377.  
  378. and you issue a:
  379.  
  380. update table set id=id+1
  381.  
  382. Rep server will do this in the replicate:
  383.  
  384. begin tran
  385. update table set id=2 where id=1
  386. update table set id=3 where id=2
  387. update table set id=4 where id=3
  388. commit tran
  389.  
  390. Hands up all who can see a bit of a problem with this!  Remember, repserver
  391. doesn't replicate statements, it replicates the results of statements.
  392.  
  393. One way to perform this update is to build a stored procedure on both sides
  394. that executes the necessary update and replicate the stored procedure call.
  395.  
  396. Back to top
  397.  
  398. -------------------------------------------------------------------------------
  399.  
  400. 2.5    What is the difference between an LTM and a RepAgent?
  401.  
  402. -------------------------------------------------------------------------------
  403.  
  404. As described in Section 1.2, Log Transfer Managers (LTMs) and RepAgents are the
  405. processes that transfer data between ASE and the Replication Server. 
  406.  
  407. LTMs were delivered with the first releases of Replication Server.  Each LTM is
  408. a separate process at the operating system level that runs along side ASE and
  409. Replication Server.  As with ASE and Replication Server, a RUN_<ltm_server> and
  410. configuration file is required for each LTM.  One LTM is required for each
  411. database being replicated.
  412.  
  413. Along with ASE 11.5 a new concept was introduced, that of RepAgent.  I am not
  414. sure if you needed to use RepServer 11.5 as well, or whether the RepAgents
  415. could talk to earlier versions of Replication Server.  Each RepAgent is, in
  416. effect, a slot-in replacement for an LTM.  However, instead of running as
  417. separate operating system process, it runs as a thread within ASE.  Pretty much
  418. all of the requirements for replication using an LTM apply to the RepAgents. 
  419. One per database being replicated, etc. but now you do not need to have
  420. separate configuration files.
  421.  
  422. Back to top
  423.  
  424. -------------------------------------------------------------------------------
  425.  
  426. 2.6    Which should I use, RepAgent or LTM?
  427.  
  428. -------------------------------------------------------------------------------
  429.  
  430. The differences between RepAgents and LTMs are discussed in  Section 2.5. 
  431. Which then to choose.  There are pros and cons to both, however, I think that
  432. it should be stated up front that RepAgents are the latest offering and I
  433. believe that Sybase would expect you you to use that.  Certainly the
  434. documentation for LTMs is a little buried implying that they do not consider it
  435. to be as current as LTMs.
  436.  
  437. LTM Cons:
  438.  
  439.   * Older technology.  Not sure if it is being actively supported.
  440.   * Not integrated within ASE, so there is a (small) performance penalty.
  441.   * Separate processes, so need additional monitoring in production
  442.     environments.
  443.  
  444. LTM Pros:
  445.  
  446.   * Possible to restart LTM without having to restart ASE.
  447.  
  448. RepAgent Cons
  449.  
  450.   * If it crashes it is possible that you will have to restart ASE in order to
  451.     restart RepAgent.
  452.  
  453. RepAgent Pros
  454.  
  455.   * Latest, and presumably greatest, offering.
  456.   * Tightly integrated with ASE so good performance.
  457.   * Less to manage, no extra entries in the interfaces file.
  458.  
  459. Back to top
  460.  
  461. -------------------------------------------------------------------------------
  462.  
  463. next prev ASE FAQ
  464.  
  465.                       Replication Server Trouble Shooting                      
  466.                                                                                
  467.  
  468.  
  469.     3.1    Why am I running out of locks on the replicate side?
  470.     3.2    Someone was playing with replication and now the transaction log on
  471.     OLTP is filling.
  472.    
  473. next prev ASE FAQ
  474.  
  475. -------------------------------------------------------------------------------
  476.  
  477. 3.1    Why am I running out of locks on the replicate side?
  478.  
  479. -------------------------------------------------------------------------------
  480.  
  481. Sybase replication works by taking each transaction that occurs in the primary
  482. dataserver and applying to the replicate.  Since replication works on the
  483. transaction log, a single, atomic, update on the primary side that updates a
  484. million rows will be translated into a million single row updates.  This may
  485. seem very strange but is a simple consequence of how it works.  On the primary,
  486. this million row update will attempt to escalate the locks that it has taken
  487. out to an exclusive table lock.  However, on the replicate side each row is
  488. updated individually, much as if they were being updated within a cursor loop. 
  489. Now, Sybase only tries to escalate locks from a single atomic statement (see
  490. ASE Qx.y), so it will never try to escalate the lock.  However, since the
  491. updates are taking place within a single transaction, Sybase will need to take
  492. out enough page locks to lock the million rows.
  493.  
  494. So, how much should you increase the locks parameter on the replicate side?  A
  495. good rule of thumb might be double it or add 40,000 whichever is the larger. 
  496. This has certainly worked for us.
  497.  
  498. Back to top
  499.  
  500. -------------------------------------------------------------------------------
  501.  
  502. 3.2    Someone was playing with replication and now the transaction log on OLTP
  503. is filling.
  504.  
  505. -------------------------------------------------------------------------------
  506.  
  507. Once replication has been configured, ASE adds another marker to the
  508. transaction log.  The first marker is the conventional one that marks which
  509. transactions have had their data written to disk.  The second is there to
  510. ensure that the transactions have also been replicated.  Clearly, if someone
  511. installed replication and did not clean up properly after themselves, this
  512. marker will still be there and consequently the transaction log will be filling
  513. up.  If you are certain that replication is not being used on your system, you
  514. can disable the secondary truncation marker with the following commands:
  515.  
  516. 1> use <database>
  517. 2> go
  518. 1> dbcc settrunc(ltm, ignore)
  519. 2> go
  520.  
  521. The above code is the normal mechanism for disabling the trucation point.  I
  522. have never had a problem with it.  However, an alternative mechanism for
  523. disabling the truncation point is given below.  I do not know if it will work
  524. in situations that the previous example won't, or if it works for databases
  525. that are damaged or what.  If someone knows when you use it and why, please let
  526. me know (mailto:dowen@midsomer.org).  
  527.  
  528. 1> sp_role "grant", sybase_ts_role, sa
  529. 2> go
  530. 1> set role sybase_ts_role on
  531. 2> go
  532. 1> dbcc dbrepair(dbname, ltmignore)
  533. 2> go
  534. 1> sp_role "revoke", sybase_ts_role, sa
  535. 2> go
  536.  
  537. This scenario is also very common if you load a copy of your replicated
  538. production database into development.
  539.  
  540. Back to top
  541.  
  542. -------------------------------------------------------------------------------
  543.  
  544. next prev ASE FAQ
  545.  
  546.                          Additional Information/Links                          
  547.                                                                                
  548.      
  549.    
  550.     4.1    Links
  551.     4.2    Newsgroups
  552.    
  553. next prev ASE FAQ
  554.  
  555. -------------------------------------------------------------------------------
  556.  
  557. 4.1    Links
  558.  
  559. -------------------------------------------------------------------------------
  560.  
  561. Thierry Antinolfi  has a replication FAQ at his site http://pro.wanadoo.fr/
  562. dbadevil that covers a lot of good stuff. 
  563.  
  564. Rob Verschoor has a 'Replication Server Tips & Tricks' section on his site, as
  565. well as an indispensible quick reference guide!
  566.  
  567. Back to top
  568.  
  569. -------------------------------------------------------------------------------
  570.  
  571. 4.2    Newsgroups
  572.  
  573. -------------------------------------------------------------------------------
  574.  
  575. There are a number of newsgroups that can deal with questions.  Sybase have
  576. several in their own forums area.
  577.  
  578. For Replication Server:
  579.  
  580.     sybase.public.rep-server
  581.     sybase.public.rep-agent
  582.    
  583. for SQL Remote and the issues of replicating with ASA:
  584.  
  585.     sybase.public.sqlanywhere.replication
  586.    
  587. and of course, there is always the ubiquitous
  588.  
  589.     comp.databases.sybase.
  590.    
  591. Back to top
  592.  
  593. -------------------------------------------------------------------------------
  594.  
  595. next prev ASE FAQ
  596.  
  597.