实现目标:
用户随机注册到不同opensips实例上,并且usrloc数据是共享的,
lookup("location","g")可被全局查询到,lookup("location")可查询到本地opensips实例的注册数据
环境:
两个 opensips 实例(版本:3.2.3)
一个 MySQL 实例
一个 mongodb 实例(版本:3.2)
openisps静态加入cluster 节点数据
INSERT INTO clusterer(id, cluster_id, node_id, url, state, no_ping_retries, priority, sip_addr, flags, description) VALUES (NULL, 1, 1, 'bin:192.168.1.251:26501', 1, 3, 50, "192.168.1.251:26500", 'Node A', NULL), (NULL, 1, 3, 'bin:192.168.1.25:26501', 1, 3, 50, "192.168.1.25:26500", 'Node B', NULL);
(其中sip_addr是opensips服务器sip监听端口)
opensips 实例的 opensips.cfg相关配置
socket=bin:192.168.1.251:26501 # CUSTOMIZE ME
#### Binary INterface protocol module feat 2022/1/3
loadmodule "proto_bin.so"
modparam("proto_bin", "bin_port", 26501)
#### USeR LOCation module
loadmodule "usrloc.so"
modparam("usrloc", "use_domain", 1)
modparam("usrloc", "location_cluster", 1)
modparam("usrloc", "nat_bflag", "NAT")
modparam("usrloc", "db_url","mysql://opensips:[email protected]/opensips") # CUSTOMIZE ME
#联合共享模式
modparam("usrloc", "working_mode_preset", "federation-cachedb-cluster")
# with MongoDB, we don't need to create any database or collection...
loadmodule "cachedb_mongodb.so"
modparam("usrloc", "cachedb_url", "mongodb://192.168.1.251:27017/opensipsDB.userlocation")
loadmodule "clusterer.so"
#不同实例节点数不同
modparam("clusterer", "my_node_id", 1)
modparam("clusterer", "seed_fallback_interval", 5)
modparam("clusterer", "db_url", "mysql://opensips:[email protected]/opensips")
modparam("clusterer", "my_node_info", "cluster_id=1, url=bin:192.168.1.25:26501")
相关链接