LoginSignup
0
0

Oracle Database 23c Free - Developer Releaseをdockerから起動

Posted at

従来、開発や検証用途のためdockerでOracleを起動するのはイメージビルドなど若干の手間が必要だったが https://container-registry.oracle.com/ords/ocr/ba/database/free のイメージ使用により非常に簡単になった。

たとえば、ちょっと試す分には以下で良い。さすがに初回はdocker pullにそれなりの時間は要するが。

docker run --name myoracle -p 11521:1521 -e ORACLE_PWD="a" container-registry.oracle.com/database/free:23.2.0.0

以下は起動確認用のspringアプリケーション。

build.gradle
plugins {
  id 'java'
  id 'org.springframework.boot' version '3.1.5'
  id 'io.spring.dependency-management' version '1.1.3'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
  sourceCompatibility = '17'
}

repositories {
  mavenCentral()
}

dependencies {
  implementation 'org.springframework.boot:spring-boot-starter-jdbc'
  runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
  testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
  useJUnitPlatform()
}
application.properties
spring.datasource.url jdbc:oracle:thin:@localhost:11521/FREEPDB1
spring.datasource.username system
spring.datasource.password a
@SpringBootApplication
public class OracleSampleMain implements ApplicationRunner {

  public static void main(String[] args) {
    SpringApplication.run(OracleSampleMain.class, args);
  }

  @Autowired
  DataSource ds;
  
  @Override
  public void run(ApplicationArguments args) throws Exception {
    JdbcTemplate t = new JdbcTemplate(ds);
    System.out.println(t.queryForObject("select 1 from dual", Integer.class));;
  }
}

参考用のdocker run時の起動ログ。

Starting Oracle Net Listener.
Oracle Net Listener started.
Starting Oracle Database instance FREE.
Oracle Database instance FREE started.

The Oracle base remains unchanged with value /opt/oracle

SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Sun Nov 5 10:11:44 2023
Version 23.2.0.0.0

Copyright (c) 1982, 2023, Oracle.  All rights reserved.


Connected to:
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0

SQL>
User altered.

SQL>
User altered.

SQL>
Session altered.

SQL>
User altered.

SQL> Disconnected from Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
The Oracle base remains unchanged with value /opt/oracle
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
FREEPDB1(3):Autotune of undo retention is turned on.
FREEPDB1(3):Undo initialization recovery: Parallel FPTR failed: start:1651134 end:1651136 diff:2 ms (0.0 seconds)
FREEPDB1(3):[163] Successfully onlined Undo Tablespace 2.
FREEPDB1(3):SUPLOG: Set PDB SUPLOG SGA at PDB OPEN, old 0x18, new 0x0 (no suplog)
FREEPDB1(3):Opening pdb with Resource Manager plan: DEFAULT_PLAN
2023-11-05T10:11:44.072875+00:00
Completed: Pluggable database FREEPDB1 opened read write
Completed: ALTER DATABASE OPEN
2023-11-05T10:11:44.498176+00:00
FREEPDB1(3):TABLE AUDSYS.AUD$UNIFIED: ADDED INTERVAL PARTITION SYS_P371 (3415) VALUES LESS THAN (TIMESTAMP' 2023-11-06 00:00:00')
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0