Home >Operation and Maintenance >Docker >Can docker install oracle?

Can docker install oracle?

WBOY
WBOYOriginal
2022-07-08 16:07:4211652browse

docker can install oracle. Installation method: 1. Pull the official Oracle image and use "docker images" to view the image; 2. After starting the container, use "docker exec -it oracle11g bash" to enter the container and edit the environment variables; 3. Use "sqlplus /nolog" Just enter the oracle command line.

Can docker install oracle?

The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.

Can docker install oracle?

You can use docker to deploy oracle, and it has many benefits. It can not only reduce the installation time, but also enable rapid deployment.

The benefits of using docker for deployment are as follows:

(1) Simplify the configuration, build it once and package it, and then it can be used as a test environment, production environment or pre-production environment. A lot of testing sessions can be saved. For example, one server can test multiple versions without waiting.

(2) can solve the difficulty of developers deploying the environment. For example, it may take half a day for a new colleague to install the environment, but it will be much more convenient to directly run an already configured container.

(3) Application isolation and server integration. One server can use docker to deploy multiple sets of services, and the isolation is very high (except for virtual machines).

(4) For development, after deployment, it can be run everywhere to facilitate development and debugging.

(5) It can reduce the utilization of resources. Compared with virtual machines, it saves a lot of unnecessary resources. The loss of isolation is more than compensated for by other advantages.

(6) For operation and maintenance, it can quickly expand the capacity and reduce the original utilization rate

(7) Each small service can be clustered, and docker’s resource utilization comparison It is small and can start multiple servers on one server. Compared with other products, it uses more I/O on the server.

(8) Can be deployed on multiple platforms

The examples are as follows:

It is very troublesome to install oracle in Linux, I believe everyone will encounter various problems. Plant pit. In order to install it once and make it easier to export the image for transplantation on various platforms in the future, I chose to install it with docker

Pull the image

Search for Oracle on DockerHub to find the official image of Oracle. Address: https://hub.docker.com/
Can docker install oracle?

Note that if you use the docker pull oraclelinux command here, you cannot pull the image because it does not have latest tag. Therefore, you can only manually specify its version number
For example docker pull oraclelinux
Can docker install oracle?
Using the official image download speed is very slow, therefore, we can use the Ali image docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

can be found on dockerHub (the second one), you can refer to this configuration
Can docker install oracle?Can docker install oracle? to use docker images Check the image and confirm that it has been downloaded
Can docker install oracle?

Start the container

  1. The default way to start the container
    docker run -d -it -p 1521:1521 --name oracle11g --restart=always registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
  2. How to start persistence
    docker run -d -it -p 1521:1521 --name oracle --restart=always --mount source=oracle_vol,target=/home/oracle/app/oracle/oradata registry.cn-hangzhou.aliyuncs.com /helowin/oracle_11g

View started threadsnetstat -tulnp
Can docker install oracle?
View running statusdocker ps -a
Can docker install oracle?

Container environment configuration

Enter the containerdocker exec -it oracle11g bash
Can docker install oracle?
Switch to the root usersu root, password The environment variables configured for the helowin
Can docker install oracle?
docker container are not in /etc/profile, and this file will not be used when the container is started.
You can set the environment variable configuration in the /home/oracle/.bashrc file, which can omit the creation of soft connections ln -s $ORACLE_HOME/bin/sqlplus /usr/ bin
Can docker install oracle?
Edit environment variablesvi /home/oracle/.bashrc, add the following command at the end of the file

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

wq Save and exit. Then use source /home/oracle/.bashrc to refresh the environment variables and make them effective

Enter the oracle command line

Use sqlplus /nolog Enter the oracle command line
Can docker install oracle?
Use the "operating system authentication" method to log in to oracle conn / as sysdba
If you directly use the default root user to log in, a login failure will be reported . The su - oracle command must be used here to switch the current user to oracle, and then execute the login command
Can docker install oracle?

ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

Can docker install oracle?This error is due to the wrong database name

su - oracle
sqlplus /nolog
conn / as sysdba
select instance_name from v$instance;
show user;

Using the above command to find out, it is all available "database names" ” and “user name”
Can docker install oracle?

In this image of Ali, all passwords are unifiedhelowin

The system user has DBA authority, but No SYSDBA permissions. This account is usually used to manage the database.
The sys user is the account with the highest authority in the Oracle database. It has "SYSDBA" and "SYSOPER" permissions and is generally not allowed to log in from the outside.

Can docker install oracle?

Configuring the firewall

The firewall must allow port 1521 so that external database management tools can connect

# 打开防火墙
systemctl start firewalld
# 查询端口状态
firewall-cmd --query-port=1521/tcp
# 永久性开放端口
firewall-cmd --permanent --zone=public --add-port=1521/tcp
# 重启防火墙
firewall-cmd --reload
firewall-cmd --query-port=1521/tcp

Can docker install oracle?

Recommended study: "docker video tutorial"

The above is the detailed content of Can docker install oracle?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn