Skip to Content
《Asterisk:权威指南》第 5 版
book

《Asterisk:权威指南》第 5 版

by Jim Van Meggelen, Russell Bryant, Leif Madsen
May 2025
Intermediate to advanced
414 pages
5h 2m
Chinese
O'Reilly Media, Inc.
Content preview from 《Asterisk:权威指南》第 5 版

第 15 章 关系数据库集成 关系数据库集成

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

没有什么比一个好榜样的烦扰更难忍受的了。

马克-吐温

在本章 中,我们将探讨如何将 Asterisk 的一些特性和功能集成到数据库中。Linux 上有几种可用的数据库,Asterisk 通过其 ODBC 连接器支持其中最常用的数据库。本章将演示使用 ODBC 连接器和 MySQL 数据库的示例,但你会发现大部分概念都适用于unixODBC 支持的任何数据库。

将 Asterisk 与数据库集成是构建大型集群或分布式系统的基本要素之一。数据库的强大功能将使你能够在拨号计划中使用动态变化的数据,完成在一系列 Asterisk 系统间共享信息或与网络服务集成等任务。我们最喜欢的拨号计划功能是func_odbc 。我们还将了解 Asterisk 实时架构 (ARA)、呼叫详情记录 (CDR) 以及来自任何 ACD 队列的日志详情。

虽然并非所有 Asterisk 部署都需要关系数据库,但了解如何利用关系数据库将为设计电信解决方案打开一个充满新方法的宝库。

您选择的数据库

第 3 章 中,我们安装并配置了 MySQL,以及与之相连的 ODBC 连接器,我们一直在使用 Asterisk 提供的表格,以便在数据库中存储各种配置选项。

我们之所以选择 MySQL ,主要是因为它仍然是最流行的开源数据库引擎,与其在各种不同的引擎上跳来跳去、重复琐碎的命令,不如将其他类型数据库的实现留给读者的技能组合。如果你想使用不同的数据库,如 MariaDB、PostGreSQL、Microsoft SQL,或事实上由unixODBC 支持的数十种(也许数百种)其他数据库,Asterisk 很有可能与之配合使用。

Asterisk 还提供了连接多个数据库的本地连接器;不过,ODBC 运行得非常好,我们从未发现有任何明显的理由要采用其他方式。我们既要推荐 ODBC,也要专门介绍它。如果您偏好其他方法,本章仍将为您提供基础知识和一些工作示例,当然,您也可以从这里开始学习其他方法。

请注意,无论您选择哪种数据库,本书都无法向您传授数据库知识。我们已经尽力提供不需要太多数据库管理(DBA)专业知识的例子,但一个简单的事实是,基本的 DBA 技能是能够充分利用任何数据库(包括你可能希望与 Asterisk 系统集成的任何数据库)的强大功能的先决条件。如今,数据库技能对于几乎所有系统管理学科来说都是必不可少的,因此我们认为至少应该对数据库概念有基本的了解。

管理数据库

虽然教你如何管理数据库不在本书 的范围之内,但至少值得简要介绍一下你可以用来帮助管理数据库的一些应用程序。有很多选择,其中一些是在你的计算机上运行并连接到数据库的本地客户端应用程序,另一些则是基于网络的应用程序,可以从运行数据库的同一台计算机上提供服务,从而允许你远程连接。

我们使用过的 包括:

在我们的示例中,我们将使用 MySQL 命令行 ,并不是因为它有什么优越性,而只是因为它在任何装有 MySQL 的系统上都无处不在,所以你已经有了它,而且在本书中也一直在使用它。

对于更繁重的数据库设计,命令行的功能可能不如设计良好的图形用户界面强大。至少拿一份 MySQL Workbench 试试吧。

排除数据库问题

当 与 ODBC 数据库连接和 Asterisk 一起工作时,必须记住 ODBC 连接抽象了 Asterisk 与数据库之间传递的某些信息。在工作不尽如人意的情况下,可能需要启用数据库平台的日志记录功能,以查看 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

What Successful Brick-and-Mortar Retailers Get Right

What Successful Brick-and-Mortar Retailers Get Right

Rob Angell
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
Three Essentials for Agentic AI Security

Three Essentials for Agentic AI Security

Paolo Dal Cin, Daniel Kendzior, Yusof Seedat, Renato Marinho

Publisher Resources

ISBN: 9798341659568