本文实践Gerrit从2.15.7升级至3.2.3。
Gerrit在2.16.x版本以后,数据库结构发生了变化,不再使用Postgres,而是使用了NoteDB;所以 Gerrit从2.15.x升级到3.x以上,需要由2.15.x过度到2.16.x,然后再升级到3.x版本。
其中Changes数据需要通过手动方式从ReviewDB迁移,Account和Group数据由Gerrit在执行init时自动迁移。
升级准备
- 清空日志目录
rm -rf /data/cicd/gerrit/review_site/logs/*
* 清空插件目录
rm -rf /data/cicd/gerrit/review_site/plugins/*
**升级至Gerrit 2.16.15**Gerrit 2.15.7升级到2.16.15,执行命令前,需要完成升级准备阶段的工作。**停止Gerrit 2.15.7**
docker stop cicd-gerrit215-service
**检测Gerrit版本**
java -jar review_site/bin/gerrit.war version
**手动执行升级**When you run ‘migrate-to-note-db‘ command, you must have to set ‘–-threads’ as small as possible. If you don’t set it, a migration process creates too many threads to make connections to a database and you will see error message ‘ you can’t make a connection to database’
java -jar review_site/bin/gerrit.war migrate-to-note-db --threads 3 -d review_site/ 2>&1 | tee /tmp/notedb.txt
输出示例[2020-11-08 15:25:33,056] [main] INFO com.google.gerrit.server.git.LocalDiskRepositoryManager : Defaulting core.streamFileThreshold to 2047m
[2020-11-08 15:25:33,953] [main] INFO com.google.gerrit.server.cache.h2.H2CacheFactory : Enabling disk cache /data/cicd/gerrit/review_site/cache
[2020-11-08 15:25:34,064] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'WorkQueue' queue
[2020-11-08 15:25:34,069] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'SendEmail' queue
[2020-11-08 15:25:34,073] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'ReceiveCommits' queue
[2020-11-08 15:25:34,334] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'Index-Interactive' queue
[2020-11-08 15:25:34,337] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'Index-Batch' queue
[2020-11-08 15:25:34,346] [main] INFO com.google.gerrit.server.rules.PrologEnvironment : reductionLimit: 100000, compileLimit: 1000000
[2020-11-08 15:25:34,646] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loading plugins from /data/cicd/gerrit/review_site/plugins
[2020-11-08 15:25:34,663] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'RebuildChange' queue
[2020-11-08 15:25:34,700] [main] INFO com.google.gerrit.server.config.ScheduleConfig : No schedule configuration for "gc".
[2020-11-08 15:25:34,702] [main] INFO com.google.gerrit.server.git.GarbageCollection : [All-Users] gc config: gc.aggressive=false;
[2020-11-08 15:25:34,703] [main] INFO com.google.gerrit.server.git.GarbageCollection : [All-Users] pack config: maxDeltaDepth=50, deltaSearchWindowSize=10, deltaSearchMemoryLimit=0, deltaCacheSize=52428800, deltaCacheLimit=100, compressionLevel=-1, indexVersion=2, bigFileThreshold=52428800, threads=0, reuseDeltas=true, reuseObjects=true, deltaCompress=true, buildBitmaps=true, bitmapContiguousCommitCount=100, bitmapRecentCommitCount=20000, bitmapRecentCommitSpan=100, bitmapDistantCommitSpan=5000, bitmapExcessiveBranchCount=100, bitmapInactiveBranchAge=90, singlePack=false
[2020-11-08 15:25:34,864] [main] INFO com.google.gerrit.server.git.GarbageCollection : [All-Users] before: sizeOfPackedObjects=1606969, sizeOfLooseObjects=1693162, numberOfPackedObjects=10189, numberOfPackFiles=2, numberOfPackedRefs=890, numberOfLooseRefs=3, numberOfLooseObjects=11717
collecting garbage for "All-Users":
Pack refs: 100% (892/892)
Counting objects: 21753
Finding sources: 100% (21753/21753)
Getting sizes: 100% (9080/9080)
Compressing objects: 100% (948987/948987)
Writing objects: 100% (21753/21753)
Selecting commits: 100% (8905/8905)
Building bitmaps: 100% (3972/3972)
Prune loose objects also found in pack files: 100% (258/258)
Prune loose, unreferenced objects: 100% (258/258)
[2020-11-08 15:25:40,472] [main] INFO com.google.gerrit.server.git.GarbageCollection : [All-Users] after: sizeOfPackedObjects=4505521, sizeOfLooseObjects=3582, numberOfPackedObjects=31942, numberOfPackFiles=3, numberOfPackedRefs=892, numberOfLooseRefs=1, numberOfLooseObjects=151
done.
[2020-11-08 15:25:40,629] [main] INFO com.google.gerrit.server.git.LocalDiskRepositoryManager : Defaulting core.streamFileThreshold to 2047m
[2020-11-08 15:25:40,755] [main] INFO com.google.gerrit.server.cache.h2.H2CacheFactory : Enabling disk cache /data/cicd/gerrit/review_site/cache
[2020-11-08 15:25:40,781] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'WorkQueue' queue
[2020-11-08 15:25:40,782] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'Index-Interactive' queue
[2020-11-08 15:25:40,782] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'Index-Batch' queue
[2020-11-08 15:25:40,794] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'SendEmail' queue
[2020-11-08 15:25:40,795] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'ReceiveCommits' queue
[2020-11-08 15:25:40,802] [main] INFO com.google.gerrit.server.rules.PrologEnvironment : reductionLimit: 100000, compileLimit: 1000000
[2020-11-08 15:25:41,080] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loading plugins from /data/cicd/gerrit/review_site/plugins
Collecting projects: 379
Reindexing changes: projects: 100% (379/379), 99% (15544/15547), done
**修改配置文件**执行上一步migrate-to-note-db命令后,将在/data/cicd/gerrit/review_site/etc/目录下生成notedb.config文件。修改notedb.config文件:
vi review_site/etc/notedb.config
[noteDb "changes"]
autoMigrate = false
trial = false
write = true
read = true
sequence = true
primaryStorage = note db
disableReviewDb = true
**获取需要升级的Gerrit**用2.16.15版本的gerrit.war替换review_site/bin目录下的gerrit.war。注意gerrit.war的执行权限、属主和属组与原本的一致。**检测Gerrit版本**
java -jar review_site/bin/gerrit.war version
**初始化需要升级的Gerrit**
java -jar review_site/bin/gerrit.war init --batch --install-all-plugins -d review_site/
输出示例Upgrading schema to 162 ...
......
Upgrading schema to 170 ...
Migrating data to schema 162 ...
Done (0.040 s)
......
Migrating data to schema 169 ...
Migrating projects: 100% (379/379)
Skipped 379 projects with no legacy comments
Done (6.877 s)
Migrating data to schema 170 ...
Done (0.000 s)
Execute the following SQL to drop unused objects:
DROP TABLE account_group_by_id_aud;
DROP TABLE account_group_members;
DROP TABLE system_config;
DROP TABLE account_groups;
DROP TABLE account_group_by_id;
DROP TABLE account_group_members_audit;
DROP TABLE account_group_names;
Initialized /data/cicd/gerrit/review_site
Reindexing projects: 100% (379/379)
Reindexed 379 documents in projects index in 1.0s (373.8/s)
**重建Changes索引**
java -jar review_site/bin/gerrit.war reindex -d review_site/ --index changes
输出示例[2020-11-08 15:15:40,809] [main] INFO com.google.gerrit.server.git.LocalDiskRepositoryManager : Defaulting core.streamFileThreshold to 2047m
[2020-11-08 15:15:41,694] [main] INFO com.google.gerrit.server.cache.h2.H2CacheFactory : Enabling disk cache /data/cicd/gerrit/review_site/cache
[2020-11-08 15:15:41,784] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'WorkQueue' queue
[2020-11-08 15:15:41,790] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'Index-Interactive' queue
[2020-11-08 15:15:41,793] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'Index-Batch' queue
[2020-11-08 15:15:41,841] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'ReceiveCommits' queue
[2020-11-08 15:15:41,842] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'SendEmail' queue
[2020-11-08 15:15:42,020] [main] INFO com.google.gerrit.server.rules.PrologEnvironment : reductionLimit: 100000, compileLimit: 1000000
[2020-11-08 15:15:42,552] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loading plugins from /data/cicd/gerrit/review_site/plugins
[2020-11-08 15:15:42,592] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin codemirror-editor, version v2.16.15
[2020-11-08 15:15:42,608] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin commit-message-length-validator, version v2.16.15
[2020-11-08 15:15:42,623] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin download-commands, version v2.16.15
[2020-11-08 15:15:42,638] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin hooks, version v2.16.15
[2020-11-08 15:15:42,656] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin replication, version v2.16.15
[2020-11-08 15:15:42,672] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin reviewnotes, version v2.16.15
[2020-11-08 15:15:42,687] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin singleusergroup, version v2.16.15
Collecting projects: 379
Reindexing changes: projects: 98% (375/379), 94% (14683/15547) ()[2020-11-08 15:16:13,147] [DiskCache-Prune-0] INFO com.google.gerrit.server.cache.h2.H2CacheImpl : Pruned 9146 entries not matching version 1 from cache jdbc:h2:file:///data/cicd/gerrit/review_site/cache/change_kind
Reindexing changes: projects: 99% (377/379), 99% (15462/15547) (-)[2020-11-08 15:16:18,423] [DiskCache-Prune-0] INFO com.google.gerrit.server.cache.h2.H2CacheImpl : Pruned 93697 entries not matching version 1 from cache jdbc:h2:file:///data/cicd/gerrit/review_site/cache/mergeability
[2020-11-08 15:16:18,435] [DiskCache-Prune-0] INFO com.google.gerrit.server.cache.h2.H2CacheImpl : Pruned 146 entries not matching version 1 from cache jdbc:h2:file:///data/cicd/gerrit/review_site/cache/git_tags
Reindexing changes: projects: 100% (379/379), 99% (15544/15547), done
Reindexed 15544 documents in changes index in 34.5s (451.0/s)
[2020-11-08 15:16:23,180] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin replication, version v2.16.15
[2020-11-08 15:16:23,181] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin codemirror-editor, version v2.16.15
[2020-11-08 15:16:23,181] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin commit-message-length-validator, version v2.16.15
[2020-11-08 15:16:23,181] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin reviewnotes, version v2.16.15
[2020-11-08 15:16:23,182] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin download-commands, version v2.16.15
[2020-11-08 15:16:23,182] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin singleusergroup, version v2.16.15
[2020-11-08 15:16:23,182] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin hooks, version v2.16.15
[2020-11-08 15:16:23,518] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_replication_201108_1515_4218509551599327313.jar
[2020-11-08 15:16:23,519] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_codemirror-editor_201108_1515_5590453549704867383.jar
[2020-11-08 15:16:23,519] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_commit-message-length-validator_201108_1515_3672451813373162299.jar
[2020-11-08 15:16:23,519] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_reviewnotes_201108_1515_6567205789463678052.jar
[2020-11-08 15:16:23,519] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_download-commands_201108_1515_7947175045620868733.jar
[2020-11-08 15:16:23,519] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_singleusergroup_201108_1515_5529529377723937575.jar
[2020-11-08 15:16:23,519] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_hooks_201108_1515_1295027737828308642.jar
**运行Gerrit实例**可通过MIGRATE_TO_NOTEDB_OFFLINE=true选项升级Gerrit到 2.16.15,在我的实践中,这种方式导致Changes索引创建失败。如果容器运行失败,请参考后面异常处理部分。
docker run \
--name cicd-gerrit216-service \
--restart always \
--network host \
#-e MIGRATE_TO_NOTEDB_OFFLINE=true \ #升级选项,Gerrit从2.15.7升级到2.16.x以上;采用手工升级后,创建容器时禁止该选项
-e WEBURL=http://192.168.122.32:8080 \
-v "/var/run/docker.sock:/var/run/docker.sock:rw" \
-v "/data/cicd/gerrit/review_site:/var/gerrit/review_site" \
-e DATABASE_TYPE=postgresql \
-e DATABASE_HOSTNAME=192.168.122.32 \
-e DATABASE_PORT=5432 \
-e DATABASE_DATABASE=reviewdb \
-e DATABASE_USERNAME=gerrit2 \
-e DATABASE_PASSWORD=secret \
-e AUTH_TYPE=LDAP \
-e AUTH_GITBASICAUTHPOLICY=LDAP \
-e LDAP_SERVER=ldap://192.168.122.32 \
-e LDAP_USERNAME=cn\=admin\,dc\=example\,dc\=org \
-e LDAP_PASSWORD=secret \
-e LDAP_ACCOUNTBASE=dc=example,dc=org \
-e LDAP_ACCOUNTPATTERN=(\&(objectClass=person)(uid=\${username})) \
-e LDAP_ACCOUNTFULLNAME=displayName \
-e LDAP_GROUPBASE=dc=example,dc=org \
-e SMTP_SERVER=<Your Emial Server> \
-e SMTP_USER=dcfenga@sina.com \
-e SMTP_PASS=<Your Password> \
-e SMTP_FROM=dcfenga@sina.com \
-d openfrontier/gerrit:2.16.15
非容器方式运行:
前台运行review_site/bin/gerrit.sh start
后台运行java -jar review_site/bin/gerrit.war daemon -d review_site/
**升级至Gerrit 3.2.3**Gerrit 2.16.15升级到3.2.3,执行命令前,需要完成升级准备阶段的工作。**停止Gerrit 2.16.15**
docker stop cicd-gerrit216-service
**检测Gerrit版本**
java -jar review_site/bin/gerrit.war version
**手动执行升级**
java -jar review_site/bin/gerrit.war migrate-to-note-db --threads 3 -d review_site/ 2>&1 | tee /tmp/notedb.txt
**修改配置文件**2.16.x升级至3.x以上时,请参考Gerrit部署实践:冷备方案/自动备份中的gerrit.config和secure.config,修改这2个配置文件。同时修改:
vi review_site/etc/notedb.config
[noteDb "changes"]
autoMigrate = false
trial = false
write = true
read = true
sequence = true
primaryStorage = note db
disableReviewDb = true
**获取需要升级的Gerrit**用3.2.3版本的gerrit.war替换review_site/bin目录下的gerrit.war。注意gerrit.war的执行权限、属主和属组与原本的一致。**检测Gerrit版本**
java -jar review_site/bin/gerrit.war version
**初始化需要升级的Gerrit**
java -jar review_site/bin/gerrit.war init --batch --install-all-plugins -d review_site/
输出示例Migrating data to schema 180 ...
Migrating data to schema 181 ...
Rebuild GPG note map to build subkey to master key map
Migrating data to schema 182 ...
Found a total of 0 zombie draft refs in All-Users repo.
Cleanup percentage = 100
Number of zombie refs to be cleaned = 0
Migrating data to schema 183 ...
Initialized /data/cicd/gerrit/review_site
**重建Changes索引**java -jar review_site/bin/gerrit.war reindex -d review_site/ --index changes
输出示例[2020-11-08 15:44:13,324] [main] INFO com.google.gerrit.server.git.SystemReaderInstaller : Set JGit's SystemReader to read system config from review_site/etc/jgit.config
[2020-11-08 15:44:13,342] [main] INFO com.google.gerrit.server.git.LocalDiskRepositoryManager : Defaulting core.streamFileThreshold to 2047m
[2020-11-08 15:44:13,914] [main] INFO com.google.gerrit.server.cache.h2.H2CacheFactory : Enabling disk cache /data/cicd/gerrit/review_site/cache
[2020-11-08 15:44:13,974] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'WorkQueue' queue
[2020-11-08 15:44:13,981] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'Index-Interactive' queue
[2020-11-08 15:44:13,985] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'Index-Batch' queue
[2020-11-08 15:44:14,041] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'ReceiveCommits' queue
[2020-11-08 15:44:14,042] [main] INFO com.google.gerrit.server.git.WorkQueue : Adding metrics for 'SendEmail' queue
[2020-11-08 15:44:14,368] [main] INFO com.google.gerrit.server.rules.PrologEnvironment : reductionLimit: 100000, compileLimit: 1000000
[2020-11-08 15:44:14,973] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loading plugins from /data/cicd/gerrit/review_site/plugins
[2020-11-08 15:44:15,042] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin codemirror-editor, version v3.2.3
[2020-11-08 15:44:15,059] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin commit-message-length-validator, version v3.2.3
[2020-11-08 15:44:15,078] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin delete-project, version v3.2.3
[2020-11-08 15:44:15,095] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin download-commands, version v3.2.3
[2020-11-08 15:44:15,115] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin gitiles, version v3.2.3
[2020-11-08 15:44:15,132] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin hooks, version v3.2.3
[2020-11-08 15:44:15,149] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin plugin-manager, version v3.2.3
[2020-11-08 15:44:15,167] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin replication, version v3.2.3
[2020-11-08 15:44:15,184] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin reviewnotes, version v3.2.3
[2020-11-08 15:44:15,200] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin singleusergroup, version v3.2.3
[2020-11-08 15:44:15,226] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin webhooks, version v3.2.3
......
Reindexing changes: project-slices: 100% (381/381), 99% (15544/15547), done
Reindexed 15544 documents in changes index in 26.4s (589.4/s)
Index changes in version 60 is ready
[2020-11-08 15:44:47,649] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin replication, version v3.2.3
[2020-11-08 15:44:47,650] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin codemirror-editor, version v3.2.3
[2020-11-08 15:44:47,650] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin commit-message-length-validator, version v3.2.3
[2020-11-08 15:44:47,650] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin gitiles, version v3.2.3
[2020-11-08 15:44:47,650] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin webhooks, version v3.2.3
[2020-11-08 15:44:47,651] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin reviewnotes, version v3.2.3
[2020-11-08 15:44:47,651] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin download-commands, version v3.2.3
[2020-11-08 15:44:47,651] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin delete-project, version v3.2.3
[2020-11-08 15:44:47,651] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin plugin-manager, version v3.2.3
[2020-11-08 15:44:47,651] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin singleusergroup, version v3.2.3
[2020-11-08 15:44:47,651] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Unloading plugin hooks, version v3.2.3
[2020-11-08 15:44:47,949] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_replication_201108_1544_4922680236002785864.jar
[2020-11-08 15:44:47,949] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_codemirror-editor_201108_1544_5086350842417489189.jar
[2020-11-08 15:44:47,950] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_commit-message-length-validator_201108_1544_4655947078639711672.jar
[2020-11-08 15:44:47,950] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_gitiles_201108_1544_5170883579453958573.jar
[2020-11-08 15:44:47,950] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_webhooks_201108_1544_1580078110702459470.jar
[2020-11-08 15:44:47,950] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_reviewnotes_201108_1544_1665259453122312566.jar
[2020-11-08 15:44:47,950] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_download-commands_201108_1544_4752854521122101176.jar
[2020-11-08 15:44:47,951] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_delete-project_201108_1544_3266685276203715677.jar
[2020-11-08 15:44:47,951] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_plugin-manager_201108_1544_1580667555814940097.jar
[2020-11-08 15:44:47,951] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_singleusergroup_201108_1544_4988390803533903124.jar
[2020-11-08 15:44:47,951] [main] INFO com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_hooks_201108_1544_2635196783551351111.jar
**运行Gerrit实例**
docker run \
--name cicd-gerrit-service \
--restart always \
--network host \
-e DOCKER_HOST=tcp://<HOST-IP>:2375 \
-v "/var/run/docker.sock:/var/run/docker.sock:rw" \
-v "/data/cicd/gerrit/review_site:/var/gerrit/review_site" \
-d openfrontier/gerrit:3.2.3-1
docker run --name cicd-gerrit-service --restart always --network host -e DOCKER_HOST=tcp://192.168.122.32:2375 -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v "/data/cicd/gerrit/review_site:/var/gerrit/review_site" -d openfrontier/gerrit:3.2.3-1
**异常处理****异常现象:change X has no note_db_state**异常现象:Gerrit 2.5.7 -> Gerrit 2.16.15: change X has no note_db_state; rebuild it first.解决方法:
宿主机上执行[root@server gerrit]# cd /data/cicd/gerrit
手动执行迁移When you run ‘migrate-to-note-db‘ command, you must have to set ‘–threads’ as small as possible.If you don’t set it, a migration process creates too many threads to make connections to adatabase and you will see error message ‘ you can’t make a connection to database’[root@server gerrit]# java -jar review_site/bin/gerrit.war migrate-to-note-db --treads 3 -d review_site/ 2>&1 | tee /tmp/notedb.txt
从日志中获取迁移出错的数据[root@server gerrit]# cat /tmp/notedb.txt | grep 'has no note_db_state' | awk '{print $3}'
删除数据库中异常数据,可使用Shell脚本批量删除或者直接从数据库中删除SELECT FROM changes WHERE change_id = 15937
SELECT FROM change_messages WHERE change_id = 15937
[root@server gerrit]# vi etc/notedb.config
[noteDb "changes"]
autoMigrate = false
trial = false
write = true
read = true
sequence = true
primaryStorage = NOTE_DB
disableReviewDb = true
primaryStorage = review db
disableReviewDb = false
[root@server gerrit]# java -jar review_site/bin/gerrit.war migrate-to-note-db -d review_site/ 2>&1 | tee /tmp/notedb.txt
执行初始化[root@server gerrit]# java -jar review_site/bin/gerrit.war init --batch --install-all-pl