热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

如何使用Plproxy设计分布式PostgreSQL数据库(二)

PostgreSQL的分布式数据库方案很多,如GridSQL,pgpool-ii,plproxy等。其中plproxy是skype开发的一个数据库组件.使用plproxy设计跨互联网部署还要考虑带宽的问题和应用是否要做本地缓存等问题,plproxy源代码对代理库的个数做了限制必须是2的次方,如果要

PostgreSQL的分布式数据库方案很多,如GridSQL,pgpool-ii,plproxy等。

其中plproxy是skype开发的一个数据库组件.

使用plproxy设计跨互联网部署还要考虑带宽的问题和应用是否要做本地缓存等问题,

plproxy源代码对代理库的个数做了限制必须是2的次方,如果要打破这个限制需要修改源代码.

以下是一个测试方案:

1. 安装postgres 8.3.3 , plproxy , libevent , pgbouncer ;

2. 配置数据库

配置pg_hba.conf , postgres.conf

创建表空间目录

创建role

创建表空间

创建数据库

创建schema

安装过程语言plproxy , plpgsql

3. 配置启用pgbouncer

4. 配置plproxy连接函数

5. 分区库(建表,函数)

6. 代理库(建表,函数)

7. 哈希分区函数

8. 测试.

9. 参考文档.

模拟环境构想(使用地区1 , 地区2 , 地区3 , 地区4 , 地区5目的是便于理解跨互联网的概念) :

1. 数据中心 ( 地区1 , 地区2 , 地区3 , 地区4 , 地区5 )

2. 数据库布局 :

地区1 : 分区库 ( sgap_testrole_0 , sgap_testrole_1 ) ; 代理库 ( sgap_plproxy_0 )

地区2 : 分区库 ( bj_testrole_0 , bj_testrole_1 ) ; 代理库 ( bj_plproxy_0 )

地区3 : 分区库 ( sh_testrole_0 , sh_testrole_1 ) ; 代理库 ( sh_plproxy_0 )

地区4 : 分区库 ( gz_testrole_0 , gz_testrole_1 ) ; 代理库 ( gz_plproxy_0 )

地区5 : 分区库 ( hz_testrole_0 , hz_testrole_1 ) ; 代理库 ( hz_plproxy_0 )

设计规范 :

1. role_name规划

分区库 ( 考虑到程序设计的方便,业务库统一使用testrole角色名,密码配置完全相同 )

代理库 ( 所有分区库统一使用与业务库同名角色名,便于管理, 密码配置完全相同 )

权限 nosuperuser nocreatedb nocreaterole noinherit login

2. schema设计 :

分区库schema设计 ( 所有业务数据放到testrole schema下 )

代理库schema设计 ( 创建一个和业务库同名的schema , 创建一个plproxy schema)

3. 集群组划分 :

all — 包含了所有的分区库

dbname=sgap_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=sgap_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=bj_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=bj_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=sh_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=sh_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=gz_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=gz_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

? dbname=hz_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

? dbname=hz_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

plproxy_all  ? 包含了所有的代理库

dbname=sgap_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=bj_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=sh_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=gz_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

? dbname=hz_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

sgap_testrole_all — 包含了当地的所有分区库

dbname=sgap_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

dbname=sgap_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601

bj_testrole_all

sh_testrole_all

gz_testrole_all

hz_testrole_all

sgap_testrole_0

sgap_testrole_1

bj_testrole_0

bj_testrole_1

sh_testrole_0

sh_testrole_1

gz_testrole_0

gz_testrole_1

hz_testrole_0

hz_testrole_1

4. 表名设计 :

记录分析列的表名:

? pk_tbl_test : partition_key tbl_test ;

5. 函数名 :

前缀设计 (?prefix缩写) :

Clust_all <==> ca_

Cluster_plproxy_all <==> cpa_

Cluster_plproxy <==> cp_

Cluster_local_all <==> cla_

后缀设计 (?suffix缩写) :

Select <==> sel

Insert <==> ins

Update <==> up

Delete <==> del

Insert + update + delete <==> iud

嵌入名(?midfix缩写) : 如表名嵌入

示例:

ca_tbl_test_sel : 解析 cluster ‘all’ , select , tbl_test ;

ca_iud : 解析 cluster ‘all’ , insert & update & delete ; — 无表名一般指所有表通用此函数 ;

