Centos7_86_64 creating Oracle instances and setting up boot and allow remote connections

Source: Internet
Author: User
Tags iptables sqlplus

First, preface

First of all, the system here is the Centos7_86_64,oracle version is oracle10g R2, assuming that the system and the database have been installed. There is an article in detail on the CentOS7 under the installation of oracle10g process, the need for students can go to see. Portal: centos7_86_64 installation oracle10g R2 The history of blood and tears.

Second, check/set up the system firewall

Description : This is primarily to set up Oracle to allow remote connections, without which you can do so without the need.

1, the client detects the network through the sex

This step is not performed or can be, if no condition is detected. This is just a description of whether the network is normal, and the subsequent firewall configuration does not have an absolute relationship.

Generally if the client

ping serverip

No problem, it means you have access to a Linux server.

tnsping serverip  

No problem stating that TNS can be accessed.

I am the Win7 client to connect to the Oracle server under Linux, is here tnsping can not pass, online to find the reason is the Linux firewall problem. But the CENTOS7 I installed did not install the firewall module by default, but accidentally shielded the external machine from accessing the Linux host.

Workaround: Install the firewall module and set up the firewall.

2. Detecting firewall configuration information under Linux

Execute command under Root

#systemctl status iptables.service

Or

#systemctl start iptables.service

Tips similar to the following information

Unit Iptables.service failed to load:no such file or directory

Or

Failed to issue method Call:unit Iptables.service Failed to load:no such file or directory.
Iptables-failthis simple means don't have the Iptables-services package installed.

This shows that my centos7 is missing the firewall module. The firewall module needs to be installed first. If you select a security module when installing CENTOS7, this problem should not occur here.

3. Yum Install firewall module
#yum install iptables-services

After the installation is successful, execute the command status to view the firewall status, and if it is, you can restart it.

#systemctl restart iptables.service

If off, execute the Open command

#systemctl start iptables.service

Then check the status, and if it turns on, it should show active.

In addition, the default firewall for CentOS7 is FIREWALLD, and there are some settings to be made here.
Perform

#systemctl disable firewalld.service

Disable firewall boot, and then execute

#systemctl enable iptables.serivce#systemctl start iptables.serivce

The above installs and turns on the CENTOS7 firewall, but here we also need to set up the 1521 port to allow remote machine access.

4. Set firewall open port 1521

There are two solutions, one is to directly shut down the firewall, one is to configure the Firewall service, open 1521 port.
(1) Close the firewall,

#systemctl  stop  iptables.service

But it will fail after the reboot,
Of course, you can do it.

#systemctl  disable  iptables.service

Permanently shut down the firewall, but it is not recommended, unsafe and unreasonable. A reasonable solution should be to open the 1521 port, while keeping the Firewall service open properly.

(2) Configure the firewall and turn on port 1521.

First use Iptables to view the current rule: iptables-l-n, such as

As you can see, there are really only a few ports that are allowed to connect. So let Iptables open 1521 port to allow this port to be connected:

First of all:

#vi /etc/sysconfig/iptables

Join:

-A-p-m--NEW-m--1521-j ACCEPT

Exit the VI editor after saving and then:

# service iptables save# service iptables restart

Then reboot, then execute

#iptables-L-n ,

If the real 1251 port is open, the setting is successful.

At this point, the firewall configuration is complete.

Iii. Creating an Oracle DB instance and configuring monitoring and network configuration

When you install Oracle, you typically create an instance of ORCL, which assumes that you haven't created a database yet, or that we need another db instance to recreate it.

1. Create an Oracle instance

With Oracle Login,
First set under the current language environment for English, to prevent garbled

$export LANG=enUS

Execute the command to open the Create Instance window--database Configuration Assistant.

$dbca

Click Next to select

Create a Database

In addition to setting the instance name, account password, and choosing character sets, the basic is to click Next, and finally click OK to start creating the DB instance. Suppose the instance test is built here, and the instance SID is TestID

2, configuration Monitoring

Under Oracle account, enter the command to open the configuration window--oracle Net configuration Assistant

$netca

Select the first item, then click Next

Listener Configuration

If you have previously configured a listener for another instance, you typically select the reconfigure item here, and then go all the way next until finish.

3. Configure the local network service name

In the Net Configuration assitant window just now, select the third--local net Service Name Configuration and click Next

Select Add, click Next, enter the instance name test, click Next, select TCP, click Next, then enter host name, where the native IP address is generally entered, Input localhost or 127.0.0.1 should also be allowed, the port remains the default 1521 unchanged, then Next, select "Yes,perform a test" for the connection test, click Next, will tell you login failure, generally, then click Change Login, use system and the password login that was set up when the instance was created, click OK, show Test successful, click Next, enter Test, click Next, select No, then Next,next, go back to the first interface, The network configuration is successful at this time.

You can enter the following command to view the configuration you just made. ( because this article is followed by an article, my oracle_home is/opt/oracle/102/.) )

$cat /opt/oracle/102/network/admin/listener.ora$cat /opt/oracle/102

Review the previous monitoring and network configuration.

Iv. starting a local database instance

or log on using an Oracle user. The test instance is created above, so let's start this instance, otherwise it doesn't make sense.
Before starting, we usually start listening, execute the command

$lsnrctl start$lsnrctl status

There are two ways to launch an instance, one is to use Sqlplus, and the other is to call the startup script Dbstart directly. But the default dbstart is problematic, we first use the first type.

1. Start the instance with Sqlplus

If you have multiple instances and point to that instance, you can use the

$echo$ORACLE_SID

