Wednesday, February 17, 2016

WebLogic Questions

WebLogic Basics

What is weblogic server?

Oracle WebLogic Server is J2EE Server (earlier known as BEA WebLogic Server) similar to
Oracle Application Server. 
or
Logically related group of java components is nothing but weblogic server.

What oracle weblogic server includes?

Oracle weblogic server includes

1)Domain
2)cluster
3)servers

What is the meaning of BEA (Oracle bought Weblogic from BEA )?

BSU Stands for Bea Smart Update.  This utility is used to apply the WebLogic Server
Patches. In simple terms, it is first letter of name of founders  Bill Coleman, Ed Scott and Alfred Chuang.

What is domain in WebLogic ?

Logically grouping of all resources and services together as a single unit is called
domain.
or
A domain is a logically related group of weblogic server resources that you manage as a
unit.
or
Domain is a group of WebLogic server resources like admin server, managed server, jms,
connection pool, data sources etc or whatever the resource you know of WebLogic server.  since domain is the basic unit you have to create after installation and everything created and configured under a domain.

or
A domain has Admin server(AS)+Managed Server(MS).

A domain provides one point of administration.

Domain is logical grouping of resources and services and consist of Administration Server,
Managed Server and cluster.  There can only be one administration Server in domain and
zero to N Managed Server.

What is Administration Server ?

Admin server is the central point from where you can configure, Monitor and manage all
resources of a domain.
Administration Server is WebLogic Server instance that maintains configuration data for a
domain. You can deploy your application on administration Server but it is recommended to
create managed Server and deploy your application in managed server and leave
Administration domain for configuration and maintenance.
—There will always be at least one Administration Server in a domain.

What is Managed Server ?

It is an instance of your WebLogic server that is running on JVM and has its own
configuration.
In Managed server we will deploy the java components
Web Applications
EJB Applications
JMS Applications
Web services
or
Any WebLogic Server instance apart from Administration Server is called as Managed
Servers. This is weblogic server where you deploy your application (Though you can deploy
your application in Administration server as well but it is not recommended in
production/UAT instance)

What is Cluster in WebLogic ?

Collection of multiple server act like as an single server to end user/Application.

OR

Two or more managed server becomes or forms the cluster in a domain and cluster handle the
load balancing across the cluster.
Group of WebLogic Managed Server Instances that work together to provide high availability
and scalability for applications is called cluster. WebLogic Servers with in cluster can
run on same machine or different machines. These are also called as managed Server
cluster.

Server
Server is an instance of your WebLogic which is running on a JVM and has dedicated RAM.

How to start Node Manager ?

$WL_HOME\server\bin\startNodeManager.sh

To Stop Node Manager
In Unix/Linux, kill the process -
kill -9 `ps -ef | grep -i nodemanager.javahome | grep -v grep | awk {'print $2'} | head -
1`

Node Manager Log Files

$WL_HOME/common/nodemanager/nodemanager.log

Important configuration file for node manager

$WL_HOME/common/nodemanager/nodemanager.properties- used by java based node manager. This file is created on first time start of nodemanager (startNodeManager.sh)

$WL_HOME/common/nodemanager/nodemanager.domains - contains mappings between the names of domains managed by Node Manager and their corresponding directories.
entry like base_domain=D:\Oracle\Middleware\user_projects\domains\base_domain
soa_domain=D:\Oracle\Middleware\user_projects\domains\soa_domain

$WL_HOME/common/nodemanager/nm_data.properties- This file stores the encryption data the
Node Manager uses as asymmetric encryption key. This file is created on first time start
of nodemanager (startNodeManager.sh)

$DOMAIN_HOME/config/nodemanager/nm_password.properties- This file stores the Node Manager username and password used by Admin Server to connect to Node Manager.

Why node manager is required?

A Node Manager process is not associated with a specific WebLogic domain but with a
machine. You can use the same Node Manager process to control server instances in any WebLogic
Server domain, as long as the server instances reside on the same machine as the Node
Manager process. Node Manager must run on each computer that hosts WebLogic Server
instances. whether Administration Server or Managed Server that you want to control with
Node Manager.

