Mac基於docker-compose 安裝 oracle
編寫 docker-compose.yaml
oracle:
image: registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
restart: always #如果docker容器由於一些問題掛掉的化,docker-composer會自動把容器給啟動起來
container_name: oracle #啟動之後容器的名稱
volumes:
- ./oracle/data/oracle-11g/data:/u01/app/oracle
ports:
- 1521:1521
執行compose
因為上面是 oracle 所以下面是 oracle 如果上面是 oracle_11,下面也要改為 oracle_11
docker-compose up -d oracle
啟動成功後如圖所示
到容器中修改東西
luwei@luweideMacBook-Pro-2 pkg-config % docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
29f0b85f1284 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home/o…" 2 hours ago Up 2 hours 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp oracle
89c169b8bd14 nginx:alpine "/docker-entrypoint.…" 7 days ago Up 7 days (healthy) 0.0.0.0:81->80/tcp, :::81->80/tcp, 0.0.0.0:444->443/tcp, :::444->443/tcp nginx
e0e4fa4bf177 lnmp_php72 "entrypoint php-fpm" 7 days ago Up 7 days (healthy) 9000-9001/tcp php72
a1ddf67627cd lnmp_php56 "entrypoint php-fpm" 7 days ago Up 7 days (healthy) 9000/tcp php56
324aa6c8b071 lnmp_php71 "entrypoint php-fpm" 7 days ago Up 7 days (healthy) 9000/tcp php71
4fd5d2ce7612 mongo:4.4.0 "docker-entrypoint.s…" 7 days ago Up 7 days 0.0.0.0:27018->27017/tcp, :::27018->27017/tcp mongo4.4
f212f81e0546 redis:4-alpine "docker-entrypoint.s…" 7 days ago Up 7 days (healthy) 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis
e42962aa16c8 mysql:5.6 "docker-entrypoint.s…" 7 days ago Up 44 hours 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp mysql
luwei@luweideMacBook-Pro-2 pkg-config %
進入oracle容器
luwei@luweideMacBook-Pro-2 pkg-config % docker exec -it 29f0b85f1284 /bin/bash
[oracle@29f0b85f1284 /]$
檢視配置 tnsnames.ora
[oracle@29f0b85f1284 /]$ find / -name tnsnames.ora
/home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/samples/tnsnames.ora
/home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/tnsnames.ora
檢視配置資訊
[oracle@29f0b85f1284 /]$ cat /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_HELOWIN =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
HELOWIN =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = helowin)
)
)
[oracle@29f0b85f1284 /]$
切換oracle資料庫的root使用者下,密碼 helowin
[oracle@29f0b85f1284 /]$ su root
Password:
[root@29f0b85f1284 /]#
修改profile的配置檔案,開啟profile檔案,在末尾新增配置。
vi /etc/profile
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
重新整理檔案
source /etc/profile
建立軟鏈
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
切換回 orcle
su - oracle
登入sqlplus,修改sys、system使用者密碼,建立使用者
sqlplus /nolog
conn /as sysdba
alter user system identified by system;
alter user sys identified by sys;
create user dev identified by dev;
grant connect,resource,dba to dev;
執行效果如下
[oracle@29f0b85f1284 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 27 14:17:17 2021
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> alter user system identified by system;
User altered.
SQL> alter user sys identified by sys;
User altered.
SQL> create user dev identified by dev;
User created.
SQL> grant connect,resource,dba to dev;
Grant succeeded.
SQL>
SQL>
開始客戶端連線
本作品採用《CC 協議》,轉載必須註明作者和本文連結