投げ銭

★当サイトへの投げ銭(PayPal)★

LINK


(無償、寄付歓迎) logo
世界中で使われるISO標準オフィスソフト(MSオフィス互換)

★LibreOfficeの導入事例★
詳細について

人気の投稿(1ヶ月間)

Ad

Ad

投げ銭

★当サイトへの投げ銭(PayPal)★

2018年12月9日日曜日

【Linux CentOS 7】ASTERISK 11.25.3 をインストールし動作させた。


下記で用いている特権Dockerコンテナは、次のページで作成したイメージをベースにしている。

しかし、通常のCentOS 7でも同じ方法でASTERISKを導入できると思う。

【Linux CentOS 7】(ベースコンテナの作成)SSH接続可能なDockerコンテナでの日本用ロケールの有効化と検証(man,dateの日本語表示)【Docker-ce 18.06.1.ce】


まず、次のようにしてコンテナを動作させた。
Dockerホスト222ポートを22ポートに通して、SSH接続を受け付けている。

Asteriskの実際の動作で必要なポートの解放については、ここでは考慮していない。

(警告)
ここで作成しているDockerコンテナは、信頼のおけるローカルネットワークのみで動作するホストで運用するものとして構築している。
ホスト上のいずれかのネットワークインターフェイスがインターネットに直接接している場合、このコンテナの運用はセキュリティの観点から非常に危険なので動作させてはいけない。
(Dockerのデフォルトでは外部からのアクセスを許してしまうことになってしまうため。)

# docker run --privileged -d -p 222:22 --name asterisk11 image_centos7-ja_20181208 /sbin/init

そして、このコンテナにSSH接続を行い、下記のように設定作業を行った。



■ASTERISKのインストール

○アップデート
[root@24ad4455f276 ~]# yum update


○必要なパッケージの導入
[root@24ad4455f276 ~]# yum install gcc gcc-c++ libxml2 libxml2-devel openssl-devel ncurses-devel sqlite-devel newt-devel libuuid-devel uuid-devel make wget


○ソースファイルの展開先
[root@24ad4455f276 ~]# mkdir software/asterisk -p
[root@24ad4455f276 ~]# cd software/asterisk/


○ソースファイルの取得
[root@24ad4455f276 asterisk]# wget http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-11.25.3.tar.gz

[root@24ad4455f276 asterisk]# ls -l
total 34312
-rw-r--r-- 1 root root 35134682 Sep 19  2017 asterisk-11.25.3.tar.gz

○コンパイルとインストール
[root@24ad4455f276 asterisk]# tar zxvf asterisk-11.25.3.tar.gz
[root@24ad4455f276 asterisk]# cd asterisk-11.25.3

以下、(1)(2)(3)の手順がある。

(1)
[root@24ad4455f276 asterisk-11.25.3]# ./configure
(略)
configure: creating ./config.status
config.status: creating makeopts
config.status: creating autoconfig.h
configure: Menuselect build configuration successfully completed
               .$$$$$$$$$$$$$$$=..
            .$7$7..          .7$$7:.
          .$$:.                 ,$7.7
        .$7.     7$$$$           .$$77
     ..$$.       $$$$$            .$$$7
    ..7$   .?.   $$$$$   .?.       7$$$.
   $.$.   .$$$7. $$$$7 .7$$$.      .$$$.
 .777.   .$$$$$$77$$$77$$$$$7.      $$$,
 $$$~      .7$$$$$$$$$$$$$7.       .$$$.
.$$7          .7$$$$$$$7:          ?$$$.
$$$          ?7$$$$$$$$$$I        .$$$7
$$$       .7$$$$$$$$$$$$$$$$      :$$$.
$$$       $$$$$$7$$$$$$$$$$$$    .$$$.
$$$        $$$   7$$$7  .$$$    .$$$.
$$$$             $$$$7         .$$$.
7$$$7            7$$$$        7$$$
 $$$$$                        $$$
  $$$$7.                       $$  (TM)
   $$$$$$$.           .7$$$$$$  $$
     $$$$$$$$$$$$7$$$$$$$$$.$$$$$$
       $$$$$$$$$$$$$$$$.
configure: Package configured for:
configure: OS type  : linux-gnu
configure: Host CPU : x86_64
configure: build-cpu:vendor:os: x86_64 : unknown : linux-gnu :
configure: host-cpu:vendor:os: x86_64 : unknown : linux-gnu :

