Wiki source code of Oracle Installation
Version 22.2 by Vincent Massol on 2020/09/21
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{box cssClass="floatinginfobox" title="**Contents**"}} | ||
2 | {{toc/}} | ||
3 | {{/box}} | ||
4 | |||
5 | = Installation steps = | ||
6 | |||
7 | Steps: | ||
8 | |||
9 | * Download and install a version of Oracle Database. For example [[Oracle Express>>http://www.oracle.com/technetwork/products/express-edition/downloads/index.html]]. | ||
10 | * Download the corresponding [[Oracle JDBC Drivers>>https://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html]] and copy the JAR (e.g. ##ojdbc8.jar## in ##WEB-INF/lib/##) | ||
11 | * Start Oracle and connect to it with a DBA or system user. For example use the Oracle SQL*Plus command-line tool: {{code}}connect system;{{/code}} | ||
12 | * Create the wiki user and schema:((( | ||
13 | {{code}} | ||
14 | create user xwiki | ||
15 | identified by xwiki; | ||
16 | {{/code}} | ||
17 | ))) | ||
18 | * Create a tablespace (which is the Oracle term for what you know as a "database" on Microsoft SQL Server):((( | ||
19 | {{code}} | ||
20 | select * | ||
21 | from dba_data_files | ||
22 | ; | ||
23 | -- | ||
24 | -- Pick an adequate name from the list above. | ||
25 | -- | ||
26 | create tablespace xwiki | ||
27 | datafile '/opt/SOMETHING/oracle/oradata/SID/xwiki01.dbf' | ||
28 | size 1m | ||
29 | autoextend on | ||
30 | maxsize 1g | ||
31 | ; | ||
32 | {{/code}} | ||
33 | ))) | ||
34 | * Create tables of the ##xwiki## user by default in the new tablespace:((( | ||
35 | {{code}} | ||
36 | alter user xwiki | ||
37 | default tablespace xwiki | ||
38 | temporary tablespace temp | ||
39 | ; | ||
40 | alter user xwiki quota unlimited on xwiki | ||
41 | ; | ||
42 | {{/code}} | ||
43 | ))) | ||
44 | * Give sufficient privileges to the ##xwiki## user:((( | ||
45 | {{code}} | ||
46 | grant connect to xwiki; | ||
47 | grant resource to xwiki; | ||
48 | grant dba to xwiki; | ||
49 | {{/code}} | ||
50 | ))) | ||
51 | * Tell XWiki to use Oracle. To do this, edit the ##WEB-INF/hibernate.cfg.xml## file where you have expanded the XWiki WAR file and uncommented the Oracle part. Make sure to review the ##connection.url## property. For example a typical Oracle Express would be:{{code}}<property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>{{/code}}((( | ||
52 | {{info}} | ||
53 | **XE** is the default name of the ORACLE SID created by default by the installation for Oracle Express. If it is another you should change it. You can find the correct SID in ##app/oracle/product/10.2.0/server/NETWORK/ADMIN/tnsnames.ora## in the Oracle installation directory (for Windows). | ||
54 | {{/info}} | ||
55 | ))) | ||
56 | |||
57 | = Installing Oracle from a VM = | ||
58 | |||
59 | An easy to test Oracle is to use a VM. Here are some easy steps: | ||
60 | |||
61 | * [[Download the VM from the Oracle web site>>http://www.oracle.com/technetwork/database/enterprise-edition/databaseappdev-vm-161299.html]] | ||
62 | * Install [[VirtualBox>>https://www.virtualbox.org/]] and import the VM in it | ||
63 | * Note: I had to configure the VM network settings to use the "Bridged Adapter" instead of "NAT" in order to be able see it from my host machine | ||
64 | * Start the VM and log in as ##oracle##/##oracle## | ||
65 | * Note that IP address printed in the shell that opens up, for example: 192.168.0.49 | ||
66 | * In the shell, starts the manager: ##emctl start dbconsole## | ||
67 | * Execute all the instructions above in the shell to create the ##xwiki## database (don't forget to download the JDBC driver and put it in ##WEB-INF/lib##). Tip: Put the following in a file (for example ##xwiki.sql## located on the Desktop) and execute {{code}}echo @Desktop/xwiki.sql | sqlplus system/oracle@orcl{{/code}}:((( | ||
68 | {{code}} | ||
69 | drop user xwiki cascade; | ||
70 | create user xwiki identified by xwiki; | ||
71 | select * from dba_data_files; | ||
72 | create tablespace xwiki datafile '/home/oracle/app/oracle/oradata/orcl/xwiki01.dbf' size 1m autoextend on maxsize 1g; | ||
73 | alter user xwiki default tablespace xwiki temporary tablespace temp; | ||
74 | alter user xwiki quota unlimited on xwiki; | ||
75 | grant create session to xwiki; | ||
76 | grant create table to xwiki; | ||
77 | grant create sequence to xwiki; | ||
78 | {{/code}} | ||
79 | ))) | ||
80 | * From your host machine, point your browser on http:~/~/192.168.0.49:1158/em and connect as ##system/oracle## | ||
81 | * In your XWiki's ##hibernate.cfg.xml##, use:((( | ||
82 | {{code}} | ||
83 | <property name="connection.url">jdbc:oracle:thin:@192.168.0.49:1521:orcl</property> | ||
84 | {{/code}} | ||
85 | ))) | ||
86 | * Don't forget to drop the Oracle JDBC driver in your ##WEB-INF/lib## directory! | ||
87 | * Enjoy ;) | ||
88 | |||
89 | = Using Docker = | ||
90 | |||
91 | Follow these steps: | ||
92 | * Start Oracle: {{code language='none'}}docker run --name oracle-xwiki -d -p 1521:1521 -v [<host mount point>:]/opt/oracle/oradata xwiki/oracle-database:19.3.0-se2{{/code}} | ||
93 | * Download the corresponding [[JDBC driver>>https://repo1.maven.org/maven2/com/oracle/ojdbc/ojdbc8/]] and put it in XWiki's ##WEB-INF/lib## directory | ||
94 | * Edit XWiki's ##hibernate.cfg.xml## file, comment out the Oracle section and make sure you use the following settings:((( | ||
95 | {{code language='none'}} | ||
96 | <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:xwiki</property> | ||
97 | <property name="hibernate.connection.username">xwiki</property> | ||
98 | <property name="hibernate.connection.password">xwiki</property> | ||
99 | {{/code}} | ||
100 | ))) | ||
101 | |||
102 | And if you need to execute some SQL command you can do the following: | ||
103 | * Connect inside the docker container with: {{code language='none'}}docker -it exec <container id> bash -l{{/code}} | ||
104 | * Run ##sqplplus## with {{code language='none'}}sqlplus xwiki/xwiki@//localhost:1521/xwiki{{/code}} or with {{code language='none'}}sqlplus sys/xwiki@//localhost:1521/xwiki as sysdba{{/code}} if you need to be DBA | ||
105 | |||
106 | {{info}} | ||
107 | You can check [[how the XWiki Oracle docker image is built>>https://github.com/xwiki/xwiki-docker-build/tree/master/build-oracle]]. | ||
108 | {{/info}} | ||
109 | |||
110 | = Indexes = | ||
111 | |||
112 | See [[Database Administration>>Documentation.AdminGuide.Performances.Database Administration.WebHome]]. | ||
113 | |||
114 | {{code}} | ||
115 | CREATE INDEX XWLS_VALUE ON XWIKILARGESTRINGS (XWL_VALUE) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('SYNC (ON COMMIT)'); | ||
116 | create index xwd_parent on xwikidoc (xwd_parent) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('SYNC (ON COMMIT)'); | ||
117 | create index xwd_class_xml on xwikidoc (xwd_class_xml) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('SYNC (ON COMMIT)'); | ||
118 | create index ase_page_date on activitystream_events (ase_page, ase_date); | ||
119 | create index xda_docid1 on xwikiattrecyclebin (xda_docid); | ||
120 | create index ase_param1 on activitystream_events (ase_param1) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('SYNC (ON COMMIT)'); | ||
121 | create index ase_param2 on activitystream_events (ase_param2) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('SYNC (ON COMMIT)'); | ||
122 | create index ase_param3 on activitystream_events (ase_param3) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('SYNC (ON COMMIT)'); | ||
123 | create index ase_param4 on activitystream_events (ase_param4) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('SYNC (ON COMMIT)'); | ||
124 | create index ase_param5 on activitystream_events (ase_param5) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('SYNC (ON COMMIT)'); | ||
125 | {{/code}} | ||
126 | |||
127 | = Troubleshooting = | ||
128 | |||
129 | == ORA-01400: cannot insert NULL into ("XWIKI"."XWIKILARGESTRINGS"."XWL_ID") == | ||
130 | |||
131 | This error can appear if you're using Oracle JDBC driver 10.2.0.1.0. The solution is to use version 10.2.0.2 or greater of the driver. | ||
132 | |||
133 | == SetString can only process strings of less than 32766 chararacters == | ||
134 | |||
135 | If you see an error that says something like this: | ||
136 | |||
137 | {{code}} | ||
138 | Error number 3201 in 3: Exception while saving document XWiki.XWikiPreferences | ||
139 | Wrapped Exception: could not update: [com.xpn.xwiki.doc.XWikiDocumentArchive#104408758] | ||
140 | com.xpn.xwiki.XWikiException: Error number 3201 in 3: Exception while saving document XWiki.XWikiPreferences | ||
141 | Wrapped Exception: could not update: [com.xpn.xwiki.doc.XWikiDocumentArchive#104408758] | ||
142 | ... | ||
143 | Wrapped Exception: | ||
144 | |||
145 | java.sql.SQLException: setString can only process strings of less than 32766 chararacters | ||
146 | ... | ||
147 | {{/code}} | ||
148 | |||
149 | Then that's because Oracle has a limitation of 32K for CLOBs. To overcome it you need to add the following 2 properties in the ##hibernate.cfg.xml## file, as specified in the installation steps section above: | ||
150 | |||
151 | {{code}} | ||
152 | <property name="hibernate.connection.SetBigStringTryClob">true</property> | ||
153 | <property name="hibernate.jdbc.batch_size">0</property> | ||
154 | {{/code}} | ||
155 | |||
156 | == NullPointerException at HqlSqlWalker == | ||
157 | |||
158 | This is actually caused by a wrong Oracle ##ojdbc## JAR being used. There are different JARs for every different minor version of Oracle. For example if you use the JDBC connector for Oracle 11g version 11.2.0.4.0 and your Oracle db version is 11.2.0.1.0 then you'll have the problem. | ||
159 | |||
160 | == Errors due to missing RAM == | ||
161 | |||
162 | If you see one of the following errors in the XWiki logs, it may simply be that you don't allocate enough RAM to Oracle. This is especially true if you're running it in a VM or in a Docker Container. For example we know that 2GB is not enough for Oracle and 2.5GB+ is ok. | ||
163 | |||
164 | {{code language='none'}} | ||
165 | SQL Error: 0, SQLState: null | ||
166 | Cannot get a connection, pool error Timeout waiting for idle object | ||
167 | ORA-12519, TNS:no appropriate service handler found | ||
168 | ORA-01435: user does not exist | ||
169 | {{/code}} | ||
170 | |||
171 | Note that it's possible to have these errors for other reasons too but you should at least check that the RAM is enough. |