0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Dockerにoraclelinuxのコンテナを立ててspringbootをoracledatabaseと紐づけて実行

Posted at

Docker

コンテナ起動
$ docker run -v /mnt/c/pleiades-2021-12-java-win-64bit-jre_20211219/pleiades/workspace:/test-table -it -d -p 1521:1521 -p 33000:33000 -e NILS_LANG=japanese_Japan.AL32UTF8 --name oraclelinux_33000 oraclelinux:8
8e672b26613be176678c6baa0ea18c3eefc8f635fb386862463a6add147fb9f1
$ docker ps
CONTAINER ID   IMAGE           COMMAND       CREATED          STATUS         PORTS                                                                                      NAMES
8e672b26613b   oraclelinux:8   "/bin/bash"   10 seconds ago   Up 9 seconds   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:33000->33000/tcp, :::33000->33000/tcp   oraclelinux_33000$ docker exec -it 8e6 /bin/bash
[root@8e672b26613b /]#

OracleDatabase

#Oracledatabaseのversion確認
# yum search oracle-database-preinstall

#oracle 21cを選択
# yum install oracle-database-preinstall-21c

#wgetをインストール
# yum install wget

#oracledatabase 21cをダウンロード
# cd /tmp
# wget https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm

#oracledatabase 21cをインストール
# export ORACLE_DOCKER_INSTALL=true
# yum -y localinstall oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm

# /rootに移動して.bashrcに環境変数を設定
# cd
# ls
# ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .cshrc  .tcshrc
# vi .bashrc

#以下を.bashrcに記述
export ORACLE_SID=XE
export ORAENV_ASK=NO
. /opt/oracle/product/21c/dbhomeXE/bin/oraenv

# pathを通す
# source .bashrc

SQLPLUSに入る

The Oracle base has been set to /opt/oracle
# sqlplus sys as sysdba/systemsss@//localhost:1521:xe

SQL> create table test(id number(3) primary key, name varchar2(100));

Table created.

SQL> insert into test values(1, 'りんご');

1 row created.

SQL> insert into test values(2, 'みかん');

1 row created.

SQL> insert into test values(3, 'キウイ');

1 row created.

SQL> commit;

Commit complete.

javaインストール

# yum -y install java-17
# java -version
openjdk version "17.0.3" 2022-04-19 LTS
OpenJDK Runtime Environment 21.9 (build 17.0.3+7-LTS)
OpenJDK 64-Bit Server VM 21.9 (build 17.0.3+7-LTS, mixed mode, sharing)

#環境変数
# vi .bashrc
#以下を.bashrcに記述
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-17.0.3.0.7-2.el8_6.x86_64"

# pathを通す
# source .bashrc

Mavenインストール

# ダウンロード
$ cd ~
$ sudo wget https://ftp.jaist.ac.jp/pub/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

# 展開&配置
$ sudo tar -xzvf apache-maven-3.6.3-bin.tar.gz
$ sudo mv apache-maven-3.6.3 /opt/
# シンボリックリンク作成
$ sudo ln -s /opt/apache-maven-3.6.3 /opt/apache-maven

#環境変数
# vi .bashrc
#以下を.bashrcに記述
export PATH=/opt/apache-maven/bin:$PATH

# pathを通す
# source .bashrc

# version確認
# mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/apache-maven
Java version: 17.0.3, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-17-openjdk-17.0.3.0.7-2.el8_6.x86_64
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "5.10.16.3-microsoft-standard-wsl2", arch: "amd64", family: "unix"

実行

# プロジェクトディレクトリに移動
# cd プロジェクトディレクトリ

# 一度targetディレクトリを作り直してからもう一度ビルド
# mvn clean
# mvn compile
# mvn package

# targetディレクトリに移動
# cd target

#実行
# java -jar ビルドされたjavaファイル
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?