CentOS7部署Oracle-19c Apex

  • 版本及下载地址:
组件 版本 下载地址
tomcat 9.0.41 https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.41/bin/apache-tomcat-9.0.41.tar.gz
oracle-ee 19c 见下文
apex 20.2 http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html
ords 20.4 https://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html

  • 安装tomcat:
mkdir /software && cd /software

vim tomcat_install.sh
#!/bin/bash
#用于安装tomcat

JAVA_VER=271
JAVA_DIR=/usr/local/jdk
TOMCAT_VER=9.0.41
Pro=tomcat
CATALINA_HOME=/usr/local/$Pro

[ ! -d /software/ ] && mkdir /software

#安装依赖包
install_java() {
    
    
    cd /software
    
    #卸载openjdk
    m=`rpm -qa |grep openjdk |wc -l`
    [ $m -ne 0 ] && rpm -qa |grep openjdk |xargs rpm -e
    
    #安装java
    if [ ! -f jdk-8u$JAVA_VER-linux-x64.tar.gz ]
    then
        echo -e "\033[31m请手动下载jdk到/software\033[0m"
        exit 1
    else
        tar xf jdk-8u$JAVA_VER-linux-x64.tar.gz
        [ ! -d $JAVA_DIR ] && mv jdk1.8.0_$JAVA_VER $JAVA_DIR
        
        n=`grep "JAVA_HOME=$JAVA_DIR" /etc/profile |wc -l`
        if [ $n -eq 0 ]
        then
            echo "JAVA_HOME=$JAVA_DIR" >> /etc/profile
            echo 'PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin' >> /etc/profile
            echo 'CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib' >> /etc/profile
            echo 'export JAVA_HOME PATH CLASSPATH' >> /etc/profile
            source /etc/profile
        else
            source /etc/profile
        fi
    fi

    java -version
    if [ $? -eq 0 ]
    then
        echo -e "\033[36mjdk安装完成\033[0m"
    else
        echo -e "\033[31mjdk安装失败\033[0m"
        exit 1
    fi
}

#安装tomcat
install_tomcat() {
    
    
    #下载tomcat
    [ ! -f apache-tomcat-$TOMCAT_VER.tar.gz ] && wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v$TOMCAT_VER/bin/apache-tomcat-$TOMCAT_VER.tar.gz
    
    #解压
    [ ! -d apache-tomcat-$TOMCAT_VER ] && tar xf apache-tomcat-$TOMCAT_VER.tar.gz
    [ ! -d $CATALINA_HOME ] && mv apache-tomcat-$TOMCAT_VER $CATALINA_HOME
    
    #设置环境变量
    n=`grep "JAVA_HOME=$JAVA_DIR" $CATALINA_HOME/bin/catalina.sh |wc -l`
    if [ $n -eq 0 ]
    then
        sed -i "124a JAVA_HOME=${JAVA_DIR}" $CATALINA_HOME/bin/catalina.sh
    fi

    #配置启动脚本
    cat > /etc/systemd/system/$Pro\.service << EOF
[Unit]
Description=Apache Tomcat 9 Servlet Container
After=syslog.target network.target

[Service]
User=root
Group=root
Type=forking
LimitNOFILE=131070
Environment=CATALINA_PID=${CATALINA_HOME}/bin/tomcat.pid
Environment=CATALINA_HOME=${CATALINA_HOME}
Environment=CATALINA_BASE=${CATALINA_HOME}
ExecStart=${CATALINA_HOME}/bin/startup.sh
ExecStop=${CATALINA_HOME}/bin/shutdown.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

    #tomcat开机启动
    systemctl daemon-reload && systemctl enable $Pro

    if [ `systemctl status $Pro | grep 'running'| wc -l` -eq 0 ]
    then
        systemctl start $Pro
        if [ $? -eq 0 ]
        then
            echo -e "\033[36m$Pro安装完毕\033[0m"
        else
            echo -e "\033[31m$Pro安装失败\033[0m"
            exit 1
        fi
    fi
}

install_java
install_tomcat
sh tomcat_install.sh                #注意先把jdk放到 /software 目录下

  • 安装oracle:
mkdir -p /opt/ords/{
    
    package,config} && cd /opt/ords/package

