postgresql

Ceph 知识摘录(核心组件、概要)

六眼飞鱼酱① 提交于 2021-02-11 20:47:27
基本概念 一、Rados 本身是一个完整的对象存储系统,Ceph所有的存储功能都是基于Rados实现。 二、Mon M o n负责监控集群管理元数据表 。同时维护着Ceph集群中的各种Map图,比如OSD Map、Monitor Map、PG Map和CRUSH Map,这些Map统称为Cluster Map,Cluster Map是RADOS的关键数据结构,管理集群中的所有成员、关系、属性等信息以及数据的分发,比如:客户端向OSD发送读写请求之前,需要从MON中拿到最新的集群表,利用CRUSH算法计算出来 数据存储位置 后,直接将读写请求发送至对应的OSD。 三、OSD OSD 负责处理客户端读写请求,功能(存储数据,处理数据复制、恢复、再均衡,与其它OSD间进行心跳检查等),并将一些变化情况上报给Ceph Monitor。 四、RGW RGW最直接的理解就 是一个协议转换层,把从上层应用符合S3或Swift协议【三级存储:Account/Bucket/Object(账户/桶/对象)】的请求转换成rados的请求, 将数据保存在rados集群中。rgw是一个监听RESTfulAPI访问的后台进程,s3 API和Swift APl使用同一个命名空间,即共享同一个命名空间;所以,你可以用其中一个接口写入数据而又用另外一个接口读出数据。 Frontend: 与客户端使用HTTP

Select only partial result but get total number of rows

南楼画角 提交于 2021-02-11 18:22:43
问题 I got stuck on SQL subquery selection. Right now, I have a table products: id | name | description ----+-------+---------------------- 6 | 123 | this is a + | | girl. 7 | 124 | this is a + | | girl. 8 | 125 | this is a + | | girl. 9 | 126 | this is a + | | girl. 10 | 127 | this is a + | | girl. 11 | 127 | this is a + | | girl. Isn't this? 12 | 345 | this is a cute slair 13 | ggg | this is a + | | girl 14 | shout | this is a monster 15 | haha | they are cute 16 | 123 | this is cute What I want

Function returning rowset with dynamic column name

佐手、 提交于 2021-02-11 18:19:37
问题 I have a generic key/value table that I would like to preprocess in a function to filter by the key, and then name the value according to the key. The table is like this where id points into another table (but really is don't care for the purposes of this question): CREATE TABLE keyed_values (id INTEGER, key TEXT, value TEXT, PRIMARY KEY(id, key)); INSERT INTO keyed_values(id, key, value) VALUES (1, 'x', 'Value for x for 1'), (1, 'y', 'Value for y for 1'), (2, 'x', 'Value for x for 2'), (2,

Function returning rowset with dynamic column name

无人久伴 提交于 2021-02-11 18:19:22
问题 I have a generic key/value table that I would like to preprocess in a function to filter by the key, and then name the value according to the key. The table is like this where id points into another table (but really is don't care for the purposes of this question): CREATE TABLE keyed_values (id INTEGER, key TEXT, value TEXT, PRIMARY KEY(id, key)); INSERT INTO keyed_values(id, key, value) VALUES (1, 'x', 'Value for x for 1'), (1, 'y', 'Value for y for 1'), (2, 'x', 'Value for x for 2'), (2,

psql import .csv - Double Quoted fields and Single Double Quote Values

≡放荡痞女 提交于 2021-02-11 17:39:37
问题 Hello Stack Overflowers, Weird question. I am having trouble importing a .csv file using psql command line arguments... The .csv is comma delimited and there are double quotes around cells/fields that have commas in them. I run into an issue where one of the cells/fields has a single double-quote that is being used for inches. So in the example below, it thinks the bottom two rows are all one cell/field. I can't seem to find a way to make this import correctly. I am hoping to not have to make

PostgreSQL with SQLalchemy database is not found

梦想与她 提交于 2021-02-11 17:21:45
问题 I am using the following code to create postgresql database using sqlalchemy: engine=create_engine('postgresql+psycopg2://postgres@localhost/testData') Base.metadata.create_all(engine) But it gives me the following error even though I manually created the database in psql: File "/home/ubuntu/venve/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 376, in connect return self.dbapi.connect(*cargs, **cparams) File "/home/ubuntu/venve/local/lib/python2.7/site-packages/psycopg2

How to write an UPDATE Query for multiple tables in Common Table Expressions (CTE's) format?

守給你的承諾、 提交于 2021-02-11 16:52:42
问题 Ho do I rewrite the following UPDATE statement into a Common Table Expressions (CTE's) format? DB::statement('UPDATE taggables, threads SET taggables.created_at = threads.created_at, taggables.updated_at = threads.updated_at WHERE taggables.thread_id = threads.id'); 回答1: I don't really see the point for using a CTE here. Since it seems like your purpose is to update taggables from threads , I would suggest simply using Postgres' update/join syntax, which goes like: update taggables ta set

How to write an UPDATE Query for multiple tables in Common Table Expressions (CTE's) format?

℡╲_俬逩灬. 提交于 2021-02-11 16:52:18
问题 Ho do I rewrite the following UPDATE statement into a Common Table Expressions (CTE's) format? DB::statement('UPDATE taggables, threads SET taggables.created_at = threads.created_at, taggables.updated_at = threads.updated_at WHERE taggables.thread_id = threads.id'); 回答1: I don't really see the point for using a CTE here. Since it seems like your purpose is to update taggables from threads , I would suggest simply using Postgres' update/join syntax, which goes like: update taggables ta set

Convert JSON string to JSONB

守給你的承諾、 提交于 2021-02-11 16:41:49
问题 I have a table with jsonb field. Some of the rows are an array of objects, but some of the others are string. I want to convert red rows to array of objects. My table structure: How I can do this in PostgreSQL ? 回答1: Following SQL should do the trick: update your_table_name set content = (content#>>'{}')::jsonb where jsonb_typeof(content)='string'; Reference: https://www.postgresql.org/docs/10/functions-json.html 来源: https://stackoverflow.com/questions/60824247/convert-json-string-to-jsonb

Creating a PostgreSQL database backup via psql on macOS

白昼怎懂夜的黑 提交于 2021-02-11 16:00:36
问题 I'm trying to create a PostgreSQL local db dump via Terminal on macOS using psql . My next step is to upload/import my entire db to my Amazon RDS PostgreSQL db instance. Can anyone help me with the Terminal command to create a dump file 'mydbdump.sql' for my 'mydb' database. I've sorted through existing questions, searched forums (tried similar Stack Overflow question), even Amazon RDS docs (above, link), and am having no luck with the commands from any of these docs. What am I doing wrong?