cpa_iud : 解析 cluster ‘plproxy_all’ , insert & update & delete ; — 有表名一般指每个表都得建此函数 ;

5. 数据库命名规范 :

$LOCALIZATION_$NAME_$ID

细节 :

1. 安装postgres 8.3.3 , plproxy , libevent , pgbouncer ;

? 参考相关文档 .

? 值得注意的是libevent安装好后,继续安装pgbouncer需要配置LD_LIBRARY_PATH使之能找到对应的so文件.

2. 配置数据库

1. 配置pg_hba.conf , postgres.conf

host all all 0.0.0.0/0 md5

listen_addresses = ‘*’

2. 创建表空间目录

su ? postgres

mkdir $PGDATA/tbs_sgap_testrole_0_def

mkdir $PGDATA/tbs_sgap_testrole_1_def

mkdir $PGDATA/tbs_sh_testrole_0_def

mkdir $PGDATA/tbs_sh_testrole_1_def

mkdir $PGDATA/tbs_bj_testrole_0_def

mkdir $PGDATA/tbs_bj_testrole_1_def

mkdir $PGDATA/tbs_gz_testrole_0_def

mkdir $PGDATA/tbs_gz_testrole_1_def

mkdir $PGDATA/tbs_hz_testrole_0_def

mkdir $PGDATA/tbs_hz_testrole_1_def

mkdir $PGDATA/tbs_sgap_plproxy_0_def

mkdir $PGDATA/tbs_bj_plproxy_0_def

mkdir $PGDATA/tbs_sh_plproxy_0_def

mkdir $PGDATA/tbs_gz_plproxy_0_def

mkdir $PGDATA/tbs_hz_plproxy_0_def

3. 创建role ( 分区库 , 代理库 )

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’ ;

4. 创建表空间

create tablespace tbs_sgap_testrole_0 owner testrole location ‘/database/pgdata/tbs_sgap_testrole_0_def’;

create tablespace tbs_bj_testrole_0 owner testrole location ‘/database/pgdata/tbs_bj_testrole_0_def’;

create tablespace tbs_sh_testrole_0 owner testrole location ‘/database/pgdata/tbs_sh_testrole_0_def’;

create tablespace tbs_gz_testrole_0 owner testrole location ‘/database/pgdata/tbs_gz_testrole_0_def’;

create tablespace tbs_hz_testrole_0 owner testrole location ‘/database/pgdata/tbs_hz_testrole_0_def’;

create tablespace tbs_sgap_testrole_1 owner testrole location ‘/database/pgdata/tbs_sgap_testrole_1_def’;

create tablespace tbs_bj_testrole_1 owner testrole location ‘/database/pgdata/tbs_bj_testrole_1_def’;

create tablespace tbs_sh_testrole_1 owner testrole location ‘/database/pgdata/tbs_sh_testrole_1_def’;

create tablespace tbs_gz_testrole_1 owner testrole location ‘/database/pgdata/tbs_gz_testrole_1_def’;

create tablespace tbs_hz_testrole_1 owner testrole location ‘/database/pgdata/tbs_hz_testrole_1_def’;

create tablespace tbs_sgap_plproxy_0 owner testrole location ‘/database/pgdata/tbs_sgap_plproxy_0_def’;

create tablespace tbs_bj_plproxy_0 owner testrole location ‘/database/pgdata/tbs_bj_plproxy_0_def’;

create tablespace tbs_sh_plproxy_0 owner testrole location ‘/database/pgdata/tbs_sh_plproxy_0_def’;

create tablespace tbs_gz_plproxy_0 owner testrole location ‘/database/pgdata/tbs_gz_plproxy_0_def’;

create tablespace tbs_hz_plproxy_0 owner testrole location ‘/database/pgdata/tbs_hz_plproxy_0_def’;

5. 创建数据库

create database sgap_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sgap_testrole_0;

create database sgap_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sgap_testrole_1;

create database sgap_plproxy_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sgap_plproxy_0;

create database bj_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_bj_testrole_0;

create database bj_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_bj_testrole_1;

create database bj_plproxy_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_bj_plproxy_0;

create database sh_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sh_testrole_0;

create database sh_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sh_testrole_1;

create database sh_plproxy_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sh_plproxy_0;

create database gz_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_gz_testrole_0;

create database gz_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_gz_testrole_1;

create database gz_plproxy_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_gz_plproxy_0;

create database hz_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_hz_testrole_0;

create database hz_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_hz_testrole_0;