wget https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

wget https://download.oracle.com/otn/linux/oracle19c/190000/oracle-database-ee-19c-1.0-1.x86_64.rpm

ls

apex_20.2.zip  oracle-database-ee-19c-1.0-1.x86_64.rpm  oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm  ords-20.4.1.013.1644.zip

yum localinstall -y oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

yum localinstall -y oracle-database-ee-19c-1.0-1.x86_64.rpm
  • 配置参考:
文件名和位置 目的
/opt/oracle Oracle Base。Oracle-XE 数据库的根目录
/opt/oracle/product/19c/dbhome_1 Oracle Home。Oracle-19c 数据库的安装目录,它包含Oracle-19c 数据库的可执行文件和网络文件
/etc/sysconfig/oracledb_ORCLCDB-19c.conf 配置默认参数
/etc/init.d/oracledb_ORCLCDB-19c 配置和服务脚本
  • 配置数据库:
/etc/init.d/oracledb_ORCLCDB-19c configure
Configuring Oracle Database ORCLCDB.
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
Database Information:
Global Database Name:ORCLCDB
System Identifier(SID):ORCLCDB
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.

Database configuration completed successfully. The passwords were auto generated, you must change them by connecting to the database using 'sqlplus / as sysdba' as the oracle user.

更改 sys、system 用户密码,

SQL> alter user sys identified by Lzxlinux2020;

SQL> alter user system identified by Lzxlinux2020;

SQL> shutdown immediate;

SQL> startup;

SQL> alter session set container = ORCLPDB1;

SQL> startup;
  • 环境变量:
chown -R oracle:dba /opt/ords/

su - oracle

vim ~/.bash_profile                #追加

export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export ORACLE_SID=ORCLCDB
export PATH=$PATH:/opt/oracle/product/19c/dbhome_1/bin
export NLS_LANG=American_America.AL32UTF8

source ~/.bash_profile
  • oracle启动、停止:
/etc/init.d/oracledb_ORCLCDB-19c start

/etc/init.d/oracledb_ORCLCDB-19c stop

  • 安装apex:

apex 下载地址:http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html

su - oracle

unzip -q /opt/ords/package/apex_20.2.zip -d /opt/ords/package/

cd /opt/ords/package/apex/

sqlplus / as sysdba
SQL> alter session set container = ORCLPDB1;

SQL> @apexins.sql SYSAUX SYSAUX TEMP /i/

SQL> @apxchpwd.sql              #创建 apex 实例管理员

Enter the administrator's username [ADMIN] ADMIN
User "ADMIN" does not yet exist and will be created.
Enter ADMIN's email [ADMIN] ADMIN
Enter ADMIN's password [] Lzxlinux_2020

SQL> ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK IDENTIFIED BY Lzxlinux2020;

SQL> ALTER USER flows_files ACCOUNT UNLOCK IDENTIFIED BY Lzxlinux2020;

SQL> BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => '*',
ace => xs$ace_type(privilege_list => xs$name_list('connect'),
principal_name => 'APEX_200200',
principal_type => xs_acl.ptype_db));
END;
/

SQL> BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'localhost',
ace => xs$ace_type(privilege_list => xs$name_list('connect'),
principal_name => 'APEX_200200',
principal_type => xs_acl.ptype_db));
END;
/

SQL> @apex_rest_config.sql

Enter a password for the APEX_LISTENER user: Lzxlinux2020

Enter a password for the APEX_REST_PUBLIC_USER user: Lzxlinux2020
  • oracle apex 汉化:
cd /opt/ords/package/apex/builder/zh-cn/

sqlplus / as sysdba

SQL> alter session set container = ORCLPDB1;

SQL> ALTER SESSION SET CURRENT_SCHEMA = APEX_200200;

SQL> @load_zh-cn.sql

  • 安装ords:

下载地址:https://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html

cd /opt/ords/package

unzip -q ords-20.4.1.013.1644.zip

java -jar ords.war install advanced
This Oracle REST Data Services instance has not yet been configured.
Please complete the following prompts


Enter the location to store configuration data: /opt/ords/config
Specify the database connection type to use.
Enter number for [1] Basic  [2] TNS  [3] Custom URL [1]:1
Enter the name of the database server [localhost]:localhost
Enter the database listen port [1521]:1521
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:1
Enter the database service name:ORCLPDB1
Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step [1]:1
Enter the database password for ORDS_PUBLIC_USER:Lzxlinux2020
Confirm password:Lzxlinux2020
Requires to login with administrator privileges to verify Oracle REST Data Services schema.

Enter the administrator username:SYS                #oracle数据库账号
Enter the database password for SYS AS SYSDBA:Lzxlinux2020
Confirm password:Lzxlinux2020
Connecting to database user: SYS AS SYSDBA url: jdbc:oracle:thin:@//localhost:1521/ORCLPDB1

Retrieving information.
Enter 1 if you want to install ORDS or 2 to skip this step [1]:1
Enter the default tablespace for ORDS_METADATA [SYSAUX]:SYSAUX
Enter the temporary tablespace for ORDS_METADATA [TEMP]:TEMP
Enter the default tablespace for ORDS_PUBLIC_USER [SYSAUX]:SYSAUX
Enter the temporary tablespace for ORDS_PUBLIC_USER [TEMP]:TEMP
Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step.
If using Oracle Application Express or migrating from mod_plsql then you must enter 1 [1]:1
Enter the PL/SQL Gateway database user name [APEX_PUBLIC_USER]:APEX_PUBLIC_USER
Enter the database password for APEX_PUBLIC_USER:Lzxlinux2020
Confirm password:Lzxlinux2020
Enter 1 to specify passwords for Application Express RESTful Services database users (APEX_LISTENER, APEX_REST_PUBLIC_USER) or 2 to skip this step [1]:1
Enter the database password for APEX_LISTENER:Lzxlinux2020
Confirm password:Lzxlinux2020
Enter the database password for APEX_REST_PUBLIC_USER:Lzxlinux2020
Confirm password:Lzxlinux2020
Enter a number to select a feature to enable:
   [1] SQL Developer Web  (Enables all features)
   [2] REST Enabled SQL
   [3] Database API
   [4] REST Enabled SQL and Database API
   [5] None
Choose [1]:1
2021-02-02T08:45:42.287Z INFO        reloaded pools: []
Installing Oracle REST Data Services version 20.4.1.r0131644
... Log file written to /root/ords_install_core_2021-02-02_164542_00395.log
... Verified database prerequisites
... Created Oracle REST Data Services proxy user
... Created Oracle REST Data Services schema
... Granted privileges to Oracle REST Data Services
... Created Oracle REST Data Services database objects
... Log file written to /root/ords_install_datamodel_2021-02-02_164559_00321.log
... Log file written to /root/ords_install_apex_2021-02-02_164600_00696.log
Completed installation for Oracle REST Data Services version 20.4.1.r0131644. Elapsed time: 00:00:19.722 

Enter 1 if you wish to start in standalone mode or 2 to exit [1]:2

  • 复制apex静态文件到tomcat:
mkdir /usr/local/tomcat/webapps/i

cp -a /opt/ords/package/apex/images/* /usr/local/tomcat/webapps/i/
  • ords.war 部署到tomcat:
cp /opt/ords/package/ords.war /usr/local/tomcat/webapps/

systemctl restart tomcat
  • 访问:

打开浏览器,访问 ip:8080/ords

在这里插入图片描述

workspace:INTERNAL、username:ADMIN、password: Lzxlinux_2020 登录,

在这里插入图片描述

  • nginx代理:
yum install -y nginx

vim /etc/nginx/conf.d/apex.conf
server {
    
    
    listen 80;
    server_name apex.lzxlinux.com;
    
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Headers X-Requested-With;
    add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
    
    location / {
    
    
        proxy_pass http://localhost:8080;
        proxy_set_header Origin "" ;
        proxy_set_header X-Forwarded-Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_connect_timeout 120s;
        proxy_read_timeout    120s;
        proxy_send_timeout    120s;
    }
}
nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

systemctl enable nginx && systemctl start nginx

添加hosts:192.168.30.135 apex.lzxlinux.com,访问 apex.lzxlinux.com/ords

在这里插入图片描述

至此,oracle-19c apex 部署完成。


猜你喜欢

转载自blog.csdn.net/miss1181248983/article/details/114375409