I have installed Oracle 11gR2 and want to connect with SQL*Plus but I can't.
I login in as root and then switch user to oracle as
su oracle
I have added required Oracle environment variables in .bash_profile but it is not executed when i switch to oracle user from root. Even executing the bash file manually does not export the variables using following command
$ ./.bash_profile
These are the contents of my .bash_profile:
#!/bin/bash
#.bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programsotp
PATH=$PATH:$HOME/bin
export PATH
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=orcl.genie.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=orcl; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
umask 022
To check if you are running in a login shell, use the following command
shopt login_shell
if it displays
login_shell off
then you are not running in a login shell. You need to switch to oracle user with -l switch
su -l oracle
Hope, it solves your problem.
Related
When using the OpenStack client in the openstack "shell" mode, I miss aliases for common tasks a lot. I see that you can add aliases or macros with "alias add ..." or "macro add ...". However the aliases are not persisted between shell sessions.
Is there some file where I can configure those ?
You could set persisted alias in /etc/profile or ~/.bashrc and others file in /etc/profile.d/.
/etc/profile: set for all users
~/.bashrc: set for current user as ~ is the user $HOME directory
/etc/profile.d/: where directory will be imported as /etc/profile shows:
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
All this method take effect when you re login after update these files.
After I installed hadoop in my MacOS, I found there is always a warning "-bash: hadoop: command not found" displayed when I open a new terminal window every time. What's wrong? and How can I fix it? Thanks.
Last login: Fri Jan 8 20:13:00 on ttys010
-bash: hadoop: command not found
SJ-DN0393:github admin$
Here is the content of my /etc/profile file:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
export GITLAB_HOME=/Users/admin/dev/gitlab
export LDFLAGS="-L/usr/local/opt/python#3.7/lib"
export BASH_SILENCE_DEPRECATION_WARNING=1
export ZEPPELIN_HOME=/Users/admin/dev/zeppelin-0.9.0-preview2-bin-all
export SPARK_HOME=/Users/admin/dev/spark-3.0.1-bin-hadoop2.7
export ZOOKEEPER_HOME=/Users/admin/dev/apache-zookeeper-3.6.2-bin
export CONFLUENT_HOME=/Users/admin/dev/confluent-6.0.1
export HADOOP_HOME=/Users/admin/dev/hadoop-2.8.5
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop
export HADOOP_CLASSPATH=`hadoop classpath`
export FLINK_HOME=/Users/admin/dev/flink-1.12.0
export FLINK_CONF_DIR=$FLINK_HOME/conf
export FLINK_OPT_DIR=$FLINK_HOME/opt
export FLINK_PLUGINS_DIR=$FLINK_HOME/plugins
export FLINK_BIN_DIR=$FLINK_HOME/bin
export FLINK_LIB_DIR=$FLINK_HOME/lib
export MYSQL_HOME=/usr/local/mysql-5.7.31-macos10.14-x86_64
export HIVE_HOME=/Users/admin/dev/apache-hive-2.3.7-bin
export HBASE_HOME=/Users/admin/dev/hbase-2.2.6
export KAFKA_HOME=/Users/admin/dev/kafka_2.12-2.4.1
export JAVA_HOME=/Users/admin/.sdkman/candidates/java/current
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$HADOOP_HOME/share/hadoop/tools/lib/hadoop-aliyun-3.3.0.jar:$HADOOP_HOME/share/hadoop/common/hadoop-common-2.8.5.jar:$HADOOP_HOME/share/hadoop/common/lib/commons-cli-1.2.jar:$HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.8.5.jar
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/opt/python#3.7/bin:/usr/local/opt/redis#4.0/bin:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH:$FLINK_HOME/bin:$SPARK_HOME/bin:$MYSQL_HOME/bin:$ZEPPELIN_HOME/bin:$ZOOKEEPER_HOME/bin:$HBASE_HOME/bin:$KAFKA_HOME/bin:$CONFLUENT_HOME/bin:$HIVE_HOME/bin
You have `hadoop classpath` being invoked when you open the shell.
Since hadoop is not in the PATH until the very end of sourcing this file, the command wouldnt be found
The appropriate solution could be use $HADOOP_HOME/bin/hadoop classpath
Hello Everybody I have confufrated bash_profile as follow
# .bash_profile
Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc` fi
User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH
Oracle Settings TMP=/tmp; export TMP TMPDIR=$TMP; export TMPDIR ORACLE_HOSTNAME=merkez-rac1.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=RAC; export ORACLE_UNQNAME ORACLE_BASE=/u01/app/oracle;
export ORACLE_BASE GRID_HOME=/u01/app/11.2.0/grid; export GRID_HOME
DB_HOME=$ORACLE_BASE/product/11.2.0/db_1; export DB_HOME
ORACLE_HOME=$DB_HOME; export ORACLE_HOME ORACLE_SID=RAC1; export
ORACLE_SID ORACLE_TERM=xterm; export ORACLE_TERM
BASE_PATH=/usr/sbin:$PATH; export BASE_PATH
PATH=$ORACLE_HOME/bin:$BASE_PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
export CLASSPATH
if [$USER = "oracle" ] ; then if [ $SHELL= "/bin/ksh" ] ; then
ulimit -p 16384 ulimit -n 65536`enter code here`
else`enter code here` K ulimit -u 16384 -n 65536 fi fi alias
gid_env='. /home/oracle/gid_env' alias db_env='. /home/oracle/db_env'
But When i wrote on terminal `[oracle#merkez-rac1 ~]$ echo
$ORACLE_HOME`
[oracle#merkez-rac1 ~]$ It give me nothing and dosent show me the
directory /u01/app/oracle/product/11.2.0/db_1
Can't tell what the question is, but if it's about ORACLE_HOME, try putting a newline in on that line:
ORACLE_HOME=$DB_HOME; export ORACLE_HOME ORACLE_SID=RAC1; export
ORACLE_SID ORACLE_TERM=xterm; export ORACLE_TERM
should be
ORACLE_HOME=$DB_HOME; export ORACLE_HOME
ORACLE_SID=RAC1; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
and so on
I'm trying automate DBCA to create a new database. I'm using the box bseller/oracle-standard with Vagrant.
provision.sh
#!/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
But this script doesn't worked:
$ sh provision.sh
Import environment variables
Connect with user ORACLE
Loading environment variables
Create database mydatabase
DBCA cannot be run as root.
Running all lines from provision.sh in command line. worked!
I am wondering that the line below does not work to run the oracle command inside of a shell script:
sudo su -l oracle
You should wrap your command to get it work:
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
I got this solution here:
how to run script as another user without password
"Unable to check for available memory"
I fixed in this form:
I go to my other server with OLD installation Oracle (running fine Oracle 11g), then I find 3 files:
oracle_env.csh
oracle_env.sh
nls_lang.sh
becouse this files no exist in new server, I create with the content (path correct) the files
oracle_env.csh
oracle_env.sh
and put this lines into they:
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
after second file:
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 the file nls_lang.sh is very long and have many config about CHARSET, I copy from OLD server to NEW server.
after is necesary config owner/group of this files:
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
also the file nls_lang.sh require 755:
chmod 0755 /opt/oracle/product/18c/dbhomeXE/bin/nls_lang.sh
is necesary login as user oracle:
su -l oracle
then I go to folder and load vars environment:
cd /opt/oracle/product/18c/dbhomeXE/bin
. ./oracle_env.sh
finally I can run the command 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
and I get the greath result:
[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]$
becouse I need PHP in this servers, I require OCI8, then I run:
/usr/bin/ea-php72-pecl install oci8
/usr/bin/ea-php71-pecl install oci8
/usr/bin/ea-php70-pecl install oci8
when this request:
**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] then this run fine for me...
Regards.
I have installed sun-java in archlinux kde by first building the package and then installing it. This is the way the environment variables are set in my machine:
file: /etc/profile
# /etc/profile
#Set our umask
umask 022
# Set our default path
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
export PATH
# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
for profile in /etc/profile.d/*.sh; do
test -r "$profile" && . "$profile"
done
unset profile
fi
# Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
. /etc/bash.bashrc
fi
# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP
# Man is much better than us at figuring this out
unset MANPATH
and file: /etc/profile.d/jdk.sh
export J2SDKDIR=/opt/java
export PATH=$PATH:/opt/java/bin:/opt/java/db/bin
export JAVA_HOME=/opt/java
export DERBY_HOME=/opt/java/db
what I understand from this is, jdk path should be set in the path environment variable but its not. But the attribute $JAVA_HOME is set correctly. Any reasons why am I facing this problem?
/etc/profile and /etc/profile.d are processed only for login shells, so unless you're doing ssh into the machine where java is installed you won't get those variables.
To have them locally (e.g. when you open an xterm on a workstation) put them in the file /etc/bash.bashrc.
Hope this helps.
Actually, it was a silly mistake on my part. I am using zsh shell. So I was required to put:
export PATH=$PATH:$JAVA_HOME/bin
in .zshrc file instead of .bashrc.