create database hz_plproxy_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_hz_plproxy_0;

6. 创建schema ( partition db ==> testrole ; plproxy db ==> testrole + plproxy )

create schema testrole authorization testrole ;

create schema plproxy authorization testrole ;

7. 安装过程语言( partition db ==> plpgsql ; plproxy db ==> plpgsql + plproxy )

? plproxy ; ( psql PLPROXY_DB_NAME postgres -f $PGHOME/share/contrib/plproxy.sql )

? psql sgap_plproxy_0 postgres -f /app/pgsql/share/contrib/plproxy.sql

? psql bj_plproxy_0 postgres -f /app/pgsql/share/contrib/plproxy.sql

? psql sh_plproxy_0 postgres -f /app/pgsql/share/contrib/plproxy.sql

? psql gz_plproxy_0 postgres -f /app/pgsql/share/contrib/plproxy.sql

? psql hz_plproxy_0 postgres -f /app/pgsql/share/contrib/plproxy.sql

create language plpgsql ;

3. 配置启用pgbouncer

1. 创建日志目录 , 配置文件 , 用户密码文件目录

? 日志目录

su ? root

mkdir -p /var/applog/pgbouncerlog

chown -R postgres:postgres /var/applog/pgbouncerlog

? 配置文件目录,注意权限管理

su ? postgres

mkdir ~/config

chmod -R 700 ~/config

? 配置文件

vi ~/config/pgbouncer.ini

[databases]

sgap_testrole_0 = host=xxx.xxx.150.88 dbname=sgap_testrole_0 port=1921

sgap_testrole_1 = host=xxx.xxx.150.88 dbname=sgap_testrole_1 port=1921

bj_testrole_0 = host=xxx.xxx.150.88 dbname=bj_testrole_0 port=1921

bj_testrole_1 = host=xxx.xxx.150.88 dbname=bj_testrole_1 port=1921

sh_testrole_0 = host=xxx.xxx.150.88 dbname=sh_testrole_0 port=1921

sh_testrole_1 = host=xxx.xxx.150.88 dbname=sh_testrole_1 port=1921

gz_testrole_0 = host=xxx.xxx.150.88 dbname=gz_testrole_0 port=1921

gz_testrole_1 = host=xxx.xxx.150.88 dbname=gz_testrole_1 port=1921

hz_testrole_0 = host=xxx.xxx.150.88 dbname=hz_testrole_0 port=1921

hz_testrole_1 = host=xxx.xxx.150.88 dbname=hz_testrole_1 port=1921

sgap_plproxy_0 = host=xxx.xxx.150.88 dbname=sgap_plproxy_0 port=1921

bj_plproxy_0 = host=xxx.xxx.150.88 dbname=bj_plproxy_0 port=1921

sh_plproxy_0 = host=xxx.xxx.150.88 dbname=sh_plproxy_0 port=1921

gz_plproxy_0 = host=xxx.xxx.150.88 dbname=gz_plproxy_0 port=1921

hz_plproxy_0 = host=xxx.xxx.150.88 dbname=hz_plproxy_0 port=1921

[pgbouncer]

pool_mode = statement

listen_port = 9601

listen_addr = *

auth_type = md5

auth_file = /home/postgres/config/users.txt

logfile = /var/applog/pgbouncerlog/pgbouncer.log

pidfile = /var/applog/pgbouncerlog/pgbouncer.pid

admin_users = pgbouncer_admin

stats_users = pgbouncer_guest

? 密码文件

vi ~/config/users.txt

“testrole” “testrole”

“pgbouncer_admin” “admin”

“pgbouncer_guest” “guest”

#and all other database role&password

4. 配置plproxy连接函数

? 获取集群组配置

CREATE OR REPLACE FUNCTION plproxy.get_cluster_partitions(cluster_name text)

RETURNS SETOF text AS $$

BEGIN

IF cluster_name = ‘all’ THEN

RETURN NEXT ‘dbname=sgap_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN NEXT ‘dbname=sgap_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 1

RETURN NEXT ‘dbname=bj_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 2

RETURN NEXT ‘dbname=bj_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 3

RETURN NEXT ‘dbname=sh_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 4

RETURN NEXT ‘dbname=sh_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 5

RETURN NEXT ‘dbname=gz_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 6

RETURN NEXT ‘dbname=gz_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 7

? RETURN NEXT ‘dbname=hz_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 8

? RETURN NEXT ‘dbname=hz_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 9

RETURN;

elsif cluster_name = ‘plproxy_all’ THEN

RETURN NEXT ‘dbname=sgap_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′; — 0

RETURN NEXT ‘dbname=bj_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′; — 1

RETURN NEXT ‘dbname=sh_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′; — 2

RETURN NEXT ‘dbname=gz_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′; — 3

? RETURN NEXT ‘dbname=hz_plproxy_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;? 4

RETURN;

elsif cluster_name = ’sgap_testrole_0′ THEN

RETURN NEXT ‘dbname=sgap_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ’sgap_testrole_1′ THEN

RETURN NEXT ‘dbname=sgap_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ‘bj_testrole_0′ THEN

RETURN NEXT ‘dbname=bj_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ‘bj_testrole_1′ THEN

RETURN NEXT ‘dbname=bj_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ’sh_testrole_0′ THEN

RETURN NEXT ‘dbname=sh_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ’sh_testrole_1′ THEN

RETURN NEXT ‘dbname=sh_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ‘gz_testrole_0′ THEN

RETURN NEXT ‘dbname=gz_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ‘gz_testrole_1′ THEN

RETURN NEXT ‘dbname=gz_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ‘hz_testrole_0′ THEN

RETURN NEXT ‘dbname=hz_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ‘hz_testrole_1′ THEN

RETURN NEXT ‘dbname=hz_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN;

elsif cluster_name = ’sgap_testrole_all’ THEN

RETURN NEXT ‘dbname=sgap_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN NEXT ‘dbname=sgap_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 1

RETURN;

elsif cluster_name = ‘bj_testrole_all’ THEN

RETURN NEXT ‘dbname=bj_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN NEXT ‘dbname=bj_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 1

RETURN;

elsif cluster_name = ’sh_testrole_all’ THEN

RETURN NEXT ‘dbname=sh_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN NEXT ‘dbname=sh_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 1

RETURN;

elsif cluster_name = ‘gz_testrole_all’ THEN

RETURN NEXT ‘dbname=gz_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN NEXT ‘dbname=gz_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 1

RETURN;

elsif cluster_name = ‘hz_testrole_all’ THEN

RETURN NEXT ‘dbname=hz_testrole_0 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 0

RETURN NEXT ‘dbname=hz_testrole_1 host=xxx.xxx.150.88 user=testrole password=testrole port=9601′;  ? 1

RETURN;

END IF;

RAISE EXCEPTION ‘Unknown cluster’;

END;

$$ LANGUAGE plpgsql;

? 获取集群组配置版本

CREATE OR REPLACE FUNCTION plproxy.get_cluster_version(i_cluster_name text)

RETURNS int4 AS $$

declare

i_ver int4;

BEGIN

select max(version) into i_ver from testrole.tbl_cluster_version where cluster_name=i_cluster_name;

if found then

RETURN i_ver;

end if;

RAISE EXCEPTION ‘Unknown cluster’;

END;

$$ LANGUAGE plpgsql;

? 获取集群组配置参数

CREATE OR REPLACE FUNCTION plproxy.get_cluster_config(

in cluster_name text,out key text,out val text )

RETURNS SETOF record AS $$

BEGIN

? lets use same config for all clusters

key := ‘connection_lifetime’;

val := 30*60;   — 30m

RETURN NEXT;

?      if cluster_name=’singap_db_testrole_2′ then

?      ? lets use same config for all clusters

?      key := ‘connection_lifetime’;

?      val := 30*60; — 30m

?      RETURN NEXT;

?      end if;

RETURN;

END;

$$ LANGUAGE plpgsql;

5. 分区库(建表,函数)

? 创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

? 创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

? 创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

? 创建cluster_all范围内使用insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

? 创建cluster_all范围插入针对某个表,高效插入时可以使用这种方式,但是需要每个表建立相应的函数

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?在cluster_local_all范围内使用 , 当使用plproxy级联时

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

6. 代理库(建表,函数)

? 创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

? 创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

? cluster 版本记录表

create table testrole.tbl_cluster_version(cluster_name varchar(50),version int4);

