在 ubuntu 12.10 中安装 opensips 1.8.2



在 ubuntu 12.10 中安装 opensips 1.8.2
 
  • 发表于 4年前 
  • 阅读 4132 
  • 收藏 2 
  • 点赞 1 
  • 评论 0

ubuntu 12.10中安装opensips 1.8.2

首先下载opensips-1.8.2_src.tar.gz

解压软件包:
tar -zxvf opensips-1.8.2_src.tar.gz

准备步骤:
编译前需确认安装以下软件包:
sudo apt-get install bison
sudo apt-get install flex

mysql数据库相关软件包安装:
sudo apt-get install mysql-server mysql-client
再装开发包
sudo apt-get install libmysqlclient-dev

修改编译配置文件: Makefile.conf
将exclude_modules中 db_mysql去掉

中间可能会有找不到curses.h文件的异常,按如下步骤安装libncurses5-dev包即可。
sudo apt-get install libncurses5 libncurses5-dev

以上步骤操作完毕可执行安装:

sudo make all

sudo make install

安装完毕后修改/usr/local/etc/opensips/opensipsctlrc 文件,需要修改的部分内容如下:

## your SIP domain
 SIP_DOMAIN=ubuntustudio

## chrooted directory
# $CHROOT_DIR="/path/to/chrooted/directory"

## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT, 
## by default none is loaded
# If you want to setup a database with opensipsdbctl, you must at least specify
# this parameter.
 DBENGINE=MYSQL

## database host
 DBHOST=localhost

## database name (for ORACLE this is TNS name)
 DBNAME=opensips

# database path used by dbtext or db_berkeley
 DB_PATH="/usr/local/etc/opensips/dbtext"

## database read/write user
 DBRWUSER=opensips

## password for database read/write user
 DBRWPW="opensipsrw"

## database super user (for ORACLE this is 'scheme-creator' user)
 DBROOTUSER="root"

# user name column
 USERCOL="username"


执行创建数据库的脚本:
opensipsdbctl create
MySQL password for root: 
INFO: test server charset
INFO: creating database opensips ...
INFO: Core OpenSIPS tables succesfully created.
Install presence related tables? (y/n): y  
INFO: creating presence tables into opensips ...
INFO: Presence tables succesfully created.
Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist? (y/n): y
INFO: creating extra tables into opensips ...
INFO: Extra tables succesfully created.

 

-----------------------------------------
查看命令:
root@ubuntu :/usr/local/etc/opensips# opensipsctl -c
/usr/local/sbin/opensipsctl $Revision: 4448 $