How do you differentiate between a server hang and server crash issue?

When a Server crashes, the JAVA process no longer exists. When the Server is hung, it stops
responding. We can use the weblogic.ADMIN utilty to ping the server. In case of a hang situation we
can take multiple thread dumps and analyze the cause of hang.

What can be the various reasons for a server crash?

a) Native IO
b) SSL Native Libraries
c) JVM
d) Supported Configuration
e) JDBC Driver issue

How do you troubleshoot a crash?

JVM crash generates a hs_err_pid file. We need to look into the stack trace of the
hs_err_pid file .
If the thread is from a native io, we need to disable native io.
if the stack trace is from the driver, we need to get in touch with the drive team.
Quite possibly its a problem with driver. Changing the type of driver can be a workaround.
If the thread shows it coming from an optimzed code, we can turn of optimization.
If the stack is from native calls of application, its a bug with the application and it
has to be modified.

How do you troubleshoot Server Hang?

We can use java weblogic.Admin PING to check if we get a normal response.
We need to take multiple thread dumps with kill -3 pid on unix and CTLR Break on Windows.
Analyze the thread dump to find the root cause.


What can be the reasons of Server hang?

Memory leak, database query taking a long time to return, Deadlock.

What is memory leak?
Memory leak is when objects are not romved from the heap even when they are not required.

What are the various causes for OUT OF MEMORY?
a) Insufficient heap size, not able to match the extra load.
b) Objects licing too long, like HTTP Sessions.
c) Memory leak in application code.
d) Full GC not happening due to JVM Bug.

How to troubleshoot and overcome such issues?
Gather memory data by enabling GC verbose.
If its due to Http Session, timing out http session after certain interval might help.
Look into the code for jdbc connection handling.
Optimizing the heap size according to the load.


When does High CPU Usage occur?

It occurs when one process or one thread utilizes unexpectedly high proportion of CPU.


How to troubleshoot it?

In Solaris environment, we need to take pstack and prstack and see what the threads are
doing.

In Windows we need to use pslist and process explorer.


What is Clustering and what is achieved through it?

Clustering is the grouping together of servers for the purpose of high availability and
scalability. with clustering Load balancing and Failover is achieved.

How does Cluster Communication Happen?

Members of the Cluster communicate over the Cluster Multicast IP and Port by sending
periodic heart beat messages.

What is the difference between the Sun JVM and BEA JRockit JVM?

The most well know JVM is the implementation from Sun. The Sun JVM is called HotSpot. The
Sun JVM is shipped in the Java Developer’s Kit (JDK) and Java Runtime Environment (JRE)
from Sun.

The BEA JRockit JVM from BEA systems is optimized for reliability and performance for
server side applications. To achieve this, BEA JRockit JVM uses technologies such as code
generation, hot spot detection, code optimization, advanced garbage collection algorithms
and tight operating system integration.

Tuning JVM Parameters.
If you have a single processor, single thread machine then you should use the serial
collector (default for some configurations, can be enabled explicitly for with -XX:
+UseSerialGC). For multiprocessor machines where your workload is basically CPU bound, use
the parallel collector. This is enabled by default if you use the -server flag, or you can
enable it explicitly with -XX:+UseParallelGC. If you’d rather keep the GC pauses shorter
at the expense of using more total CPU time for GC, and you have more than one CPU, you
can use the concurrent collector (-XX:+UseConcMarkSweepGC). Note that the concurrent
collector tends to require more RAM allocated to the JVM than the serial or parallel
collectors for a given workload because some memory fragmentation can occur.

How do you do performance tuning of WLS?

It can be categorized in 4 parts.

a. Application Tuning.
jsp precompilation, ejb pool size cache..

b. OS Tuning
Setting tcp ip parameter.
tcp_time_wait_interval
tcp_conn_req_max_q

c. Core Server Tuning.
tune workmanager, tune chuck size and chunck pool size, using performance packs,
conenction backlog buffering.