View, if you need to change, you can use the following command to develop the SID of the Oracle instance to start.

$export ORACLE_SID=testsid$echo$ORACLE_SID

Then execute the command.

$sqlplus /nolog$conn /as sysdba

Enter as DBA, and then enter the instruction

SQL>startup

The DB instance test is started.
If you need to close, the previous process is the same, and the last step is to execute shutdown immediate.

2. Start the database using Dbstart

There is a very useful command Dbstart and Dbshut, but Dbstart need to configure, if directly executed, will be error:

Oracle_home_listner is isn't SET, unable to auto-start Oracle Net Listener

or something like

Failed to Auto-start Oracle Net listene Using/ade/vikrkuma_new/oracle/bin/tnslsnr

It appears that the listener service is not up, but executing lsnrctl start can start the listener service.
Searching for Tnslsnr strings in Dbstart files

$grep tnslsnr dbstart

return Result:
 

 if-f$ORACLE_HOME_LISTNERthen  echo"Failed to auto-start Oracle Net Listene using $ORACLE_HOME_LISTNER/bin/tnslsnr"

It may seem that the Oracle_home_listner environment variable is causing the lookup Oracle_home_listner

grep ORACLE_HOME_LISTNER dbstart

return results

   # 3) Set Oracle_home_listnerOracle_home_listner=/ade/vikrkuma_new/oracleif[ !$ORACLE _home_listner] ; Then    Echo "Oracle_home_listner is not SET, unable to Auto-start ORACLE Net Listener"log=$ORACLE _home_listner/listener.logif[- F $ORACLE _home_listner/bin/tnslsnr]; Then    $ORACLE _home_listner/bin/lsnrctl Start >>$LOG 2>&1&ExportVer10list= '$ORACLE _home_listner/bin/lsnrctl Version | Grep"Lsnrctl for"| Cut- D"' - F5 | Cut- D'. ' - F1 'Echo "Failed to Auto-start Oracle Net listene using $ORACLE _home_listner/bin/tnslsnr"    $LOGMSG "Restart Oracle Net Listener using an alternate oracle_home_listner:lsnrctl start"

There is an assignment to the ORACLE_HOME_LISTNER environment variable, but this path is not correct, edit the Dbstart file

vi /opt/oracle/102/bin/dbstar

Change the line to

export ORACLE_HOME_LISTNER=$ORACLE_HOME

Save exit, and then execute Dbstart there's no problem.

Under normal circumstances, Dbshut will not be wrong, if any, the same solution.

Here we have created a database instance, started the service, and set up a remote connection, that is, our database server is already available. But another problem is that Oracle does not start automatically with the boot, we have to manually dbstart each boot, which is not what we want. There are many ways to set up the Oracle service on the network, here choose a relatively simple one, toss a long time, finally fix. In fact, it is very simple, mainly on Linux, especially centos7 not familiar.

Five, set Linux boot 1, configuration Oratab

Log on to the Linux system as root, type the command

vi /etc/oratab

After entering the VI editor, find

Testsid:/opt/oracle/102:n

, instead

Testsid:/opt/oracle/102:y

After the modification is complete, save Exit VI.

Description: Testsid The installation directory for the instance sid;/opt/oracle/102, depending on the installation situation.

2, Configuration rc.local

Type the command

vi /etc/rc.d/rc.local

Add as Downstream

su oracle -lc"/opt/oracle/102/bin/lsnrctl start"su oracle -lc /opt/oracle/102/bin/dbstart

The first line because there are spaces after lsnrctl, need quotation marks, the second line is not quoted can. After you have modified the save exit.

But there is a very important question, if it is in the previous CentOS version, so it is possible. But Centos7/etc/rc.local will not boot execution, so carefully read the next/etc/rc.local file content found the cause of the problem

#!/bin/bash# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES## It is highly advisable to create own systemd services or udev rules# to run scripts during boot instead of using this file.## In constrast to previous versions due to parallel execution during boot# this script will NOT be run after all other services.## Please note that you must run ‘chmod +x /etc/rc.d/rc.local‘ to ensure# that this script will be executed during boot.

Translation:

#这个文件是为了兼容性的问题而添加的.
#强烈建议创建自己的systemd服务或udev规则来在开机时运行脚本而不是使用这个文件.
#与以前的版本引导时的并行执行相比较, this script will not be executed after all other services.
#请记住, you must perform "chmod +x/etc/rc.d/rc.local" to ensure that the script executes at boot time.

So I confirmed the permissions of the next/etc/rc.local.

[root@localhost ~]# ll /etc/rc.local1138月  1206:09 /etc/rc.local -> rc.d/rc.local[root@localhost ~]# ll /etc/rc.d/rc.local14776月  1013:35 /etc/rc.d/rc.local

found that the original/etc/rc.d/rc.local do not have permission to execute, and then follow the contents of the instructions

chmod +x /etc/rc.d/rc.local

After rebooting, it was found that/etc/rc.local was able to execute.
Then use the following command to view the startup of the DB instance.

$lnsrctl status$ps -ef |grep ora_

Review the operation of the listener and the instance separately.

To this end, it is basically possible for Oracle to boot from the boot. In addition, due to the collation of this article, has been away from my actual experiment for some time, there may be some places leaked, but the general Internet can find information. There is a description of the content of this article, is to combine the information of other people on the network and their own practice, many places are the content of other people's articles, I just put the problems encountered to comb a bit, only for the purpose of learning. Thanks to everyone who is willing to share knowledge. If there is any mistake, please correct me.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Centos7_86_64 creating Oracle instances and setting up boot and allow remote connections

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.