How to connect Oracle using SQL Developer or Apex - database

I installed Oracle 11g on Ubuntu 14.04 by review this reference links. When installing, I do not see any step to create username and password
After that, I configured as below
$# sudo /etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition Configuration
This will configure on-boot properties of Oracle Database 11g Express Edition. The following questions will determine whether the database should be starting upon system boot, the ports it will use, and the passwords that will be used for database accounts. Press <Enter> to accept the defaults.
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:8080
Specify a port that will be used for the database listener [1521]:1522
Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. Oracle recommends the use of different passwords for each database account. This can be done after initial configuration:
Confirm the password:
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y
Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
I tried to login to apex using http://localhost:8080/apex/f?p=4950 ==> Unable to connect. Firefox can't establish a connection to the server at localhost:8080.
I try to connect using SQL Developer
Error: Status : Failure -Test failed: Listener refused the connection with the following error:ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
More information:
$ lsnrctl status
rgm#Motown:~$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 25-JUL-2015 08:49:19
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE))) STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 23-JUL-2015 17:21:04
Uptime 1 days 15 hr. 28 min. 14 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/Motown/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Motown)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
listener.ora file
# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = Motown)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
Login SqlPlus using SYSTEM
rgm#Motown:~$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Sat Jul 25 09:00:29 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-01031: insufficient privileges
Enter user-name: SYSTEM
Enter password:
ERROR:
ORA-01033: ORACLE initialization or shutdown in progress
Process ID: 0
Session ID: 0 Serial number: 0
Enter user-name: oracle
Enter password:
ERROR:
ORA-01033: ORACLE initialization or shutdown in progress
Process ID: 0
Session ID: 0 Serial number: 0
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
Login SqlPlus using oracle (su to oracle user)
rgm#Motown:~$ su oracle
Password:
oracle#Motown:/home/rgm$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Sat Jul 25 09:02:19 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>
SQL>
Please help me to fix the problem to login SQL using Apex and SQL Developer.
Thanks

Your SQL Developer screenshot, you are not using tnsnames.ora - which is fine.
How about using service name = XE, instead of SID. And localhost to Motown.
Before doing this - Go to the command and see if you can tnsping Motown.
c:\ tnsping motown
You should see OK somewhere on the last line. I'm assuming you have installed the Oracle client tools

In your install log it shows a port of 1522 instead of the default 1521.
Specify a port that will be used for the database listener [1521]:1522
In your SQL Developer screenshot you showed a connection dialog using the default of 1521. At least getting the port number right will move you closer if not solve it.

Related

Connection Failed Database-Zabbix

I received this error after updating Zabbix from 5 to 6 for my database:
# cat /var/log/zabbix/zabbix_server.log | grep database
55202:20220803:093334.621 [Z3001] connection to database 'zabbix' failed: [0] FATAL: the database system is shutting down
FATAL: the database system is shutting down
55202:20220803:093334.621 database is down: reconnecting in 10 seconds
55202:20220803:093344.636 database connection re-established
55202:20220803:093344.639 current database version (mandatory/optional): 05000000/05000005
1117:20220807:163451.680 current database version (mandatory/optional): 05000000/05000005
The following one is in my zabbix webpage:
The Zabbix database version does not match current requirements. Your database version: 5000000. Required version: 6000000. Please contact your system administrator.
I use postgresql!Zabbix and Postgresql services are active!

SQL Server Agent service could not be started

