本文介绍 TeamSpeak 服务器端搭建方法 ,TeamSpeak (简称TS) 是一套专有的VoIP软件,使用者可以用耳机和麦克风,通过客户端软件连线到指定的服务器,与在服务器内频道的其他使用者进行通话。是一种很像电话会议的方式。 通常 TeamSpeak 的使用者大多为多人连线游戏的玩家,与同队伍的玩家进行通讯。在游戏的对战方面,语音对话通讯具有竞争优势。
如果您想找一个最快最简单的搭建方法,请参考 使用 Docker 搭建 TeamSpeak 服务器。除此之外的更多情况下,我更推荐按照本文来进行搭建。
请务必从官网下载最新版本服务端,否则可能会出现无法连接至服务器的情况
TeamSpeak 官网 teamspeak.com
安装前准备
- 首先需要一台腾讯轻量应用服务器购买
为了保证系统的安全,不要使用 root 账户安装并配置TS服务器
执行一下系统更新操作:
代码语言:txt复制apt update && apt full-upgrade -y
apt install curl vim wget git sudo unzip apt-transport-https screen ca-certificates dialog softw
新建一个用户
代码语言:txt复制useradd teamspeak
切换至 /opt录下
代码语言:txt复制cd /opt
复制并解压TS服务器端文件
代码语言:txt复制wget https://files.teamspeak-services.com/releases/server/3.12.0/teamspeak3-server_linux_amd64-3.12.0.tar.bz2 && tar -xjvf teamspeak3-server_linux_amd64-3.12.0.tar.bz2 && rm teamspeak3-server_linux_amd64-3.12.0.tar.bz2
赋予刚刚新建的用户权限,并进入该目录
代码语言:txt复制chown -R teamspeak:teamspeak teamspeak3-server_linux_amd64 && cd /opt/teamspeak3-server_linux_amd64 && su teamspeak
同意许可条款
代码语言:txt复制touch .ts3server_license_accepted
您可以选择以下任意一种搭建方式进行搭建,若您不理解这些方式的区别,请直接使用第一种搭建方式,即使用 SQLite 搭建
数据库配置
方式一: 使用 SQLite 搭建
因 TeamSpeak 默认使用 SQLite, 所以直接执行以下操作即可自动配置,并启动服务器
代码语言:txt复制./ts3server_startscript.sh start
注意保存密钥及 ServerQuery 管理员账户和密码
方法二:使用 MySQL/MariaDB 数据库搭建
- 首先使用 root 登录 MySQL/MariaDB
mysql -u root -p
- 会提示输入密码,输入密码登陆后,创建一个名为 teamspeak 的数据库
代码语言:txt复制数据库名,用户名和密码请自行修改,此处以数据库名
teamspeak_database
,用户名teamspeak_user
及密码teamspeak_password
为例
CREATE DATABASE teamspeak_database DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
- 创建一个叫做
teamspeak_user
的用户,使用强大的密码并且赋予teamspeak_database
数据库权限
由于手机端的流行,我们已经不再使用 utf-8
编码,而改用 utf8mb4
这样我们就可以在 MySQL 数据库里储存 emoji 表情了。你甚至可以尝试使用 emoji 作为用户名或者密码。
GRANT ALL ON teamspeak_database.* TO 'teamspeak_user'@'localhost' IDENTIFIED BY 'teamspeak_password';
这里请将密码
teamspeak_password
改成你要设置的强大的没人能猜出来的随机的密码
终端会提示类似 Query OK, 0 rows affected, 1 warning 不用去管它
- 刷新权限,没问题就可以退出结束安装了
FLUSH PRIVILEGES;
EXIT;
进行后续步骤前,首先确保您已经安装 MySQL/MariaDB, 且已经创建好数据库
- 创建
ts3server.ini
文件,以启用数据库插件
代码语言:txt复制若您已经使用的是 MySQL 数据库, 请将
dbpluginparameter=ts3db_mariadb.ini
部分修改为dbpluginparameter=ts3db_mysql.ini
cat > ts3server.ini << EOF
dbplugin=ts3db_mariadb
dbpluginparameter=ts3db_mariadb.ini
dbsqlpath=sql/
dbsqlcreatepath=create_mariadb/
dbconnections=10
- 新建
ts3db_mariadb.ini
文件并输入如下内容
代码语言:txt复制若您已经使用的是 MySQL 数据库, 请创建
ts3db_mysql.ini
, 不要创建ts3db_mariadb.ini
文件
[config]
server='localhost'
port='3306'
username='teamspeak_user'
password='teamspeak_password'
database='teamspeak_database'
将 数据库名
teamspeak_database
,用户名teamspeak_user
及密码teamspeak_password
部分修改为您自己数据库的信息
- 将 redist 目录下的
libmariadb.so.2
文件拷贝至当前目录下
cp redist/libmariadb.so.2 ./
执行以下操作即可启动服务器
代码语言:txt复制./ts3server_startscript.sh start inifile=ts3server.ini
注意保存密钥及 ServerQuery 管理员账户和密码
设置自启动
创建并编辑文件 /lib/systemd/system/teamspeak.service
代码语言:txt复制此步骤需要root权限
[Unit]
Description=Teamspeak, The most superior online voice communication solution.
Wants=network-online.target
After=syslog.target network.target network-online.target
[Service]
User=teamspeak
Group=teamspeak
WorkingDirectory=/opt/teamspeak3-server_linux_amd64/
ExecStart=/opt/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
ExecStop=/opt/teamspeak3-server_linux_amd64/ts3server_startscript.sh stop
PIDFile=/opt/teamspeak3-server_linux_amd64/ts3server.pid
Type=forking
[Install]
WantedBy=multi-user.target
代码语言:txt复制若您是使用 MySQL 或 MariaDB 数据库方式搭建的话,请将
ExecStart=/opt/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
修改为
代码语言:txt复制ExecStart=/opt/teamspeak3-server_linux_amd64/ts3server_startscript.sh start inifile=ts3server.ini
重新加载 systemd : systemctl daemon-reload
开启自启动(可选): systemctl enable teamspeak.service
启动 TeamSpeak : systemctl start teamspeak.service
停止 TeamSpeak : systemctl stop teamspeak.service
重启 TeamSpeak : systemctl restart teamspeak.service
TSDNS设置方法 (可选)
进入tsdns文件夹中,并创建的 tsdns_settings.ini
文件,
nano tsdns_settings.ini
配置的格式为 DOMAIN=IP:PORT
,比如:
example.com=1.1.1.1:9987
即代表将example.com
和其他任何以example.com
为后缀的域名,解析到地址为1.1.1.1:9987
的ts服务器- 包括 example.com, abc.example.com, abc.def.ghi.example.com …
- *.example.com=2.2.2.2:9987
即代表将任何以符合
*.example.com格式的域名,解析到地址为1.1.1.1:9987的ts服务器
- 包括 abc.example.com, abc.example.com, 123.example.com …
- PORT 也可以调用变量, 如
abc.example.com=1.2.3.4:$PORT
- *=1.2.3.4:10000
在这种情况下,它充当向后兼容机制, 可以对没有使用新 TSDNS 名称进行连接的人,连接至当前服务器.
- 比如一名用户连接至
test.example.com:20000
,则该用户会被自动转至1.2.3.4:10000
的服务器地址 - IPv6 格式为
example.com=2001:0db8::1:9987
example.com=[2001:0db8::1]:9987 1.1.1.1:9987
域名 SRV 记录添加格式
此处以给 example.com
域名配置 TSDNS 为例, 假如 tsdns 的
类别 | 记录值 |
---|---|
名称 | _tsdns._tcp.example.com |
Priority | 1 |
Weight | 0 |
Port | 41144 |
Address | tsdns.example.com |
此处以 TSDNS 所在服务器地址为 tsdns.example.com 为例,
Address
部分请务必填写为域名格式。
类别 | 记录值 |
---|---|
名称 | _ts3._udp.example.com |
Priority | 1 |
Weight | 0 |
Port | 9987 |
Address | teamspeak.example.com |
Port
为 TeamSpeak 服务器地址端口,Address
为 TeamSpeak 服务器地址
接下载, 运行tsdnsserver程序即可,现在连接到TS服务器,可以看到已经显示成功
可通过此代码来后台运行
代码语言:txt复制screen -AmdS tsdns ./tsdnsserver
添加至开机自启动 (可选)
通过 crontab 来实现开机启动
代码语言:txt复制crontab -e
在文件中添加
代码语言:txt复制@reboot /opt/teamspeak3-server_linux_amd64/tsdns/tsdnsserver
关闭编辑器并保存。
接下来,你可以通过 crontab -l
来确认是否添加成功即可。
许可证介绍
2018-09-11 Non-Profit License (NPL) 现在申请接口已经关闭,许可证相关信息也发生了改变
2019-03-23 许可证信息前不久又发生了改变,当前许可证状态
2019-10-06 官方于 2019-05-13
[1] 上线了 Sponsorship License,可供游戏俱乐部,教育机构,视频创作者使用,详细说明可在此处查看 https://teamspeak.com/sponsorship/ (Thanks to @xcgjack)
TeamSpeak 端口
TeamSpeak 默认情况下, 服务器端需要下表中的端口[2]
端口 | 协议 | 说明 |
---|---|---|
9987 | UDP | 默认语音服务器端口 |
10011 | TCP | ServerQuery raw 端口 |
10022 | TCP | ServerQuery SSH 端口(需要 3.3.0 以上版本服务端) |
10080 | TCP | ServerQuery HTTP 端口(需要 3.12.0 以上版本服务端) |
10443 | TCP | ServerQuery HTTPS 端口(需要 3.12.0 以上版本服务端) |
30033 | TCP | 文件传输端口 |
41144 | TCP | TSDNS |
服务端的所有端口都可自由更改
TeamSpeak 3 服务器还会与下方的地址进行连接[3]
域名 | 协议 | 本地端口(服务器) | 远程端口 | 说明 |
---|---|---|---|---|
accounting.teamspeak.com | TCP | 1024-65535 | 2008 | 3.0.x 服务端版本 |
accounting2.teamspeak.com | TCP | 1024-65535 | 443 | 3.1.x 服务端版本 |
ts3services.teamspeak.com | TCP | 1024-65535 | 443 | 3.1.x 服务端版本 |
weblist.teamspeak.com | UDP | 2011-2110 | 2010 | 全部服务端版本 |
至此 TeamSpeak 服务器端的搭建方法到此结束。
我们的 TeamSpeak 服务器列表 服务器列表
ServerQuery 相关部分
其实我对于 ServerQuery 的使用也是比较少,这次更新了通过 API 调用 ServerQuery 的方法之后,感觉之后可能我会拿他做一些比较好玩的事情吧,目前对于 HTTP/HTTPS 方式调用的官方说明还是比较少啦,但是官方有表示会写一个完整的 web-query 文档[3],但是以 TeamSpeak 的工作效率来看,怕是要又要咕蛮久的了。
首先,如何启用 http 或者 https query 呢,在之前的版本中 SSH RAW 的方式都是默认启用的,但是这次以我目前的测试来看,默认是关闭的
启用 HTTP / HTTPS ServerQuery
在 ts3server.ini 文件中添加以下内容
启用 HTTP 连接
代码语言:txt复制默认端口为 10080,且默认情况下监听全部端口,可在此处自行修改
query_protocols=raw,ssh,http
query_http_ip=0.0.0.0,::
query_http_port=10080
如上所示填写后,会同时启用 raw,ssh,http
启用 HTTPS 连接
代码语言:txt复制默认端口为 10443,且默认情况下监听全部端口,可在此处自行修改
query_protocols=https
query_https_ip=0.0.0.0,::
query_https_port=10443
query_https_certificate_file=your_cert.pem
query_https_private_key_file=your_key.pem
此处为仅启用 HTTPS
对于 ts3server.ini 的完整说明我会在日后进行详细说明
Web-Query 调用 示例
代码语言:txt复制curl -H 'x-api-key: BAByFoiEXZfnSJyE6dbXFiW_nn_SdwkclpKNz9j' 'http://127.0.0.1:10080/gm?msg=Hello World'
{"status":{"code":0,"message":"ok"}}
curl -H 'x-api-key: BAByFoiEXZfnSJyE6dbXFiW_nn_SdwkclpKNz9j' 'http://127.0.0.1:10080/1/channellist?-topic&-icon'
{"body":[{"channel_icon_id":"0","channel_name":"Default Channel","channel_needed_subscribe_power":"0","channel_order":"0","channel_topic":"Default Channel has no topic","cid":"1","pid":"0","total_clients":"1"}],"status":{"code":0,"message":"ok"}}
参数和可与这些参数一起使用的命令
代码语言:txt复制{ "apikeyadd", { manage_scope, } },
{ "apikeydel", { manage_scope, } },
{ "apikeylist", { manage_scope, } },
{ "banadd", { manage_scope, write_scope, } },
{ "banclient", { manage_scope, write_scope, } },
{ "bandel", { manage_scope, write_scope, } },
{ "bandelall", { manage_scope, write_scope, } },
{ "banlist", { manage_scope, write_scope, read_scope, } },
{ "bindinglist", { manage_scope, read_scope } },
{ "channeladdperm", { manage_scope, } },
{ "channelclientaddperm", { manage_scope, } },
{ "channelclientdelperm", { manage_scope, } },
{ "channelclientpermlist", { manage_scope, write_scope, read_scope, } },
{ "channelcreate", { manage_scope, write_scope, } },
{ "channeldelete", { manage_scope, write_scope, } },
{ "channeldelperm", { manage_scope, } },
{ "channeledit", { manage_scope, write_scope, } },
{ "channelfind", { manage_scope, write_scope, read_scope, } },
{ "channelgroupadd", { manage_scope, write_scope, } },
{ "channelgroupaddperm", { manage_scope, } },
{ "channelgroupclientlist", { manage_scope, write_scope, read_scope, } },
{ "channelgroupcopy", { manage_scope, } },
{ "channelgroupdel", { manage_scope, } },
{ "channelgroupdelperm", { manage_scope, } },
{ "channelgrouplist", { manage_scope, write_scope, read_scope, } },
{ "channelgrouppermlist", { manage_scope, write_scope, read_scope, } },
{ "channelgrouprename", { manage_scope, } },
{ "channelinfo", { manage_scope, write_scope, read_scope, } },
{ "channellist", { manage_scope, write_scope, read_scope, } },
{ "channelmove", { manage_scope, write_scope, } },
{ "channelpermlist", { manage_scope, write_scope, read_scope, } },
{ "clientaddperm", { manage_scope, } },
{ "clientdbdelete", { manage_scope, write_scope, } },
{ "clientdbedit", { manage_scope, write_scope, } },
{ "clientdbfind", { manage_scope, write_scope, read_scope, } },
{ "clientdbinfo", { manage_scope, write_scope, read_scope, } },
{ "clientdblist", { manage_scope, write_scope, read_scope, } },
{ "clientdelperm", { manage_scope, } },
{ "clientedit", { manage_scope, write_scope, } },
{ "clientfind", { manage_scope, write_scope, read_scope, } },
{ "clientgetdbidfromuid", { manage_scope, write_scope, read_scope, } },
{ "clientgetids", { manage_scope, write_scope, read_scope, } },
{ "clientgetnamefromdbid", { manage_scope, write_scope, read_scope, } },
{ "clientgetnamefromuid", { manage_scope, write_scope, read_scope,} },
{ "clientgetuidfromclid", { manage_scope, write_scope, read_scope, } },
{ "clientinfo", { manage_scope, write_scope, read_scope, } },
{ "clientkick", { manage_scope, write_scope, } },
{ "clientlist", { manage_scope, write_scope, read_scope, } },
{ "clientmove", { manage_scope, write_scope, } },
{ "clientpermlist", { manage_scope, write_scope, read_scope, } },
{ "clientpoke", { manage_scope, write_scope, } },
{ "clientsetserverquerylogin", { manage_scope, write_scope, } },
{ "clientupdate", { manage_scope, write_scope, } },
{ "complainadd", { manage_scope, write_scope, } },
{ "complaindel", { manage_scope, write_scope, } },
{ "complaindelall", { manage_scope, write_scope, } },
{ "complainlist", { manage_scope, write_scope, read_scope, } },
{ "custominfo", { manage_scope, write_scope, read_scope, } },
{ "customsearch", { manage_scope, write_scope, read_scope, } },
{ "customset", { manage_scope, write_scope, } },
{ "customdelete", { manage_scope, write_scope, } },
{ "ftcreatedir", not_supported },
{ "ftdeletefile", not_supported },
{ "ftgetfileinfo", not_supported },
{ "ftgetfilelist", not_supported },
{ "ftinitdownload", not_supported },
{ "ftinitupload", not_supported },
{ "ftlist", not_supported },
{ "ftrenamefile", not_supported },
{ "ftstop", not_supported },
{ "gm", { manage_scope, } },
{ "help", { manage_scope, write_scope, read_scope, } },
{ "hostinfo", { manage_scope, write_scope, read_scope, } },
{ "instanceedit", { manage_scope, } },
{ "instanceinfo", { manage_scope, write_scope, read_scope, } },
{ "logadd", { manage_scope, write_scope, } },
{ "login", not_supported },
{ "logout", not_supported },
{ "logview", { manage_scope, write_scope, read_scope, } },
{ "messageadd", { manage_scope, write_scope, } },
{ "messagedel", { manage_scope, write_scope, } },
{ "messageget", { manage_scope, write_scope, read_scope, } },
{ "messagelist", { manage_scope, write_scope, read_scope, } },
{ "messageupdateflag", { manage_scope, write_scope, } },
{ "permfind", { manage_scope, write_scope, read_scope, } },
{ "permget", { manage_scope, write_scope, read_scope, } },
{ "permidgetbyname", { manage_scope, write_scope, read_scope, } },
{ "permissionlist", { manage_scope, write_scope, read_scope, } },
{ "permoverview", { manage_scope, write_scope, read_scope, } },
{ "permreset", { manage_scope, } },
{ "privilegekeyadd", { manage_scope, write_scope, } },
{ "privilegekeydelete", { manage_scope, write_scope, } },
{ "privilegekeylist", { manage_scope, write_scope, read_scope, } },
{ "privilegekeyuse", { manage_scope, write_scope, } },
{ "queryloginadd", { manage_scope, write_scope, } },
{ "querylogindel", { manage_scope, write_scope, } },
{ "queryloginlist", { manage_scope, write_scope, read_scope } },
{ "quit", not_supported },
{ "sendtextmessage", { manage_scope, write_scope, } },
{ "servercreate", { manage_scope, } },
{ "serverdelete", { manage_scope, } },
{ "serveredit", { manage_scope, write_scope, } },
{ "servergroupadd", { manage_scope, } },
{ "servergroupaddclient", { manage_scope, } },
{ "servergroupaddperm", { manage_scope, } },
{ "servergroupautoaddperm", { manage_scope, } },
{ "servergroupautodelperm", { manage_scope, } },
{ "servergroupclientlist", { manage_scope, } },
{ "servergroupcopy", { manage_scope, } },
{ "servergroupdel", { manage_scope, } },
{ "servergroupdelclient", { manage_scope, } },
{ "servergroupdelperm", { manage_scope, } },
{ "servergrouplist", { manage_scope, } },
{ "servergrouppermlist", { manage_scope, } },
{ "servergrouprename", { manage_scope, } },
{ "servergroupsbyclientid", { manage_scope, } },
{ "serveridgetbyport", { manage_scope, } },
{ "serverinfo", { manage_scope, } },
{ "serverlist", { manage_scope, } },
{ "servernotifyregister", not_supported },
{ "servernotifyunregister", not_supported },
{ "serverprocessstop", { manage_scope, } },
{ "serverrequestconnectioninfo", { manage_scope, write_scope, read_scope, } },
{ "serversnapshotcreate", { manage_scope, } },
{ "serversnapshotdeploy", { manage_scope, } },
{ "serverstart", { manage_scope, } },
{ "serverstop", { manage_scope, } },
{ "servertemppasswordadd", { manage_scope, write_scope, } },
{ "servertemppassworddel", { manage_scope, write_scope, } },
{ "servertemppasswordlist", { manage_scope, write_scope, read_scope, } },
{ "setclientchannelgroup", { manage_scope, write_scope, } },
{ "tokenadd", { manage_scope, write_scope, } },
{ "tokendelete", { manage_scope, write_scope, } },
{ "tokenlist", { manage_scope, write_scope, read_scope, } },
{ "tokenuse", { manage_scope, write_scope, } },
{ "use", not_supported },
{ "version", { manage_scope, write_scope, read_scope, } },
{ "whoami", { manage_scope, write_scope, read_scope, } },
参考链接
Teamspeak 3 Server Ports
Teamspeak 3 server TSDNS setup
Server address resolution and TSDNS changes with Client 3.1.x
Does TeamSpeak 3 support DNS SRV records?
TeamSpeak Server 3.12.0
- TeamSpeak Official Twitter
- What ports TeamSpeak 3 server use?
- TeamSpeak Server 3.12.0