insert into testrole.tbl_cluster_version values (‘all’,1),(‘plproxy_all’,1),(’sgap_testrole_0′,1),(’sgap_testrole_1′,1),(‘bj_testrole_0′,1),(‘bj_testrole_1′,1),(’sh_testrole_0′,1),(’sh_testrole_1′,1),(‘gz_testrole_0′,1),(‘gz_testrole_1′,1),(‘hz_testrole_0′,1),(‘hz_testrole_1′,1),(’sgap_testrole_all’,1),(‘bj_testrole_all’,1),(’sh_testrole_all’,1),(‘gz_testrole_all’,1),(‘hz_testrole_all’,1) ;

? 分区关键值表

create table testrole.pk_tbl_test(phonenum varchar(30));

create table testrole.pk_tbl_test_sgap() inherits (testrole.pk_tbl_test);

create table testrole.pk_tbl_test_bj() inherits (testrole.pk_tbl_test);

create table testrole.pk_tbl_test_sh() inherits (testrole.pk_tbl_test);

create table testrole.pk_tbl_test_gz() inherits (testrole.pk_tbl_test);

create table testrole.pk_tbl_test_hz() inherits (testrole.pk_tbl_test);

create table testrole.pk_tbl_test_def() inherits (testrole.pk_tbl_test);

insert into testrole.pk_tbl_test_sgap values(‘0′),(‘1′),(‘2′),(‘3′),(‘4′),(‘5′),(‘6′),(‘7′),(‘8′),(‘9′);

insert into testrole.pk_tbl_test_bj values(‘10′),(‘11′),(‘12′),(‘13′),(‘14′),(‘15′),(‘16′),(‘17′),(‘18′),(‘19′);

insert into testrole.pk_tbl_test_sh values(‘20′),(‘21′),(‘22′),(‘23′),(‘24′),(‘25′),(‘26′),(‘27′),(‘28′),(‘29′);

insert into testrole.pk_tbl_test_gz values(‘30′),(‘31′),(‘32′),(‘33′),(‘34′),(‘35′),(‘36′),(‘37′),(‘38′),(‘39′);

insert into testrole.pk_tbl_test_hz values(‘40′),(‘41′),(‘42′),(‘43′),(‘44′),(‘45′),(‘46′),(‘47′),(‘48′),(‘49′);

? cluster_all范围内使用的查询函数 , 每个表需要一个查询函数

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

cluster ‘all’;

run on all;

select * from testrole.ca_tbl_test_sel(v_sql);

$BODY$ language plproxy;

? 每个代理库仅需要建一个,用于cluster_all范围内Insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns setof void as $BODY$

cluster ‘all’;

run on all;

$BODY$ language plproxy;

? cluster_plproxy_all范围内使用的函数 , 级联

create or replace function testrole.cpa_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

cluster ‘plproxy_all’;

run on testrole.get_pk_tbl_test(i_phonenum);

select * from testrole.cla_tbl_test_ins(i_phonenum,i_price,i_createtime);

$BODY$ language plproxy;

?(各代理库配置不一样)对上面函数的接口,每个代理库配置对应自己的代理名

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

cluster ’sgap_testrole_all’;   — 对应自己所在的代理

run on abs(trunc(mod(hashtext(i_phonenum),2))::int4);

$BODY$ language plproxy;

? cluster_plproxy_all 范围内对数据进行分类的函数

create or replace function testrole.get_pk_tbl_test(i_phonenum varchar) returns int4 as $BODY$

begin

perform 1 from testrole.pk_tbl_test_sgap where phOnenum=i_phonenum;

if found then

return 0 ;

end if;

perform 1 from testrole.pk_tbl_test_bj where phOnenum=i_phonenum;

if found then

return 1 ;

end if;

perform 1 from testrole.pk_tbl_test_sh where phOnenum=i_phonenum;

if found then

return 2 ;

end if;

perform 1 from testrole.pk_tbl_test_gz where phOnenum=i_phonenum;

if found then

return 3 ;

end if;

?perform 1 from testrole.pk_tbl_test_hz where phOnenum=i_phonenum;

?if found then

?return 4 ;

?end if;

perform 1 from testrole.pk_tbl_test_def where phOnenum=i_phonenum;

if found then

return 0 ; — 设计为默认往sgap插入.当然可以设计为每个代理库的该函数返回为该代理库的ID;即往本地插;

end if ;

insert into testrole.pk_tbl_test_def values(i_phonenum);

return 0 ;  ? 设计为默认往sgap插入.当然可以设计为每个代理库的该函数返回为该代理库的ID;即往本地插;

end;

$BODY$ language plpgsql;

7. 哈希分区 :

