Show Table of Contents
2.6. 对历史数据库的只读访问
您可以创建一个只读的 PostgreSQL 用户,这个用户将只能对
ovirt_engine_history 数据库的数据进行读操作,而没有权限进行写操作。以下步骤必须在历史数据库所在的系统上进行。
过程 2.1. 对历史数据库的只读访问
- 创建对历史数据库只有只读权限的用户:
# psql -U postgres -c "CREATE ROLE [user name] WITH LOGIN ENCRYPTED PASSWORD '[password]';" -d ovirt_engine_history
- 赋予新创建的用户连接到历史数据库的权限:
# psql -U postgres -c "GRANT CONNECT ON DATABASE ovirt_engine_history TO [user name];"
- 赋予新创建的用户使用
publicschema 的权限:# psql -U postgres -c "GRANT USAGE ON SCHEMA public TO [user name];" ovirt_engine_history
- 创建新建用户需要的其它权限,并把它们保存到一个文件:
# psql -U postgres -c "SELECT 'GRANT SELECT ON ' || relname || ' TO [user name];' FROM pg_class JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace WHERE nspname = 'public' AND relkind IN ('r', 'v');" --pset=tuples_only=on ovirt_engine_history > grant.sql - 使用您在上一步创建的文件来为新创建的用户赋予权限:
# psql -U postgres -f grant.sql ovirt_engine_history
- 删除被用来为新创建的用户赋予权限的文件:
# rm grant.sql
您可以使用以下命令来以新创建的用户身份访问
ovirt_engine_history 数据库:
# psql -U [user name] ovirt_engine_history针对表和视图(view)的
SELECT 命令会成功运行,而修改的命令会失败。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.