Existing commands:

 -- command 'start|stop|restart'

 restart ............................ restart OpenSIPS
 start .............................. start OpenSIPS
 stop ............................... stop OpenSIPS

 -- command 'acl' - manage access control lists (acl)

 acl show [<username>] .............. show user membership
 acl grant <username> <group> ....... grant user membership (*)
 acl revoke <username> [<group>] .... grant user membership(s) (*)

 -- command 'cr' - manage carrierroute tables

 cr show ....................................................... show tables
 cr reload ..................................................... reload tables
 cr dump ....................................................... show in memory tables
 cr addrt <routing_tree_id> <routing_tree> ..................... add a tree
 cr rmrt  <routing_tree> ....................................... rm a tree
 cr addcarrier <carrier> <scan_prefix> <domain> <rewrite_host> ................
               <prob> <strip> <rewrite_prefix> <rewrite_suffix> ...............
               <flags> <mask> <comment> .........................add a carrier
               (prob, strip, rewrite_prefix, rewrite_suffix,...................
                flags, mask and comment are optional arguments) ...............
 cr rmcarrier  <carrier> <scan_prefix> <domain> ................ rm a carrier

 -- command 'rpid' - manage Remote-Party-ID (RPID)

 rpid add <username> <rpid> ......... add rpid for a user (*)
 rpid rm <username> ................. set rpid to NULL for a user (*)
 rpid show <username> ............... show rpid of a user

 -- command 'add|passwd|rm' - manage subscribers

 add <username> <password> .......... add a new subscriber (*)
 passwd <username> <passwd> ......... change user's password (*)
 rm <username> ...................... delete a user (*)

 -- command 'add|dump|reload|rm|show' - manage address

 address show ...................... show db content
 address dump ...................... show cache content
 address reload .................... reload db table into cache
 address add <grp> <ip> <mask> <port> <proto> [<context_info>] [<pattern>]
             ....................... add a new entry
             ....................... (from_pattern and tag are optional arguments)
 address rm <grp> <ip> <mask> <port> ............... remove all entries 
             ....................... for the given grp ip mask port

 -- command 'dr' - manage dynamic routing

   * Examples: dr addgw '1' 10 '192.168.2.2' 0 '' 'GW001' 0 'first_gw'
   *           dr addgw '2' 20 '192.168.2.3' 0 '' 'GW002' 0 'second_gw'
   *           dr rmgw 2
   *           dr addgrp 'alice' 'example.com' 10 'first group'
   *           dr rmgrp 1
   *           dr addcr 'cr_1' '10' 0 'CARRIER_1' 'first_carrier'
   *           dr rmcr 1
   *           dr addrule '10,20' '+1' '20040101T083000' 0 0 '1,2' 'NA_RULE' 'NA routing'
   *           dr rmgrule 1
 dr show ............................ show dr tables
 dr addgw <gwid> <type> <address> <strip> <pri_prefix>
          <attrs> <probe_mode> <description>
    ................................. add gateway
 dr rmgw <id> ....................... delete gateway
 dr addgrp <username> <domain> <groupid> <description>
    ................................. add gateway group
 dr rmgrp <id> ...................... delete gateway group
 dr addcr <carrierid> <gwlist> <flags> <attrs> <description>
          ........................... add carrier
 dr rmcr <id> ....................... delete carrier
 dr addrule <groupid> <prefix> <timerec> <priority> <routeid>
            <gwlist> <attrs> <description>
    ................................. add rule
 dr rmrule <ruleid> ................. delete rule
 dr reload .......................... reload dr tables
 dr gw_status ....................... show gateway status
 dr carrier_status .................. show carrier status

 -- command 'dispatcher' - manage dispatcher

   * Examples:  dispatcher addgw 1 sip:1.2.3.1:5050 1 'outbound gateway'
   *            dispatcher addgw 2 sip:1.2.3.4:5050 3 ''
   *            dispatcher rmgw 4
 dispatcher show ..................... show dispatcher gateways
 dispatcher reload ................... reload dispatcher gateways
 dispatcher dump ..................... show in memory dispatcher gateways
 dispatcher addgw <setid> <destination> <flags> <description>
            .......................... add gateway
 dispatcher rmgw <id> ................ delete gateway

 -- command 'registrant' - manage registrants

   * Examples:  registrant add sip:opensips.org '' sip:user@opensips.org '' user password sip:user@localhost '' 3600 ''
 registrant show ......................... show registrant table
 registrant dump ......................... show registrant status
 registrant add <registrar> <proxy> <aor> <third_party_registrant>
                <username> <password> <binding_URI> <binding_params>
                <expiry> <forced_socket> . add a registrant
 registrant rm ........................... removes the entire registrant table
 registrant rmaor <id> ................... removes the gived aor id

 -- command 'db' - database operations

 db exec <query> ..................... execute SQL query
 db roexec <roquery> ................. execute read-only SQL query
 db run <id> ......................... execute SQL query from $id variable
 db rorun <id> ....................... execute read-only SQL query from 
                                       $id variable
 db show <table> ..................... display table content

 -- command 'speeddial' - manage speed dials (short numbers)

 speeddial show <speeddial-id> ....... show speeddial details
 speeddial list <sip-id> ............. list speeddial for uri
 speeddial add <sip-id> <sd-id> <new-uri> [<desc>] ... 
           ........................... add a speedial (*)
 speeddial rm <sip-id> <sd-id> ....... remove a speeddial (*)
 speeddial help ...................... help message
    - <speeddial-id>, <sd-id> must be an AoR (username@domain )
    - <sip-id> must be an AoR (username@domain )
    - <new-uri> must be a SIP AoR (sip:username@domain)
    - <desc> a description for speeddial

 -- command 'avp' - manage AVPs

 avp list [-T table] [-u <sip-id|uuid>]
     [-a attribute] [-v value] [-t type] ... list AVPs
 avp add [-T table] <sip-id|uuid>
     <attribute> <type> <value> ............ add AVP (*)
 avp rm [-T table]  [-u <sip-id|uuid>]
     [-a attribute] [-v value] [-t type] ... remove AVP (*)
 avp help .................................. help message
    - -T - table name
    - -u - SIP id or unique id
    - -a - AVP name
    - -v - AVP value
    - -t - AVP name and type (0 (str:str), 1 (str:int),
                              2 (int:str), 3 (int:int))
    - <sip-id> must be an AoR (username@domain )
    - <uuid> must be a string but not AoR

 -- command 'alias_db' - manage database aliases

 alias_db show <alias> .............. show alias details
 alias_db list <sip-id> ............. list aliases for uri
 alias_db add <alias> <sip-id> ...... add an alias (*)
 alias_db rm <alias> ................ remove an alias (*)
 alias_db help ...................... help message
    - <alias> must be an AoR (username@domain )"
    - <sip-id> must be an AoR (username@domain )"

 -- command 'domain' - manage local domains

 domain reload ....................... reload domains from disk
 domain show ......................... show current domains in memory
 domain showdb ....................... show domains in the database
 domain add <domain> ................. add the domain to the database
 domain rm <domain> .................. delete the domain from the database

 -- command 'cisco_restart' - restart CISCO phone (NOTIFY)

 cisco_restart <uri> ................ restart phone configured for <uri>

 -- command 'online' - dump online users from memory

 online ............................. display online users

 -- command 'monitor' - show internal status

 monitor ............................ show server's internal status

 -- command 'ping' - ping a SIP URI (OPTIONS)

 ping <uri> ......................... ping <uri> with SIP OPTIONS

 -- command 'ul|alias' - manage user location or aliases

 ul show [<username>]................ show in-RAM online users
 ul show --brief..................... show in-RAM online users in short format
 ul rm <username> [<contact URI>].... delete user's usrloc entries
 ul add <username> <uri> ............ introduce a permanent usrloc entry
 ul add <username> <uri> <expires> .. introduce a temporary usrloc entry

 -- command 'fifo'

 fifo ............................... send raw FIFO command


