Percona Server til MongoDB er en MongoDB open source distribution drevet af Percona. Det er en gratis, fuldt kompatibel og drop-in erstatning for MongoDB Community-udgave. Det giver også "enterprise grade"-funktioner, som ellers kun ville være tilgængelige i Enterprise Edition af MongoDB, for eksempel:LDAP-godkendelse og -autorisation, revisionslogning, Kerberos-godkendelse.
Opgradering af Percona Server til MongoDB er virkelig ligetil. I denne blog vil vi diskutere nogle opgraderingstips og vise et eksempel på, hvordan man opgraderer fra version 3.6 til version 4.0.
Opgraderingsforberedelse
Før du kører opgraderingen, vil du måske forberede dig. Kontroller altid kompatibilitetsændringer i dokumentationen og på din applikationsside; tjek dokumentationen relateret til ændringer og forbedringsfunktioner, forældet funktionalitet (hvis nogen).
Tjek driverkompatibilitetsmatrixen for MongoDB for at forstå, om du også skal opgradere driveren.
Forbered en trinvis tjekliste over, hvordan opgraderingen vil blive udført. Skriv handlingsplanen ned, parterne skal involveres i dokumentationen, rollback plan for worst case scenarier.
Opgradering af Percona Server til MongoDB
Det er altid godt at teste din opgradering i udviklings- eller iscenesættelsesmiljøet, før du flytter til produktionsmiljøet. Du kan bygge nøjagtig den samme MongoDB-arkitektur som produktion, teste og gendanne dataene fra den sidste backup. Derefter kan du teste opgraderingen og validere din opgraderingsplan, ikke kun at du kan få et skøn over, hvor lang tid opgraderingen vil tage og også verificere, om applikationen er kompatibel med den nye version af databasen.
Opgraderingsprocessen installerer bare den nye pakke fra percona-lageret. Sådan opgraderes på CentOS baseret fra version 3.6 til version 4.0.
Trin 1
Hvis du ikke har installeret Percona Repository, kan du installere percona-release-latest.
[[email protected] ~]# yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
Loaded plugins: fastestmirror
percona-release-latest.noarch.rpm | 19 kB 00:00:00
Examining /var/tmp/yum-root-evWD4w/percona-release-latest.noarch.rpm: percona-release-1.0-25.noarch
Marking /var/tmp/yum-root-evWD4w/percona-release-latest.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package percona-release.noarch 0:1.0-25 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================
Installing:
percona-release noarch 1.0-25 /percona-release-latest.noarch 31 k
Transaction Summary
===========================================================================================================================================
Install 1 Package
Total size: 31 k
Installed size: 31 k
Is this ok [y/d/N]: y
Trin to
Efter installation af Percona-lageret, aktiver Percona Server til MongoDB 4.0
[[email protected] ~]# percona-release enable psmdb-40
* Enabling the Percona Server for MongoDB 4.0 repository
<*> All done!
Trin tre
Installer den nye pakke percona-server-mongodb, den vil automatisk fjerne den gamle pakke og installere ny pakke:
[[email protected] ~]# yum install percona-server-mongodb
Loaded plugins: fastestmirror
Repository percona-release-noarch is listed more than once in the configuration
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
percona-release | 2.9 kB 00:00:00
percona-release-noarch | 2.9 kB 00:00:00
percona-release-x86_64 | 2.9 kB 00:00:00
prel-release-noarch | 2.9 kB 00:00:00
psmdb-40-release-x86_64 | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/3): prel-release-noarch/7/primary_db | 2.5 kB 00:00:00
(2/3): psmdb-40-release-x86_64/7/primary_db | 47 kB 00:00:01
(3/3): percona-release-x86_64/7/primary_db | 1.1 MB 00:00:03
Loading mirror speeds from cached hostfile
* base: mirror.buana.web.id
* extras: mirror.buana.web.id
* updates: mirror.buana.web.id
Resolving Dependencies
--> Running transaction check
---> Package Percona-Server-MongoDB-36.x86_64 0:3.6.19-8.0.el7 will be obsoleted
---> Package percona-server-mongodb.x86_64 0:4.0.20-14.el7 will be obsoleting
--> Processing Dependency: percona-server-mongodb-tools = 4.0.20-14.el7 for package: percona-server-mongodb-4.0.20-14.el7.x86_64
--> Processing Dependency: percona-server-mongodb-mongos = 4.0.20-14.el7 for package: percona-server-mongodb-4.0.20-14.el7.x86_64
--> Processing Dependency: percona-server-mongodb-shell = 4.0.20-14.el7 for package: percona-server-mongodb-4.0.20-14.el7.x86_64
--> Processing Dependency: percona-server-mongodb-server = 4.0.20-14.el7 for package: percona-server-mongodb-4.0.20-14.el7.x86_64
--> Running transaction check
---> Package Percona-Server-MongoDB-36-mongos.x86_64 0:3.6.19-8.0.el7 will be obsoleted
---> Package Percona-Server-MongoDB-36-server.x86_64 0:3.6.19-8.0.el7 will be obsoleted
---> Package Percona-Server-MongoDB-36-shell.x86_64 0:3.6.19-8.0.el7 will be obsoleted
---> Package Percona-Server-MongoDB-36-tools.x86_64 0:3.6.19-8.0.el7 will be obsoleted
---> Package percona-server-mongodb-mongos.x86_64 0:4.0.20-14.el7 will be obsoleting
---> Package percona-server-mongodb-server.x86_64 0:4.0.20-14.el7 will be obsoleting
---> Package percona-server-mongodb-shell.x86_64 0:4.0.20-14.el7 will be obsoleting
---> Package percona-server-mongodb-tools.x86_64 0:4.0.20-14.el7 will be obsoleting
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================
Installing:
percona-server-mongodb x86_64 4.0.20-14.el7 psmdb-40-release-x86_64 4.9 k
replacing Percona-Server-MongoDB-36.x86_64 3.6.19-8.0.el7
percona-server-mongodb-mongos x86_64 4.0.20-14.el7 psmdb-40-release-x86_64 8.9 M
replacing Percona-Server-MongoDB-36-mongos.x86_64 3.6.19-8.0.el7
percona-server-mongodb-server x86_64 4.0.20-14.el7 psmdb-40-release-x86_64 19 M
replacing Percona-Server-MongoDB-36-server.x86_64 3.6.19-8.0.el7
percona-server-mongodb-shell x86_64 4.0.20-14.el7 psmdb-40-release-x86_64 9.8 M
replacing Percona-Server-MongoDB-36-shell.x86_64 3.6.19-8.0.el7
percona-server-mongodb-tools x86_64 4.0.20-14.el7 psmdb-40-release-x86_64 28 M
replacing Percona-Server-MongoDB-36-tools.x86_64 3.6.19-8.0.el7
Transaction Summary
===========================================================================================================================================
Install 5 Packages
Total download size: 66 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): percona-server-mongodb-4.0.20-14.el7.x86_64.rpm | 4.9 kB 00:00:05
(2/5): percona-server-mongodb-mongos-4.0.20-14.el7.x86_64.rpm | 8.9 MB 00:00:39
(3/5): percona-server-mongodb-shell-4.0.20-14.el7.x86_64.rpm | 9.8 MB 00:00:42
(4/5): percona-server-mongodb-server-4.0.20-14.el7.x86_64.rpm | 19 MB 00:01:23
(5/5): percona-server-mongodb-tools-4.0.20-14.el7.x86_64.rpm | 28 MB 00:02:00
-------------------------------------------------------------------------------------------------------------------------------------------
Total 332 kB/s | 66 MB 00:03:22
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : percona-server-mongodb-shell-4.0.20-14.el7.x86_64 1/10
Installing : percona-server-mongodb-server-4.0.20-14.el7.x86_64 2/10
warning: /etc/mongod.conf created as /etc/mongod.conf.rpmnew
* To start the service, configure your engine and start mongod
** WARNING: Access control is not enabled for the database.
** Read and write access to data and configuration is unrestricted.
** To fix this please use /usr/bin/percona-server-mongodb-enable-auth.sh
Installing : percona-server-mongodb-mongos-4.0.20-14.el7.x86_64 3/10
Installing : percona-server-mongodb-tools-4.0.20-14.el7.x86_64 4/10
Installing : percona-server-mongodb-4.0.20-14.el7.x86_64 5/10
Erasing : Percona-Server-MongoDB-36-3.6.19-8.0.el7.x86_64 6/10
Erasing : Percona-Server-MongoDB-36-server-3.6.19-8.0.el7.x86_64 7/10
Erasing : Percona-Server-MongoDB-36-shell-3.6.19-8.0.el7.x86_64 8/10
Erasing : Percona-Server-MongoDB-36-mongos-3.6.19-8.0.el7.x86_64 9/10
Erasing : Percona-Server-MongoDB-36-tools-3.6.19-8.0.el7.x86_64 10/10
Verifying : percona-server-mongodb-server-4.0.20-14.el7.x86_64 1/10
Verifying : percona-server-mongodb-tools-4.0.20-14.el7.x86_64 2/10
Verifying : percona-server-mongodb-mongos-4.0.20-14.el7.x86_64 3/10
Verifying : percona-server-mongodb-shell-4.0.20-14.el7.x86_64 4/10
Verifying : percona-server-mongodb-4.0.20-14.el7.x86_64 5/10
Verifying : Percona-Server-MongoDB-36-server-3.6.19-8.0.el7.x86_64 6/10
Verifying : Percona-Server-MongoDB-36-tools-3.6.19-8.0.el7.x86_64 7/10
Verifying : Percona-Server-MongoDB-36-mongos-3.6.19-8.0.el7.x86_64 8/10
Verifying : Percona-Server-MongoDB-36-shell-3.6.19-8.0.el7.x86_64 9/10
Verifying : Percona-Server-MongoDB-36-3.6.19-8.0.el7.x86_64 10/10
Installed:
percona-server-mongodb.x86_64 0:4.0.20-14.el7 percona-server-mongodb-mongos.x86_64 0:4.0.20-14.el7
percona-server-mongodb-server.x86_64 0:4.0.20-14.el7 percona-server-mongodb-shell.x86_64 0:4.0.20-14.el7
percona-server-mongodb-tools.x86_64 0:4.0.20-14.el7
Replaced:
Percona-Server-MongoDB-36.x86_64 0:3.6.19-8.0.el7 Percona-Server-MongoDB-36-mongos.x86_64 0:3.6.19-8.0.el7
Percona-Server-MongoDB-36-server.x86_64 0:3.6.19-8.0.el7 Percona-Server-MongoDB-36-shell.x86_64 0:3.6.19-8.0.el7
Percona-Server-MongoDB-36-tools.x86_64 0:3.6.19-8.0.el7
Complete!
Trin fire
Start endelig mongod-tjenester.
$ systemctl start mongod.service
Installationsprocessen på Ubuntu/Debian-baseret er den samme, du skal bare bruge kommandoen fra APT-pakkehåndteringen.
I en meget tilgængelig MongoDB-arkitektur kan du lave en rullende opgradering for at minimere nedetiden.
Hvis din applikation allerede understøtter den seneste MongoDB-version, kan du indstille parameteren
setFeatureCompatibilityVersion after the upgrade was completed.
> db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
Opgraderingsbekræftelse
Du kan bekræfte, om opgraderingen var vellykket, ved at oprette forbindelse direkte til MongoDB-instansen. Tjek om databasen kører med den korrekte version:
> db.version()
Eller du kan tjekke fra kommandolinjen:
[[email protected] lib]# mongod --version
db version v4.0.20-14
git version: b96ae5b9e6c70670b6880d4c5412167a7017713a
OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017
allocator: tcmalloc
modules: none
build environment:
distarch: x86_64
target_arch: x86_64