/
usrloc_admin.xml
1723 lines (1652 loc) · 54.1 KB
/
usrloc_admin.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section id="overview" xreflabel="Overview">
<title>Overview</title>
<para>
A SIP user location implementation. Its main purpose is to store,
manage and provide access to SIP registration bindings (contacts) for
other modules (e.g. registrar, mid-registrar, nathelper, etc.). The
module exports no functions that could be directly used from the
OpenSIPS script.
</para>
<para>
At runtime, the contacts may reside in memory, in an SQL database or in
a NoSQL database. Combinations of two of the above are also possible.
For example, contacts may only be directly manipulated in memory in
order to guarantee fast interactions while being asynchronously
synchronized to an SQL database. The latter helps achieve restart
persistency. Consult the
<emphasis role='bold'><xref linkend="param_working_mode_preset"/></emphasis>
parameter for more details on all possible runtime behaviors of the
module.
</para>
<para>
The OpenSIPS user location implementation is cluster-enabled. On top of
supporting traditional "single instance" setups, it also allows multiple
OpenSIPS user location nodes to form a single, global user location cluster.
This allows high-level features such as startup synchronization (data tunneling)
from a random, healthy "donor" node, and evenly distributed contact
pinging workloads (a mandatory requirement of NAT'ed endpoints).
</para>
</section>
<section id="distributed-sip-user-location"
xreflabel="Distributed SIP User Location">
<title>Distributed SIP User Location</title>
<para>
Starting with OpenSIPS 2.4, the user location module offers several optional
data distribution models, each tailoring to specific real-life production use cases.
Built on top of the OpenSIPS clustering module, these models take into
account service concerns such as <emphasis>high availability, geographical
distribution, horizontal scalability and NAT traversal</emphasis>.
</para>
<para>
Depending on data locality, the distribution models are split in two main
categories:
</para>
<section id="federation-topology" xreflabel="Federation Topology">
<title>"Federation" Topology</title>
<para>
A <emphasis>federated</emphasis> user location keeps contact data local
to the original OpenSIPS node the contact initially registered to. In
order to share the reachability of these contacts with the global
OpenSIPS user location cluster, registrar nodes will only publish some
light "metadata" entries for any new Addresses-of-Record which are
reachable from it. These entries will cause other nodes to also fork
additional SIP branches pointing to the above-mentioned registrar upon
receiving a call for the above-mentioned Addresses-of-Record.
</para>
<para>
The <emphasis role='bold'>federation</emphasis> topology is an
optimized solution for the following core problems:
<itemizedlist>
<listitem>
<para>
<emphasis role='bold'>IP restrictions</emphasis> - In some cases,
calls routed towards registered contacts must necessarily egress
through the original registration nodes of these contacts. A
classic example of this situation is when an OpenSIPS registrar
sitting at the edge of the platform is directly facing a NAT device
on the way to the contact. Unless calls are sent out from this
exact registrar, they will not be able to traverse the NAT device
and reach the contact.
</para>
</listitem>
<listitem>
<para>
<emphasis role='bold'>horizontal scalability</emphasis> - Avoiding
global replication/contact broadcasting within the cluster not only
dramatically improves contact storage performance, but also leads
to better service scalability. Different geographical locations can
be sized according to their local subscriber populations (traffic
may be balanced to them using DNS SRV weights, for example),
without losing platform-wide reachability.
</para>
</listitem>
</itemizedlist>
</para>
<para>
Currently, the metadata information may be published to NoSQL databases
which support key/multi-value column-like associations. Example known
backends to support these abstractions at the time of writing are
MongoDB and Cassandra. Of these two, only the MongoDB OpenSIPS driver
has been so far extended to implement the required NoSQL API endpoints.
</para>
<para>
The <ulink url="http://www.opensips.org/Documentation/Tutorials-Distributed-User-Location-Federation">
<citetitle>federated user location tutorial</citetitle></ulink>
contains precise details on how to achieve this setup (including High
Availability support).
</para>
</section>
<section id="full-sharing-topology" xreflabel="Full Sharing Topology">
<title>"Full Sharing" Topology</title>
<para>
A <emphasis>fully sharing</emphasis> user location propagates
(broadcasts) contact information to all data nodes (OpenSIPS or NoSQL).
The main assumption behind this mode is that any routing
restrictions have been alleviated beforehand. Consequently, either SIP
traffic egressing from a "full sharing"
OpenSIPS user location topology is being intermediated by an
additional SIP edge endpoint of our platform, or there are no egress IP
restrictions at all (for example, if all SIP UAs have public IPs). In
this setup, all OpenSIPS user location nodes are
<emphasis>equivalent</emphasis> to one another, as they each have
access to the same dataset and have no routing restrictions.
</para>
<para>
The <emphasis role='bold'>full sharing</emphasis> topology is
an appropriate solution for multi-layer VoIP platforms, where the
OpenSIPS registrar nodes do not directly interact with external SIP
endpoints. Moreover, it can be configured to fully store contact data
within a NoSQL cluster (zero in-memory storage), thus taking full
advantage of the data sharing, sharding, migration and other
capabilities of a specialized distributed data handling engine.
</para>
<para>
Additionally, a "full sharing" topology can be used to achieve a basic
"hot backup" high-availability setup with an active-passive registrar
nodes configuration, both of which make use of a shared virtual IP.
</para>
<para>
Currently, registrations may optionally be fully managed inside NoSQL
databases which support key/multi-value column-like associations.
Example known backends to support these abstractions at the time of
writing are MongoDB and Cassandra. Of these two, only the MongoDB
OpenSIPS driver has been so far extended to implement the required
NoSQL API endpoints.
</para>
<para>
The <ulink url="http://www.opensips.org/Documentation/Tutorials-Distributed-User-Location-Full-Sharing">
<citetitle>"full sharing" user location tutorial</citetitle></ulink>
contains precise details on how to achieve this setup (including full
NoSQL storage support).
</para>
</section>
<section id="n-contact-pings-problem" xreflabel="N contact pings problem">
<title>"N Contact Pings" Problem</title>
<para>
A long-standing problem caused by contact information being replicated
to multiple SIP registrar instances directly through replication or
indirectly through a globally reachable database. As long as
traditionally clusterized nodes are not aware of
each other, they will each scan the entire contact dataset, thus
periodically sending "N pings" instead of "1 ping" for each contact.
This difference directly affects service scalability, as well as the
amount of consumed cloud compute resources such as CPU and network
bandwidth, both on the service and client side.
</para>
<para>
This problem is solved with the help of the OpenSIPS cluster layer,
which makes all nodes aware of each others' presence. Thus, the
distributed user location node topologies are able to collectively
partition the pinging workload and spread it evenly across the current
number of cluster nodes, at any given point in time.
</para>
</section>
</section>
<section id="contact-matching" xreflabel="Contact Matching">
<title>Contact matching</title>
<para>
Contact matching (for the same Address-of-Record, AoR) is an important
aspect of a SIP user location service, especially in the context of NAT
traversal. The latter raises more problems, since contacts from different
phones of same users may overlap (if behind NATs with identical
configurations) or the re-register Contact of the same SIP User Agent may
be seen as a new one (due to the request arriving via a new NAT binding).
</para>
<para>
The SIP RFC 3261 publishes a matching algorithm based only on the
contact string with Call-ID and CSeq number extra checking (if the Call-ID
matches, it must have a higher CSeq number, otherwise the registration is
invalid). But as argumented above, this is not enough in a NAT traversal
context, so the &osips; implementation of contact matching offers more
algorithms:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>Contact based only</emphasis> - strict RFC 3261
compliancy - the contact is matched as string and extra checked
via Call-ID and CSeq (if Call-ID is the same, it must have a
higher CSeq number, otherwise the registration is invalid).
</para>
</listitem>
<listitem>
<para>
<emphasis>Contact and Call-ID based</emphasis> - an extension
of the first case - the Contact and Call-ID header field values
must match as strings; the CSeq must be higher than the previous
one - so be careful how you deal with REGISTER retransmissions in
this case.
</para>
</listitem>
</itemizedlist>
<para>
For more details on how to control/select the contact matching algorithm,
please go to
<emphasis role='bold'><xref linkend="param_matching_mode"/></emphasis>.
</para>
</section>
<section id="dependencies" xreflabel="Dependencies">
<title>Dependencies</title>
<section>
<title>&osips; Modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>Optionally an SQL database module</emphasis>.
</para>
</listitem>
<listitem>
<para>
<emphasis>Optionally a NoSQL database module</emphasis>.
</para>
</listitem>
<listitem>
<para>
<emphasis>clusterer, if <xref linkend="param_cluster_mode"/>
is different than "none".</emphasis>
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed before
running &osips; with this module loaded:
<itemizedlist>
<listitem>
<para>
<emphasis>None</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
</section>
<section id="exported_parameters" xreflabel="Exported Parameters">
<title>Exported Parameters</title>
<section id="param_nat_bflag" xreflabel="nat_bflag">
<title><varname>nat_bflag</varname> (string/integer)</title>
<para>
The name of the branch flag to be used as NAT marker (if the contact
is or not natted). This is a branch flag and it will be imported and
used by all other modules depending of usrloc module.
</para>
<para>
<emphasis>WARNING: </emphasis>Setting INT flags is deprecated!
Use quoted strings instead!
<emphasis>
Default value is <quote>NULL</quote> (not set).
</emphasis>
</para>
<example>
<title>Set <varname>nat_bflag</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "nat_bflag", "NAT_BFLAG")
...
</programlisting>
</example>
</section>
<section id="param_contact_id_column" xreflabel="contact_id_column">
<title><varname>contact_id_column</varname> (string)</title>
<para>
Name of the column holding the unique contact IDs.
</para>
<para>
<emphasis>
Default value is <quote>contact_id</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>contact_id_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "contact_id_column", "ctid")
...
</programlisting>
</example>
</section>
<section id="param_user_column" xreflabel="user_column">
<title><varname>user_column</varname> (string)</title>
<para>
Name of column containing usernames.
</para>
<para>
<emphasis>
Default value is <quote>username</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>user_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "user_column", "username")
...
</programlisting>
</example>
</section>
<section id="param_domain_column" xreflabel="domain_column">
<title><varname>domain_column</varname> (string)</title>
<para>
Name of column containing domains.
</para>
<para>
<emphasis>
Default value is <quote>domain</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>user_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "domain_column", "domain")
...
</programlisting>
</example>
</section>
<section id="param_contact_column" xreflabel="contact_column">
<title><varname>contact_column</varname> (string)</title>
<para>
Name of column containing contacts.
</para>
<para>
<emphasis>
Default value is <quote>contact</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>contact_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "contact_column", "contact")
...
</programlisting>
</example>
</section>
<section id="param_expires_column" xreflabel="expires_column">
<title><varname>expires_column</varname> (string)</title>
<para>
Name of column containing expires value.
</para>
<para>
<emphasis>
Default value is <quote>expires</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>expires_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "expires_column", "expires")
...
</programlisting>
</example>
</section>
<section id="param_q_column" xreflabel="q_column">
<title><varname>q_column</varname> (string)</title>
<para>
Name of column containing q values.
</para>
<para>
<emphasis>
Default value is <quote>q</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>q_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "q_column", "q")
...
</programlisting>
</example>
</section>
<section id="param_callid_column" xreflabel="callid_column">
<title><varname>callid_column</varname> (string)</title>
<para>
Name of column containing callid values.
</para>
<para>
<emphasis>
Default value is <quote>callid</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>callid_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "callid_column", "callid")
...
</programlisting>
</example>
</section>
<section id="param_cseq_column" xreflabel="cseq_column">
<title><varname>cseq_column</varname> (string)</title>
<para>
Name of column containing cseq numbers.
</para>
<para>
<emphasis>
Default value is <quote>cseq</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>cseq_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "cseq_column", "cseq")
...
</programlisting>
</example>
</section>
<section id="param_methods_column" xreflabel="methods_column">
<title><varname>methods_column</varname> (string)</title>
<para>
Name of column containing supported methods.
</para>
<para>
<emphasis>
Default value is <quote>methods</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>methods_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "methods_column", "methods")
...
</programlisting>
</example>
</section>
<section id="param_flags_column" xreflabel="flags_column">
<title><varname>flags_column</varname> (string)</title>
<para>
Name of column to save the internal flags of the record.
</para>
<para>
<emphasis>
Default value is <quote>flags</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>flags_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "flags_column", "flags")
...
</programlisting>
</example>
</section>
<section id="param_cflags_column" xreflabel="cflags_column">
<title><varname>cflags_column</varname> (string)</title>
<para>
Name of column to save the branch/contact flags of the record.
</para>
<para>
<emphasis>
Default value is <quote>cflags</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>cflags_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "cflags_column", "cflags")
...
</programlisting>
</example>
</section>
<section id="param_user_agent_column" xreflabel="user_agent_column">
<title><varname>user_agent_column</varname> (string)</title>
<para>
Name of column containing user-agent values.
</para>
<para>
<emphasis>
Default value is <quote>user_agent</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>user_agent_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "user_agent_column", "user_agent")
...
</programlisting>
</example>
</section>
<section id="param_received_column" xreflabel="received_column">
<title><varname>received_column</varname> (string)</title>
<para>
Name of column containing the source IP, port, and protocol from the REGISTER
message.
</para>
<para>
<emphasis>
Default value is <quote>received</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>received_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "received_column", "received")
...
</programlisting>
</example>
</section>
<section id="param_socket_column" xreflabel="socket_column">
<title><varname>socket_column</varname> (string)</title>
<para>
Name of column containing the received socket information (IP:port)
for the REGISTER message.
</para>
<para>
<emphasis>
Default value is <quote>socket</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>socket_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "socket_column", "socket")
...
</programlisting>
</example>
</section>
<section id="param_path_column" xreflabel="path_column">
<title><varname>path_column</varname> (string)</title>
<para>
Name of column containing the Path header.
</para>
<para>
<emphasis>
Default value is <quote>path</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>path_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "path_column", "path")
...
</programlisting>
</example>
</section>
<section id="param_sip_instance_column" xreflabel="sip_instance_column">
<title><varname>sip_instance_column</varname> (string)</title>
<para>
Name of column containing the SIP instance.
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>sip_instance_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "sip_instance_column", "sip_instance")
...
</programlisting>
</example>
</section>
<section id="param_kv_store_column" xreflabel="kv_store_column">
<title><varname>kv_store_column</varname> (string)</title>
<para>
Name of column containing generic key-value data.
</para>
<para>
<emphasis>
Default value is <quote>kv_store</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>kv_store_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "kv_store_column", "json_data")
...
</programlisting>
</example>
</section>
<section id="param_attr_column" xreflabel="attr_column">
<title><varname>attr_column</varname> (string)</title>
<para>
Name of column containing additional registration-related information.
</para>
<para>
<emphasis>
Default value is <quote>attr</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>attr_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "attr_column", "attributes")
...
</programlisting>
</example>
</section>
<section id="param_use_domain" xreflabel="use_domain">
<title><varname>use_domain</varname> (integer)</title>
<para>
If the domain part of the user should be also saved and used for
identifing the user (along with the username part). Useful in
multi domain scenarios. Non 0 value means true.
</para>
<para>
<emphasis>
Default value is <quote>0 (false)</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>use_domain</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "use_domain", 1)
...
</programlisting>
</example>
</section>
<section id="param_desc_time_order" xreflabel="desc_time_order">
<title><varname>desc_time_order</varname> (integer)</title>
<para>
If the user's contacts should be kept timestamp ordered; otherwise the
contact will be ordered based on q value.
Non 0 value means true.
</para>
<para>
<emphasis>
Default value is <quote>0 (false)</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>desc_time_order</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "desc_time_order", 1)
...
</programlisting>
</example>
</section>
<section id="param_timer_interval" xreflabel="timer_interval">
<title><varname>timer_interval</varname> (integer)</title>
<para>
Number of seconds between two timer runs. The module uses timer to
delete expired contacts, synchronize with database and other tasks,
that need to be run periodically.
</para>
<warning>
<para>
In case of crash or restart contacts that are in memory only and
haven't been flushed yet will get lost. If you want minimize the
risk, use a shorter timer interval.
</para>
</warning>
<para>
<emphasis>
Default value is 60.
</emphasis>
</para>
<example>
<title>Set <varname>timer_interval</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "timer_interval", 120)
...
</programlisting>
</example>
</section>
<section id="param_db_url" xreflabel="db_url">
<title><varname>db_url</varname> (string)</title>
<para>
&url; of the database that should be used.
</para>
<para>
<emphasis>
Default value is <quote>&defaultdb;</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>db_url</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "db_url", "&exampledb;")
...
</programlisting>
</example>
</section>
<section id="param_cachedb_url" xreflabel="cachedb_url">
<title><varname>cachedb_url</varname> (string)</title>
<para>
&url; of a NoSQL database to be used. Only required in a
cachedb-enabled
<emphasis role='bold'><xref linkend="param_cluster_mode"/></emphasis>.
</para>
<para>
<emphasis>
Default value is <quote>none</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>cachedb_url</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "cachedb_url", "&examplecdb;")
...
</programlisting>
</example>
</section>
<section id="param_db_mode" xreflabel="db_mode">
<title><varname>db_mode</varname> (integer, deprecated)</title>
<para>
<emphasis role='bold'>Although it is backwards-compatible, this
parameter has been deprecated in favour of the more complete
<xref linkend="param_working_mode_preset"/>, which it conflicts with.
</emphasis>
</para>
<para>
<emphasis>
Default value is "not set".
</emphasis>
</para>
<example>
<title>Set <varname>db_mode</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "db_mode", 2)
...
</programlisting>
</example>
</section>
<section id="param_working_mode_preset" xreflabel="working_mode_preset">
<title><varname>working_mode_preset</varname> (string)</title>
<para>
<itemizedlist>
<listitem>
<para>
<emphasis role="bold">"single-instance-no-db"</emphasis> - This
disables database completely. Only memory will be used.
Contacts will not survive restart. Use this value if you need a
really fast usrloc and contact persistence is not necessary or
is provided by other means.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">"single-instance-sql-write-through"</emphasis>
- Write-Through scheme. All changes to usrloc are immediately
reflected in database too. This is very slow, but very reliable.
Use this scheme if speed is not your priority but need to make
sure that no registered contacts will be lost during crash or
reboot.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">"single-instance-sql-write-back"</emphasis>
- Write-Back scheme. This is a combination of previous two
schemes. All changes are made to memory and database
synchronization is done in the timer. The timer deletes all
expired contacts and flushes all modified or new contacts to
database. Use this scheme if you encounter high-load peaks
and want them to process as fast as possible. The mode will
not help at all if the load is high all the time. Also, latency
of this mode is much lower than latency of mode 1, but slightly
higher than latency of mode 0.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">"sql-only"</emphasis> -
DB-Only scheme. No memory cache is kept, all operations being
directly performed with the database. The timer deletes all
expired contacts from database - cleans after clients that didn't
un-register or re-register. The mode is useful if you configure
more servers sharing the same DB without any replication at SIP
level. The mode may be slower due the high number of DB operation.
For example NAT pinging is a killer since during each ping cycle
all nated contact are loaded from the DB; The lack of memory
caching also disable the statistics exports.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">"federation-cachedb-cluster"</emphasis> -
OpenSIPS will run with a "federation-cachedb"
<xref linkend="param_cluster_mode"/> and
"sync-from-cluster" <xref linkend="param_restart_persistency"/>.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">"full-sharing-cluster"</emphasis> -
OpenSIPS will run with a "full-sharing"
<xref linkend="param_cluster_mode"/> and
"sync-from-cluster" <xref linkend="param_restart_persistency"/>.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">"full-sharing-cachedb-cluster"</emphasis> -
OpenSIPS will run with a "full-sharing-cachedb"
<xref linkend="param_cluster_mode"/>, where all location data strictly
resides in a NoSQL database, thus it will have natural restart
persistency.
</para>
</listitem>
</itemizedlist>
</para>
<para>
Refer to section
<xref linkend="distributed-sip-user-location"/> for details
regarding the clustering topologies and their behavior.
</para>
<para>
<emphasis>
Default value is "single-instance-no-db".
</emphasis>
</para>
<example>
<title>Set <varname>working_mode_preset</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "working_mode_preset", "full-sharing-cachedb-cluster")
...
</programlisting>
</example>
</section>
<section id="param_cluster_mode" xreflabel="cluster_mode">
<title><varname>cluster_mode</varname> (string)</title>
<para>
<emphasis role='bold'>This parameter is automatically set by
<xref linkend='param_working_mode_preset'/>.</emphasis>
</para>
<para>
The behavior of the global OpenSIPS user location cluster. Refer to
section <xref linkend="distributed-sip-user-location"/> for details.
</para>
<para>
This parameter may take the following values:
</para>
<itemizedlist>
<listitem>
<para><emphasis>"none"</emphasis> - single instance mode.
</para>
</listitem>
<listitem>
<para><emphasis>"federation-cachedb"</emphasis> -
federation-based data sharing. Local AoR metadata is published
inside a NoSQL database, so other cluster nodes can fork SIP
traffic over to the current node. Consequently, the
<xref linkend="param_location_cluster"/> and
<xref linkend="param_cachedb_url"/> parameters are mandatory.
</para>
</listitem>
<listitem>
<para><emphasis>"full-sharing"</emphasis> -
Full contact data broadcasting (mirroring) to all other
OpenSIPS cluster participants.
inside a NoSQL database, so other cluster nodes are able to
route SIP traffic through the current node. Consequently, the
<xref linkend="param_location_cluster"/> parameter is mandatory.
</para>
</listitem>
<listitem>
<para><emphasis>"full-sharing-cachedb"</emphasis> -
Full contact data management through the use of a NoSQL
database (somewhat resembling the "sql-only" preset).
The cluster layer is still required in order to
be able to partition and spread the pinging workload evenly
among participating OpenSIPS nodes. Consequently, the
<xref linkend="param_location_cluster"/> parameter is mandatory.
</para>
</listitem>
</itemizedlist>
<para>
<emphasis>
Default value is <emphasis>none (single instance mode)</emphasis>.
</emphasis>
</para>
<example>
<title>Set <varname>cluster_mode</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "cluster_mode", "federation-cachedb")
...
</programlisting>
</example>
</section>
<section id="param_restart_persistency" xreflabel="restart_persistency">
<title><varname>restart_persistency</varname> (string)</title>
<para>
<emphasis role='bold'>This parameter is automatically set by
<xref linkend='param_working_mode_preset'/>.</emphasis>
</para>
<para>
Controls the behavior of OpenSIPS user location instance following a
restart. This parameter has no effect in some database-only working
mode presets, where restart persistency is naturally ensured.
</para>
<para>
This parameter may take the following values:
</para>
<itemizedlist>
<listitem>
<para><emphasis>"none"</emphasis> - no explicit data
synchronization following a restart. The node starts empty.
</para>
</listitem>
<listitem>
<para><emphasis>"load-from-sql"</emphasis> - enable
SQL-based restart persistency. This causes all runtime
in-memory writes (i.e. new registrations, re-registrations or
de-registrations) to also propagate to an SQL database, from
which all data will be imported following a restart.
Choosing this value will make the <xref linkend='param_db_url'/>
parameter mandatory, as well as cause
<xref linkend='param_sql_write_mode'/> to default to "write-back"
instead of "none".
</para>
</listitem>
<listitem>
<para><emphasis>"sync-from-cluster"</emphasis> - enable
cluster-based restart persistency. Following a restart,
an OpenSIPS cluster node will search for a healthy "donor" node
from which to mirror the entire user location dataset via
direct cluster sync (TCP-based, binary-encoded data transfer).
Choosing this value will make the
<xref linkend='param_location_cluster'/> parameter mandatory.
</para>
</listitem>
</itemizedlist>
<para>
<emphasis>
Default value is
<emphasis>"none" (no restart persistency)</emphasis>.
</emphasis>
</para>
<example>
<title>Set <varname>restart_persistency</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "restart_persistency", "sync-from-cluster")
...
</programlisting>
</example>