#mysql的版本至少5.5.14或更新
mysql --version
mysql Ver 14.14 Distrib 5.5.40, for Linux (x86_64) using readline 5.1
创建数据库用户并授权
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mysql -u root -p
mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY 'gitpwd';
mysql> show variables like "%engine";
+------------------------+--------+
| Variable_name | Value |
+------------------------+--------+
| default_storage_engine | InnoDB |
| storage_engine | InnoDB |
+------------------------+--------+
2 rows in set (0.01 sec)
#如果不是InnoDB引擎,需执行下面命令
mysql> SET storage_engine=INNODB;
创建数据库
1
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
给用户授权
1
mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost';
测试是否能够成功登录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mysql -ugit -pgitpwd -D gitlabhq_production
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.5.40-log Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> \q
七,配置redis
1
2
3
4
5
6
7
8
9
10
11
chkconfig redis on
cp /etc/redis.conf /etc/redis.conf.orig
#修改监听端口
sed 's/^port .*/port 0/' /etc/redis.conf.orig |tee /etc/redis.conf
#增加内容
echo 'unixsocket /var/run/redis/redis.sock' |tee -a /etc/redis.conf
echo -e 'unixsocketperm 0770' |tee -a /etc/redis.conf
sudo -u git -H vim config/gitlab.yml
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: localhost
port: 80
https: false
su - git -c "cd gitlab/;bundle install --deployment --without development test postgres puma aws"
#报错信息:
Fetching source index from https://rubygems.org/
Retrying source fetch due to error (2/3): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Retrying source fetch due to error (3/3): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Could not find gitlab-grack-2.0.0.pre in any of the sources
#继续执行
bundle install --deployment --without development test postgres puma was
1
2
3
4
#报错信息:
Gem::RemoteFetcher::UnknownHostError: no such name (https://rubygems.org/gems/net-scp-1.1.2.gem)
An error occurred while installing net-scp (1.1.2), and Bundler cannot continue.
Make sure that `gem install net-scp -v '1.1.2'` succeeds before bundling.
1
2
3
4
5
6
7
8
9
10
11
12
13
#解决办法:
gem install net-scp -v '1.1.2'
#报错信息:
Gem::RemoteFetcher::FetchError: Errno::ETIMEDOUT: Connection timed out - connect(2) for "rubygems.global.ssl.fastly.net" port 443 (https://rubygems.org/gems/httparty-0.13.0.gem)
An error occurred while installing httparty (0.13.0), and Bundler cannot continue.
Make sure that `gem install httparty -v '0.13.0'` succeeds before bundling."
#报错信息:
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
This will create the necessary database tables and seed the database.
You will lose any previous data stored in the database.
Do you want to continue (yes/no)? yes
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "collation"=>"utf8_general_ci", "reconnect"=>false, "database"=>"gitlabhq_production", "pool"=>10, "username"=>"git", "password"=>"gitpwd"}, {:charset=>"utf8", :collation=>"utf8_general_ci"}
(If you set the charset manually, make sure you have a matching collation)
-- enable_extension("plpgsql")
rake aborted!
Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
1
2
3
4
#解决办法:
vim config/database.yml
#mysql.sock的位置指定,默认在/tmp目录下
socket: /var/lib/mysql/mysql.sock
#报错信息:
Running /home/git/gitlab-shell/bin/check
Check GitLab API access: /home/git/gitlab-shell/lib/gitlab_net.rb:122:in `read': No such file or directory @ rb_sysopen - /home/git/gitlab-shell/.gitlab_shell_secret (Errno::ENOENT)
from /home/git/gitlab-shell/lib/gitlab_net.rb:122:in `secret_token'
from /home/git/gitlab-shell/lib/gitlab_net.rb:79:in `get'
from /home/git/gitlab-shell/lib/gitlab_net.rb:39:in `check'
from /home/git/gitlab-shell/bin/check:11:in `<main>''