内存数据库中的PostgreSQL [英] PostgreSQL In Memory Database

查看:160
本文介绍了内存数据库中的PostgreSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从内存中运行我的PostgreSQL数据库服务器.原因是在新服务器上,我有24 GB的内存,几乎没有使用任何内存.

I want to run my PostgreSQL database server from memory. The reason is that on my new server, I have 24 GB of memory, and hardly any of it is used.

我知道我可以运行以下命令制作一个虚拟磁盘:

I know I can run this command to make a ramdisk:

mdmfs -s 1024m md2 /mnt

从理论上讲,我可以让PostgreSQL将其数据存储在那里.但是,这样做的问题是,如果服务器崩溃或重新启动,则数据将消失.

And I could theoretically have PostgreSQL store its data there. But the problem with this is that if the server crashes or reboots, the data will be gone.

基本上,我希望数据库始终加载到内存中,这样就不必去硬盘驱动器读取每条记录,因为我有TONS内存,并且内存比硬盘驱动器快.

Basically, I want the database to be loaded in memory at all times so that it does not have to go to the hard disk drive to read every record, since I have TONS of memory and since memory is faster than hard disk drives.

在将PostgreSQL写入磁盘的同时,是否有办法做到这一点,以防服务器宕机而不会丢失任何数据?还是有一种方法可以将所有数据缓存在内存中?

Is there a way to do this while also having PostgreSQL write to disk so I don't lose any data in case the server goes down? Or is there a way to cache all data in memory?

推荐答案

我现在正在使用异步的流复制.这意味着我的MASTER可以在内存中全部运行,而使用传统磁盘的单独SLAVE实例可以运行.

I'm now using streaming replication which is async. This means my MASTER could be running all in memory, with the separate SLAVE instance using traditional disk.

计算机重新启动将涉及停止SLAVE,将postgresql数据复制回ramdisk,然后重新启动MASTER,然后重新启动SLAVE.与REDIS之类的东西相比,这将是一个有趣的可能性,但是具有冗余/hotstandby/backup/sql/rich toolset等优点.

A machine restart would involve stopping the SLAVE, copying the postgresql data back into ramdisk and then restarting the MASTER followed by the SLAVE. This would be an interesting possibility which compares well with something like REDIS, but with the advantage of redundancy / hotstandby / backup / sql / rich toolset etc.

这篇关于内存数据库中的PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