manual: https://docs.cloudera.com/documentation/enterprise/5-6-x/topics/cdh_ig_hive_metastore_configure.html

第一步
安裝環境:CENOS8
1)安裝JDBC DRIVER
Oracle Database 19c (19.6) JDBC Driver & UCP Downloads
https://www.oracle.com/database/technologies/appdev/jdbc-ucp-19-6-c-downloads.html
因為下載的是18c的express edition,所以點擊18c行下載對應的drivers:https://www.oracle.com/database/technologies/appdev/jdbc-ucp-183-downloads.html

名稱:ojdbc8-full.tar.gz
[root@bigdata Downloads]# tar zxf ojdbc8-full.tar.gz
[root@bigdata Downloads]# cd ojdbc8-full/
[root@bigdata ojdbc8-full]# cp ojdbc8.jar /home/admin/Downloads/apache-hive-2.3.7/lib
[root@bigdata lib]# pwd
/home/admin/Downloads/apache-hive-2.3.7/lib
[root@bigdata lib]# ls |grep ojdbc
ojdbc8.jar
后來添加了ojdbc6.jar 不知道有沒有影響
第二步
2)安裝oracle express edition
下載安裝包:https://www.oracle.com/database/technologies/appdev/xe.html
oracle-database-xe-18c-1.0-1.x86_64.rpm

在CentOS8,需要設置個參數才能看到sharefolder。輸入:
/usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_other
[root@bigdata] cd /mnt/hgfs/ShareFolder
下載oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
# curl -o oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
安裝oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
# yum -y localinstall oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
執行報錯
[root@bigdata ShareFolder]# yum -y localinstall oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm Last metadata expiration check: 0:07:08 ago on Wed 20 May 2020 07:36:26 PM CST. Error: Problem: conflicting requests - nothing provides compat-libcap1 needed by oracle-database-preinstall-18c-1.0-1.el7.x86_64 - nothing provides compat-libstdc++-33 needed by oracle-database-preinstall-18c-1.0-1.el7.x86_64 (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
如何解決 缺少2個需要的package?
網友方案,但是我沒有完全采納。ref1:https://community.oracle.com/thread/4303249,其實只要把缺的包安裝下就好了。
1)google compat-libcap1,有很多資源。我下載了compat-libcap1-1.10-7.el7.x86_64.rpm。
https://www.rpmfind.net/linux/rpm2html/search.php?query=compat-libcap1

[root@bigdata ShareFolder]# rpm -ivh compat-libcap1-1.10-7.el7.x86_64.rpm
同理:下載compat-libstdc++-33: compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
[root@bigdata ShareFolder]# rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
再次執行 yum -y localinstall oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm 安裝成功!
Installed: oracle-database-preinstall-18c-1.0-1.el7.x86_64 ksh-20120801-253.el8_1.x86_64 sysstat-11.7.3-2.el8.x86_64 libaio-devel-0.3.112-1.el8.x86_64 lm_sensors-libs-3.4.0-20.20180522git70f7e08.el8.x86_64 make-1:4.2.1-9.el8.x86_64 Complete!
如果沒有運行xx-preinstall-xxx.rpm,直接運行oracle-database-xe-xx.rpm會報錯,如下:
[root@bigdata ShareFolder]# yum -y localinstall oracle-database-xe-18c-1.0-1.x86_64.rpm Last metadata expiration check: 0:08:33 ago on Wed 20 May 2020 07:36:26 PM CST. Error: Problem: conflicting requests - nothing provides oracle-database-preinstall-18c needed by oracle-database-xe-18c-1.0-1.x86_64 (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
安裝oracle-database-xe-18c-1.0-1.x86_64.rpm
[root@bigdata ShareFolder]# yum -y localinstall oracle-database-xe-18c-1.0-1.x86_64.rpm
[INFO] Executing post installation scripts... [INFO] Oracle home installed successfully and ready to be configured. To configure Oracle Database XE, optionally modify the parameters in '/etc/sysconfig/oracle-xe-18c.conf' and then execute '/etc/init.d/oracle-xe-18c configure' as root. Verifying : oracle-database-xe-18c-1.0-1.x86_64 1/1 Installed: oracle-database-xe-18c-1.0-1.x86_64 Complete! 安裝成功!
[root@localhost ShareFolder]# /etc/init.d/oracle-xe-18c configure
The location '/opt/oracle' specified for database files has insufficient space. Database creation needs at least '4.5GB' disk space. Specify a different database file destination that has enough space in the configuration file '/etc/sysconfig/oracle-xe-18c.conf'.
有點小意外,磁盤空間不夠了,用gparted可視化工具增加10G磁盤空間。 Ref 2:https://www.jianshu.com/p/1d020b01177c
yum install epel-release
yum install gparted
Gpart使用方法請google一下。

