这里是普通文章模块栏目内容页
asterisk输入启动命令无法启动的解决方法
今天要测试我写的一个程序,需要连接asterisk的ami接口,但是服务器上的asterisk没有启动。  
输入启动命令: /usr/sbin/asterisk start  
之后,再输入命令: asterisk -vvvr  
出现提示: Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)  
还是无法启动。在网上搜索了好几次,都没有正确的,后来总算找到了一个比较对的。  
解决方法如下所示:   应该是修改过 /etc/asterisk/zapata.conf文件,加了一行busydetect=yes  
我用WinScp连接上服务器,查看了zapata.conf,果然是找到了busydetect=yes  
于是用了下面的解决方法:   /var/run/asterisk/amportal stop  
出现提示信息:  
STOPPING ASTERISK
STOPPING FOP SERVER  
然后再输入命令:  service asterisk stop
service zaptel stop  
之后在输入命令:  service asterisk start
出现提示信息: Automatically restarting Asterisk. Asterisk ended with exit status 1 Asterisk died with code
1.  循环出现这个提示信息,让我都不能再输入命令了。所以我关了putty,另外再开了一个putty。( 下次就不能再犯这个错误了。这个service asterisk start命令应该是在加载所有模块之后再使用的。)
 /var/run/asterisk/amportal start  
出现下面的提示信息:    
SETTING FILE PERMISSIONS
Permissions OK
STARTING ASTERISK
 Asterisk ended with exit status 1
Asterisk died with code 1.
Automatically restarting Asterisk.
Asterisk ended with exit status 1
Asterisk died with code 1.
Automatically restarting Asterisk.
mpg123: no process killed  
-----------------------------------------------------  
Asterisk could not start!
Use 'tail /var/log/asterisk/full' to find out why.  
于是输入 tail /var/log/asterisk/full命令查看出错信息:
 Jan 19 10:48:39 VERBOSE[32752] logger.c: [chan_skinny.so]Jan 19 10:48:39 VERBOSE[32752] logger.c: [chan_skinny.so] => (Skinny Client Control Protocol (Skinny))  
Jan 19 10:48:39 VERBOSE[32752] logger.c:   == Parsing '/etc/asterisk/skinny.conf':
Jan 19 10:48:39 VERBOSE[32752] logger.c:   == Parsing '/etc/asterisk/skinny.conf': Found
Jan 19 10:48:39 VERBOSE[32752] logger.c:   == Skinny listening on 0.0.0.0:2000
Jan 19 10:48:39 VERBOSE[32752] logger.c:   == Registered channel type 'Skinny' (Skinny Client Control Protocol (Skinny))
Jan 19 10:48:39 VERBOSE[32752] logger.c: [chan_zap.so]
Jan 19 10:48:39 VERBOSE[32752] logger.c: [chan_zap.so] => (Zapata Telephony w/PRI)
Jan 19 10:48:39 VERBOSE[32752] logger.c:   == Parsing '/etc/asterisk/zapata.conf': Jan 19 10:48:39 VERBOSE[32752] logger.c:   == Parsing '/etc/asterisk/zapata.conf': Found
Jan 19 10:48:39 VERBOSE[32752] logger.c:   == Parsing '/etc/asterisk/zapata-channels.conf': Jan 19 10:48:39 VERBOSE[32752] logger.c:   == Parsing '/etc/asterisk/zapata-channels.conf': Found
Jan 19 10:48:39 ERROR[32752] chan_zap.c: Unable to open /dev/zap/ctl to set toneduration Jan 19 10:48:39 WARNING[32752] loader.c: chan_zap.so: load_module failed, returning -1
Jan 19 10:48:39 WARNING[32752] loader.c: Loading module chan_zap.so failed!  
根据所得到的信息,应该是加载模块的时候出错。
于是我另外开了一个putty连接上服务器,在命令行下输入
service zaptel start
出现提示信息:  
Loading zaptel framework:                                  [ ok]
Waiting for zap to come online...OK
Loading zaptel hardware modules:No hardware timing source found in /proc/zaptel, loading ztdummy
Running ztcfg:                                             [ok]  
然后我再输入命令:
asterisk -vvvr  
出现提示信息:
== Parsing '/etc/asterisk/asterisk.conf': Found
== Parsing '/etc/asterisk/extconfig.conf': Found
Asterisk 1.2.24, Copyright (C) 1999 - 2007 Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'show warranty' for details.
This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'show license' for details. =========================================================================
Connected to Asterisk 1.2.24 currently running on localhost (pid = 419)
Verbosity was 0 and is now 3
    -- Executing Answer("SIP/6008-0a0bb0b0", "") in new stack
    -- Executing INTERACT("SIP/6008-0a0bb0b0", "/root/interact") in new stack
    -- Remote UNIX connection
    -- Executing Hangup("SIP/6008-0a0bb0b0", "") in new stack
== Spawn extension (schtest, 5014, 3) exited non-zero on 'SIP/6008-0a0bb0b0'
    -- Registered SIP '6004' at 192.168.20.108 port 39726 expires 3600
启动asterisk成功!