(2)
[root@24ad4455f276 asterisk-11.25.3]# make
(略)
updating cache ./config.cache
creating ./config.status
creating Makefile
creating makelist
creating config.h
   [LD] abstract_jb.o acl.o adsi.o alaw.o aoc.o app.o ast_expr2.o ast_expr2f.o asterisk.o astfd.o astmm.o astobj2.o audiohook.o autochan.o autoservice.o bridging.o callerid.o ccss.o cdr.o cel.o channel.o channel_internal_api.o chanvars.o cli.o config.o config_options.o data.o datastore.o db.o devicestate.o dial.o dns.o dnsmgr.o dsp.o enum.o event.o features.o file.o fixedjitterbuf.o format.o format_cap.o format_pref.o frame.o framehook.o fskmodem.o global_datastores.o hashtab.o heap.o http.o image.o indications.o io.o jitterbuf.o loader.o lock.o logger.o manager.o md5.o message.o named_acl.o netsock.o netsock2.o pbx.o plc.o poll.o presencestate.o privacy.o rtp_engine.o say.o sched.o security_events.o sha1.o sip_api.o slinfactory.o srv.o stdtime/localtime.o strcompat.o strings.o stun.o syslog.o taskprocessor.o tcptls.o tdd.o term.o test.o threadstorage.o timing.o translate.o udptl.o ulaw.o utils.o version.o xml.o xmldoc.o editline/libedit.a  -> asterisk
Building Documentation For: channels pbx apps codecs formats cdr cel bridges funcs tests main res addons
 +--------- Asterisk Build Complete ---------+
 + Asterisk has successfully been built, and +
 + can be installed by running:              +
 +                                           +
 +                make install               +
 +-------------------------------------------+

(3)
[root@24ad4455f276 asterisk-11.25.3]# make install
(略)
 +---- Asterisk Installation Complete -------+
 +                                           +
 +    YOU MUST READ THE SECURITY DOCUMENT    +
 +                                           +
 + Asterisk has successfully been installed. +
 + If you would like to install the sample   +
 + configuration files (overwriting any      +
 + existing config files), run:              +
 +                                           +
 +                make samples               +
 +                                           +
 +-----------------  or ---------------------+
 +                                           +
 + You can go ahead and install the asterisk +
 + program documentation now or later run:   +
 +                                           +
 +               make progdocs               +
 +                                           +
 + **Note** This requires that you have      +
 + doxygen installed on your local system    +
 +-------------------------------------------+

○サンプルファイルのインストール
[root@24ad4455f276 asterisk-11.25.3]# make samples


○自動起動用のスクリプトのインストール
[root@24ad4455f276 asterisk-11.25.3]# make config


以下、asteriskを起動させる段階でも、パッケージ不足や手順の不足を補っている。



■asteriskの起動

〇システム起動時に自動起動させる設定
[root@24ad4455f276 asterisk-11.25.3]# systemctl enable asterisk
asterisk.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig asterisk on

〇asteriskの起動と状態の確認
[root@24ad4455f276 asterisk-11.25.3]# systemctl start asterisk
Job for asterisk.service failed because the control process exited with error code. See "systemctl status asterisk.service" and "journalctl -xe" for details.
asteriskの起動に失敗した。

ステータスを表示させた。
[root@24ad4455f276 asterisk-11.25.3]# systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2018-12-08 11:15:37 UTC; 11s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 19926 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=1/FAILURE)
Dec 08 11:15:37 24ad4455f276 systemd[1]: Starting LSB: Asterisk PBX...
Dec 08 11:15:37 24ad4455f276 asterisk[19926]: /etc/rc.d/init.d/asterisk: line 42: /etc/rc.d/init.d/functions: No such file or...ectory
Dec 08 11:15:37 24ad4455f276 systemd[1]: asterisk.service: control process exited, code=exited status=1
Dec 08 11:15:37 24ad4455f276 systemd[1]: Failed to start LSB: Asterisk PBX.
Dec 08 11:15:37 24ad4455f276 systemd[1]: Unit asterisk.service entered failed state.
Dec 08 11:15:37 24ad4455f276 systemd[1]: asterisk.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

必要なパッケージを導入した。
[root@24ad4455f276 asterisk-11.25.3]# yum install initscripts
Installed:
  initscripts.x86_64 0:9.49.46-1.el7
Dependency Installed:
  sysvinit-tools.x86_64 0:2.88-14.dsf.el7
Complete!

再び起動を試行した。
[root@24ad4455f276 asterisk-11.25.3]# systemctl start asterisk
^C

エラーも何も表示されない状態になったので、ctrl+c で強制停止した。
ステータスを表示させたが有益な情報は得られなかった。

ldconfigを実行した。(†1)
[root@24ad4455f276 asterisk-11.25.3]# ldconfig


再び、起動させてみる。
[root@24ad4455f276 asterisk-11.25.3]# systemctl start asterisk
Starting asterisk (via systemctl):                         [  OK  ]
起動したようである。


