TeamCity Windows to Centos migration

TeamCity Win+SQL -> Centos+Postgres migration

Дано: 

Windows Server 2012 R2 + SQL Server + TeamCity

Задача: 

вынести TeamCity Server c Win sandbox на отдельную машину

Цель:

standalone vm centos 7 + postgres + teamcity server

Решение:

Prepare new environment

as for vm parameters I’ve set recomended 2×2 CPU and 4Gb RAM

High Important!!! Migration must be done between same TeamCity versions!!!

— server setup

centos 7 installed with next filesystem mapping:

install different requirements:

yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel pam-devel curl-devel gcc make freetds-devel python34-devel wget curl unzip  autoconf automake net-tools -y

install git

install postgresql 10:

yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-1.noarch.rpm
yum install postgresql10 postgresql10-server
systemctl enable postgresql-10

markup db directory:

mkdir /db/teamcity

prepare psql teamcity user:

useradd teamcity
usermod -aG postgres teamcity
chmod 775 /run/postgresql/
chown teamcity /db/teamcity/

create special daemon for teamcity psql instance:

/etc/init.d/postgresql-teamcity <- click to view

add some tuning for instance (leave the port as is because we have only one psql instance)

/db/teamcity/postgresql.conf

port = 5432

shared_buffers = 512MB

effective_cache_size = 3GB

max_wal_size = 1500MB

checkpoint_completion_target=0.9

synchronous_commit=off

create database and teamcity db user

su teamcity
/usr/pgsql-10/bin/initdb -D /db/teamcity/ -U postgres -E UTF-8
ctrl+d
chown teamcity /db/teamcity/ -R
/etc/init.d/postgresql-teamcity start
su teamcity
psql -U postgres

postgres=# CREATE DATABASE teamcity;
postgres=# CREATE USER teamcity with password 'password';
postgres=# GRANT ALL PRIVILEGES ON DATABASE teamcity to teamcity;

install Java 8

cd /usr/local/src/ && wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm"
yum localinstall jdk-8u*-linux-x64.rpm -y

—teamcity server setup

cd /tmp
wget https://download.jetbrains.com/teamcity/TeamCity-2017.2.tar.gz
tar -xf TeamCity-2017.2.tar.gz
mv TeamCity /opt/teamcity && cd /opt/teamcity/bin
bash runAll.sh start 

example of successfull output:
Agent home directory is /opt/teamcity/buildAgent
Current Java runtime version is 1.8 
Lock file: /opt/teamcity/buildAgent/logs/buildAgent.properties.lock 
Using no lock 
Done [31576], see log at /opt/teamcity/buildAgent/logs/teamcity-agent.log

check that teamcity is really running:

 netstat -nlptu | grep 8111
tcp6 0 0 :::8111 :::* LISTEN 31480/java 

you may have centos firewall so if you cannot open http://<teamcity host>:8111/ in your browser try this
systemctl stop firewalld

if web page begin works it means that some rule in your default firewall block 8111 port
so if you want you can inspect it and open or ( if you bad boy just) disable firewall forever:
systemctl disable firewalld

first look on front

let’s point Data DIrectory = /opt/teamcity/.BuildServer

let’s satisfy this requirement

cd /opt/teamcity/.BuildServer/lib/jdbc
wget https://jdbc.postgresql.org/download/postgresql-42.1.4.jar

and press Refresh JDBC drivers

driver has been loaded so just fill db connection strings and press Proceed

after ~1-2 min we will see License Agreement which needs to be Accepted and we see this

we can Login as SU (via token from teamcity-server.log in startup section) or just create SU

Export’n’Restore all things from old TeamCity instance

I’ve created basic backup: Administration → Backup → Backup scope = Basic → Start Backup

and placed this zip backup to the /opt/teamcity/.BuildServer/import of new server

(or we can do the same with Administration → Projects Import)

AskDevops —> https://t.me/ithangouts

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *