在CentOS上安装GitLab时,可以选择使用MySQL或PostgreSQL作为数据库。以下是相关介绍:
sudo yum install -y mysql-server mariadb
sudo systemctl start mysqld
sudo systemctl enable mysqld
sudo mysql_secure_installation
/etc/gitlab/gitlab.rb
文件,设置MySQL的连接信息:gitlab_rails['db_host'] = "localhost"
gitlab_rails['db_port'] = 3306
gitlab_rails['db_user'] = "gitlab"
gitlab_rails['db_password'] = "your_mysql_password"
gitlab_rails['db_name'] = "gitlabhq_production"
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo yum install -y postgresql-server
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo -u postgres psql
CREATE DATABASE gitlabhq_production;
CREATE USER gitlab WITH PASSWORD 'your_postgresql_password';
ALTER ROLE gitlab SET client_encoding TO 'utf8';
ALTER ROLE gitlab SET default_transaction_isolation TO 'read committed';
ALTER ROLE gitlab SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production TO gitlab;
\q
/etc/gitlab/gitlab.rb
文件,设置PostgreSQL的连接信息:gitlab_rails['db_host'] = "localhost"
gitlab_rails['db_port'] = 5432
gitlab_rails['db_user'] = "gitlab"
gitlab_rails['db_password'] = "your_postgresql_password"
gitlab_rails['db_name'] = "gitlabhq_production"
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
以上是在CentOS上为GitLab选择MySQL或PostgreSQL数据库的方法,具体选择哪种数据库可以根据个人或组织的需求和偏好来决定。
亿速云「云数据库 MySQL」免部署即开即用,比自行安装部署数据库高出1倍以上的性能,双节点冗余防止单节点故障,数据自动定期备份随时恢复。点击查看>>
推荐阅读:CentOS中GitLab数据库选择