abs(trunc(mod(hashtext(createtime::text),2))::int4)

8. 测试 .

/* 分区库详细操作 */

/* 地区1sgap_testrole_0 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_sgap_testrole_0 owner testrole location ‘/database/pgdata/tbs_sgap_testrole_0_def’;

?创建分区数据库

create database sgap_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sgap_testrole_0;

?连接至已常见好的分区数据库及role

\c sgap_testrole_0 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

?在cluster_all范围内使用,每个表一个

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?在cluster_local_all范围内使用 , 当使用plproxy级联时

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

/* 地区1sgap_testrole_1 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_sgap_testrole_1 owner testrole location ‘/database/pgdata/tbs_sgap_testrole_1_def’;

?创建分区数据库

create database sgap_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sgap_testrole_1;

?连接至已常见好的分区数据库及role

\c sgap_testrole_1 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

?创建global_all,每个表一个

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?创建local_all

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

/* 地区2bj_testrole_0 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_bj_testrole_0 owner testrole location ‘/database/pgdata/tbs_bj_testrole_0_def’;

?创建分区数据库

create database bj_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_bj_testrole_0;

?连接至已常见好的分区数据库及role

\c bj_testrole_0 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

?创建global_all,每个表一个

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?创建local_all

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

/* 地区2bj_testrole_1 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_bj_testrole_1 owner testrole location ‘/database/pgdata/tbs_bj_testrole_1_def’;

?创建分区数据库

create database bj_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_bj_testrole_1;

?连接至已常见好的分区数据库及role

\c bj_testrole_1 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

?创建global_all,每个表一个

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?创建local_all

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

/* 地区3sh_testrole_0 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_sh_testrole_0 owner testrole location ‘/database/pgdata/tbs_sh_testrole_0_def’;

?创建分区数据库

create database sh_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sh_testrole_0;

?连接至已常见好的分区数据库及role

\c sh_testrole_0 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

?创建global_all,每个表一个

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?创建local_all

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

/* 地区3sh_testrole_1 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_sh_testrole_1 owner testrole location ‘/database/pgdata/tbs_sh_testrole_1_def’;

?创建分区数据库

create database sh_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_sh_testrole_1;

?连接至已常见好的分区数据库及role

\c sh_testrole_1 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

?创建global_all,每个表一个

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?创建local_all

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

/* 地区4gz_testrole_0 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_gz_testrole_0 owner testrole location ‘/database/pgdata/tbs_gz_testrole_0_def’;

?创建分区数据库

create database gz_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_gz_testrole_0;

?连接至已常见好的分区数据库及role

\c gz_testrole_0 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

?创建global_all,每个表一个

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?创建local_all

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

/* 地区4gz_testrole_1 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_gz_testrole_1 owner testrole location ‘/database/pgdata/tbs_gz_testrole_1_def’;

?创建分区数据库

create database gz_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_gz_testrole_1;

?连接至已常见好的分区数据库及role

\c gz_testrole_1 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

?创建global_all,每个表一个

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?创建local_all

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

/* 地区5hz_testrole_0 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_hz_testrole_0 owner testrole location ‘/database/pgdata/tbs_hz_testrole_0_def’;

?创建分区数据库

create database hz_testrole_0 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_hz_testrole_0;

?连接至已常见好的分区数据库及role

\c hz_testrole_0 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;

?创建global_all,每个表一个

create or replace function testrole.ca_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

?创建local_all

create or replace function testrole.cla_tbl_test_ins(i_phonenum varchar,i_price real,i_createtime timestamp with time zone) returns setof void as $BODY$

begin

insert into testrole.tbl_test values(i_phonenum,i_price,i_createtime);

end;

$BODY$ language plpgsql;

/* 地区5hz_testrole_1 */

?创建role

create role testrole nosuperuser nocreatedb nocreaterole noinherit login encrypted password ‘testrole’;

?创建表空间

create tablespace tbs_hz_testrole_1 owner testrole location ‘/database/pgdata/tbs_hz_testrole_1_def’;

?创建分区数据库

create database hz_testrole_1 with owner testrole template=template0 encoding=’UTF8′ tablespace=tbs_hz_testrole_1;

?连接至已常见好的分区数据库及role

\c hz_testrole_1 testrole;

?创建本地schema

create schema testrole authorization testrole;

?创建过程语言

create language plpgsql;

?创建测试收费表