I start a Windows SQL Server in a Docker Container on a Windows Server 2016 virtual machine with this command:
docker container run --name mssql-server --detach --publish 1433:1433 --memory 2048mb --volume C:\_Data:C:\_Data --env sa_password=myPassword --env ACCEPT_EULA=Y microsoft/mssql-server-windows-developer
Afterwards I want to start the SQL Agent with this command:
docker container exec mssql-server cmd.exe /C "net start sqlserveragent"
Unfortunately I get this Output:
The SQL Server Agent (MSSQLSERVER) service is starting.
The SQL Server Agent (MSSQLSERVER) service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534
When I type NET HELPMSG 3534 I get:
The service did not report an error.
I am completely out of ideas. On my local machine this works fine, but not on the build server.
Any help appreciated.
Edit:
I opened the SQL Server Management Studio and noticed the SQL Server Agent (Agent XPs disabled) node.
So I went through everything in https://www.mssqltips.com/sqlservertip/2729/how-to-start-sql-server-agent-when-agent-xps-show-disabled/. Afterwards I executed
exec sp_configure 'Agent XPs'
and the result was:
But when I tried to start the agent, I got the exact same error message from above (service ist starting... service could not be started... no error reported).
The interesting thing is, when I run
exec sp_configure 'Agent XPs'
again, I get this:
How is it possible, that the start-agent-command disables the Agent XPs?
Edit2: I just learned from a comment at https://community.spiceworks.com/topic/293771-sql-server-agent-agent-xps-disabled-sql-server-2008 that the agent configures this values automatically when it is started and stopped. So I shouldn't enabled it manually.
Edit3:
After a comment from Jeroen Mostert I looked into the EventLog.
I used the following command:
docker container exec mssql-server powershell.exe "Get-EventLog Application -Newest 100"
This is the result from the Application-Log
Time EntryType Source InstanceID Message
---- --------- ------ ---------- -------
Jun 25 10:37 Information SQLSERVERAGENT 1073741926 SQLServerAgent service successfully stopped.
Jun 25 10:37 Information MSSQLSERVER 1073757281 Configuration option 'Agent XPs' changed from 1 to 0. Run the RECONFIGURE statement to install.
Jun 25 10:36 Information MSSQLSERVER 1073757281 Configuration option 'Agent XPs' changed from 0 to 1. Run the RECONFIGURE statement to install.
You can see, that I have manually enabled the Agent XPs. Then I ran the command from above to start the agent, which gave me the next two lines
The System-EventLog gave me:
Time EntryType Source InstanceID Message
---- --------- ------ ---------- -------
Jun 25 10:37 Information Service Control Manager 1073748860 The SQL Server Agent (MSSQLSERVER) service entered the stopped state.
Edit 4:
As per the comment from Dan Guzman: this is the content of SQLAGENT.OUT:
2019-07-09 11:03:44 - ? [000]
2019-07-09 11:03:44 - ? [098] SQLServerAgent terminated (normally)
Edit 5:
The version is (select ##version) is:
Microsoft SQL Server 2017 (RTM-CU3-GDR) (KB4052987) - 14.0.3015.40 (X64) Dec 22 2017 16:13:22 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor)
My solution was to upgrade the build-server to Windows Server 2019. That's it. Then everything worked without any further change.
Hi you need to start SQL Server Agent Service, How to start service you can follow this link: Start Service
Step 1: First, you have to click on the start menu and search for the SQL Server Configuration Manager and click on the SQL Server Configuration Manager option from the search result.
Step 2: Then you have to select the SQL Server Services from the left menu and you can see the service SQL Server (SQLEXPRESS) is not running and it is stopped.
Step 3: Now, you have to start the service SQL Server (SQLEXPRESS) and for that, you have to press mouse right click on SQL Server (Agent) service and select Start option to start the service.
Step 4: You can see the state of service is running, Now you should try again to connect SQL server database engine.
Because you are running in a docker container, i am assuming you are also using some form of environmental management (chef, puppet, jenkins) etc. Carefully review all the actors in your environment. maybe one of these is detecting the agents status and whether agent xp's should be allowed. Further you may need to check SQL Policy and AD Policies if you are in a domain. But the speed at which the reversal occurs suggests that an agent in the docker instance is too blame.
I managed to solve this getting into the docker container using "cmd" and then run a specific command to start windows services.
1) docker exec -it YourSQLServerContainerName cmd
2) net start sqlserveragent
You can stop and start your container and it preserve the running status.
I had the same issue, here how I fix my problem.
First, I install the SQL Server as a Docker container using the mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-16.04 image, and I use host network_mode for the Database container.
Next, after I view the SQL Agent log, I notice it wasn't able to connect to the server.
$ tail -100f /var/opt/mssql/log/sqlagent.1 # read agent's logs
...
2020-10-03 21:25:01 - ! [000] Unable to connect to server '(local),1433'; SQLServerAgent cannot start
2020-10-03 21:25:01 - ! [103] SQLServerAgent could not be started (reason: Unable to connect to server '(local),1433'; SQLServerAgent cannot start)
2020-10-03 21:25:06 - ! [298] SQLServer Error: 11001, TCP Provider: No such host is known. [SQLSTATE 08001]
...
Finally, I found from logs that the SQL Agent was trying to connect with instance '(local),1433', so my solution was to resolve the local and sqlserver host with the local IP. I accomplish it by adding the following records to the /etc/hosts file of the server.
127.0.0.1 local
127.0.0.1 sqlserver
I found from logs that the SQL Agent was trying to connect with instance '(local),1433' in /var/opt/mssql/log/sqlagent.out
I'm using Amazon Linux 2 with Sql Server 2017 updated.
Edit the local and sqlserver host with the local I by adding the following record (first line) to the /etc/hosts file of the server.
172.31.1.200 ip-172-31-1-200
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost6 localhost6.localdomain6