d. JVM Tuning
tuning gc strategy, monitoring garbage collection..


What is HTTP tunneling? How can we configure it on WebLogic?

HTTP tuning provides a way to simulate a tasteful socket connection between WebLogic
Server and a Java client when your only option is to use the HTTP protocol. It is
generally used to tunnel through an HTTP port in a security firewall. HTTP is a stateless
protocol, but WebLogic Server provides tunneling functionality to make the connection
appear to be a regular T3Connection.
Steps to configure Http tunneling.
Login into the Admin Console, click on the server on which you want to enable he Http
Tunneling feature
Click on the Protocols tab ? General ? check the “Enable Tunneling” check box.
Now you can communicate with the JVMs (Server Instances) using protocols other than t3


What is the difference between T3 and HTTP protocol?

WebLogic uses the T3 protocols for internal and external connections to the servers. The
T3 protocol often is used in WebLogic’s implementation of RMI. Proprietary of WebLogic
Server.

Http protocols are used primarily for HTTP communication between the browser and the web
server. Standard follows the W3C (World Wide Web Consortium).
Note: All of these protocols are, by default, multiplexed over the same connection to the
server’s address and port. So you can access a web page hosted by the server using a URL
such as http://host:port/page.jsp. An external client can set up an initial JNDI context
to a server using the URL t3://host:port/. All that has changed is the protocol over which
the client must communicate with the server.

States of the Server?

There are 9 states of server:-

Shutdown
Starting
Standby
Resuming
Running
Suspending
Shutting down
Failed
Unknown

Difference between .out and .log files
.out will print all logs related to your java application deployed whereas
.log file will print all logs related to weblogic server like startup, stop and deployment
etc....

Multicast - Unicast

Unicast is the best option in real time scenario..Because here is the examples..
In your cluster if u are having 10 Managed server instances then,

Multicast: Each MS is talking to other 9 MS So that total 90 connection was established.
Which is burden on the server in the peak business hours. Bcz of which weblogic
performance will may go down.

Unicast: 1st MS will brought up and it will act as a leader..So remaining 9 MS talking to
that leader only so only 10 connections will established. So that weblogic performance may
not go down.
If there is an issue with MS1 then it will be removed from the cluster and the requests
will be processed by other managed servers in the cluster.So this is not an issue..
Multicast requires network config and support from network team to do it, but unicast
doesn't require any additional setup on network or from the network team. Oracle
recommends to use Unicast.

How to access admin console ?
ssl enabled admin console accessed as :
https://<hostname_or_ip_address_where_admin_server_running>:<port_on_which_admin_server_is
_running>/console
Example - https://localhost:7001/console
non ssl admin console accessed as :
http://<hostname_or_ip_address_where_admin_server_running>:<port_on_which_admin_server_is_
running>/console
Example - http://localhost:7001/console

How many admin consoles possible in a single domain ?

only one.

What is the default port of admin server ?

7001

What is config.xml ?

config.xml is the central configuration repository for a domain. every resource you have
configured from admin console or by command line or by any other tool registered under
this file.
WLS 9.x onwards, this file contain references to other xml configuration files also those
are under your domain/config folder ( further sub folder under it for respective resources
) since wls 9.x onwards concept of modules are introduced for sub resources like data
source, jms etc otherwise prior to 9.x ( 8.x or older ) every configuration was stored
under this single config.xml file.  

What is boot.properties file ?

boot.properties is the file used by admin or managed server during startup for username
and password. it exist under your domain/servers/server_name/security folder.
( Below information is for some advance users )
To specify a customer directory for this file you can use
-Dweblogic.system.BootIdentityFile=[location]/boot.properties
 When you create a domain in development mode then it creates automatically during startup
of admin server but if you create a domain in production mode then you need to define it
explicitly otherwise on every reboot of admin server it will prompt you for username and
password.
So in production mode -
Start admin server by manually passing the username and password
stop it ( press cntrl+c on the started session )
go to your domain/servers/your_admin_server/
create a folder "security"
go inside security and create a file "boot.properties" with below contents
username=your_admin_username
password=your_admin_password
now start the admin server, it will not prompt you for username & password further.
If you are going to start your managed servers from admin console then no need to create
this file for managed server but if you are going to start managed servers via
startManagedweblogic script then you need to follow the same above procedure for each
managed server.

