重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 69|回复: 0
打印 上一主题 下一主题

PG16 开启SELINUX重新打标签

[复制链接]
跳转到指定楼层
楼主
发表于 2024-7-27 02:05:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
PG16简单的开启SELINUX,使用systemctl start pg16.service ,会报权限错误,可以通过 setroubleshotting去排查,会发现是标签错误导致.

那么在PG 中,SELINUX 标签不统一,$PGHOME 和$PGDATA不一样,就是$PGHOME下面的各目录及文件,标签也不一样。

$PGHOME/bin/postgres    标签: postgresql_exec_t
$PGHOME/bin/initdb       标签: postgresql_exec_t
$PGHOME/bin/pg_ctl       标签: initrc_exec_t
$PGHOME/bin/*               标签:    bin_t
$PGHOME/lib/*               标签: lib_t
$PGHOME/*                      标签: usr_t


$PGDATA/*        标签: postgresql_db_t


针对这种情况,我们需要对这些文件重新打标签


方法如下:
使用root用户去执行
比如:
$PGDATA=/u01/app/postgres/pgdata
$PGHOME=/u01/app/postgres/product/16.3/dbhome_1


1.设置目录标签
# semanage fcontext -a -t usr_t '/u01/app/postgres/product/16.3/dbhome_1(/.*)?'
# semanage fcontext -a -t bin_t '/u01/app/postgres/product/16.3/dbhome_1/bin(/.*)?'
# semanage fcontext -a -t lib_t '/u01/app/postgres/product/16.3/dbhome_1/lib(/.*)?'
# semanage fcontext -a -t postgresql_db_t '/u01/app/postgres/pgdata(/.*)?'

2.设置单个文件的标签
# semanage fcontext -a -t postgresql_exec_t '/u01/app/postgres/product/16.3/dbhome_1/bin/postgres'
# semanage fcontext -a -t postgresql_exec_t '/u01/app/postgres/product/16.3/dbhome_1/bin/initdb'
# semanage fcontext -a -t initrc_exec_t '/u01/app/postgres/product/16.3/dbhome_1/bin/pg_ctl'

3.恢复文件安全上下文,含标签

# restorecon -FRv /u01/app/postgres/product/16.3/dbhome_1
# restorecon -FRv /u01/app/postgres/pgdata

4.验证SELINUX的安全上下文

                               
登录/注册后可看大图



                               
登录/注册后可看大图



至此,再去systemctl start PG16 不再报错


                               
登录/注册后可看大图



                               
登录/注册后可看大图













分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-9-8 08:30 , Processed in 0.206211 second(s), 19 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表