孤雪飘寒 2019-07-01
$ service iptables stop $ vim /etc/selinux/config disabled $ reboot添加gitlab yum源
$ cd /etc/yum.repos.d/ $ touch gitlab-ce.repo $ vim gitlab-ce.repo [gitlab-ce] name=gitlab-ce baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6 repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key :wq $ yum clean all $ yum makecache
$ yum -y install curl openssh-server openssh-clients postfix cronie $ service postfix start $ chkconfig postfix on $ yum -y install gitlab-ce It looks like GitLab has not been configured yet; skipping the upgrade script. *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ `/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! gitlab-ctl reconfigure Running handlers: Running handlers complete Chef Client finished, 423/602 resources updated in 02 minutes 37 seconds gitlab Reconfigured!
已安装好Gitlab
external_url 'http://gitlab.example.com' vim /etc/hosts 127.0.0.1 gitlab.example.com gitlab-ctl reconfigure \\使配置生效修改本机电脑hosts文件
$ cat /opt/gitlab/emdedded/service/gitlab-rails/VERSION 10.8.4 $ git clone https://gitlab.com/xhang/gitlab.git $ ls;cd gitlab $ git branch -a #查看当前有哪些版本的汉化包 $ git diff remotes/origin/10-8-stable remotes/origin/10-8-stable-zh > /tmp/10-8.diff $ gitlab-ctl stop $ patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 10-8.diff $ gitlab-ctl start $ gitlab-ctl reconfigure
Gitlab的数据备份还是非常有必要的,毕竟都是辛辛苦苦写的代码
默认数据备份目录是/var/opt/gitlab/backups,手动创建备份文件:
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-rake gitlab:backup:restore BACKUP=1393513186
gitlab-ctl start
gitlab-rake gitlab:check SANITIZE=true
Gitlab安装完成,可以先登录试试水了
$ tar -xvf jdk-8u171-linux-x64.tar.gz -C /usr/local/ $ cd /usr/local $ mv jdk1.8.0_171/ jdk1.8 $ vim /etc/profile export JAVA_HOME=/usr/local/jdk1.8 export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar $ source /etc/profile #之后java -version没有生效,还是java1.7 $ which java /usr/bin/java $ which javac /usr/bin/javac $ mv /usr/bin/java /usr/bin/java_original $ mv /usr/bin/javac /usr/bin/javac_original $ ln -s $JAVA_HOME/bin/java /usr/bin/java $ ln -s $JAVA_HOME/bin/javac /usr/bin/javac $ source /etc/profile $ java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
$ wget http://mirrors.shu.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz $ tar -xvf apache-maven-3.5.4-bin.tar.gz -C /usr/local $ mv apache-maven-3.5.4/ maven-3.5.4 $ vim /etc/profile export MAVEN_HOME=/usr/local/maven-3.5.4 export PATH=$MAVEN_HOME/bin:$PATH $ surce /etc/profile $ mvn -v Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00) Maven home: /usr/local/maven-3.5.4 Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: /usr/local/jdk1.8/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-696.el6.x86_64", arch: "amd64", family: "unix"
$ tar -xvf apache-tomcat-8.5.31.tar.gz -C /usr/local/ $ mv apache-tomcat-8.5.31/ tomcat-jenkins默认配置启动Tomcat,访问正常后关闭。下载Jenkins war包
$ wget http://mirrors.jenkins-ci.org/war-stable/2.121.1/jenkins.war $ vim /usr/local/tomcat-jenkins/conf/server.xml 148 <Host name="localhost" appBase="/usr/local/tomcat-jenkins/webapps/jenkins" 149 unpackWARs="true" autoDeploy="true"> 150 <Context path="" docBase="/usr/local/tomcat-jenkins/webapps/jenkins" debug="0" reloadable="true"/>保存并启动Tomcat,访问地址:http://172.16.16.12:8080/jenkins
添加域名解析
vim /etc/hosts 172.16.16.12 jenkins.example.com
C:\Windows\System32\drivers\etc\hosts 172.16.16.12 jenkins.example.com
Nginx配置文件
user nginx; worker_processes 2; error_log /var/run/nginx/error.log notice; pid /usr/local/nginx/logs/nginx.pid; events { use epoll; worker_connections 10000; } http { server_tokens off; include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $server_name $remote_user $time_local [$request_time] [$upstream_response_time] "$server_name" "$request" "$request_uri"' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$http_cookie"'; access_log /var/run/nginx/access.log main; sendfile on; keepalive_timeout 65; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_comp_level 3; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary off; gzip_disable "MSIE [1-6]\."; client_header_buffer_size 128k; large_client_header_buffers 4 128k; client_header_timeout 180s; client_body_timeout 180s; client_max_body_size 1024M; port_in_redirect off; include /usr/local/nginx/conf/vhosts/*.conf; } jenkins.conf server { listen 80; add_header Cache-Control no-cache; server_name jenkins.example.com; charset utf-8; access_log /var/log/nginx/jenkins.access.log main; location / { proxy_pass http://localhost:8080; proxy_redirect http://localhost:8080 $scheme://example.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 100m; client_body_buffer_size 10240k; proxy_connect_timeout 60; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffers 32 1024k; keepalive_timeout 180; sendfile on; tcp_nodelay on; } }
访问地址:http://jenkins.example.com