Linux下安装ejabberd支持MSSQL
一、Linux下安装unixODBC、freetds源码包:freetds-0.82.tar.gz、unixODBC-2.3.0.tar.gz1. 安装unixODBCgunzip unixODBC-2.3.t
一、Linux下安装unixODBC、freetds
源码包:freetds-0.82.tar.gz、unixODBC-2.3.0.tar.gz
1. 安装unixODBC
gunzip unixODBC-2.3.tar.gz
tar zxvf unixODBC-2.3.tar
./configure --prefix=/usr/local/unixODBC
make
make install
2. 安装freetds
tar zxvf freetds-0.82.tar.gz
cd freetds-0.82
./configure --prefix=/usr/local/freetds --with-unixodbc=/usr/local/unixODBC --with-tdsver=8.0
make
make install
cd /usr/local/unixODBC,向ODBC添加SQLServer驱动
# vi etc/odbcinst.ini
写入如下内容:
[ODBC]
Trace = Yes
TraceFile = /tmp/sql.log
ForceTrace = Yes
Pooling = No
[SQLSERVER]
Description = SQLSERVER
Driver = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtds.so
UsageCount = 1
CPTimeout = 5
CPReuse = 5
FileUsage = 1
添加DSN
# vi etc/odbc.ini
写入如下内容
[ejabberd]
Driver = SQLSERVER
Description = SQLSERVER
Server = 192.168.2.159
Database = ejabberd
Port = 1433
odbcinst.ini中的驱动名称,Database是数据库的名称
保存并退出。
测试ODBC的连接
# bin/isql -v ejabberd sa 111111
SQL>
SQL> quit
二、 ejabberd修改odbc文件
1. 安装ejabberd二进制包(略)
安装位置为/usr/local/ejabberd
2. 修改ejabberd的ODBC文件
进入/usr/local/ejabberd/conf目录
Vi odbc.ini
再次添加DSN信息:
[ejabberd]
Driver = SQLSERVER
Description = SQLSERVER
Server = 192.168.2.159
Database = ejabberd
Port = 1433
Vi odbcinst.ini
再次添加MSSQL的driver信息:
[ODBC]
Trace = Yes
TraceFile = /tmp/sql.log
ForceTrace = Yes
Pooling = No
[SQLSERVER]
Description = SQLSERVER
Driver = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtds.so
UsageCount = 1
CPTimeout = 5
CPReuse = 5
FileUsage = 1
注:用二进制安装的包,,Ejabberd包内置安装了一部分ODBC文件,但是包没有安装完全。
[root@ejabberd bin]# pwd
/usr/local/ejabberd/lib/odbc-2.10.3/priv/linux-x86/bin
[root@ejabberd bin]# ls
odbcserver
Ejabberd会调用此文件odbcserver,运行此文件会提示找不到libodbc.so.1
此时我们自己安装的unixODBC位于/usr/local/unixODBC下。
我们做一个软链接即可调用:
ln -s /usr/local/unixODBC/lib/libodbc.so.1 /usr/lib
三、 ejabberd修改配置文件
修改配置文件路径:/usr/local/ejabberd/conf/ejabberd.cfg
1. 验证修改
这个选项值的名字可能被误导, 因为 auth_method 名字用于通过ODBC以及通过原生MySQL接口访问关系数据库.
把{auth_method, internal}.注释掉。
{auth_method, [odbc]}.
2. 数据库连接
实际的数据库访问使用选项 odbc_server 来定义. 它的值通常用来定义我们是否想使用 ODBC, 或两个可用的原生接口之一。
{odbc_server, "DSN=ejabberd;UID=sa;PWD=111111"}.
3. 存储模块修改
以下几项,在原有基础上加上_odbc
mod_last_odbc、mod_offline_odbc、mod_privacy_odbc、mod_private_odbc、mod_pubsub_odbc、mod_roster_odbc、mod_vcard_odbc
mod_last_odbc: 最后连接日期和时间
mod_offline_odbc: 离线消息
mod_privacy_odbc: 用户黑名单规则
mod_private_odbc: 私有XML存储
mod_pubsub_odbc:发行-订阅
mod_roster_odbc:名册管理
mod_vcard_odbc:用户的VCARD
四、 MSSQL扩展架构
利用ejabberd-2.1.4.tar.gz源码包ODBC自带的mssql2005.sql文件,执行生成表和主键。
五、 其他配置
删除以前的数据库文件,进入/usr/local/ejabberd/database 目录,
删除ejabberd@localhost
新建一个管理员用户,首先./start启动ejabberd
ejabberdctl register admin ejabberd 111111 添加一个用户
将用户加入到管理员进行web管理
{acl, admin, {user, "admin", "ejabberd"}}.
{access, configure, [{allow, admin}]}.
注册用户正常可用。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.