Can't start SQL Server services

I have 2 SQL Server instances on my PC, MSSQLSERVER2012 and SQLEXPRESS2014 and both of them were working properly.
But suddenly, both of them stopped and I can't run them again at all.
I get this error:
The request failed or the service did not respond in a timely fashion
I checked tcp/ip setting, even disabled tcp/ip of both instances.
I guessed it might be related to VIA protocol, but I can't see VIA protocol in my configuration manager.
I'll post the error log that SQL Server generates when it failed to start.
2017-05-17 22:24:07.77 Server Microsoft SQL Server 2012 -
11.0.2100.60 (X64) Feb 10 2012 19:39:15 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.2
(Build 9200: )
2017-05-17 22:24:07.77 Server (c) Microsoft Corporation.
2017-05-17 22:24:07.77 Server All rights reserved. 2017-05-17
22:24:07.77 Server Server process ID is 6044. 2017-05-17
22:24:07.77 Server System Manufacturer: 'System manufacturer',
System Model: 'System Product Name'. 2017-05-17 22:24:07.77 Server
Authentication mode is MIXED. 2017-05-17 22:24:07.77 Server
Logging SQL Server messages in file 'C:\Program Files\Microsoft SQL
Server\MSSQL11.MSSQLSERVER\MSSQL\Log\ERRORLOG'. 2017-05-17 22:24:07.77
Server The service account is 'WORKGROUP\HAMED-PC$'. This is an
informational message; no user action is required. 2017-05-17
22:24:07.77 Server
Registry startup parameters:
-d C:\Program> Files\Microsoft SQL server\MSSQL11.MSSQLSERVER\MSSQL\DATA\master.mdf
-e C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log\ERRORLOG
-l C:\Program
Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
2017-05-17 22:24:07.77 Server Command Line Startup Parameters:
-s "MSSQLSERVER" 2017-05-17 22:24:07.91 Server SQL Server detected 1 sockets with 4 cores per socket and 4 logical processors
per socket, 4 total logical processors; using 4 logical processors
based on SQL Server licensing. This is an informational message; no
user action is required. 2017-05-17 22:24:07.91 Server SQL Server
is starting at normal priority base (=7). This is an informational
message only. No user action is required. 2017-05-17 22:24:07.91
Server Detected 4087 MB of RAM. This is an informational message;
no user action is required. 2017-05-17 22:24:07.91
Server Using conventional memory in the memory manager.
2017-05-17 22:24:07.94 Server Error: 9694, Severity: 16, State:27.
2017-05-17 22:24:07.94 Server Could not start Service Broker manager. Check the SQL Server error log and the Windows error log for
additional error messages.
2017-05-17 22:24:07.94 Server Error: 9643, Severity: 16, State:1.
2017-05-17 22:24:07.94 Server An error occurred in the Service
Broker/Database Mirroring transport manager: Error: 9694, State: 27.
2017-05-17 22:24:07.94 Server Error: 9694, Severity: 16, State:
30.
2017-05-17 22:24:07.94 Server Could not start Service Broker
manager. Check the SQL Server error log and the Windows error log for
additional error messages.
2017-05-17 22:24:07.94 Server SQL Server Audit failed to record
the SERVER SHUTDOWN action.
Now I will appreciate if someone can help me start my SQL Server instances again
I have the same problem.
Suddenly the services do not work anymore.. I suspect a windows update did this.
Or new group policies that not allow this account to use resources?
Two errors in the Event Viewer:
The SQL Server (SQLEXPRESS) service failed to start due to the
following error: The service did not start due to a logon failure.
And
The MSSQL$SQLEXPRESS service was unable to log on as NT
Service\MSSQL$SQLEXPRESS with the currently configured password due to
the following error: Logon failure: the user has not been granted the
requested logon type at this computer.
Service: MSSQL$SQLEXPRESS
Domain and account: NT Service\MSSQL$SQLEXPRESS
This service account not have the required user right "Log on as a service."
User Action
Assign "Log on as a service" to the service account on this
computer. You can use Local Security Settings (Secpol.msc) to do this.
If this computer is a node in a cluster, check that this user right is
assigned to the Cluster service account on all nodes in the cluster.
If you have already assigned this user right to the service account,
and the user right appears to be removed, check with your domain
administrator to find out if a Group Policy object associated with
this node might be removing the right.
Hope this helps to get more information..
A solution I don't trust is removing he password of the user.
Go to Services > SQL Server (SQLEXPRESS) > Properties > Log On > Remove password
But I don't think this solution is a permanent solution.
If you find anything please let me know.
==================================================
Edit 1
We found the reason, my administrator pushed a group policy 'Log on as a service' which overruled my computer users.. and bad things started to happen.
He removed the policy and the original users returned. Everything works again after a 'gpupdate /force' in the command line.
You can find the group policy:
Start > Local Security Policy > Security Settings > Local Policies > User Right Assignment > Log on as a service. If the button 'Add User or Group' is grayed then the Admins are pushing this..
Good luck!
Jonas