启动opensips 服务:
opensipsctl start
------------------------------------------------------------
启动服务的过程中可能出现的数据库错误:
 ERROR:core:db_check_api: module db_mysql does not export db_use_table function
 ERROR:uri:mod_init: No database module found

解决办法:

在/usr/local/etc/opensips/opensips.cfg文件中添加有关数据库的配置如下:

db_default_url="mysql://opensips:opensipsrw@localhost/opensips"


/* uncomment next line for MySQL DB support */  
loadmodule "db_mysql.so" 

/* uncomment next lines for MySQL based authentication support   
   NOTE: a DB (like db_mysql) module must be also loaded */  
loadmodule "auth.so"  
loadmodule "auth_db.so"  
/* uncomment next line for aliases support  
   NOTE: a DB (like db_mysql) module must be also loaded */  
loadmodule "alias_db.so"  
/* uncomment next line for multi-domain support  
   NOTE: a DB (like db_mysql) module must be also loaded  
   NOTE: be sure and enable multi-domain support in all used modules  
         (see "multi-module params" section ) */  
#loadmodule "domain.so"  
/* uncomment the next two lines for presence server support  
   NOTE: a DB (like db_mysql) module must be also loaded */  
#loadmodule "presence.so"  
#loadmodule "presence_xml.so" 


# ----------------- setting module-specific parameters ---------------  
  
  
# ----- mi_fifo params -----  
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")  
  
  
# ----- rr params -----  
# do not append from tag to the RR (no need for this script)  
modparam("rr", "append_fromtag", 0)  
  
  
# ----- registrar params -----  
/* uncomment the next line not to allow more than 10 contacts per AOR */  
#modparam("registrar", "max_contacts", 10)  
  
  
# ----- usrloc params -----  
#modparam("usrloc", "db_mode",   0)  
/* uncomment the following lines if you want to enable DB persistency  
   for location entries */  
