upgrade to nexus 3.75.1-01

This commit is contained in:
Rui Lopes 2024-12-09 08:40:00 +00:00
parent 1c2f7570ed
commit efe4608194
No known key found for this signature in database
7 changed files with 75 additions and 52 deletions

View File

@ -109,36 +109,53 @@ The logs are at `/opt/nexus/log/nexus.log`.
You can also see them with `journalctl -u nexus`.
## OrientDB
## H2 Database
Nexus uses [OrientDB](https://en.wikipedia.org/wiki/OrientDB) as its database. To directly use it from the console run:
Nexus uses [H2 Database](https://en.wikipedia.org/wiki/H2_(database)) as its database management system.
**NB** Nexus OSS can only use the H2 database management system.
**NB** Nexus Pro can use the H2 or PostgreSQL database management system.
The Web based H2 Database Console is available at https://nexus.example.com/h2-console with the following settings:
| Setting | Value |
|----------------|--------------------------------------------------|
| Saved Settings | Generic H2 (Embedded) |
| Setting Name | Generic H2 (Embedded) |
| Driver Class | org.h2.Driver |
| JDBC URL | jdbc:h2:/opt/nexus/sonatype-work/nexus3/db/nexus |
| User Name | _empty_ |
| Password | _empty_ |
You can also access the database cli shell as:
```bash
sudo su -l # switch to the root user.
systemctl stop nexus # make sure nexus is not running while you use the database.
su -s /bin/bash nexus # switch to the nexus user.
nexus_home=/opt/nexus/nexus-3.70.3-01 # make sure you have the correct version here.
nexus_data=$nexus_home/../sonatype-work/nexus3
function orientdb-console {
java -jar $nexus_home/lib/support/nexus-orient-console.jar $*
nexus_home=/opt/nexus/nexus-3.75.1-01 # make sure you have the correct version here.
nexus_data="$(realpath $nexus_home/../sonatype-work/nexus3)"
function h2-shell {
java \
-cp $nexus_home/system/com/h2database/h2/*/h2*.jar \
org.h2.tools.Shell \
-url jdbc:h2:$nexus_data/db/nexus
}
cd $nexus_data
ls -laF db | grep ^d # list the databases
orientdb-console # start the console.
h2-shell
```
Then connect to one of the databases, e.g. to the `security` database:
Then execute some commands and exit the console, e.g.:
```plain
connect plocal:db/security admin admin
```
Then execute some commands and exit the orientdb console, e.g.:
```plain
```sql
-- see https://h2database.com/html/commands.html
help
config
list classes
show schemas;
show tables;
show columns from security_user;
select * from security_user;
select * from api_key_v2;
select * from repository;
exit
```
@ -154,24 +171,7 @@ And start nexus again:
systemctl start nexus
```
For more information about the console see [Running the OrientDB Console](http://orientdb.com/docs/master/Tutorial-Run-the-console.html).
## OrientDB Check Databases
Execute the commands from the OrientDB section to stop nexus, to enter the
nexus account and create the `orientdb-console` function, then:
```bash
# check the databases.
# NB use CHECK DATABASE -v to see the verbose log.
orientdb-console 'CONNECT PLOCAL:db/component admin admin; CHECK DATABASE;'
#orientdb-console 'CONNECT PLOCAL:db/component admin admin; REPAIR DATABASE;'
orientdb-console 'CONNECT PLOCAL:db/config admin admin; CHECK DATABASE;'
orientdb-console 'CONNECT PLOCAL:db/security admin admin; CHECK DATABASE;'
#orientdb-console 'CONNECT PLOCAL:db/OSystem admin admin; CONFIG; LIST CLASSES;' # XXX fails to connect. see https://groups.google.com/a/glists.sonatype.com/forum/#!topic/nexus-users/7dVofIwC5HM
```
Then start nexus.
For more information see the [available Command Line Tools](https://h2database.com/html/tutorial.html#command_line_tools).
## Reference

View File

@ -130,10 +130,12 @@ server {
proxy_send_timeout 120;
proxy_read_timeout 300;
proxy_buffering off;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header Host \$host;
proxy_set_header X-Forwarded-Host \$host;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
location /h2-console/ {
proxy_http_version 1.1;
proxy_pass http://localhost:8082/;
proxy_redirect http://localhost:8082/ /h2-console/;
}
location / {
root /opt/nexus/public;
@ -141,6 +143,10 @@ server {
}
location @nexus {
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header Host \$host;
proxy_set_header X-Forwarded-Host \$host;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8081;
}
}

View File

@ -12,7 +12,7 @@ config_authentication='nexus'
# install java.
# see https://help.sonatype.com/repomanager3/product-information/system-requirements#SystemRequirements-Java
apt-get install -y openjdk-8-jre-headless
apt-get install -y openjdk-17-jre-headless
apt-get install -y gnupg
@ -35,17 +35,17 @@ pushd /opt/nexus
# see https://help.sonatype.com/repomanager3/product-information/download/download-archives---repository-manager-3
# see https://help.sonatype.com/repomanager3/product-information/release-notes
# see https://help.sonatype.com/repomanager3
nexus_version=3.70.3-01
nexus_version=3.75.1-01
nexus_home=/opt/nexus/nexus-$nexus_version
nexus_tarball=nexus-$nexus_version-unix.tar.gz
nexus_download_url=https://download.sonatype.com/nexus/3/$nexus_tarball
nexus_download_sha1=56bf87028892450b2841756bd9fc4caed6b48287
nexus_download_sha1=cfc9e7bdaeb1f1b9fb45aecc7a50821759c8b847
wget -q $nexus_download_url
if [ "$(sha1sum $nexus_tarball | awk '{print $1}')" != "$nexus_download_sha1" ]; then
echo "downloaded $nexus_download_url failed the checksum verification"
exit 1
fi
tar xf $nexus_tarball # NB this creates the $nexus_home (e.g. nexus-3.70.3-01) and sonatype-work directories.
tar xf $nexus_tarball # NB this creates the $nexus_home (e.g. nexus-3.75.1-01) and sonatype-work directories.
rm $nexus_tarball
install -d -o nexus -g nexus -m 700 .java # java preferences are saved here (the default java.util.prefs.userRoot preference).
install -d -o nexus -g nexus -m 700 sonatype-work/nexus3/etc
@ -65,6 +65,11 @@ nexus.security.randompassword=false
# see https://issues.sonatype.org/browse/NEXUS-23205
# see Scripting Nexus Repository Manager 3 at https://support.sonatype.com/hc/en-us/articles/360045220393
nexus.scripts.allowCreation=true
# enable the database console.
# see https://support.sonatype.com/hc/en-us/articles/213467158-How-to-reset-a-forgotten-admin-password-in-Sonatype-Nexus-Repository-3#DatabaseConsoleforh2Database
nexus.h2.httpListenerEnabled=true
nexus.h2.httpListenerPort=8082
EOF
diff -u $nexus_home/etc/nexus-default.properties sonatype-work/nexus3/etc/nexus.properties || true
popd

View File

@ -17,7 +17,7 @@ binaries: binaries-download
binaries-download:
mkdir -p binaries
wget -qO- https://download.sonatype.com/nexus/3/nexus-3.70.3-01-unix.tar.gz \
wget -qO- https://download.sonatype.com/nexus/3/nexus-3.75.1-01-unix.tar.gz \
| tar xzf - --strip-components 1 -C binaries
clean:

View File

@ -8,7 +8,7 @@
<version>1.0-SNAPSHOT</version>
<properties>
<nx-version>3.70.3-01</nx-version>
<nx-version>3.75.1-01</nx-version>
</properties>
<dependencies>
<dependency>

View File

@ -3,7 +3,9 @@ set -euxo pipefail
nexus_domain=$(hostname --fqdn)
mkdir -p tmp/use-maven-repository-from-gradle && cd tmp/use-maven-repository-from-gradle
rm -rf tmp/use-maven-repository-from-gradle
mkdir -p tmp/use-maven-repository-from-gradle
cd tmp/use-maven-repository-from-gradle
#
# test the maven repository from gradle.
@ -116,8 +118,8 @@ application {
mainClass = project.mainClassName
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 17
targetCompatibility = 17
jar {
manifest {

View File

@ -3,14 +3,16 @@ set -euxo pipefail
nexus_domain=$(hostname --fqdn)
mkdir -p tmp/use-maven-repository-from-mvn && cd tmp/use-maven-repository-from-mvn
rm -rf tmp/use-maven-repository-from-mvn
mkdir -p tmp/use-maven-repository-from-mvn
cd tmp/use-maven-repository-from-mvn
#
# test the maven repository.
# install maven and the java development kit.
sudo apt-get install -y maven
sudo apt-get install -y openjdk-8-jdk-headless
sudo apt-get install -y openjdk-17-jdk-headless
sudo apt-get install -y xmlstarlet
# setup the user maven configuration to use nexus as a mirror the
@ -72,6 +74,14 @@ mvn \
# test publishing a package.
pushd example-helloworld
# set the java version.
xmlstarlet ed --inplace -N pom=http://maven.apache.org/POM/4.0.0 \
--subnode /pom:project --type elem --name properties \
pom.xml
xmlstarlet ed --inplace -N pom=http://maven.apache.org/POM/4.0.0 \
--subnode /pom:project/pom:properties --type elem --name maven.compiler.source --value 17 \
--subnode /pom:project/pom:properties --type elem --name maven.compiler.target --value 17 \
pom.xml
# add the nexus repository to pom.xml.
xmlstarlet ed --inplace -N pom=http://maven.apache.org/POM/4.0.0 \
--subnode '/pom:project' \