Sql server (Service) doesn't start

I removed old sql server from PC. Then I installed new sql server. After this sql server service doesn't start. When I am running service from sql server config manager - I receive error msg:
"The request failed or the service did not respond in a timely
fashion. Consult the event log or other applicable error logs for
details."
this command: sqlservr.exe -s MSSQL -e C:\1.txt returned logs:
2017-05-09 18:32:55.05 Server Microsoft SQL Server 2016 (RTM) - 13.0.1601.5 (X64)
Apr 29 2016 23:23:58
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows 10 Enterprise 6.3 <X64> (Build 10586: )
2017-05-09 18:32:55.05 Server UTC adjustment: 3:00
2017-05-09 18:32:55.05 Server (c) Microsoft Corporation.
2017-05-09 18:32:55.05 Server All rights reserved.
2017-05-09 18:32:55.05 Server Server process ID is 7956.
2017-05-09 18:32:55.05 Server System Manufacturer: 'ASUSTeK COMPUTER INC.', System Model: 'X550JX'.
2017-05-09 18:32:55.06 Server Authentication mode is WINDOWS-ONLY.
2017-05-09 18:32:55.06 Server Logging SQL Server messages in file 'C:\1.txt'.
2017-05-09 18:32:55.06 Server The service account is 'USER-PC\User'. This is an informational message; no user action is required.
2017-05-09 18:32:55.06 Server Command Line Startup Parameters:
-s "MSSQL"
-e "C:\1.txt"
2017-05-09 18:32:55.06 Server Error: 17113, Severity: 16, State: 1.
2017-05-09 18:32:55.06 Server Error 3(The system cannot find the path specified.) occurred while opening file 'master.mdf' to obtain configuration information at startup. An invalid startup option might have caused the error. Verify your startup options, and correct or remove them if necessary.
2017-05-09 18:32:55.07 Server SQL Server shutdown has been initiated
I tried to add permissions for windows user, local system and local service but it didn't help.
The error log gives you the information about the failure: Error 3(The system cannot find the path specified.) occurred while opening file 'master.mdf' to obtain configuration information at startup. An invalid startup option might have caused the error.
You should check your startup parameters.
Start Configuration Manager -> SQL Server Services -> your instance -> Properties -> Advanced -> Startup Parameters.
It should contain paths to master.mdf, mastlog.ldf and errorlog

Error ORA-12560 TNS:protocol adapter error

I just Installed Oracle DB g11 whenever I want to login to scott/tiger database, It gives me ORA-12560: TNS:protocol adapter error.
But there's a weird thing. Now, alot of people say that I have to start the OracleService from services in my PC. But, I can't find it there. I would be thankful if you helped me. Thanks
Please check your oracle service and listener are started. Oracle service name usual like OracleService<your sid>. For example.
your Oracle SID is orcl. Your Orace service name is OracleServiceORCL.
and your Listener should end with "TNSListener" like default listener name OracleOraDb11g_home1TNSListener. The both of them have to running.
Then, try to connect your DB with SQLPlus. Open DOS command promt and type this command
>sqlplus <your userlogin>/<your login password>#<your sid>
If connection is success. Result should show like below massage.
C:\Users\monkawee>sqlplus ***/******#orcl
SQL*Plus: Release 11.2.0.1.0 Production on ネ. 狠.ツ. 3 17:04:57 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
爼ラ靉チオ靉。ムコ:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
Good luck.

Resources