开发者社区 问答 正文

linux下 gitlab启动报无权限的问题

linux 下执行 gitlab-8.9.6-0/ctlscript.sh 启动脚本 出现如下错误 主要是提示 Permission denied 无权限,网上查了很多资料都没找到解决方法 看过里面的启动脚本 当中有切换 postgres 用户 执行命令 尝试给 postgres 增加权限 但没有效果

/home/admin/tools/gitlab-8.9.6-0/apache2/scripts/ctl.sh : apache not running /home/admin/tools/gitlab-8.9.6-0/apps/gitlab/scripts/sidekiq.sh : gitlab_sidekiq not running /home/admin/tools/gitlab-8.9.6-0/apps/gitlab-workhorse/scripts/ctl.sh : gitlab_workhorse not running /home/admin/tools/gitlab-8.9.6-0/apps/gitlabci/gitlabci-multirunner/scripts/ctl.sh : gitlabci_multirunner not running /home/admin/tools/gitlab-8.9.6-0/redis/scripts/ctl.sh : redis not running /home/admin/tools/gitlab-8.9.6-0/postgresql/scripts/ctl.sh : postgresql not running bash: /home/admin/tools/gitlab-8.9.6-0/postgresql/bin/pg_ctl: Permission denied /home/admin/tools/gitlab-8.9.6-0/postgresql/scripts/ctl.sh : postgresql could not be started sh: /home/admin/tools/gitlab-8.9.6-0/redis/bin/redis-server: Permission denied /home/admin/tools/gitlab-8.9.6-0/redis/scripts/ctl.sh : redis could not be started /home/git/.bashrc: line 10: /home/admin/tools/gitlab-8.9.6-0/scripts/setenv.sh: Permission denied -bash: line 0: cd: /home/admin/tools/gitlab-8.9.6-0/apps/gitlab/htdocs: Permission denied /home/admin/tools/gitlab-8.9.6-0/apps/gitlab/scripts/sidekiq.sh : gitlab_sidekiq could not be started /home/git/.profile: line 2: /home/admin/tools/gitlab-8.9.6-0/scripts/setenv.sh: Permission denied -sh: /home/admin/tools/gitlab-8.9.6-0/apps/gitlab-workhorse/logs/workhorse.log: Permission denied /home/admin/tools/gitlab-8.9.6-0/apps/gitlab-workhorse/scripts/ctl.sh : gitlab-workhorse could not be started /home/admin/tools/gitlab-8.9.6-0/apps/gitlabci/gitlabci-multirunner/scripts/ctl.sh : gitlabci_multirunner started Syntax OK /home/admin/tools/gitlab-8.9.6-0/apache2/scripts/ctl.sh : httpd started at port 80

展开
收起
shiwei 2021-07-12 17:43:14 797 分享 版权
阿里云 AI 助理回答

遇到权限问题,通常需要确保执行脚本的用户对相关文件和目录有正确的访问权限。根据你的描述,错误信息显示多个服务因为权限问题无法启动,包括PostgreSQL、Redis、GitLab Sidekiq等组件。以下是一些可能的解决步骤:

  1. 检查文件所有者和权限

    • 首先,确认gitlab-8.9.6-0目录及其子目录下的文件的所有权是否正确。这些服务通常应该由它们各自的系统用户(如postgres对于PostgreSQL)拥有或至少可执行。
    • 使用命令 ls -l /home/admin/tools/gitlab-8.9.6-0/ 检查主要目录的权限,并使用 sudo chown -R 用户名:组名 /路径/ 来修改所有权,如果需要的话。
    • 对于执行脚本和二进制文件,确保它们具有执行权限。可以使用 chmod +x /path/to/file 命令来添加执行权限。
  2. 针对PostgreSQL和Redis的具体操作

    • 对于PostgreSQL,确保/home/admin/tools/gitlab-8.9.6-0/postgresql/bin/pg_ctl这个文件所属用户是postgres,并且该用户有执行权限。
    • 对于Redis,同样检查/home/admin/tools/gitlab-8.9.6-0/redis/bin/redis-server的权限,确保redis用户(或者你配置的服务运行用户)能够执行它。
  3. GitLab相关组件

    • 确保gitlab用户(如果有的话)对它的家目录、.bashrc.profile以及工作目录有适当的读写权限。
    • 特别注意错误中提到的/home/admin/tools/gitlab-8.9.6-0/scripts/setenv.sh文件,确保任何依赖此脚本的用户能正确访问它。
  4. 使用sudo(谨慎操作)

    • 如果某些服务确实需要以特定用户身份运行,但直接切换用户执行又不现实,可以考虑在启动脚本中使用sudo,但这样做需要仔细配置sudoers文件,避免安全风险。
  5. 服务管理脚本调整

    • 考虑到你是通过一个总的控制脚本(ctlscript.sh)来启动各个服务,确保这个脚本内部正确地切换到了每个服务所需的用户上下文,并且执行了必要的权限检查和调整。
  6. 查看日志

    • 详细查看各服务的日志文件,可能会提供更多关于权限问题的线索。
  7. 阿里云ECS环境下的特殊考虑

    • 如果这是在阿里云ECS实例上部署,确保遵循阿里云的安全最佳实践,比如使用安全组规则开放必要的端口,以及利用云监控来跟踪服务状态。

如果以上步骤仍然不能解决问题,建议查阅GitLab官方文档或社区论坛,看是否有针对特定版本的已知问题和解决方案。此外,考虑到GitLab 8.9.6是一个较旧的版本,升级到最新稳定版也可能解决一些已知的权限或其他问题。

有帮助
无帮助
AI 助理回答生成答案可能存在不准确,仅供参考
0 条回答
写回答
取消 提交回答