coredns mysql 扩展使用+readyset 试用
基于db 进行dns 记录的管理还是比较有用的,尤其在一些开发环境中,以下是一个使用
同时也会尝试集成readyset(但是木有成功,应该是mysql 编码兼容的问题)
添加&构建插件
方法比较简单,官方有比较完整的文档说明,主要就是修改plugin.cfg 文件,同时通过go get 获取插件,然后就是
go generate 以及 go build,为了方便我构建了一个容器镜像,可以直接使用dalongrong/coredns
环境准备
- docker-compose 文件
version: '3'
services:
coredns:
image: dalongrong/coredns
command: -conf=/opt/Corefile
volumes:
- ./Corefile:/opt/Corefile
ports:
- 53:53
- 53:53/udp
mysql:
image: mysql:8.0.32
command: --default-authentication-plugin=mysql_native_password --log-bin --binlog-format=ROW --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
- MYSQL_ROOT_PASSWORD=dalong
- MYSQL_DATABASE=coredns
ports:
- 3306:3306
# 包含了readyset 但是目前似乎是兼容问题没成功
readyset:
image: public.ecr.aws/readyset/readyset:beta-2023-01-18
command: --standalone --deployment=quickstart-mysql --database-type=mysql -upstream-db-url=mysql://root:dalong@mysql:3306/coredns --address=0.0.0.0:5433 --password=dalong --query-caching=explicit --db-dir=/state --allow-unauthenticated-connections
environment:
- DEPLOYMENT_ENV=quickstart_docker
- RS_API_KEY
ports:
- 5433:5433
volumes:
- ./readyset:/state
Corefile 配置文件
.:53 {
mysql {
dsn root:dalong@tcp(mysql:3306)/coredns?tls=skip-verify&autocommit=true
ttl 20
}
}
运行&准备
- 启动环境
docker-compose up -d
- 初始化数据表
CREATE TABLE `coredns_records` (
`id` INT NOT NULL AUTO_INCREMENT,
`zone` VARCHAR(255) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`ttl` INT DEFAULT NULL,
`content` TEXT,
`record_type` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`)
)
INSERT INTO coredns_records (zone, name, ttl, content, record_type) VALUES
('example.org.', 'foo', 30, '{"ip": "1.1.1.1"}', 'A'),
('example.org.', 'foo', '60', '{"ip": "1.1.1.0"}', 'A'),
('example.org.', 'foo', 30, '{"text": "hello"}', 'TXT'),
('example.org.', 'foo', 30, '{"host" : "foo.example.org.","priority" : 10}', 'MX');
- 查询效果
dig @127.0.0.1 A MX foo.example.org
说明
本来是想测试readyset的,但是碰到了兼容问题,基本就是没成功,错误信息如下,应该是编码兼容问题,readyset 的想法是很不错的,目前兼容性问题还是不少的,可能pg 协议会好点,后边尝试下
参考资料
https://docs.readyset.io/guides/quickstart/
https://github.com/readysettech/readyset
https://github.com/cloud66-oss/coredns_mysql
https://github.com/coredns/coredns
https://coredns.io/2017/07/25/compile-time-enabling-or-disabling-plugins/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2022-01-23 smithy aws 开源的方便开发语言无关服务SDK的idl
2022-01-23 Fluid Framework微软开源的构建实时分布式协作web 应用的框架
2022-01-23 modelmapper 简单智能的对象映射工具
2022-01-23 基于commons-discovery 开发简单的插件化java系统
2021-01-23 cube.js 动态schema 编译处理
2017-01-23 Automating CSS Regression Testing
2014-01-23 vertx.io 与nodejs 一个简单的性能比较