Connect oracle from linux

Connecting to Your Instance

You connect to a running Linux instance using a Secure Shell (SSH) connection. Most Linux and UNIX-like operating systems include an SSH client by default. Windows 10 and Windows Server 2019 systems should include the OpenSSH client, which you’ll need if you created your instance using the SSH keys generated by Oracle Cloud Infrastructure . For other Windows versions, you can download a free SSH client called PuTTY from http://www.putty.org.

Before You Begin

  • You know the public IPВ address of your instance. See Launching a Linux Instance.
  • You know the path to the private key file.

Connecting to Your Linux Instance Using SSH

Log in to the instance using SSH.

Use the following command to set the file permissions so that only you can read the file:

is the full path and name of the file that contains the private key associated with the instance you want to access.

Use the following SSHВ command to access the instance.

Note

Copy the following example to ensure the correct characters are used. If the wrong character is used in ssh -i , a Could not resolve hostname . No such host is known. error might occur.

is the full path and name of the file that contains the private key associated with the instance you want to access.

is the default username for the instance. For Oracle Linux and CentOS images, the default username is opc . For Ubuntu images, the default username is ubuntu .

is your instance IPВ address that you retrieved from the Console .

If the instance uses a key pair that was generated by Oracle Cloud Infrastructure , use the following procedure.

If this is the first time you are using this key pair, you must set the file permissions so that only you can read the file. Do the following:

  1. In Windows Explorer, navigate to the private key file, right-click the file, and then click Properties.
  2. On the Security tab, click Advanced.
  3. On the Permissions tab, for Permission entries, under Principal, ensure that your user account is listed.
  4. Click Disable Inheritance, and then select Convert inherited permissions into explicit permissions on this object.
  5. For Permission entries, select each permission entry that is not your user account and click Remove.
  6. Ensure that the access permission for your user account is Full control.
  7. Save your changes.

To connect to the instance, open Windows PowerShell and run the following command:

Note

Copy the following example to ensure the correct characters are used. If the wrong character is used in ssh -i , a Could not resolve hostname . No such host is known. error might occur.

is the full path and name of the file that contains the private key associated with the instance you want to access.

is the default username for the instance. For Oracle Linux and CentOS images, the default username is opc . For Ubuntu images, the default username is ubuntu .

Читайте также:  Mac os and nokia