modparam("usrloc", "db_mode",   2)  
modparam("usrloc", "db_url",  
    "mysql://opensips:opensipsrw@localhost/opensips")  
  
  
# ----- uri params -----  
modparam("uri", "use_uri_table", 0)  
  
  
# ----- acc params -----  
/* what sepcial events should be accounted ? */  
modparam("acc", "early_media", 1)  
modparam("acc", "report_cancels", 1)  
/* by default ww do not adjust the direct of the sequential requests.  
   if you enable this parameter, be sure the enable "append_fromtag"  
   in "rr" module */  
modparam("acc", "detect_direction", 0)  
/* account triggers (flags) */  
modparam("acc", "failed_transaction_flag", 3)  
modparam("acc", "log_flag", 1)  
modparam("acc", "log_missed_flag", 2)  
/* uncomment the following lines to enable DB accounting also */  
modparam("acc", "db_flag", 1)  
modparam("acc", "db_missed_flag", 2)  
  
  
# ----- auth_db params -----  
/* uncomment the following lines if you want to enable the DB based  
   authentication */  
modparam("auth_db", "calculate_ha1", yes)  
modparam("auth_db", "password_column", "password")  
#modparam("auth_db", "db_url","mysql://opensips:opensipsrw@localhost/opensips")  
#modparam("auth_db", "load_credentials", "")  
  
  
# ----- alias_db params -----  
/* uncomment the following lines if you want to enable the DB based  
   aliases */  
#modparam("alias_db", "db_url",  
#   "mysql://opensips:opensipsrw@localhost/opensips")  
  
  
# ----- domain params -----  
/* uncomment the following lines to enable multi-domain detection  
   support */  
#modparam("domain", "db_url",  
#   "mysql://opensips:opensipsrw@localhost/opensips")  
#modparam("domain", "db_mode", 1)   # Use caching  
  
  
# ----- multi-module params -----  
/* uncomment the following line if you want to enable multi-domain support  
   in the modules (dafault off) */  
#modparam("auth_db|usrloc|uri", "use_domain", 1)  
  
  
# ----- presence params -----  
/* uncomment the following lines if you want to enable presence */  
#modparam("presence|presence_xml", "db_url",  
#   "mysql://opensips:opensipsrw@localhost/opensips")  
#modparam("presence_xml", "force_active", 1)  
#modparam("presence", "server_address", "sip:192.168.1.2:5060")  
  
  
-------------------------------------------------------------


添加sip用户
opensipsctl add username password  

如:
opensipsctl add 100 100
opensipsctl add 101 101


使用软电话x-lite成功登陆
查看注册的sip用户
opensipsctl ul show

是否在线
opensipsctl online


root@ubuntu :/usr/local/lib/opensips/modules# opensipsctl ul show
Domain:: location table=512 records=2
        AOR:: 100
                Contact:: sip:100@192.168.17.1:5061;rinstance=a40cd182a1adbeb8;transport=TCP Q=
                        Expires:: 3313
                        Callid:: ZTBkZjZlNTJmYzdmOWVlYzI5N2M0NzY5MmFjNGU3ZWQ.
                        Cseq:: 2
                        User-agent:: X-Lite release 5.0.0 stamp 67284
                        State:: CS_SYNC
                        Flags:: 0
                        Cflag:: 0
                        Methods:: 5951
        AOR:: 101
                Contact:: sip:101@192.168.17.1:5060;rinstance=1626363c473bd98d Q=
                        Expires:: 3591
                        Callid:: N2UxZGVkNmNjMWQyOGJkODYzM2Y4NjlmODBlN2UzMjk.
                        Cseq:: 1
                        User-agent:: X-Lite release 5.0.0 stamp 67284
                        State:: CS_NEW
                        Flags:: 0
                        Cflag:: 0
                        Socket:: udp:192.168.17.132:5060
                        Methods:: 5951
root@ubuntu :/usr/local/lib/opensips/modules# opensipsctl online
100
101