What is actually WebLogic Cache?

Basically all the web-tier related files (.jsp .class, JSPCompiled files etc.,) get stored
in some directory. This is treated as cache whenever there is restart of a WebLogic
instance happen then the WebLogic server will look-up for last serviced object status
stored in the cache to service for any pending requests. Usually, when your EJB Classes
need sessions, JMS object requires persistance, your web-tier may contain static contents
then Cache will be used by WebLogic Application Server instance.

Why we need to remove Cache?

Whenever your application is accessed for the first time that fresh deployment of a new
version, WebLogic server lookup in this directory, if there are older objects persists
that will be conflict with new code objects. This is where the need of removal of cache
arises.Where there is a need of new version deployment we might need to clear the cache when the
changes to the new version is not reflected.
WLS 9.x, 10.x

In new version of WebLogic 9.x onwards removal of cache means deleting each server
instance's tmp folder contains cache, stage folders or you can simply remove tmp folder
too provided there should not be configuration changes happen to the server.
Generally for WebLogic 9.x and higher versions

WIN: C:\bea\user_projects\domains\yourdomain\servers\yourserver\tmp

UNIX: /bea/user_projects/domains/yourdomain/servers/yourserver/tmp

you can use the following commands to clear the cache:
WIN: rd C:\bea\user_projects\domains\yourdomain\servers\yourserver\tmp\
UNIX: rm -rf /bea/user_projects/domains/yourdomain/servers/yourserver/tmp

Here I am removing all the subdirectories and files in the the given directory.


Thread Dump

Thread dump provides a snapshot of the current active live threads. It provides the stack
trace of all the java threads in the JVM. It is used when the server is hung and we want
to see the threads executing and take their dump.

There are different ways to take thread dump.

1.Command line:  use the below command when you know the port number. just run the same
command 3 times in 5 sec intervel of gaps.
kill -3 PID

2.WebLogic.Admin utility:  javaWebLogic.Admin adminurl -username WebLogic -password
WebLogic1 THRED_DUMP

3.Admin console:
Step1: login to the admin console
Step2: Click on server
Step3: Navigate to servers
Step4: Click monitor tab
Step5: Click on tread
Step6: Click on the dumpthread stack.
Location of the Thread Dump: 
/DOMAIN_NAME/servers/logs/KK_stdout.log


What is Thread dump?

Thread Dump is a textual dump of all active threads and monitors of Java apps running in a
Virtual Machine.
When we will take Thread dump? (Scenarios)

1. Scenario 1: when server is hang Position, i.e. that time server will not respond to
coming requests.
2. Scenario 2: While sever is taking more time to restart
3. Scenario 3: When we are Getting exception like “java.lang.OutOfMemoryException”
4. Scenario 4: Process running out of File descriptors. Server cannot accept further
requests because sockets cannot be created
5. Scenario 5: Infinite Looping in the code

How many ways take Thread Dumps?

Many types we have to take a Thread dumps. As per your flexibility you can choose one
Procedure. For analyzing take dumps some Intervals (like every 10mins, 10mins etc.).
Node Manager is a WebLogic Server utility that enables you to start, shut down, and
restart Administration Server and Managed Server instances from a remote location.
A Node Manager process is not associated with a specific WebLogic domain but with a
machine.
You can use the same Node Manager process to control server instances in any WebLogic
Server domain, as long as the server instances reside on the same machine as the Node
Manager process.
Node Manager must run on each computer that hosts WebLogic Server instances whether
Administration Server or Managed Server that you want to control with Node Manager.
WebLogic Server provides two versions of Node Manager, Java-based and script-based, with
similar functionality. However, each version has different configuration and security
considerations.
Java-based Node Manager
Java-based Node Manager runs within a Java Virtual Machine (JVM) process.
This version of Node Manager determines its configuration from the nodemanager.properties
file.
Java-based Node Manager provides more security than the script-based version.