起動後の状態の確認
[root@24ad4455f276 asterisk-11.25.3]# systemctl status asterisk -l
asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled)
   Active: active (running) since Sat 2018-12-08 14:29:21 UTC; 8s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 20930 ExecStop=/etc/rc.d/init.d/asterisk stop (code=exited, status=0/SUCCESS)
  Process: 20974 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
 Main PID: 21003 (asterisk)
   CGroup: /docker/24ad4455f27604b55f691aa3c35c7d948eac9334cff7b4aa216bf7ca9dcc8625/system.slice/asterisk.service
           ├─21001 /bin/sh /usr/sbin/safe_asterisk
           └─21003 /usr/sbin/asterisk -f -vvvg -c
           ‣ 21003 /usr/sbin/asterisk -f -vvvg -c
Dec 08 14:29:21 24ad4455f276 systemd[1]: Starting LSB: Asterisk PBX...
Dec 08 14:29:21 24ad4455f276 asterisk[20974]: Starting asterisk:
Dec 08 14:29:21 24ad4455f276 systemd[1]: PID file /var/run/asterisk/asterisk.pid not readable (yet?) after start.
Dec 08 14:29:21 24ad4455f276 systemd[1]: asterisk.service: Supervising process 21003 which is not our child. We'll most likely not notice when it exits.
Dec 08 14:29:21 24ad4455f276 systemd[1]: Started LSB: Asterisk PBX.


上記の状態表示で、pidファイルが(まだ)読める状態になっていないとある。
そこで念の為にpidファイルの確認をした。

読める状態であった。(asteriskはrootユーザーで動作中である。)
[root@24ad4455f276 asterisk-11.25.3]# ls -l /var/run/asterisk/asterisk.pid
-rw-r--r-- 1 root root 6 Dec  8 14:29 /var/run/asterisk/asterisk.pid

[root@24ad4455f276 asterisk-11.25.3]# cat /var/run/asterisk/asterisk.pid
21003
動作中のプロセスも確認した。
[root@24ad4455f276 asterisk-11.25.3]# ps -A | grep asterisk
21001 ?        00:00:00 safe_asterisk
21003 ?        00:00:00 asterisk
タイミング的に、pidファイルが読めなかったのではないだろうか。(†3)


また、上記の状態表示の次の行では、プロセス21003は自分の子プロセスでないもののsystemd[1]は監視していると言っている。
次のようにプロセスツリーを確認すると、systemdのツリーにasteriskが存在していることがわかった。

プロセスツリーの確認
[root@24ad4455f276 asterisk-11.25.3]# yum install psmisc
[root@24ad4455f276 asterisk-11.25.3]# pstree
systemd─┬─agetty
         ├─crond
         ├─dbus-daemon
         ├─dnsmasq
         ├─master─┬─pickup
         │        └─qmgr
         ├─rsyslogd───2*[{rsyslogd}]
         ├─safe_asterisk───asterisk───42*[{asterisk}]
         ├─sshd───sshd───bash───tmux
         ├─systemd-journal
         ├─systemd-logind
         ├─systemd-udevd
         └─tmux───bash───pstree


以上より、特に問題が発生しているわけではないと判断した。



■asteriskのCLIを表示

[root@24ad4455f276 asterisk-11.25.3]# asterisk -r
Asterisk 11.25.3, Copyright (C) 1999 - 2013 Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core 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 'core show license' for details.
=========================================================================
Connected to Asterisk 11.25.3 currently running on 24ad4455f276 (pid = 20563)
24ad4455f276*CLI>
!              acl            ael            agent          agi            aoc            calendar       cc
cdr            cel            channel        cli            confbridge     config         console        core
data           database       devstate       dialplan       dnsmgr         dundi          event          fax
features       file           group          hangup         help           http           iax2           indication
keys           local          logger         manager        mgcp           minivm         mixmonitor     module
moh            no             originate      parkedcalls    phoneprov      presencestate  pri            queue
realtime       reload         rtcp           rtp            say            sip            skinny         stun
timing         udptl          ulimit         unistim        voicemail
24ad4455f276*CLI>

以上




<参考>
(1)Asterisk 11
< https://www.voip-info.jp/index.php/Asterisk_11 > 2018年12月8日

(2)CentOS7のAsterisk11イメージ作った
< https://qiita.com/tukiyo3/items/6fe69285ac076672072c > 2018年12月8日

(3)PIDファイル読み取り不可
< http://www.zabbix.jp/node/4158 > 2018年12月8日

(4)How to Install Asterisk on CentOS 7
< https://www.rosehosting.com/blog/how-to-install-asterisk-on-centos-7/ > 2018年12月8日

(5)CentOS7でpstreeが無い
< https://qiita.com/todanano/items/f421c237eaa2d9adff04 > 2018年12月8日

投げ銭

★当サイトへの投げ銭(PayPal)★

Ad

Ad