启用停止gp
- 停止:gpstop -M fast
- 启动:gpstart -a
- 查看状态 gpstate -s
- 查看集群的状态:(查询失败的segment,status='d'表示该segment不能用,u表示up)
SELECT * FROM gp_segment_configuration WHERE status='d';
如果集群节点都没问题,那么上面的sql执行是查询不到结果的 - 在数据库中查询最大链接数:
show max_connections - 查询当前的连接数:
select count(*) from pg_stat_activity;
下面的信息可以忽略,这个是本人常用的一些sql信息,比较杂乱
su - mppdb 先
gunzip -c | /root/mppdb/bin/psql -U portal hnechg
导出:
pg_dump -n schema名称 -h 172.14.172.11 -p 5432 数据库名称 | gzip > /data/cp.sql.gz
导入:
/root/mppdb/bin/psql -U portal -h 172.24.4.51 -d hnechg -p 5432 -f portal.sql
pg_restore -d hnechg —c -F t -f your.backup.tar
psql -v ON_ERROR_STOP=1
使用如下导入数据:
psql -U hnechg -h 172.24.4.51 -d hnechg -p 5432 -f portal.sql
alter user portal with password 'opcdata45Tgb';
alter user cepop with password 'opcdata23Edc';
alter user cepoprpt with password 'opcdata34Rfv';
alter user opcdata with password ‘opcdata12Wsx';
grant all on schema portal to portal;
grant all on schema cepop to cepop;
grant all on schema cepoprpt to cepoprpt;
grant all on schema opcdata to opcdata;
grant all on all tables in schema portal to portal;
grant all on all tables in schema cepop to cepop;
grant all on all tables in schema cepoprpt to cepoprpt;
grant all on all tables in schema opcdata to opcdata;
权限赋予
grant all on schema cepop to cepop;
grant all on all tables in schema cepop to cepop;
create user opcdata superuser password 'opcdata12Wsx';
create user cepop superuser password 'opcdata23Edc';
create user cepoprpt superuser password 'opcdata34Rfv';
create user portal superuser password 'opcdata45Tgb';
create user etl superuser password 'opcdata56Yhn';
create user hnechg superuser password ‘Zhnh567Ujm’;
create user readonly_user superuser password 'bGt54rfv';
//创建用户"test"并设置密码:
create user test with password '123456';
//创建数据库testdb,所有者为test:
create database testdb owner test;
//将testdb数据库的所有权限赋予test,否则test只能登录psql,没有任何数据库操作权限:
grant all privileges on database testdb to test;
权限赋予
create user opcdata superuser password 'opcdata12Wsx';
grant all on schema cepop to cepop;
grant all on all tables in schema cepop to cepop;
本地倒入copy数据就是:
psql -h localhost -p 5432 -U postgres -f /Users/wesfer/Desktop/p5user.sql
然后文件来源需要从备份数据中找:
COPY portal.p5user (user_id, user_code, user_name, dep_id, post_id, default_menu_id, user_sys, isadmin, session_id, password, ct_dep_id, bt_dep_id, lg_dep_id, cc_dep_id, tableau_user, user_type, phone_number, email, skype, login_status) FROM stdin;
最后一行的./也需要去掉
网友评论