当前位置: 首页 > news >正文

FreeSWITCH 简单图形化界面30 - 使用MYODBC时可能遇到的错误

FreeSWITCH 简单图形化界面30 - 使用MYODBC时可能遇到的错误

  • 测试环境
  • 1、 MYODBC 3.51.18 or higher
  • 2、分析和解决
    • 2.1 解决1,降级MySQL ODBC
    • 2.2 解决2,修改FreeSWITCH代码


测试环境

http://myfs.f3322.net:8020/
用户名:admin,密码:admin

FreeSWITCH界面安装参考:https://blog.csdn.net/jia198810/article/details/137820796

1、 MYODBC 3.51.18 or higher

在编译FreeSWITCH,支持ODBC的时候,启动的时候,可能会遇到以下问题:

2020-06-11 07:30:48.559653 [DEBUG] sofia.c:3158 Creating agent for default
2020-06-11 07:30:48.559653 [ERR] switch_odbc.c:522 ERR: [delete from sip_registrations where sub_host is null and hostname='betelgeuse_web_serice1' and network_ip like '%' and network_port like '%' and sip_username like '%' and mwi_user  like '%' and mwi_host like '%' and orig_server_host like '%' and orig_hostname like '%';delete from sip_registrations where sub_host is null and hostname='betelgeuse_web_serice1' and network_ip like '%' and network_port like '%' and sip_username like '%' and mwi_user  like '%' and mwi_host like '%' and orig_server_host like '%' and orig_hostname like '%']
[STATE: 42000 CODE 1064 ERROR: [MySQL][ODBC 8.0(a) Driver][mysqld-8.0.16]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete from sip_registrations where sub_host is null and hostname='betelgeuse_we' at line 1
]
2020-06-11 07:30:48.559653 [ERR] switch_core_sqldb.c:732 [db="ASTPP";type="odbc"user="astpp_odbc";pass="Iuv4_wuHjU6cqMFXn4Hm"] ODBC SQL ERR [STATE: 42000 CODE 1064 ERROR: [MySQL][ODBC 8.0(a) Driver][mysqld-8.0.16]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete from sip_registrations where sub_host is null and hostname='betelgeuse_we' at line 1
]
delete from sip_registrations where sub_host is null and hostname='betelgeuse_web_serice1' and network_ip like '%' and network_port like '%' and sip_username like '%' and mwi_user  like '%' and mwi_host like '%' and orig_server_host like '%' and orig_hostname like '%';delete from sip_registrations where sub_host is null and hostname='betelgeuse_web_serice1' and network_ip like '%' and network_port like '%' and sip_username like '%' and mwi_user  like '%' and mwi_host like '%' and orig_server_host like '%' and orig_hostname like '%'
2020-06-11 07:30:48.559653 [CRIT] sofia_glue.c:2625 GREAT SCOTT!!! Cannot execute batched statements! [STATE: 42000 CODE 1064 ERROR: [MySQL][ODBC 8.0(a) Driver][mysqld-8.0.16]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete from sip_registrations where sub_host is null and hostname='betelgeuse_we' at line 1
]
If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS
2020-06-11 07:30:48.559653 [CRIT] sofia.c:3161 Cannot Open SQL Database [default]!

2、分析和解决

这是因为可能使用高版本的MySQL ODBC版本所致。
FreeSWITCH 需要 MySQL ODBC 支持批处理,即能够一次性执行多个 SQL 语句(通过分号分隔多个SQL语句)。MySQL ODBC 5.x 版本支持通过在 /etc/odbc.ini 中设置 option=67108864 来启用批处理。FreeSWITCH 可以通过 SQLPrepare() 和 SQLExecute() 执行批处理。但是,MySQL ODBC 8.x 之后的版本不支持 option 这个选项,而是可以通过 SQLExecDirect() 来执行多个 SQL 语句。
MySQL ODBC 官网描述如下:
在这里插入图片描述

2.1 解决1,降级MySQL ODBC

要在选定的系统上编译 MySQL ODBC 5.x 版本,并通过设置启动选项 option=67108864 来启用批处理功能。
当前(2024年10月26日)MySQL 官网提供的版本为 mysql-connector-odbc-5.3.13-src.tar.gz。您可以从此链接下载源码包:mysql-connector-odbc-5.3.13-src.tar.gz。下载后,解压并按照官方文档指示进行编译和安装。安装完成后,可以通过在连接字符串中添加 option=67108864 来启用批处理。
在这里插入图片描述
编译后生成libmyodbc5w.so模块,/etc/odbc.ini配置文件使用该模块。

# /etc/odbc.ini
[freeswitch]
DRIVER   = /usr/lib64/libmyodbc5w.so
SERVER   = localhost
PORT     = 3306
DATABASE = freeswitch
USER     = user
PASSWORD = 123456
OPTION   = 67108864
Socket   = /var/run/mysqld/mysqld.sock
CHARSET  = utf8mb4

2.2 解决2,修改FreeSWITCH代码

科技在发展,时代在进步,不可能一直用MySQL ODBC 5.x,目前MySQL ODBC都到9.x版本了,有的新版操作系统,可能也无法编译MySQL ODBC 5.x,会各种兼容报错,因此只能选用新版本的MySQL ODBC。
如果我们可以使用MySQL8.x,使用MySQL ODBC8.x,那么需要修改一下FreeSWITCH的代码,让其使用SQLExecDirect() 执行SQL。

MySQL ODBC8.x的库为libmyodbc8w.so,/etc/odbc.ini使用此库

修改的FreeSWITCH文件是,源码目录下的src/switch_odbc.c,修改如下图:
在这里插入图片描述
重新编译FreeSWITCH可执行文件和库,安装即可。

make
make install

再次启动查看是否还有上面的报错。

祝君好运

http://www.lryc.cn/news/470536.html

相关文章:

  • 阿里云物联网的通信方式
  • 自由职业者的一天:作为小游戏开发者的真实工作日记
  • 【RL Latest Tech】分层强化学习:Option-Critic架构算法
  • 分布式数据库
  • MySQL(2)【库的操作】
  • python pip更换(切换)国内镜像源
  • 阿里云镜像源无法访问?使用 DaoCloud 镜像源加速 Docker 下载(Linux 和 Windows 配置指南)
  • 使用 BERT 和逻辑回归进行文本分类及示例验证
  • 【skywalking 】监控 Spring Cloud Gateway 数据
  • SpringWeb
  • 嵌入式刷题(day21)
  • OpenAI 下一代旗舰模型现身?奥尔特曼亲自辟谣“猎户座“传闻
  • 【C++】STL初识
  • 框架篇补充(东西多 需要重新看网课)
  • 合约门合同全生命周期管理系统:企业合同管理的数字化转型之道
  • 等保测评与风险管理:识别、评估和缓解潜在的安全威胁
  • Golang Agent 可观测性的全面升级与新特性介绍
  • SpringBoot的开篇 特点 初始化 ioc 配置文件
  • docker 可用镜像服务地址(2024.10.25亲测可用)
  • 【SQL实验】表的更新和简单查询
  • 【C++】 string的了解及使用
  • 【K8S】kubernetes-dashboard.yaml
  • 远程root用户访问服务器中的MySQL8
  • 解释一下 Java 中的静态变量(Static Variable)和静态方法(Static Method)?
  • 【Linux】————磁盘与文件系统
  • 平衡控制——直立环——速度环
  • 面试简要介绍hashMap
  • HTTPS如何实现加密以及SSL/TSL加密的详细过程
  • Golang | Leetcode Golang题解之第516题最长回文子序列
  • (done) 什么 RPC 协议? remote procedure call 远程调用协议