TeamCity v9.x on CentOS v7.x with MariaDB
This documents describes install TeamCity on a CentOS v7 virtual machine. MariaDB is used for database storage. A systemd service script is used to manage the TeamCity service.
Steps:
- Create a empty minimal CentOS v7 VM (with sufficient disk to store atrifacts/logs etc)
- Install and configure MariaDB
- Install OpenJDK
- Install/unpack TeamCity
- Configure/restore TeamCity
- Configure a Nginx reverse proxy in front of TeamCity (not described)
- patch to 'conf.server.xml' for reverse proxy support
MariaDB
Install the server package:
# yum install mariadb-server
Add the following to the '/etc/my.cnf' to get mysql to only listen on localhost:
[mysqld] default-storage-engine=innodb innodb_buffer_pool_size=500M innodb_file_per_table innodb_flush_log_at_trx_commit=0 bind-address = localhost
Start MariaDB and run the setup script:
# systemctl enable mariadb # systemctl start mariadb # /usr/bin/mysql_secure_installation
Create a database for the TeamCity server (enter the db root password when prompted):
# mysql -p mysql> CREATE DATABASE teamcity DEFAULT CHARACTER SET utf8; mysql> GRANT USAGE ON *.* TO 'teamcity'@'localhost' IDENTIFIED BY 'teamcity'; mysql> GRANT ALL ON teamcity.* TO 'teamcity'@'localhost'; mysql> flush privileges;
OpenJDK and JDBC Driver
Install the latest OpenJDK and a MySQL/MariaDB JDBC connector:
# yum install java-1.8.0-openjdk-headless mysql-connector-java
Teamcity
Create a TeamCity user account - the server will run as this identity. This installation puts the 'teamcity' home directory on the 'srv' filesystem which has sufficient disk to store artifacts.
# adduser -c "TeamCity Build Server" -m -d /srv/teamcity -r teamcity
Extract the TeamCity distribution archive into the teamcity user directory (as the teamcity user). Rename the top level distribution directory so that it contains a version number. This will allow upgrades to be done easily in the future, as well as meeting the requirement of absolute paths for the systemd configuration. These command are done as the 'teamcity' user in the teamcity home directory ('/srv/teamcity').
$ tar -xpzf TeamCity-9.0.tar.gz $ mv TeamCity 9.0.0 $ ln -s 9.0.0 teamcity
Create a systemd service file '/lib/systemd/system/teamcity.service'. Note: The TeamCity server doesn't seem to have a pid file and it doesn't support a restart style command.
[Unit] Description=JetBrains TeamCity Requires=network.target After=syslog.target network.target [Service] Type=forking EnvironmentFile=/etc/sysconfig/teamcity ExecStart=/srv/teamcity/teamcity/bin/teamcity-server.sh start ExecStop=/srv/teamcity/teamcity/bin/teamcity-server.sh stop User=teamcity PIDFile=/srv/teamcity/teamcity.pid Environment="TEAMCITY_PID_FILE_PATH=/srv/teamcity/teamcity.pid" [Install] WantedBy=multi-user.target
Create an environment configuration file '/etc/sysconfig/teamcity':
TEAMCITY_SERVER_MEM_OPTS="-Xmx1024m -Djava.awt.headless=true -XX:+UseConcMarkSweepGC -XX:MaxPermSize=200m "
Start the service (Note: If restoring an existing installation, don't start the server yet):
# systemctl enable teamcity
Firewall
Over and above standard firewall access (ssh, dns, http, local smtp); allow ingress for:
- http for the main web interface (port 8111)
Allow egress for:
- SSH access to GIT
- HTTP access to agents (tcp port 9090)
- Jabber (xmpp-client)
ip4 rules:
-A tcpOut -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT -A tcpOut -p tcp -m tcp --dport 9090 -m conntrack --ctstate NEW -j ACCEPT -A tcpOut -p tcp -m tcp --dport 5222 -m conntrack --ctstate NEW -j ACCEPT -A tcpIn -p tcp -m tcp --source 10.20.7.0/24 --dport 8111 -m conntrack --ctstate NEW -j ACCEPT
ipv6 rules:
-A tcpOut -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT -A tcpOut -p tcp -m tcp --dport 9090 -m conntrack --ctstate NEW -j ACCEPT -A tcpOut -p tcp -m tcp --dport 5222 -m conntrack --ctstate NEW -j ACCEPT
firewalld
If you are using the standard firewalld then only only ingress rules are required.
# firewall-cmd --zone=public --permanent --add-port=8111/tcp # firewall-cmd --reload
Reverse Proxy
The following document describes a patch required to 'conf/server.xml'. This must be applied to the distribution file each time the teamcity server is upgraded.
<Service name="Catalina"> <Engine name="Catalina" defaultHost="localhost"> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="x-forwarded-for" protocolHeader="x-forwarded-proto" internalProxies="192\.168\.1\.25" /> </Host> </Engine> </Service>
First time setup
Note: It is important to note that if you want to restore and existing backup then this step should be skipped and a command line restore should be completed.
# systemctl start teamcityLink the installed mysql connector into the build server hierarchy and press the 'refresh JDBC driver' button to rescan for it (because the server will be started, the '.BuildServer' directory hierarchy will have been created):
$ ln -s /usr/share/java/mysql-connector-java.jar ~teamcity/.BuildServer/lib/jdbc/
Select the database type. If the driver is not found then the message below will be shown. Sym-link the driver in as described above.
The new server is ready to create the first account:
Restore
The restore requires:
- a properties file to describe the destination database
- the backup file to restore
- JAVA_HOME set
- a JDBC driver for the database
The JAVA_HOME location can be determined by running 'alternatives --display jre_openjdk'. The JDBC driver must be referenced from the buildserver data directory (but it should be empty/non-existent at this point in time); thus the path must be created. These commands are performed as the 'teamcity' user.
$ cat > database.properties <<EOF connectionProperties.user=teamcity connectionProperties.password=teamcity connectionUrl=jdbc\:mysql\://localhost/teamcity EOF $ mkdir -p ~teamcity/.BuildServer/lib/jdbc $ ln -s /usr/share/java/mysql-connector-java.jar ~teamcity/.BuildServer/lib/jdbc/ $ export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64/jre $ bin/maintainDB.sh restore -F ~/TeamCity_Backup_20141212_104822.zip -T ~/database.properties
Once the restore is complete start the server:
# systemctl start teamcity
Browse to the server to complete the database upgrade:
Logs
The following symlink is handy for logging
# ln -s /srv/teamcity/teamcity/logs /var/log/teamcity
Links
- https://www.jetbrains.com/teamcity
- https://confluence.jetbrains.com/pages/viewpage.action?pageId=54334889#HowTo...-Tomcatsettings
- http://confluence.jetbrains.com/display/TCD9/Restoring+TeamCity+Data+from+Backup
- Web sockets support:
Appendices
yum install mariadb-server
Dependencies Resolved ======================================================================================= Package Arch Version Repository Size ======================================================================================= Installing: mariadb-server x86_64 1:5.5.40-1.el7_0 updates 11 M Installing for dependencies: libaio x86_64 0.3.109-12.el7 base 24 k mariadb x86_64 1:5.5.40-1.el7_0 updates 8.9 M perl x86_64 4:5.16.3-283.el7 base 8.0 M perl-Carp noarch 1.26-244.el7 base 19 k perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k perl-DBD-MySQL x86_64 4.023-5.el7 base 140 k perl-DBI x86_64 1.627-4.el7 base 802 k perl-Data-Dumper x86_64 2.145-3.el7 base 47 k perl-Encode x86_64 2.51-7.el7 base 1.5 M perl-Exporter noarch 5.68-3.el7 base 28 k perl-File-Path noarch 2.09-2.el7 base 26 k perl-File-Temp noarch 0.23.01-3.el7 base 56 k perl-Filter x86_64 1.49-3.el7 base 76 k perl-Getopt-Long noarch 2.40-2.el7 base 56 k perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k perl-IO-Compress noarch 2.061-2.el7 base 260 k perl-Net-Daemon noarch 0.48-5.el7 base 51 k perl-PathTools x86_64 3.40-5.el7 base 82 k perl-PlRPC noarch 0.2020-14.el7 base 36 k perl-Pod-Escapes noarch 1:1.04-283.el7 base 49 k perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k perl-Pod-Usage noarch 1.63-3.el7 base 27 k perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k perl-Socket x86_64 2.010-3.el7 base 49 k perl-Storable x86_64 2.45-3.el7 base 77 k perl-Text-ParseWords noarch 3.29-4.el7 base 14 k perl-Time-Local noarch 1.2300-2.el7 base 24 k perl-constant noarch 1.27-2.el7 base 19 k perl-libs x86_64 4:5.16.3-283.el7 base 686 k perl-macros x86_64 4:5.16.3-283.el7 base 42 k perl-parent noarch 1:0.225-244.el7 base 12 k perl-podlators noarch 2.5.1-3.el7 base 112 k perl-threads x86_64 1.87-4.el7 base 49 k perl-threads-shared x86_64 1.43-6.el7 base 39 k Transaction Summary ======================================================================================= Install 1 Package (+36 Dependent packages) Total download size: 32 M Installed size: 144 M
Secure MariaDB
# mysql_secure_installation /bin/mysql_secure_installation: line 379: find_mysql_client: command not found NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] n ... skipping. By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
yum install JDK
Dependencies Resolved ======================================================================================= Package Arch Version Repository Size ======================================================================================= Installing: java-1.7.0-openjdk-headless x86_64 1:1.7.0.71-2.5.3.1.el7_0 updates 25 M mysql-connector-java noarch 1:5.1.25-3.el7 base 1.3 M Installing for dependencies: apache-commons-lang noarch 2.6-15.el7 base 276 k apache-commons-logging noarch 1.1.2-7.el7 base 78 k atk x86_64 2.8.0-4.el7 base 233 k avalon-framework noarch 4.3-10.el7 base 88 k avalon-logkit noarch 2.1-14.el7 base 87 k cairo x86_64 1.12.14-6.el7 base 697 k cal10n noarch 0.7.7-4.el7 base 36 k cups-libs x86_64 1:1.6.3-14.el7 base 352 k flac-libs x86_64 1.3.0-4.el7 base 169 k fontconfig x86_64 2.10.95-7.el7 base 228 k fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k gdk-pixbuf2 x86_64 2.28.2-4.el7 base 533 k geronimo-jms noarch 1.1.1-19.el7 base 31 k geronimo-jta noarch 1.1.1-17.el7 base 20 k giflib x86_64 4.1.6-9.el7 base 40 k graphite2 x86_64 1.2.2-5.el7 base 81 k gsm x86_64 1.0.13-11.el7 base 30 k gtk2 x86_64 2.24.22-5.el7_0.1 updates 3.4 M harfbuzz x86_64 0.9.20-3.el7 base 144 k hicolor-icon-theme noarch 0.12-7.el7 base 42 k jasper-libs x86_64 1.900.1-26.el7 base 147 k java-1.7.0-openjdk x86_64 1:1.7.0.71-2.5.3.1.el7_0 updates 196 k javamail noarch 1.4.6-8.el7 base 758 k javapackages-tools noarch 3.4.1-6.el7_0 updates 72 k javassist noarch 3.16.1-10.el7 base 627 k jbigkit-libs x86_64 2.0-11.el7 base 46 k lcms2 x86_64 2.5-4.el7 base 133 k libICE x86_64 1.0.8-7.el7 base 63 k libSM x86_64 1.2.1-7.el7 base 38 k libX11 x86_64 1.6.0-2.1.el7 base 605 k libX11-common noarch 1.6.0-2.1.el7 base 181 k libXau x86_64 1.0.8-2.1.el7 base 29 k libXcomposite x86_64 0.4.4-4.1.el7 base 22 k libXcursor x86_64 1.1.14-2.1.el7 base 30 k libXdamage x86_64 1.1.4-4.1.el7 base 20 k libXext x86_64 1.3.2-2.1.el7 base 38 k libXfixes x86_64 5.0.1-2.1.el7 base 18 k libXfont x86_64 1.4.7-2.el7_0 updates 144 k libXft x86_64 2.3.1-5.1.el7 base 57 k libXi x86_64 1.7.2-2.1.el7 base 39 k libXinerama x86_64 1.1.3-2.1.el7 base 14 k libXrandr x86_64 1.4.1-2.1.el7 base 25 k libXrender x86_64 0.9.8-2.1.el7 base 25 k libXtst x86_64 1.2.2-2.1.el7 base 20 k libXxf86vm x86_64 1.1.3-2.1.el7 base 17 k libasyncns x86_64 0.8-7.el7 base 26 k libfontenc x86_64 1.1.1-5.el7 base 29 k libjpeg-turbo x86_64 1.2.90-5.el7 base 134 k libogg x86_64 2:1.3.0-7.el7 base 24 k libpng x86_64 2:1.5.13-5.el7 base 212 k libsndfile x86_64 1.0.25-9.el7 base 149 k libthai x86_64 0.1.14-9.el7 base 187 k libtiff x86_64 4.0.3-14.el7 base 167 k libvorbis x86_64 1:1.3.3-8.el7 base 204 k libxcb x86_64 1.9-5.el7 base 169 k libxslt x86_64 1.1.28-5.el7 base 242 k log4j noarch 1.2.17-15.el7 base 443 k mesa-libEGL x86_64 9.2.5-6.20131218.el7_0 updates 69 k mesa-libGL x86_64 9.2.5-6.20131218.el7_0 updates 142 k mesa-libgbm x86_64 9.2.5-6.20131218.el7_0 updates 30 k mesa-libglapi x86_64 9.2.5-6.20131218.el7_0 updates 34 k pango x86_64 1.34.1-5.el7 base 283 k pixman x86_64 0.32.4-3.el7 base 254 k pulseaudio-libs x86_64 3.0-22.el7 base 555 k python-javapackages noarch 3.4.1-6.el7_0 updates 31 k python-lxml x86_64 3.2.1-4.el7 base 758 k slf4j noarch 1.7.4-3.el7 base 170 k tomcat-servlet-3.0-api noarch 7.0.42-8.el7_0 updates 188 k ttmkfdir x86_64 3.0.9-41.el7 base 47 k tzdata-java noarch 2014j-1.el7_0 updates 144 k xalan-j2 noarch 2.7.1-23.el7 base 1.9 M xerces-j2 noarch 2.11.0-17.el7_0 updates 1.1 M xml-commons-apis noarch 1.4.01-16.el7 base 227 k xml-commons-resolver noarch 1.2-15.el7 base 108 k xorg-x11-font-utils x86_64 1:7.5-18.1.el7 base 87 k xorg-x11-fonts-Type1 noarch 7.5-9.el7 base 521 k Transaction Summary ======================================================================================= Install 2 Packages (+76 Dependent packages) Total download size: 45 M Installed size: 143 M
Create DB
# mysql -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 5.5.40-MariaDB MariaDB Server Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE teamcity DEFAULT CHARACTER SET utf8; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> GRANT USAGE ON *.* TO 'teamcity'@'localhost' IDENTIFIED BY 'teamcity'; Query OK, 0 rows affected (0.09 sec) MariaDB [(none)]> GRANT ALL ON teamcity.* TO 'teamcity'@'localhost'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec)
Restore Teamcity DB
$ teamcity/bin/maintainDB.sh restore -F ~/TeamCity_Backup_20141212_104822.zip -T ~/database.properties ../webapps/ROOT/WEB-INF/lib Using logs directory /srv/teamcity/9.0.0/bin/teamcity/logs Specified log4j configuration file (teamcity/bin/../conf/teamcity-maintenance-log4j.xml) not found. TeamCity maintenance tool. Copyright 2013 JetBrains s.r.o. All Rights Reserved. Command line arguments: restore -F /srv/teamcity/TeamCity_Backup_20141212_104822.zip -T /srv/teamcity/database.properties TeamCity Data Directory path is determined using the user home directory Using TeamCity data directory: /srv/teamcity/.BuildServer Restoring from backup file: /srv/teamcity/TeamCity_Backup_20141212_104822.zip Backup of TeamCity data version: Version: 8.1.5 Build number: 30240 Data format version: 658 Using explicitly specified target database settings: /srv/teamcity/database.properties Using target database database type: MYSQL connection string: jdbc:mysql://localhost/teamcity Target JDBC driver version 5.1 (MySQL Connector Java) Target database system version 5.5.40 (MySQL) Connected to the Target DB successfully. Starting restore Opening zip file: /srv/teamcity/TeamCity_Backup_20141212_104822.zip Using character set UTF-8 for database import. Restoring Configuration Could not restore file "lib/jdbc/mysql-connector-java.jar", skipped. Error: java.io.FileNotFoundException: /srv/teamcity/.BuildServer/lib/jdbc/mysql-connector-java.jar (Permission denied) Restoring Database Analyzing database... Creating tables Importing data... Importing table: db_version (4 KB) Importing table: meta_file_line (61 KB) Importing table: single_row (<1 KB) Importing table: db_heartbeat (<1 KB) Importing table: project_mapping (<1 KB) Importing table: build_type_mapping (<1 KB) Importing table: vcs_root_mapping (<1 KB) Importing table: server_health_items (<1 KB) Importing table: agent (<1 KB) Importing table: deleted_build_types (<1 KB) Importing table: build_data_storage (601 KB) Importing table: canceled_info (5 KB) Importing table: running (<1 KB) Importing table: build_state (35 KB) Importing table: build_dependency (<1 KB) Importing table: build_attrs (309 KB) Importing table: problem (2 KB) Importing table: build_problem (104 KB) Importing table: build_problem_attribute (28 KB) Importing table: build_problem_muted (<1 KB) Importing table: build_artifact_dependency (<1 KB) Importing table: final_artifact_dependency (<1 KB) Importing table: agent_sources_version (3 KB) Importing table: vcs_history (661 KB) Importing table: build_type_vcs_change (42 KB) Importing table: build_checkout_rules (166 KB) Importing table: vcs_changes (2 MB) Importing table: vcs_changes_graph (281 KB) Importing table: vcs_change_attrs (<1 KB) Importing table: personal_vcs_changes (33 KB) Importing table: personal_vcs_history (<1 KB) Importing table: test_names (144 KB) Importing table: mute_info (<1 KB) Importing table: mute_info_bt (<1 KB) Importing table: mute_info_test (<1 KB) Importing table: mute_test_in_proj (<1 KB) Importing table: mute_test_in_bt (<1 KB) Importing table: mute_info_problem (<1 KB) Importing table: mute_problem_in_proj (<1 KB) Importing table: mute_problem_in_bt (<1 KB) Importing table: test_info (1 MB) Importing table: test_muted (<1 KB) Importing table: test_failure_rate (<1 KB) Importing table: build_queue (<1 KB) Importing table: stats (9 KB) Importing table: stats_publisher_state (<1 KB) Importing table: failed_tests_output (<1 KB) Importing table: compiler_output (5 KB) Importing table: ignored_tests (229 KB) Importing table: downloaded_artifacts (<1 KB) Importing table: users (1 KB) Importing table: user_property (6 KB) Importing table: user_blocks (<1 KB) Importing table: user_projects_visibility (<1 KB) Importing table: user_projects_order (<1 KB) Importing table: user_notification_events (<1 KB) Importing table: user_watch_type (<1 KB) Importing table: user_roles (<1 KB) Importing table: usergroups (<1 KB) Importing table: usergroup_users (<1 KB) Importing table: usergroup_subgroups (<1 KB) Importing table: usergroup_roles (<1 KB) Importing table: usergroup_notification_events (<1 KB) Importing table: usergroup_watch_type (<1 KB) Importing table: server_property (<1 KB) Importing table: build_revisions (452 KB) Importing table: vcs_root_first_revision (2 KB) Importing table: user_build_parameters (<1 KB) Importing table: default_build_parameters (20 KB) Importing table: build_labels (<1 KB) Importing table: personal_build_relative_path (23 KB) Importing table: action_history (4 KB) Importing table: audit_additional_object (10 KB) Importing table: remember_me (<1 KB) Importing table: vcs_root_instance (18 KB) Importing table: comments (7 KB) Importing table: agent_pool (<1 KB) Importing table: agent_pool_project (<1 KB) Importing table: agent_type (<1 KB) Importing table: agent_type_bt_access (<1 KB) Importing table: agent_type_info (<1 KB) Importing table: agent_type_runner (<1 KB) Importing table: agent_type_vcs (<1 KB) Importing table: agent_type_param (6 KB) Importing table: responsibilities (<1 KB) Importing table: cloud_started_instance (<1 KB) Importing table: cloud_image_without_agent (<1 KB) Importing table: inspection_results (<1 KB) Importing table: inspection_data (<1 KB) Importing table: inspection_stats (<1 KB) Importing table: inspection_info (<1 KB) Importing table: inspection_fixes (<1 KB) Importing table: inspection_diff (<1 KB) Importing table: duplicate_results (<1 KB) Importing table: duplicate_fragments (<1 KB) Importing table: fragments (<1 KB) Importing table: project_files (<1 KB) Importing table: duplicate_diff (<1 KB) Importing table: duplicate_stats (<1 KB) Importing table: tc_build_tags (<1 KB) Importing table: build_set_tmp (<1 KB) Importing table: history (187 KB) Importing table: light_history (64 KB) Importing table: backup_info (<1 KB) Importing table: backup_builds (5 KB) Importing table: build_overriden_roots (<1 KB) Importing table: data_storage_dict (1 KB) Importing table: cleanup_history (17 KB) Importing table: clean_checkout_enforcement (<1 KB) Importing table: server (<1 KB) Creating indices creating index project_mapping_ak... creating index build_type_mapping_ak... creating index vcs_root_mapping_ak... creating index agent_name_ui... creating index problem_ak... creating index build_type_vcs_change_ui... creating index mute_info_ak... creating index users_ak... creating index user_property_ui... creating index user_blocks_ui... creating index user_projects_visibility_ui... creating index user_projects_order_ui... creating index user_watch_type_ui... creating index user_roles_ui... creating index usergroups_name... creating index usergroup_users_ui... creating index usergroup_subgroups_ui... creating index usergroup_roles_ui... creating index usergroup_watch_type_ui... creating index server_property_ak... creating index personal_build_relative_p_ak... creating index agent_pool_ak... creating index agent_type_ak... creating index inspection_info_ak... creating index inspection_diff_ak... creating index backup_builds_ak... creating index value_type_key_index... creating index project_mapping_ie... creating index build_type_mapping_ie... creating index vcs_root_mapping_ie... creating index server_health_items_ie... creating index agent_host_address... creating index agent_authorization_token... creating index agent_agent_type_id... creating index running_state_id... creating index build_state_mod_id... creating index build_state_build_type_id... creating index build_state_build_id... creating index build_attrs_num_i... creating index build_artif_dep_state_id... creating index final_artif_dep_state_id... creating index agent_sources_version_hidx... creating index vcs_history_root... creating index vcs_history_user... creating index vcs_version_in_root_i... creating index build_type_vcs_change_btid... creating index vcs_changes_index... creating index vcs_personal_changes_index... creating index personal_vcs_history_user_id... creating index mute_test_in_proj_ie... creating index mute_test_in_bt_ie... creating index mute_problem_in_proj_ie... creating index mute_problem_in_bt_ie... creating index test_name_id_idx... creating index test_muted_mute_id... creating index build_queue_build_state_id... creating index co_build_id_index... creating index ignored_tests_build_id... creating index downloaded_artifacts_source_id... creating index downloaded_artifacts_ts_id... creating index notification_events_notifier... creating index notification_events_user_id... creating index watch_type_rule_id... creating index usergroup_events_notifier... creating index usergroup_events_group_id... creating index group_watch_type_rule_id... creating index build_revisions_vcs_root_i... creating index user_build_params_state_id... creating index def_build_params_state_id... creating index build_labels_build... creating index build_labels_vcs_root... creating index action_history_comment... creating index action_history_object... creating index action_history_action_object_i... creating index audit_a_o_comment... creating index audit_a_o_object_index... creating index vcs_root_instance_parent_idx... creating index vcs_root_instance_hash_idx... creating index agent_type_pool_i... creating index agent_type_bt_access_bt_i... creating index responsibilities_reporter... creating index responsibilities_assignee... creating index inspection_results_hash_index... creating index inspection_results_buildhash_i... creating index inspection_data_file_index... creating index inspection_data_insp_index... creating index inspection_fixes_hash_index... creating index inspection_diff_hash_index... creating index duplicate_results_build_id... creating index duplicate_fragments_index... creating index duplicate_fragments_file_index... creating index duplicate_results_file_index... creating index fragments_hash_index... creating index project_files_file_name_index... creating index tc_tags_id_index... creating index tc_tags_id_tag... creating index start_time_index... creating index build_type_id_index... creating index pinned_index... creating index status_index... creating index history_state_id... creating index history_agname_bfintimesrv_i... creating index history_finish_time_i... creating index history_build_number... creating index history_agt_b_i... creating index start_time_index_light... creating index build_type_id_index_light... creating index pinned_index_light... creating index status_index_light... creating index light_history_agname_bftime_i... creating index light_history_finish_time_i... creating index light_history_agt_b_i... creating index backup_info_file_i... creating index build_subst_root_index... Created indices: 114 Importing Supplementary Data Importing Personal Changes Importing Build Logs Finishing Restored 2948 files. Restoring finished with warnings Changing default database connection in TeamCity configuration: Copying target database properties file from: /srv/teamcity/database.properties to: /srv/teamcity/.BuildServer/config/database.properties Done.
Nginx
The following nginx configuration is used as a reverse proxy in front of TeamCity:
server { listen [::]:80; server_name teamcity.lucidsolutions.co.nz; location / { # redirect to secure page [permanent | redirect] rewrite ^ https://teamcity.lucidsolutions.co.nz$request_uri? permanent; } } map $http_upgrade $connection_upgrade { default upgrade; '' ''; } server { listen [::]:443; server_name teamcity.lucidsolutions.co.nz; keepalive_timeout 70; ssl on; ssl_certificate certs/teamcity.lucidsolutions.co.nz.startssl.crt; ssl_certificate_key certs/teamcity.lucidsolutions.co.nz.key; access_log /var/log/nginx/teamcity.lucidsolutions.co.nz.access.log main; location / { proxy_pass http://10.20.20.2:8111/; proxy_http_version 1.1; proxy_read_timeout 1200; proxy_connect_timeout 240; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; client_max_body_size 100M; } }
cron based backup
A trivial cron task to create backup files Mon-Fri at 2am. Use 'crontab -e' as the teamcity user to create/edit:
JAVA_HOME=/usr/lib/jvm/jre/ MAILTO=me@example.com 0 2 * * 1-5 ~/teamcity/bin/maintainDB.sh backup -C -D -L