在 ubuntu 12.10 中安装 opensips 1.8.2
 
  • 发表于 4年前 
  • 阅读 4132 
  • 收藏 2 
  • 点赞 1 
  • 评论 0

ubuntu 12.10中安装opensips 1.8.2

首先下载opensips-1.8.2_src.tar.gz

解压软件包:
tar -zxvf opensips-1.8.2_src.tar.gz

准备步骤:
编译前需确认安装以下软件包:
sudo apt-get install bison
sudo apt-get install flex

mysql数据库相关软件包安装:
sudo apt-get install mysql-server mysql-client
再装开发包
sudo apt-get install libmysqlclient-dev

修改编译配置文件: Makefile.conf
将exclude_modules中 db_mysql去掉

中间可能会有找不到curses.h文件的异常,按如下步骤安装libncurses5-dev包即可。
sudo apt-get install libncurses5 libncurses5-dev

以上步骤操作完毕可执行安装:

sudo make all

sudo make install

安装完毕后修改/usr/local/etc/opensips/opensipsctlrc 文件,需要修改的部分内容如下:

## your SIP domain
 SIP_DOMAIN=ubuntustudio

## chrooted directory
# $CHROOT_DIR="/path/to/chrooted/directory"

## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT, 
## by default none is loaded
# If you want to setup a database with opensipsdbctl, you must at least specify
# this parameter.
 DBENGINE=MYSQL

## database host
 DBHOST=localhost

## database name (for ORACLE this is TNS name)
 DBNAME=opensips

# database path used by dbtext or db_berkeley
 DB_PATH="/usr/local/etc/opensips/dbtext"

## database read/write user
 DBRWUSER=opensips

## password for database read/write user
 DBRWPW="opensipsrw"

## database super user (for ORACLE this is 'scheme-creator' user)
 DBROOTUSER="root"

# user name column
 USERCOL="username"


执行创建数据库的脚本:
opensipsdbctl create
MySQL password for root: 
INFO: test server charset
INFO: creating database opensips ...
INFO: Core OpenSIPS tables succesfully created.
Install presence related tables? (y/n): y  
INFO: creating presence tables into opensips ...
INFO: Presence tables succesfully created.
Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist? (y/n): y
INFO: creating extra tables into opensips ...
INFO: Extra tables succesfully created.

 

-----------------------------------------
查看命令:
root@ubuntu :/usr/local/etc/opensips# opensipsctl -c
/usr/local/sbin/opensipsctl $Revision: 4448 $

