前期准备
https://mirrors.tuna.tsinghua.edu.cn/ 清华大学镜像源
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.0.0-ce.0.el7.x86_64.rpm
https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el7/gitlab-runner-14.4.0-1.x86_64.rpm
https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.34.1.tar.gz
rpm -ivh 安装
安装git
tar包安装
cd /usr/local/src/
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.34.1.tar.gz
tar -vxf git-2.34.1.tar.xz
cd git-2.34.1
make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
source /etc/profile
git --version
yum安装(推荐)
#安装源
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
#安装git
yum install git
#更新
yum update git
安装gitlabl
vim /etc/gitlab/gitlab.rb
#
external_url 'http://192.168.75.95'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "1015962444@qq.com"
gitlab_rails['smtp_password'] = "wxaxewsnboxwbfhf"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_pool'] = false
gitlab_rails['gitlab_email_from'] = '1015962444@qq.com'
wxaxewsnboxwbfhf
fkghlaiyfbzebcce
配置
gitlab-ctl reconfigure&&gitlab-ctl start
重置密码
gitlab-rake "gitlab:password:reset[root]"
Enter password:
Confirm password:
gitlab常用命令
gitlab-ctl reconfigure #更新配置
gitlab-ctl start #启动全部服务
gitlab-ctl restart #重启全部服务
gitlab-ctl stop #停止全部服务
gitlab-ctl restart nginx #重启单个服务
gitlab-ctl status #查看全部组件的状态
gitlab-ctl show-config #验证配置文件
gitlab-ctl uninstall #删除gitlab(保留数据)
gitlab-ctl cleanse #删除所有数据,重新开始
gitlab-ctl tail <svc_name> #查看服务的日志
gitlab-rails console production #进入控制台,可以修改root的密码
安装gitlab runner
#安装gitlab-runner
rpm -ivh gitlab-runner-14.4.0-1.x86_64.rpm
systemctl start gitlab-runner
systemctl status gitlab-runner
注册runner
gitlab-runner register \
--non-interactive \
--executor "shell" \
--url "http://192.168.75.95/" \
--registration-token "yA5s2yv-_2hh6wWg_eex" \
--description "deveops-runner" \
--tag-list "build, deploy" \
--run-untagged="true" \
--locked="false" \
--access-level="not_protected"
设置管理员权限
gitlab-runner用户设置root权限
在 runner执行过程中大多数是文件夹不存在,无权限。
sudo gitlab-runner uninstall #删除gitlab-runner
gitlab-runner install --working-directory /home/gitlab-runner --user root #安装并设置-user(设置为root)
sudo service gitlab-runner restart #重启gitlab-runner
ps aux| grep gitlab-runner#查看当前 runner用户
安装sonarqube
安装mysql5.7
docker pull mysql:5.7
docker run -p 3306:3306 --name mysql -v /opt/docker/mysql/conf:/etc/mysql -v /opt/docker/mysql/log:/var/log/mysql -v /opt/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=12345678 -d mysql:5.7
参数说明
-p 3306:3306 将容器的端口号3306映射到主机的336端口号
-v /opt/docker/mysq1/log:/ar/log/mysql \ 将配置文件夹挂载到主机
-v /opt/docker/mysql/data:/var/lib/mysql \ 将日志文件夹挂载到主机
-v /opt/docker/mysql/conf:/etc/mysql \ 将配置文件夹挂载到主机
-e MYSQL_ROOT_PASSWORD=12345678 \ 初始化root的密码
vim /opt/docker/mysql/conf/my.cnf
[client]
#对本地的msq1客户端的配置
default-character-set = utf8
#对其他远程连接的mysq1客户端的配置
[mysql]
default-character-set = utf8
#本地msq1服务的配置
[mysqld]
init_connect= 'SET collation_connection = utf8_unicode_ci'
init_connect= 'SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-reso⊥ve
docker restart mysql
查看配置文件
进入mysq1中
docker exec -it mysql /bin/bash
cat /etc/mysql/my.cnf
创建sonar的用户
create user 'sonar'@'%' identified by '12345678';
grant all privileges on *.* to 'sonar'@'%' with grant option;
flush privileges;
sonarqube汉化包
https://github.com/xuhuisheng/sonar-l10n-zh/releases
修改sonar的配置
sonar.jdbc.username=sonar
sonar.jdbc.password=12345678
sonar.jdbc..url=jdbc:mysql://192.168.75.95:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&Useconfigs=maxPerformance&usessl=false
登录
默认用户名和密码都是 admin
配置 token后保留响应
mvn sonar:sonar \
-Dsonar.host.url=http://192.168.75.95:9000 \
-Dsonar.login=08d4b2be0950c9606f46f560f0ocf16bf9d62410
安装sonar-scanner
修改配置
sonar.host.url=http://192.168.75.95:9000
sonar.login=b446601096689e2e25fc1bf96ac681501270799
gitlab-runner register \
—non-interactive \
—executor “shell” \
—url “http://10.24.42.244/“ \
—registration-token “A2x65BbwShuhPnJVeyVo” \
—description “deveops” \
—tag-list “build, deploy” \
—run-untagged=”true” \
—locked=”false” \
—access-level=”not_protected”