Arquivo

Archive for abril \14\UTC 2014

Stop Start Weblogic Server

Recentemente fiz um script para parar e iniciar todos servers de um domínio weblogic, bem mais complexo pois tinha cluster e dois node Manager, era necessário subir cada Node depois conectar via node e subir todos servidores da lista de Mbeans do AdminServer.

Esse script você coloca o nome de um servidor específico e ele faz o Stop e Start via AdminServer.

  1. cria-se um arquivo restartServer.py com o seguinte conteúdo:

    import getopt
    ################################################################
    # Script para reniciar um server do weblogic.
    ################################################################
    # 1 – Conecta no AdminServer
    # 2 – Para o servidor
    # 3 – Inicia o servidor
    #
    # @author Herivelto Gabriel
    # @Date Abril/2014
    ###############################################################

    ################################################################
    # Variaveis.
    ################################################################
    adminusername=’weblogic’
    adminpassword=’weblogic11′
    adminurl=’t3://172.18.4.62:7001′
    serverRestart=’Server-DB’

    ################################################################
    # Conecta no AdminServer entra em runtime e ler o server
    ################################################################

    connect(adminusername, adminpassword, adminurl)
    domainRuntime()

    ################################################################
    # STOP – Server
    ################################################################
    bean = getMBean(‘ServerRuntimes/’ + serverRestart)
    if bean:
    print ”
    print ‘======================================’
    print ‘ STOP Server, Please wait……….!!!’
    print ‘======================================’
    shutdown(serverRestart, ‘Server’ , force=’true’)
    print ‘======================================’
    print ‘ START Server, Please wait…………….!!!’
    print ‘======================================’
    start(serverRestart, ‘Server’, block=’true’)
    print ‘======================================’
    print ‘Started Server ‘ + serverRestart
    print ‘======================================’
    print ”
    print ”

    ################################################################
    # START – Server
    ################################################################

    bean = getMBean(‘ServerRuntimes/’ + serverRestart)
    if bean:
    print ‘Server ‘ + serverRestart + ‘ is ‘ + bean.getState()
    else:
    print ”
    print ‘======================================’
    print ‘ START Server, Please wait…………….!!!’
    print ‘======================================’
    start(serverRestart, ‘Server’, block=’true’)
    print ‘======================================’
    print ‘Started Server ‘ + serverRestart
    print ‘======================================’
    print ”
    print ”

    ################################################################
    # Desconecta e sai do script
    ################################################################
    disconnect()
    exit()

  2. Excutando o script:

    /var/Oracle/Middleware/wlserver/common/bin/wlst.sh restartServer.py

  3. Saída do Script:

    ===================================================
    STOP Server, Please wait……………..!!!
    ===================================================
    Shutting down the server Server-DB with force=true while connected to AdminServer …
    ===================================================
    START Server, Please wait…………….!!!
    ===================================================
    Starting server Server-DB ……………
    Server with name Server-DB started successfully
    ===================================================
    Started Server Server-DB !!
    ==================================================

Anúncios
Categorias:weblogic, wlst Tags:

Criar Dominio Weblogic 12 WLST

O weblogic 12c(12.1.2) não tem mais o modo console para instalação e nem criação de domínio. Fiz um script para criar domínio que simula um pouco o modo console como era nas versões anteriores.

  1. cria-se um arquivo createDomain.py com o seguinte conteúdo
    ###############################################################
    # Script para criar dominio weblogic 12c
    # Para : Oracle WebLogic 12c
    # Author : Herivelto Gabriel
    ###############################################################
      
    print'#========================================================'
    print'# Enter Weblogic Home: Ex: /var/Oracle/Middleware'
    print'#========================================================'
    print'
    WLHOME=raw_input('Please Enter Weblogic Home install: ') 
    print'
    #Ler o template padrão do weblogic
    readTemplate(WLHOME+'/wlserver/common/templates/wls/wls.jar')
     
    print'#========================================================'
    print'# Create Domain in Weblogic 12c.'
    print'#========================================================'
    print''
    cd('Servers/AdminServer')
    set('Name',"AdminServer")
    
    domainName=raw_input('Please Enter domain name: ')
    domainPath=raw_input('Please Enter the domain path: ')
    AdminListenAdr=raw_input('Please Enter Admin Listen Address: ')
    AdminListenPort=input('Please enter Admin listen Port: ')
     
    set('ListenAddress',AdminListenAdr)
    set('ListenPort', AdminListenPort)
    
    cd('/')
    cd('Security/base_domain/User/weblogic')
    usr=raw_input('Please Enter AdminUser Name: ')
    set('Name',usr)
    AdminPassword=raw_input('Please enter Admin password:')
    cmo.setPassword(AdminPassword)
     
    # - OverwriteDomain: Se existir dominio com o mesmo nome sobrescreve
    setOption('OverwriteDomain', 'true')
    print'' 
    print'# Please wait ... Creating Domain '
    print'' 
    writeDomain(domainPath+"/"+domainName)
    
    print'#========================================================'
    print'# Domain create with sucesso !' 
    print'#========================================================'
    print'' 
    print'Domain Name = ',domainName  
    print'Path Name = ', domainPath
    print'Username = ', usr
    print'Listern = ',AdminListenAdr
    print'Port = ', AdminListenPort
    print'' 
    print '#========================================================'
    
    closeTemplate()
    exit()
    
  2. Excutando o script:

      /var/Oracle/Middleware/wlserver/common/bin/wlst.sh createDomain.py
    
  3. Saída do Script:

    #========================================================
    # Enter Weblogic Home: Ex: /var/Oracle/Middleware
    #========================================================
    
    Please Enter Weblogic Home install: /var/Oracle/Middleware12
    
    #========================================================
    # Create Domain in Weblogic 12c.
    #========================================================
    
    Please Enter domain name: weblogic12c
    Please Enter the domain path: /var/Oracle/domains
    Please Enter Admin Listen Address: 192.168.14.129
    Please enter Admin listen Port: 7001
    Please Enter AdminUser Name: weblogic
    Please enter Admin password:weblogic12
    
    # Please wait ... Creating Domain 
    
    #========================================================
    # Domain create with sucesso !
    #========================================================
    
    Domain Name =  weblogic12c
    Path Name =  /var/Oracle/domains
    Username =  weblogic
    Listern =  192.168.14.129
    Port =  7001
    
    #========================================================
    
Categorias:weblogic, wlst Tags:,