is your instance IPВ address that you retrieved from the Console .

  • If you’re connecting to this instance for the first time, you need to accept the fingerprint of the key. To accept the fingerprint, type yes and press Enter.
  • SSH private key files generated by Oracle Cloud Infrastructure are not compatible with PuTTY. If you are using a private key file generated during the instance creation process you need to convert the file to a .ppk file before you can use it with PuTTY to connect to the instance.

    Note

    If you changed the file permissions on your key to connect from a Windows system using OpenSSH, the key will not work with a PuTTY connection. Use OpenSSH to connect instead.

    Convert a generated .key private key file:

    Click Load, and select the private key generated when you created the instance. The extension for the key file is .key .

    Click Save private key.

    Specify a name for the key. The extension for new private key is .ppk .

    Connect to the Linux instance using a .ppk private key file:

    If the instance uses a key pair that you created using PuTTY Key Generator, use the following procedure.

    In the Category pane, select Session and enter the following:

    Host Name (or IP address):

    is the default username for the instance. For Oracle Linux and CentOS images, the default username is opc . For Ubuntu images, the default username is ubuntu .

    is your instance public IPВ address that you retrieved from the Console

    Click Browse, and then select your .ppk private key file.

    Click Open to start the session.

    If this is your first time connecting to the instance, you might see a message that the server’s host key is not cached in the registry. Click Yes to continue the connection.

    Tip

    If the connection fails, you may need to update your PuTTY proxy configuration.

    Running Administrative Tasks on the Instance

    When you’re logged in as the default user, opc , you can use the sudo command to run administrative tasks.

    What’s Next

    Now that you’ve got an instance and have successfully connected to it, consider the following next steps:

    Install software on the instance.

  • Add a block volume. See Adding a Block Volume.
  • Add more users to work with Oracle Cloud Infrastructure . See Adding Users.
  • Allow additional users to connect to your instance. See Adding Users to an Instance.
  • Or, if you are finished with your instance, delete the resources that you created in the tutorial. See Cleaning Up Resources from the Tutorial.
  • If you’re having trouble connecting, see Troubleshooting the SSH Connection.

    Источник

    Accessing the Oracle Database from Linux

    This Note describes how to run Oracle client applications on the School’s Linux workstations and servers.

    For information about the Oracle database management system in the School, and to learn about your Oracle account and schema on it, see

    Oracle SQL Applications

    The Oracle client applications covered in the Note are —

    Using SQL Developer in the Lab

    Oracle’s SQL Developer is installed on the School’s Ubuntu Linux Mate Workstations in Teaching Laboratory #3.

    Starting SQL Developer

    You can start SQL Developer from either the Mate Graphical User Interface menu, or from the Linux terminal.

    In the Mate GUI, SQL Developer can be found in the Programming sub-menu in the Applications menu.

    Читайте также:  Python execute shell linux

    Click the left mouse button down over the Mate Menu button at the left of the bottom edge panel to open the Menu panel.

    If the panel shows Favourites , click on All applications to see the Applications sub-menus instead.

    Move down over Programming and click over SQL Developer .

    Alternatively, SQL Developer can be invoked from the command line in a Linux terminal.

    The terminal must be associated with a graphical display (ie the X11 DISPLAY variable must be set), like it would be if you are logged in at a workstation, or SQL Developer will give an error message and fail to run.

    As SQL Developer runs, a splash screen shows its progress. It should take only a few seconds to start up.

    It’s possible to import settings from an earlier version of SQL Developer that you may have run.

    During start-up, SQL Developer shows this import panel (even if, as is the case here, there are no previous settings to import).

    Click on No to continue.

    Oracle can make use of product usage information by tracking the features that you use in SQL Developer .

    Untick the option box to turn this off and click on OK .

    SQL Developer first shows its start window.

    There are four parts to the window –

    • A menu bar across the top
    • A Connections pane to the top left
    • A Reports pane to the bottom left
    • The Start Page in the pane to the right

    The Start Page has links to videos, tutorials and demonstrations that you can use to learn more about SQL Developer .

    Setting up a Database Connection

    Click on the + in the Connections pane to create a new connection to the School’s Oracle database server.

    A New Database Connection panel opens.

    This panel allows you to specify your account user name and password and other details about the Oracle database so that you can connect to it.

    In the panel, think of a Connection Name and type it in the field. Any name will do – we’ve put comsc in this example.

    Enter your School Oracle user name and password into the Username and Password fields. Leave the Save Password box unticked.

    Use the pull-down menu to change the Connection Type to TNS .

    Now, we can use the network alias to specify our database server. Click on the pull-down menu and choose CSORA12EDU .

    Click on the Test button to see if the settings work. (If they don’t, you have probably made a mistake in your user name or password). Once it’s ok, click on Save to save the settings.

    Connecting to the Database

    The connection you have configured appears in the Connections pane at the left of the SQL Developer window. Click on the + alongside the name to connect to the database.

    You will need to enter your Oracle account password to complete the connection. A panel appears showing your Oracle connection user name. Enter your password in the Password field.

    If you have typed your password correctly, an SQL Worksheet tab opens in the main pane to the right.

    Note that, once you have connected to the database, you can start a new SQL Worksheet tab at any time by clicking on the SQL icon in the top menu bar (or type Alt-F10 ).

    Читайте также:  Windows 10 локальный пользователь создать при установке

    Using the SQL Worksheet in SQL Developer

    The simplest use of SQL Developer is to run SQL statements in the SQL Worksheet . Look at the tutorials, demonstrations and help within SQL Developer for other usage.

    Type SQL statements in the SQL Worksheet tab. The tab is an editable window where you can type and amend text.

    You can type as many statements as you want but remember to erase unwanted earlier text so that it doesn’t get executed again.

    To execute the SQL statement, click the Run statement icon above the tab. Alternatively, just type Ctrl-ENTER .

    The results of your SQL statement are output in a new Query Result pane as shown here.

    There’s also an SQL History pane that logs the commands you have executed.

    Exiting SQL Developer

    To exit SQL Developer , either close the window using the X at the top right of the window, or select Exit from the File pull-down menu.

    If you have statements in the SQL Worksheet tab, you will be given the opportunity to save them to an SQL file that SQL Worksheet can read and run later.

    Using SQL*Plus

    SQL*Plus is a terminal-based application that can connect to an Oracle database to run SQL statements and view results. It’s a handy appplication to use if a Graphical User Interface is not available. SQL*Plus is installed on the School’s Linux workstations and servers as sqlplus .

    Running SQL*Plus

    The Linux application program sqlplus is a command that can be invoked in a Linux terminal. The terminal can be a remote SSH login to a Linux system in the School, for example lapis.cs.cf.ac.uk, or the Mate GUI terminal application.

    In Teaching Laboratory #3 on the Ubuntu Mate workstations, start a Mate Terminal from the All applications menu System Tools category, or from the Menu System shortcuts Terminal entry, or from the desktop background menu that is obtained by clicking the right mouse button on the background.

    In the terminal, invoke SQL*Plus with the sqlplus command. Put your Oracle account user name, followed by an @ and then the Network Alias csora12edu as an argument the command. E.g.

    Logging in to Oracle with SQL*Plus

    You will be prompted for your School Oracle password. Type your password (which is not echoed) and press the RETURN key.

    SQL*Plus connects to the Oracle server and prompts you for SQL commands.

    Writing, saving, getting and editing commands

    Type your SQL statements after the SQL prompt. Each SQL statement is terminated by a semi-colon.

    You can edit the statements in the command buffer by typing the edit command:

    This will invoke the simple text editor. If you prefer to use a different editor, you should set the EDITOR environment variable before running sqlplus . E.g.: or or

    Remember to write or save the edited changes before closing the editor.

    The amended SQL statements will appear in the SQL*Plus terminal window.

    Type the command run to execute the new statements.

    It is also possible to invoke the text editor on a named file:

    You can save the SQL*Plus command buffer to a file and execute the contents of a file. Use save followed by a file name to save the buffer to a file.

    Use start or @ followed by the file name to execute the SQL statements from the file.

    Terminating sqlplus

    When you have finished with SQL*Plus , type the quit command.

    Источник

    Оцените статью