lvextend /dev/mapper/cl-root -L +2G
fsadm resize /dev/mapper/cl-root 19G
[root@bigdata displayFolder]# /etc/init.d/oracle-xe-18c configure Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts: Confirm the password: Configuring Oracle Listener. Listener configuration succeeded. Configuring Oracle Database XE. Enter SYS user password: **** Enter SYSTEM user password: ***** Enter PDBADMIN User Password: ***** Prepare for db operation 7% complete Copying database files
29% complete
Creating and starting Oracle instance
30% complete
31% complete
34% complete
38% complete
41% complete
43% complete
Completing Database Creation
47% complete
50% complete
Creating Pluggable Databases
54% complete
71% complete
Executing Post Configuration Actions
93% complete
Running Custom Scripts
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.
Connect to Oracle Database using one of the connect strings:
Pluggable database: bigdata/XEPDB1
Multitenant container database: bigdata
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
登錄mozilla,需要安裝flash后,瀏覽ORACLE Enterprise Manager Database Express 18c:https://localhost:5500/em

需要運行下面這句話,才能進入網站。
SQL> exec dbms_xdb_config.SetGlobalPortEnabled(TRUE) --You should enable global port for EM Express to Manage a CDB and the PDBs

ref-Linux如何安裝flash:https://jingyan.baidu.com/album/90bc8fc8b7b6a7f653640cab.html?picindex=2
[root@bigdata dbhomeXE]# pwd
/opt/oracle/product/18c/dbhomeXE
配置一下.bash_profile
[root@bigdata /]# cat /home/oracle/.bash_profile # .bash_profile export ORACLE_BASE=/opt/oracle/ export ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE export ORACLE_SID=XE export PATH=$ORACLE_HOME/bin:$PATH
cd <oracle_home>\bin
sqlplus / as sysdba
cd <oracle_home>\bin
lsnrctl status
[root@bigdata bin]# sqlplus system@localhost:1521/XEPDB1
登錄報錯:
SQL> conn /as sysdba
;ERROR:
ORA-01017: invalid username/password; logon denied
解決方案:
1)In order for you to connect as sysdba with no password, your OS user needs to be a member of a special group. On Windows - it's called ora_dba
2)或者su - oracle
[oracle@bigdata ~]$ sqlplus / as sysdba
Connected.
更改oracle密碼:
SQL> alter user sys identified by "1QAZxsw2";
User altered.
SQL> alter user system identified by "1QAZxsw2";
User altered.
第三步:
Create the Metastore database and user account
schema很重要
[root@bigdata oracle]# cd $HIVE_HOME/scripts/metastore/upgrade/oracle
/home/admin/Downloads/apache-hive-2.3.7/scripts/metastore/upgrade/oracle
[root@bigdata oracle]# ls | grep hive-schema
hive-schema-0.10.0.oracle.sql
hive-schema-0.11.0.oracle.sql
hive-schema-0.12.0.oracle.sql
hive-schema-0.13.0.oracle.sql
hive-schema-0.14.0.oracle.sql
hive-schema-0.9.0.oracle.sql
hive-schema-1.1.0.oracle.sql
hive-schema-1.2.0.oracle.sql
hive-schema-1.3.0.oracle.sql
hive-schema-2.0.0.oracle.sql
hive-schema-2.1.0.oracle.sql
hive-schema-2.2.0.oracle.sql
hive-schema-2.3.0.oracle.sql <-----
SQL> @/usr/lib/hive/scripts/metastore/upgrade/oracle/hive-schema-2.3.0.oracle.sql
@/home/admin/Downloads/apache-hive-2.3.7/scripts/metastore/upgrade/oracle/hive-schema-2.3.0.oracle.sql
我的oracle默認連接CBD, 大家根據實際情況處理。
$ sqlplus "sys as sysdba"
select *from v$pdbs;
CBD下:
SQL> CREATE USER C##hive identified by hive;
grant connect to C##hive;
grant all privileges to C##hive;
PDB下:
alter session set container = XEPDB1;
因為安裝好后,默認啟動在Container db(cdb)下,所以切換到pdb(pluggable db)。
-- switch to the corresponding pluggable databases via the alter session command --alter session set container=CDB$ROOT;
【為什么alter session?】因為在Container db下,create user
hive 時報錯:ERROR at line 1:ORA-65096: invalid common user or role name.
Ref: https://dbtut.com/index.php/2019/10/31/how-to-connect-to-container-database-cdb-and-pluggable-databases-pdb-in-oracle-12c/
-------------------------------------------------------------------------
SQL> CREATE USER hive identified by hive;
grant connect to hive;
grant all privileges to hive;
in the /opt/mapr/hive//hive-<version>/conf/hive-site.xml file.
Suppose an Oracle database running on myhost and the user account hiveuser with the password mypassword, set the following properties (overwriting any existing values) in the hive-site.xml file:
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:oracle:thin:@//myhost/metastore</value> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>oracle.jdbc.OracleDriver</value> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hiveuser</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>mypassword</value> </property> <property> <name>hive.metastore.uris</name> <value>thrift://<n.n.n.n>:9083</value> <description>IP address (or fully-qualified domain name) and port of the metastore host</description> </property>
<n.n.n.n> 記得改成ip
Run schemaTool to create the initial DB structure.
/opt/mapr/hive/hive-<version>/bin/schematool -dbType oracle -initSchema
[root@bigdata bin]# pwd /home/admin/Downloads/apache-hive-2.3.7/bin [root@bigdata bin]# schematool -dbType oracle -initSchema
or
/home/admin/Downloads/apache-hive-2.3.7/bin/schematool -dbType oracle -initSchema
以下報錯,是因為
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/admin/Downloads/apache-hive-2.3.7/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/admin/Downloads/hadoop-2.10.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Metastore connection URL: jdbc:oracle:thin:@//localhost/XE Metastore Connection Driver : oracle.jdbc.OracleDriver Metastore connection User: hive org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version. Underlying cause: java.sql.SQLException : ORA-01017: invalid username/password; logon denied SQL Error code: 1017 Use --verbose for detailed stacktrace.
解決:hive-site.xml中將用戶改為CDB的C##hive。
<property> <name>javax.jdo.option.ConnectionUserName</name> <value>C##hive</value> </property>
[oracle@bigdata oracle]$ /home/admin/Downloads/apache-hive-2.3.7/bin/schematool -dbType oracle -initSchema SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/admin/Downloads/apache-hive-2.3.7/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/admin/Downloads/hadoop-2.10.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Metastore connection URL: jdbc:oracle:thin:@//localhost/XE Metastore Connection Driver : oracle.jdbc.OracleDriver Metastore connection User: C##hive Starting metastore schema initialization to 2.3.0 Initialization script hive-schema-2.3.0.oracle.sql Initialization script completed schemaTool completed
ref: https://mapr.com/docs/61/Hive/Config-RemoteOracleDBForHiveMetastore.html
第四步
配置SQL DEVELOPER
工具-首選項-數據庫-第三發JDBC驅動程序