Script-based Node Manager
For UNIX and Linux systems, WebLogic Server provides a script-based version of Node
Manager.
This script is based on UNIX shell scripts, but uses SSH for increased security. SSH uses
user-id based security
This version does not provide as much security as the Java-based version.
The advantage of the script-based Node Manager is that it can remotely manage servers over
a network that has been configured to use SSH. No additional server installation is
required. The scripts merely have to be copied to the remote machine.

What You Can Do with Node Manager

Start, Shut Down, and Restart an Administration Server
Start, Shut Down, Suspend, and Restart Managed Servers
Monitor Servers and View Log Data
Starting Java-based Node Manager

Start scripts for Node Manager are installed in the WL_HOME\server\bin directory, where
WL_HOME is the top-level installation directory for WebLogic Server.
Use startNodeManager.cmd on Windows systems and startNodeManager.sh on UNIX systems.
The scripts set the required environment variables and start Node Manager in
WL_HOME/common/nodemanager. Node Manager uses this directory as a working directory for
output and log files.

Important Node Manager Configuration Files

nodemanager.properties
This is the configuration file used by the Java-based version of Node Manager.
This file is located in WL_HOME/common/nodemanager.

nodemanager.hosts
This file contains a list of all the trusted hosts that can issue commands to Node
Manager.
This file is located in WL_HOME/common/nodemanager.

nodemanager.domains
This file contains mappings between the names of domains managed by Node Manager and their
corresponding directories.
This file is located in WL_HOME/common/nodemanager.

nm_data.properties
This file stores the encryption data the Node Manager uses a symmetric encryption key. The
data is stored in encrypted form.
This file is located in WL_HOME/common/nodemanager.

nm_password.properties
This file stores a username/password pair specific to the Node Manager server that is
managing this domain. This is known as the Node Manager secret. The username and password
are appended to a salt value (obtained from the SerializedSystemIni.dat of the domain) and
SHA-hashed.
This file is located in DOMAIN_HOME/config/nodemanager.

boot.properties
Node Manager uses this file to specify a boot identity when starting a server. This file
is located in domain-name/servers/server_name/data/nodemanager.

startup.properties
Each Managed Server instance has its own startup.properties file with properties that
control how Node Manager starts up and controls the server. Node Manager automatically
creates this file by using properties passed to Node Manager when the Administrative
Server was last used to start the server. This allows a Node Manager client or startup
scripts to restart a Managed Server using the same properties last used by the

Administrative Server.
These properties correspond to the server startup attributes contained in ServerStartMBean
and the health monitoring attributes in ServerStartMBean.
This file is located in domain-name/servers/server_name/data/nodemanager.
server_name.addr
server_name.addr stores the IP address added when a server starts or is migrated. This
file is generated after the server IP address is successfully brought online during
migration. server_name.addr is deleted when the IP address is brought offline. The server
IP address is used to validate remove requests to prevent addresses being erroneously
removed while shutting down the server.
This file is located in domain-name/servers/server_name/data/nodemanager.
server_name.lck
server_name.lck is generated by each server and contains an internally used lock ID.
This file is located in domain-name/servers/server_name/data/nodemanager
server_name.pid
server_name.pid is generated by each server and contains the process ID of the server.
Node Manager checks the process ID generated by the server during crash recovery.
This file is located in domain-name/servers/server_name/data/nodemanager
server_name.state
server_name.state is generated by the server and contains the server's current state. Node
Manager monitors the contents of this file to determine the current state of the server.
Note: Do not delete or alter this file. Without this file Node Manager cannot determine
the current state of the server.
This file is located in domain-name/servers/server_name/data/nodemanager.

How to check port number?

netstat -na |grep connected (to find the ports connected in Linux box.)
netstat -na |grep listen (to find the listening ports in HP-UX,Solaris)

Check the version of java.

root@h1vm /]# java -version run this command in linux to know the java version.

No comments:

Post a Comment