Cainiao database (6)-enabling and disabling Oracle services conveniently and quickly

Source: Internet
Author: User

Cainiao database (6)-enabling and disabling Oracle services conveniently and quickly

Background:

As a programmer, in daily work, our computer often needs to run many programs at the same time, such as Eclipse, browsers, and instant messaging software, you may need to open several Office documents or pdf documents. At this time, your memory is estimated to have exploded. Especially for browsers like Chrome and FireFox, you can install a few plug-ins at will, and the memory usage is astonishing. We have to install a variety of plug-ins to meet our needs, because these two browsers have no difference with IE without installing any plug-ins.


As shown in, the FireFox and Java processes and Eclipse occupy the top four of the memory usage steadily. If your computer is still running Oracle services, your computer will become terrible.

I upgraded my computer to 8 GB memory. I felt very good at first. It didn't take long and it became very slow again. How much memory does it actually provide? How much memory does it dare to use. Unlimited hardware upgrades are obviously not practical, so we need to use our brains on the software. In this case, we need to turn off the services and background processes that are not commonly used.

Browsers are indispensable every day, and there are no background processes when the main program is turned off. Therefore, our goal is not to use them. Java and Eclipse cannot do without them every day, so you can't get rid of them. Hey, Oracle is sorry, you can only get rid of them, because with frameworks like Hibernate, let us do not need to know what database we will target when writing code. Therefore, we do not have to drive the Heavy background services of Oracle on our machines every day. A small MySQL can handle this problem, so we only need to turn off all its services and enable them again when using them.

However, the new problem arises again. Each time you need to enable the service, you also need to enable the System Service Management, find the Oracle-related services, and right-click and choose start, if I have any experience in similar operations, I think this is a very annoying job.

But as a programmer, we should naturally think that these complicated tasks can be automatically solved by the program. That's right. It's very simple. You only need a few lines of code!


Solution:

First, go to the service (Press "Win", enter "service", and press Enter) to find the Oracle-related services. I have installed 11 GB of services as follows:

We do not need to enable all services. The basic functions only need to enable the following two services:

OracleServiceORCL
OracleOraDb11g_home1TNSListener


Save the following code as a ". bat" file or a ". cmd" file.

Code:

@echo offnet start OracleServiceORCLnet start OracleOraDb11g_home1TNSListenerpause 

Running effect:


After running, you can see that the status of the two services has changed to "started":



To stop a service, you only need to change "start" to "stop ":

@echo offnet stop OracleServiceORCLnet stop OracleOraDb11g_home1TNSListenerpause 

Running effect:



Now, with these two pieces of Oracle code, the service is just for us. The trick is coming, and it will be lingering. Think about it. The following is a detailed description of Oracle services:

1. oracle orcl vss Writer Service: Oracle Volume ing Copy write Service. VSS (Volume Shadow Copy Service) allows storage basic devices (such as disks and arrays) to create high fidelity time point images, that is, shadow copy ). It can create ing copies on multiple volumes or a single volume without affecting the system performance. (Not mandatory)

2. OracleDBConsoleorcl: Oracle Database Console service. orcl is the instance id of Oracle and the default instance is orcl. Start this service when running Enterprise Manager (Enterprise Manager OEM. (Not mandatory)

3. OracleJobSchedulerORCL: Oracle Job Scheduling (timer) service. ORCL is the Oracle instance id. (Not mandatory)

4. OracleMTSRecoveryService: Server Control. This service allows the database to act as a resource manager for transactions in the distributed environment, such as the Microsoft Transaction Server MTS, COM/COM + objects, and transactions. (Not mandatory)

5. OracleOraDb11g_home1ClrAgent: Part of the Oracle database. NET extension service. (Not mandatory)

6. OracleOraDb11g_home1TNSListener: Listener service, which is required only when the database needs remote access. (It is not required to be started. Details will be provided below ).

7. OracleServiceORCL: Database Service (database instance) is the core service of Oracle. It is the basis for database startup. Only when the service is started can the Oracle database be started normally. (Must be started) What services should be started during development?

For beginners, if you only use the SQL * plus provided by Oracle, you only need to start OracleServiceORCL. If you use third-party tools such as PL/SQL Developer, the OracleOraDb11g_home1TNSListener service must also be enabled. OracleDBConsoleorcl must be enabled to access the WEB-based EM, and is rarely used by other services.

Note: ORCL is the database instance name, and the default database is ORCL. You can create another database, that is, OracleService + database name.



How to enable the oracle Database Service by running the commands in dos? Must I enable the listener first?

Start OracleService in Task Manager Service <SID> Start oracle Database Service
The Service and the listener start sequence are not necessarily related unless dynamic listening is set.

How to enable and disable the Oracle database service?

This is very simple. You can set the fiddler service to non-automatic boot, so that it does not take a long time to start up. For another problem, you can create a bat batch file on the desktop to solve the problem, the following is my oracle batch processing file. copy it and modify the service name. Very convenient.
@ Echo off
: Dosmenu
REM selection menu
Echo #************************************** ********************************#
Echo Windows Service Startup Script
Echo #************************************** ********************************#
Parameters of the echo command are described as follows:
Echo #************************************** ********************************#
Echo.
Echo [1] Start oracletest [2] disable oracletest [3]
Echo.
Echo #************************************** ********************************#
Set/p chs = select [1], [2], [3]?

If/I "% CHS %" = "1 "(
Goto aaaa
)

If/I "% CHS %" = "2 "(
Goto bbbb
)
If/I "% CHS %" = "3 "(
Goto zzzz
)
: Aaaa
REM starts oracletest
Net start "OracleServiceORACLETEST"
Net start "OracleOraDb10g_home1TNSListener"
Pause
Cls
Goto dosmenu
: Bbbb
Rem disable oracletest
Net stop "OracleOraDb10g_home1TNSListener"
Net stop "OracleServiceORACLETEST"
Pause
Cls
Goto dosmenu
: Zzzz
REM exit
Exit

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.