Existing commands:

 -- command 'start|stop|restart'

 restart ............................ restart OpenSIPS
 start .............................. start OpenSIPS
 stop ............................... stop OpenSIPS

 -- command 'acl' - manage access control lists (acl)

 acl show [<username>] .............. show user membership
 acl grant <username> <group> ....... grant user membership (*)
 acl revoke <username> [<group>] .... grant user membership(s) (*)

 -- command 'cr' - manage carrierroute tables

 cr show ....................................................... show tables
 cr reload ..................................................... reload tables
 cr dump ....................................................... show in memory tables
 cr addrt <routing_tree_id> <routing_tree> ..................... add a tree
 cr rmrt  <routing_tree> ....................................... rm a tree
 cr addcarrier <carrier> <scan_prefix> <domain> <rewrite_host> ................
               <prob> <strip> <rewrite_prefix> <rewrite_suffix> ...............
               <flags> <mask> <comment> .........................add a carrier
               (prob, strip, rewrite_prefix, rewrite_suffix,...................
                flags, mask and comment are optional arguments) ...............
 cr rmcarrier  <carrier> <scan_prefix> <domain> ................ rm a carrier

 -- command 'rpid' - manage Remote-Party-ID (RPID)

 rpid add <username> <rpid> ......... add rpid for a user (*)
 rpid rm <username> ................. set rpid to NULL for a user (*)
 rpid show <username> ............... show rpid of a user

 -- command 'add|passwd|rm' - manage subscribers

 add <username> <password> .......... add a new subscriber (*)
 passwd <username> <passwd> ......... change user's password (*)
 rm <username> ...................... delete a user (*)

 -- command 'add|dump|reload|rm|show' - manage address

 address show ...................... show db content
 address dump ...................... show cache content
 address reload .................... reload db table into cache
 address add <grp> <ip> <mask> <port> <proto> [<context_info>] [<pattern>]
             ....................... add a new entry
             ....................... (from_pattern and tag are optional arguments)
 address rm <grp> <ip> <mask> <port> ............... remove all entries 
             ....................... for the given grp ip mask port

 -- command 'dr' - manage dynamic routing

   * Examples: dr addgw '1' 10 '192.168.2.2' 0 '' 'GW001' 0 'first_gw'
   *           dr addgw '2' 20 '192.168.2.3' 0 '' 'GW002' 0 'second_gw'
   *           dr rmgw 2
   *           dr addgrp 'alice' 'example.com' 10 'first group'
   *           dr rmgrp 1
   *           dr addcr 'cr_1' '10' 0 'CARRIER_1' 'first_carrier'
   *           dr rmcr 1
   *           dr addrule '10,20' '+1' '20040101T083000' 0 0 '1,2' 'NA_RULE' 'NA routing'
   *           dr rmgrule 1
 dr show ............................ show dr tables
 dr addgw <gwid> <type> <address> <strip> <pri_prefix>
          <attrs> <probe_mode> <description>
    ................................. add gateway
 dr rmgw <id> ....................... delete gateway
 dr addgrp <username> <domain> <groupid> <description>
    ................................. add gateway group
 dr rmgrp <id> ...................... delete gateway group
 dr addcr <carrierid> <gwlist> <flags> <attrs> <description>
          ........................... add carrier
 dr rmcr <id> ....................... delete carrier
 dr addrule <groupid> <prefix> <timerec> <priority> <routeid>
            <gwlist> <attrs> <description>
    ................................. add rule
 dr rmrule <ruleid> ................. delete rule
 dr reload .......................... reload dr tables
 dr gw_status ....................... show gateway status
 dr carrier_status .................. show carrier status

 -- command 'dispatcher' - manage dispatcher

   * Examples:  dispatcher addgw 1 sip:1.2.3.1:5050 1 'outbound gateway'
   *            dispatcher addgw 2 sip:1.2.3.4:5050 3 ''
   *            dispatcher rmgw 4
 dispatcher show ..................... show dispatcher gateways
 dispatcher reload ................... reload dispatcher gateways
 dispatcher dump ..................... show in memory dispatcher gateways
 dispatcher addgw <setid> <destination> <flags> <description>
            .......................... add gateway
 dispatcher rmgw <id> ................ delete gateway

 -- command 'registrant' - manage registrants

   * Examples:  registrant add sip:opensips.org '' sip:user@opensips.org '' user password sip:user@localhost '' 3600 ''
 registrant show ......................... show registrant table
 registrant dump ......................... show registrant status
 registrant add <registrar> <proxy> <aor> <third_party_registrant>
                <username> <password> <binding_URI> <binding_params>
                <expiry> <forced_socket> . add a registrant
 registrant rm ........................... removes the entire registrant table
 registrant rmaor <id> ................... removes the gived aor id

 -- command 'db' - database operations

 db exec <query> ..................... execute SQL query
 db roexec <roquery> ................. execute read-only SQL query
 db run <id> ......................... execute SQL query from $id variable
 db rorun <id> ....................... execute read-only SQL query from 
                                       $id variable
 db show <table> ..................... display table content

 -- command 'speeddial' - manage speed dials (short numbers)

 speeddial show <speeddial-id> ....... show speeddial details
 speeddial list <sip-id> ............. list speeddial for uri
 speeddial add <sip-id> <sd-id> <new-uri> [<desc>] ... 
           ........................... add a speedial (*)
 speeddial rm <sip-id> <sd-id> ....... remove a speeddial (*)
 speeddial help ...................... help message
    - <speeddial-id>, <sd-id> must be an AoR (username@domain )
    - <sip-id> must be an AoR (username@domain )
    - <new-uri> must be a SIP AoR (sip:username@domain)
    - <desc> a description for speeddial

 -- command 'avp' - manage AVPs

 avp list [-T table] [-u <sip-id|uuid>]
     [-a attribute] [-v value] [-t type] ... list AVPs
 avp add [-T table] <sip-id|uuid>
     <attribute> <type> <value> ............ add AVP (*)
 avp rm [-T table]  [-u <sip-id|uuid>]
     [-a attribute] [-v value] [-t type] ... remove AVP (*)
 avp help .................................. help message
    - -T - table name
    - -u - SIP id or unique id
    - -a - AVP name
    - -v - AVP value
    - -t - AVP name and type (0 (str:str), 1 (str:int),
                              2 (int:str), 3 (int:int))
    - <sip-id> must be an AoR (username@domain )
    - <uuid> must be a string but not AoR

 -- command 'alias_db' - manage database aliases

 alias_db show <alias> .............. show alias details
 alias_db list <sip-id> ............. list aliases for uri
 alias_db add <alias> <sip-id> ...... add an alias (*)
 alias_db rm <alias> ................ remove an alias (*)
 alias_db help ...................... help message
    - <alias> must be an AoR (username@domain )"
    - <sip-id> must be an AoR (username@domain )"

 -- command 'domain' - manage local domains

 domain reload ....................... reload domains from disk
 domain show ......................... show current domains in memory
 domain showdb ....................... show domains in the database
 domain add <domain> ................. add the domain to the database
 domain rm <domain> .................. delete the domain from the database

 -- command 'cisco_restart' - restart CISCO phone (NOTIFY)

 cisco_restart <uri> ................ restart phone configured for <uri>

 -- command 'online' - dump online users from memory

 online ............................. display online users

 -- command 'monitor' - show internal status

 monitor ............................ show server's internal status

 -- command 'ping' - ping a SIP URI (OPTIONS)

 ping <uri> ......................... ping <uri> with SIP OPTIONS

 -- command 'ul|alias' - manage user location or aliases

 ul show [<username>]................ show in-RAM online users
 ul show --brief..................... show in-RAM online users in short format
 ul rm <username> [<contact URI>].... delete user's usrloc entries
 ul add <username> <uri> ............ introduce a permanent usrloc entry
 ul add <username> <uri> <expires> .. introduce a temporary usrloc entry

 -- command 'fifo'

 fifo ............................... send raw FIFO command


启动opensips 服务:
opensipsctl start
------------------------------------------------------------
启动服务的过程中可能出现的数据库错误:
 ERROR:core:db_check_api: module db_mysql does not export db_use_table function
 ERROR:uri:mod_init: No database module found

解决办法:

在/usr/local/etc/opensips/opensips.cfg文件中添加有关数据库的配置如下:

db_default_url="mysql://opensips:opensipsrw@localhost/opensips"


/* uncomment next line for MySQL DB support */  
loadmodule "db_mysql.so" 

/* uncomment next lines for MySQL based authentication support   
   NOTE: a DB (like db_mysql) module must be also loaded */  
loadmodule "auth.so"  
loadmodule "auth_db.so"  
/* uncomment next line for aliases support  
   NOTE: a DB (like db_mysql) module must be also loaded */  
loadmodule "alias_db.so"  
/* uncomment next line for multi-domain support  
   NOTE: a DB (like db_mysql) module must be also loaded  
   NOTE: be sure and enable multi-domain support in all used modules  
         (see "multi-module params" section ) */  
#loadmodule "domain.so"  
/* uncomment the next two lines for presence server support  
   NOTE: a DB (like db_mysql) module must be also loaded */  
#loadmodule "presence.so"  
#loadmodule "presence_xml.so" 


# ----------------- setting module-specific parameters ---------------  
  
  
# ----- mi_fifo params -----  
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")  
  
  
# ----- rr params -----  
# do not append from tag to the RR (no need for this script)  
modparam("rr", "append_fromtag", 0)  
  
  
# ----- registrar params -----  
/* uncomment the next line not to allow more than 10 contacts per AOR */  
#modparam("registrar", "max_contacts", 10)  
  
  
# ----- usrloc params -----  
#modparam("usrloc", "db_mode",   0)  
/* uncomment the following lines if you want to enable DB persistency  
   for location entries */  