配置完畢!
成功!~~
其他Hive問題:
SQLDeveloper鏈接hive報錯
狀態: 失敗 -測試失敗: [Cloudera][HiveJDBCDriver](500164) Error initialized or created transport for authentication: java.net.ConnectException: Connection refused: connect.
一般是hiveserver2沒有跑起來,或者beeline沒有起來
我自己碰到的是imetastore的問題。
$ hive --service metastore
hiveserver2跑起來后,localhost:10002就能展示網頁。
beeline> !connect jdbc:hive2://localhost:10000/
其他ORACLE安裝問題:
根據ref1中所述,需要yum install很多個文件,其實不用,比如下面這個安裝就不用執行,它里面沒有compat-libstdc++-33的包。
[root@bigdata ShareFolder]# yum install -y gcc-c++
Installed:
gcc-c++-8.3.1-4.5.el8.x86_64 cpp-8.3.1-4.5.el8.x86_64
gcc-8.3.1-4.5.el8.x86_64 isl-0.16.1-6.el8.x86_64
libstdc++-devel-8.3.1-4.5.el8.x86_64 glibc-devel-2.28-72.el8_1.1.x86_64
glibc-headers-2.28-72.el8_1.1.x86_64 kernel-headers-4.18.0-147.8.1.el8_1.x86_64
libxcrypt-devel-4.1.1-4.el8.x86_64
================================
自用請忽略:
D:\Downloads\hive_jdbc_2.5.20\2.5.20.1060\ClouderaHiveJDBC-2.5.20.1060\ClouderaHiveJDBC41-2.5.20.1060
Ref 3:EPEL:https://fedoraproject.org/wiki/EPEL
https://cwiki.apache.org/confluence/display/Hive/AdminManual+Metastore+Administration
