轻量级易安装数据库

huangapple go评论76阅读模式
英文:

Lightweight easy to install db

问题

我有一个小型的家庭费用管理应用,我在闲暇时间用Java开发。现在它已经可以使用了,我想要将它变成便携式的,这样我就可以将它传给朋友们(非开发人员)来尝试。

我已经成功将API和Web界面放入Docker容器中,但数据库有点棘手。目前我正在使用安装在我的机器上的MySQL。但我不希望用户安装和配置数据库。

我需要的是:

  • 免费使用
  • 自建部署(不希望用户担心他们的数据可能会被窃取)
  • 低容量和速度要求。这些数据相对较小。
  • 便携。最好不需要安装。或者通过无需参数的脚本进行安装。
  • 零维护。我不希望用户检查健康状况或安装补丁。
  • 持久性。内存中的数据库如果崩溃会丢失数据,这是不好的。
  • 由于我已经投资于Spring ORM,我更希望使用能与现有代码配合的解决方案。
英文:

I have small home expenses application, that I'm developing in my free time in Java.
Now that it is functional, I want to make it portable so I could pass it to friends (non-developers) to try out.

I managed to dockerize the api and the web ui, but the DB is a little tricky.
Currently I am using mysql, installed on my machine. But I don't want the user to install and configure a db.

What I need is:

  • Something free of charge
  • On prem (don't want the users to fear their data might be stolen)
  • Low volume and speed requirements. this data is relatively small.
  • Portable. Ideally no installation. Or installation by script with no arguments.
  • Zero maintenance. I don't want users to check health or install patches.
  • Persistency. On memory DB that will loose data if crushes is no good.
  • As I already invested in Spring ORM, I prefer something that will work with my existing code.

答案1

得分: 0

基本上你的选择有:

  1. 将 MySQL 数据库也 Docker 化(使用现有的镜像),可能还想使用 Docker Compose 同时启动数据库和应用。如果你的朋友已经安装了 Docker(似乎已经是你的应用要求的一部分),那这可能是最简单的方法。

  2. 使用另一个可以嵌入到你的应用中的数据库。例如:SQLite、Derby、H2。如果你的查询足够简单且“可移植”,这个方法也可以,但你至少需要重新检查所有查询,因为有时这些数据库的行为可能与 MySQL 不同。与第一种方法相比,你不需要运行另一个容器,也不需要使用 docker-compose,不过这也不是什么大问题,因为现在任何 Docker 安装中都包含了 Docker Compose。

  3. 在某个云服务中托管数据库(比如 AWS),然后从应用中连接到云上的数据库。这可能会比较慢(在这三种方法中应该是最慢的),但可以减轻你维护数据库的负担。当然,如果不同副本的应用需要访问不同的数据(每个用户在云上都有一个数据库副本),这个方法就不适用了。这也可能会有成本,因为你需要向云服务提供商支付费用。

总之,我建议你选择方案1,如果不行就选择方案2,而最差的选择在我看来是方案3。

英文:

Basically your options are:

  1. Dockerize also the mysql database (use a ready image) + you might want to use docker compose to start both the db and the app together. If your friends have docker (which seem to be a requirement of your application anyway already, then its probably the easiest approach).

  2. Use another databas which is embeddable into your application. Examples are: SQLLight, Derby, H2. If your queries are simple and "portable enough" this approach can work as well, but you'll have to at least re-check all your queries, since sometimes these DBs can behave different from MySql. As opposed to the approach 1 you won't need another container to run and won't use docker-compose, which is not a big deal anyway, since docker compose is a part of any docker installation these days.

  3. Host a database in some cloud (like AWS) and connect to the cloud from your application. This will probably be slow (should be the slowest approach of these 3) but will save you from the burden of maintaining the database. Of course it won't work if different copies of your app should access the different data (then you'll have to maintain a database per user in the cloud). This also can be costy since you'll have to pay to the cloud provider.

To wrap up I suggest you going with solution 1, if you can't go with 2, and the worst is solution 3 IMO.

huangapple
  • 本文由 发表于 2020年9月6日 13:41:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/63761072.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定