create table testrole.tbl_test(phonenum varchar(30),price real,createtime timestamp with time zone default now());

?创建测试下载记录表

create table testrole.tbl_test_table2(imsi varchar(50),appid varchar(10),createtime timestamp with time zone default now());

?创建全局查询tbl_test的函数,(每个表都得建)

create or replace function testrole.ca_tbl_test_sel(v_sql text) returns setof testrole.tbl_test as $BODY$

declare

v_rec testrole.tbl_test%rowtype;

begin

for v_rec in execute v_sql loop

return next v_rec;

end loop;

return;

end;

$BODY$ language plpgsql;

?创建全局insert,update,delete的函数

create or replace function testrole.ca_iud(v_sql text) returns void as $BODY$

begin

execute v_sql;

end;

$BODY$ language plpgsql;


推荐阅读
  • 数据库内核开发入门 | 搭建研发环境的初步指南
    本课程将带你从零开始,逐步掌握数据库内核开发的基础知识和实践技能,重点介绍如何搭建OceanBase的开发环境。 ... [详细]
  • MySQL缓存机制深度解析
    本文详细探讨了MySQL的缓存机制,包括主从复制、读写分离以及缓存同步策略等内容。通过理解这些概念和技术,读者可以更好地优化数据库性能。 ... [详细]
  • Hadoop入门与核心组件详解
    本文详细介绍了Hadoop的基础知识及其核心组件,包括HDFS、MapReduce和YARN。通过本文,读者可以全面了解Hadoop的生态系统及应用场景。 ... [详细]
  • 本文探讨了MariaDB在当前数据库市场中的地位和挑战,分析其可能面临的困境,并提出了对未来发展的几点看法。 ... [详细]
  • 探讨如何真正掌握Java EE,包括所需技能、工具和实践经验。资深软件教学总监李刚分享了对毕业生简历中常见问题的看法,并提供了详尽的标准。 ... [详细]
  • Windows服务与数据库交互问题解析
    本文探讨了在Windows 10(64位)环境下开发的Windows服务,旨在定期向本地MS SQL Server (v.11)插入记录。尽管服务已成功安装并运行,但记录并未正确插入。我们将详细分析可能的原因及解决方案。 ... [详细]
  • 本文介绍了如何使用 Spring Boot DevTools 实现应用程序在开发过程中自动重启。这一特性显著提高了开发效率,特别是在集成开发环境(IDE)中工作时,能够提供快速的反馈循环。默认情况下,DevTools 会监控类路径上的文件变化,并根据需要触发应用重启。 ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 网络运维工程师负责确保企业IT基础设施的稳定运行,保障业务连续性和数据安全。他们需要具备多种技能,包括搭建和维护网络环境、监控系统性能、处理突发事件等。本文将探讨网络运维工程师的职业前景及其平均薪酬水平。 ... [详细]
  • 该平台旨在为大型企业提供一个高效、灵活且可扩展的分布式微服务架构解决方案。它采用模块化、微服务化和热部署的设计理念,结合当前最先进且无商业限制的主流开源技术,如Spring Cloud、Spring Boot2、MyBatis、OAuth2和Element UI,实现前后端分离的系统管理平台。 ... [详细]
  • 深入解析:阿里实战 SpringCloud 微服务架构与应用
    本文将详细介绍 SpringCloud 在微服务架构中的应用,涵盖入门、实战和案例分析。通过丰富的代码示例和实际项目经验,帮助读者全面掌握 SpringCloud 的核心技术和最佳实践。 ... [详细]
  • 本文详细介绍了Git分布式版本控制系统中远程仓库的概念和操作方法。通过具体案例,帮助读者更好地理解和掌握如何高效管理代码库。 ... [详细]
  • 随着网络安全威胁的不断演变,电子邮件系统成为攻击者频繁利用的目标。本文详细探讨了电子邮件系统中的常见漏洞及其潜在风险,并提供了专业的防护建议。 ... [详细]
  • 探讨架构师在项目中应如何平衡对产品的关注和对团队成员的关注,以实现最佳的开发成果。 ... [详细]
  • 在本周的白板演练中,Apache Flink 的 PMC 成员及数据工匠首席技术官 Stephan Ewen 深入探讨了如何利用保存点功能进行流处理中的数据重新处理、错误修复、系统升级和 A/B 测试。本文将详细解释保存点的工作原理及其应用场景。 ... [详细]
author-avatar
饮娃_456
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有