2

コンテキスト: Spring MVC プロジェクトに取り組んでおり、Hibernate を使用して、注釈を使用してクラスからデータベース スキーマを生成しています。ローカル マシンで実行されている MySQL サーバーを使用します。ホスティングを取得して、ウェブサイトを公開することを目指しています。

  1. その場合、ホスティング プロバイダーの mySQL サーバーを使用してデータベースを実行する必要がありますか?
  2. 長所と短所は何ですか?彼らは通常、データベースのバックアップを行いますか、それとも自分でそれを行い、それを自分のマシンに保存する価値がありますか?
  3. サーバーを再起動するとデータが失われますか?

前もって感謝します。私はこれに慣れていないので、不合理に聞こえる場合は遠慮なく質問をモデレートしてください。

4

2 に答える 2

1

これの多くは、サイトをホストする方法によって異なります。VMWare の人々が提供する無料のサービスとしてのプラットフォーム (PAAS) である CloudFoundry を検討することをお勧めします。Spring を使用して休止状態をセットアップする場合、Cloudfoundry はアプリケーションを提供する MySql サービスに自動的にフックできます。

いずれにせよ、マシンの静的 IP を確立してデータベース サービスを公開しない限り、データベースはホスト サーバー上に存在する可能性が高くなります。その時点で、独自のサイトをホストすることもできます。

データが保存される場所は、ホストのタイプによって異なります。たとえば、PAAS を使用している場合、サーバー上のデータベースを保存する場所を選択します。それはあなたに透明になります。専用サーバーを使用する場合は、ほとんどの場合、データベース ソフトウェアをインストールする必要があります。

Web サイトをサポートするほとんどのデータベースは、永続ストレージを提供するか、そのように構成する必要があります。再起動後に MySql データベースのデータが失われる理由はわかりませんが、そのままではそうすべきではありません。Hibernate を使用して DDL を自動生成している場合、再起動するたびにデータが吹き飛ばされていることがわかりました。この構成から離れたいと思うでしょう。

于 2013-05-24T20:55:38.793 に答える
1

1 Do I use mySQL server of a hosting provider in that case to run my database?

Yes. In your application you only change the JDBC connection URL and credentials.

There are other details about the level of service that you want for the database: security, backup, up time. But that depends on your hosting provider and your application needs.

2 Is it stored somewhere on the server?

Depends on how your hosting provider hosts the database. The usual approach is to have the web server in one machine and the database in another machine inside the VPN.

From the Hibernate configuration perspective, is just changing the JDBC url. But there are other quality attributes that will be affected by your provider infrastructure, and that depends on the level of service that you contract.

3 Should I declare somehow that data must be stored f.e. in a separate file on server?

Probably not. If your provider gives you a database service, what you choose is the level of service: storage, up-time... they take care of providing the infrastructure. And yes usually they do that using a separate machine for the database.

4 Am I going to loose data in case of server reboot? (As f.e. I do when I restart server on my local machine)

Depends on the kind of hosting that you are using. BTW Why you loose the data on reboot in your local machine? Probably you are re-creating the database each time (check your Hibernate usage). Because the main feature of any database is well... persistent storage :)

If you host your application in a virtual machine and you install MySQL in that VM... yes you are going to loose data on reboot. Because in this kind of hosting (like Amazon EC2) you host a VM for CPU execution, and all the disk data is transient. If you want persistent data you have to use a database located in another machine (this is done in this way for architectural reasons, and cloud providers like Amazon gives you also different storage services).

But if the database is provided, no.. a persistent database is the usual level of service that you should expect from a provider.

于 2013-05-24T21:33:34.233 に答える