我试图自动化DBCA创建一个新的数据库。我使用的盒子bseller/oracle-standard与放浪。
provision.是
#!/bin/bash
echo 'Import environment variables'
env=$( grep -ic "ORACLE_SID" /etc/profile )
if [ ! $env -eq 1 ] ; then
echo export ORACLE_SID=mydatabase >> /etc/profile
echo export ORACLE_BASE=/u01/app/oracle >> /etc/profile
echo export ORACLE_HOME=/u01/app/oracle/product/11.2/dbhome_1 >> /etc/profile
source /etc/profile
echo export PATH=$PATH:$ORACLE_HOME/bin >> /etc/profile
fi
echo "Connect with user ORACLE"
sudo su -l oracle
echo "Loading environment variables"
source /etc/profile
echo 'Create database mydatabase'
if [ ! -d /u01/app/oracle/oradata/mydatabase ] ; then
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName mydatabase -sysPassword mypassword -systemPassword mypassword -scriptDest /u01/app/oracle/oradata/mydatabase -characterSet WE8ISO8859P1
fi
但是,这个脚本不工作:
$ sh provision.sh
Import environment variables
Connect with user ORACLE
Loading environment variables
Create database mydatabase
DBCA cannot be run as root.
从运行在provision.sh命令行中的所有行。成功了!
我想知道,下面的行不工作,运行shell脚本里面的神谕命令:
sudo su -l oracle
你应该换你的命令得到它的工作:
su -c "dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName qualidade -sysPassword password -systemPassword password -scriptDest /u01/app/oracle/oradata/qualidade -characterSet WE8ISO8859P1" -s /bin/sh oracle
我在这里得到了此解决方案:how to run script as another user without password
“无法检查可用内存”
我固定的格式如下:
我去我的旧安装甲骨文(运行良好的Oracle 11g)以外的服务器,然后我发现3个文件:
oracle_env.csh
oracle_env.sh
nls_lang.sh
因为这个文件没有新的服务器存在,我与内容(路径正确)的文件创建
并把这个线到他们:
touch /opt/oracle/product/18c/dbhomeXE/bin/oracle_env.csh
echo 'setenv ORACLE_HOME /opt/oracle/product/18c/dbhomeXE
setenv ORACLE_SID XE
setenv NLS_LANG `$ORACLE_HOME/bin/nls_lang.sh`
setenv PATH $ORACLE_HOME/bin:$PATH' >> /opt/oracle/product/18c/dbhomeXE/bin/oracle_env.csh
之后第二个文件:
touch /opt/oracle/product/18c/dbhomeXE/bin/oracle_env.sh
echo 'export ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export PATH=$ORACLE_HOME/bin:$PATH' >> /opt/oracle/product/18c/dbhomeXE/bin/oracle_env.sh
becouse文件nls_lang.sh很长,而且有关于字符集很多的配置,我从旧服务器到新的服务器上复制。
后necesary配置所有者/组此文件:
chown oracle:oinstall /opt/oracle/product/18c/dbhomeXE/bin/oracle_env.csh
chown oracle:oinstall /opt/oracle/product/18c/dbhomeXE/bin/oracle_env.sh
chown oracle:oinstall /opt/oracle/product/18c/dbhomeXE/bin/nls_lang.sh
也文件nls_lang.sh需要755:
chmod 0755 /opt/oracle/product/18c/dbhomeXE/bin/nls_lang.sh
是必要的登录oracle用户:
su -l oracle
然后我去到文件夹和负载瓦尔环境:
cd /opt/oracle/product/18c/dbhomeXE/bin
. ./oracle_env.sh
终于我可以运行命令DBCA:
dbca -createDatabase -silent -gdbName ora18c -templateName XE_Database.dbc -sysPassword YourPWD1 -systemPassword YourPWD1 -dbsnmpPassword YourPWD1 -datafileDestination /opt/oracle/oradata -storageType FS -memoryPercentage 20 -emConfiguration NONE -sampleSchema false -J-Doracle.assistants.dbca.validate.ConfigurationParams=false
我也得到了很大的成绩:
[server@petro bin]$ dbca -createDatabase -silent -gdbName ora18c -templateName XE_Database.dbc -sysPassword YourPWD1 -systemPassword YourPWD1 -dbsnmpPassword YourPWD1 -datafileDestination /opt/oracle/oradata -storageType FS -memoryPercentage 20 -emConfiguration NONE -sampleSchema false -J-Doracle.assistants.dbca.validate.ConfigurationParams=false
Prepare for db operation
10% complete
Copying database files
40% complete
Creating and starting Oracle instance
42% complete
46% complete
50% complete
54% complete
60% complete
Completing Database Creation
66% complete
69% complete
70% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/ora18c.
Database Information:
Global Database Name:ora18c
System Identifier(SID):ora18c
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ora18c/ora18c.log" for further details.
[server@petro bin]$
因为我需要PHP在此服务器的,我需要OCI8,然后我运行:
/usr/bin/ea-php72-pecl install oci8
/usr/bin/ea-php71-pecl install oci8
/usr/bin/ea-php70-pecl install oci8
当这个请求:
**Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] :**
samplelly [ENTER],那么该运行正常,我...
问候。