modparam("usrloc", "db_mode",   2)  
modparam("usrloc", "db_url",  
    "mysql://opensips:opensipsrw@localhost/opensips")  
  
  
# ----- uri params -----  
modparam("uri", "use_uri_table", 0)  
  
  
# ----- acc params -----  
/* what sepcial events should be accounted ? */  
modparam("acc", "early_media", 1)  
modparam("acc", "report_cancels", 1)  
/* by default ww do not adjust the direct of the sequential requests.  
   if you enable this parameter, be sure the enable "append_fromtag"  
   in "rr" module */  
modparam("acc", "detect_direction", 0)  
/* account triggers (flags) */  
modparam("acc", "failed_transaction_flag", 3)  
modparam("acc", "log_flag", 1)  
modparam("acc", "log_missed_flag", 2)  
/* uncomment the following lines to enable DB accounting also */  
modparam("acc", "db_flag", 1)  
modparam("acc", "db_missed_flag", 2)  
  
  
# ----- auth_db params -----  
/* uncomment the following lines if you want to enable the DB based  
   authentication */  
modparam("auth_db", "calculate_ha1", yes)  
modparam("auth_db", "password_column", "password")  
#modparam("auth_db", "db_url","mysql://opensips:opensipsrw@localhost/opensips")  
#modparam("auth_db", "load_credentials", "")  
  
  
# ----- alias_db params -----  
/* uncomment the following lines if you want to enable the DB based  
   aliases */  
#modparam("alias_db", "db_url",  
#   "mysql://opensips:opensipsrw@localhost/opensips")  
  
  
# ----- domain params -----  
/* uncomment the following lines to enable multi-domain detection  
   support */  
#modparam("domain", "db_url",  
#   "mysql://opensips:opensipsrw@localhost/opensips")  
#modparam("domain", "db_mode", 1)   # Use caching  
  
  
# ----- multi-module params -----  
/* uncomment the following line if you want to enable multi-domain support  
   in the modules (dafault off) */  
#modparam("auth_db|usrloc|uri", "use_domain", 1)  
  
  
# ----- presence params -----  
/* uncomment the following lines if you want to enable presence */  
#modparam("presence|presence_xml", "db_url",  
#   "mysql://opensips:opensipsrw@localhost/opensips")  
#modparam("presence_xml", "force_active", 1)  
#modparam("presence", "server_address", "sip:192.168.1.2:5060")  
  
  
-------------------------------------------------------------


添加sip用户
opensipsctl add username password  

如:
opensipsctl add 100 100
opensipsctl add 101 101


使用软电话x-lite成功登陆
查看注册的sip用户
opensipsctl ul show

是否在线
opensipsctl online


root@ubuntu :/usr/local/lib/opensips/modules# opensipsctl ul show
Domain:: location table=512 records=2
        AOR:: 100
                Contact:: sip:100@192.168.17.1:5061;rinstance=a40cd182a1adbeb8;transport=TCP Q=
                        Expires:: 3313
                        Callid:: ZTBkZjZlNTJmYzdmOWVlYzI5N2M0NzY5MmFjNGU3ZWQ.
                        Cseq:: 2
                        User-agent:: X-Lite release 5.0.0 stamp 67284
                        State:: CS_SYNC
                        Flags:: 0
                        Cflag:: 0
                        Methods:: 5951
        AOR:: 101
                Contact:: sip:101@192.168.17.1:5060;rinstance=1626363c473bd98d Q=
                        Expires:: 3591
                        Callid:: N2UxZGVkNmNjMWQyOGJkODYzM2Y4NjlmODBlN2UzMjk.
                        Cseq:: 1
                        User-agent:: X-Lite release 5.0.0 stamp 67284
                        State:: CS_NEW
                        Flags:: 0
                        Cflag:: 0
                        Socket:: udp:192.168.17.132:5060
                        Methods:: 5951
root@ubuntu :/usr/local/lib/opensips/modules# opensipsctl online
100
101

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值