cd /home/ubuntu/go/src/github.com/hyperledger/fabric/examples/e2e_cli
mkdir -p -m 750 postgresDB
docker run --name postgres01 -p 5432:5432 \
-e POSTGRES_USER=user \
-e POSTGRES_PASSWORD=pass \
-e POSTGRES_DB=db01 \
-v /home/ubuntu/go/src/github.com/hyperledger/fabric/examples/e2e_cli/postgresDB:/var/lib/postgresql/data \
-d postgres:9.6
sudo apt-get install postgresql libpq-dev
sudo apt-get install postgresql-9.5 postgresql-client-9.5
psql -h localhost -p 5432 -U user -d b01
--------------------------------------------------------------------------------------------------------------------
组从备份自动切换
http://blog.csdn.net/qguanri/article/details/51151974
https://github.com/qinguanri/pg-ha/tree/master
https://www.slideshare.net/smellman/linuxha-postgresql
---------------------------------------------------------------------------------------------------------------------
中文手册
http://www.postgres.cn/docs/9.3/index.html
http://blog.csdn.net/dyx1024/article/details/6912530
--------------------------------------------------------------------------------------------------------------------
postgresql docker版本需要和postgresql-client版本一致
https://askubuntu.com/questions/831292/how-to-install-postgresql-9-6-on-any-ubuntu-version
------------------------------------------------------------------------------------------------------------------------
postgresql docker启动的时候,可以指定下面参数。
一个超级账户user被创建,同时与名字相同的db也被创建(即使不写默认也会被创建)。
-e POSTGRES_USER=user
-e POSTGRES_PASSWORD=pass
-e POSTGRES_DB=user
fabric-ca-server-config.yaml需要修改的地方
db:
type: postgres
datasource: host=xx.xx.xx port=5432 user=user password=pass dbname=db01 sslmode=disable
fabric-ca第一次启动的时候做了一下的事情(dbutil.go)
1.判断上面那个名字为user的db是否存在(上面自动创建)
2.判断db01这个db是否存在
3.如果db01不存在的时候,
・会创建db01,同时创建users,affiliations,certificates这三个表,
・根据fabric-ca-server-config.yaml的registry定义,把用户admin的数据插入到users表
・根据fabric-ca-server-config.yaml的affiliations定义,把组织结构插入到affiliations表
*(certificates表数据还不会生成)。
对admin进行enrolls后,会在certificates里面插入一条数据,并返回各种key情报(key情报也被存在db中)。
后续可以按原来方式[fabric-ca-client register,fabric-ca-client enroll]这样创建新用户
affiliations存的是数结构的数据,字段prekey存的是父节点