LoginSignup
2
2

More than 5 years have passed since last update.

Chefを使ってWebLogic Serverの基本ドメインを作ってみた

Last updated at Posted at 2016-06-15

概要

Chefを使ってWebLogic Serverのサイレント・インストールを行いました。

WebLogicはインストールした後に、WebLogic Server ドメインという論理的な管理グループを作成する必要があります。
このWebLogic ServerドメインをChefを使って作成してみます。

WebLogic Server ドメイン

マニュアルでは次の箇所にWebLogic Server ドメインについて記載があります。

WebLogic Server ドメインは論理的な管理グループとお伝えしましたが、その管理対象に含まれる要素は以下のものがあります。

  • サーバ
    • 管理サーバ:ドメインに必ず1つ必要なドメインの設定を管理するサーバ
    • 管理対象サーバ:アプリケーションやサービスをホストするサーバであり、管理サーバから設定を取得
  • マシン:ハードウェアの境界(ノードマネージャを使用する場合は必須)
  • クラスタ:アプリケーションに可用性と拡張性を提供するサーバの論理的なグループ

このWebLogic Server ドメインは論理的な単位なので、どのように区分するかは制限がありません。
基本的には、運用ポリシーやルール、サービスレベルが同じアプリケーションやサーバは同一のドメインに含めるようにします。

Chefを使ってやりたい事

Chefを使って1ドメイン中に1管理サーバのみの最もシンプルなWebLogic Server ドメインを作成します。

今回作成するRecipe

  • WLSTのスクリプト・モードでWebLogic Server ドメインを作成します。
    • 使用するドメイン・テンプレートは「Basic WebLogic Server Domain Template」
    • ドメイン構成は1サーバインスタンス(管理サーバ)/1マシン

Recipe. WebLogic Server ドメインの作成

以下の3種類のファイルを作成します。
- Recipe
- Template
- Attribute

Templateでは、WebLogic Server ドメイン作成用のWLSTスクリプトを用意します。

  • Template

以下の箇所でドメイン・テンプレート「Basic WebLogic Server Domain」を適用しています。

templates/default/create_domain.py.erb
selectTemplate('Basic WebLogic Server Domain', '12.2.1.0')
loadTemplates()

以下の箇所で管理サーバのポートを指定しています。

templates/default/create_domain.py.erb
cd('Servers/AdminServer')
set('ListenAddress','')
set('ListenPort', 7001)
create('AdminServer','SSL')
cd('SSL/AdminServer')
set('Enabled', 'True')
set('ListenPort', 7002)

そして以下の箇所で管理ユーザとパスワードの指定を行います。

templates/default/create_domain.py.erb
cd('/')
cd('Security/base_domain/User/<%= node['weblogic-domain']['admin_user'] %>')
cmo.setPassword('<%= node['weblogic-domain']['admin_password'] %>')

WebLogic Serverは起動時に開発者モードプロダクションモードの異なる起動サーバモードがあります。
以下で、起動モードを設定します。Attributeで開発者モード(dev)を設定しています。

templates/default/create_domain.py.erb
setOption('ServerStartMode', '<%= node['weblogic-domain']['startmode'] %>')

最後にドメイン構成情報を書き込みます

templates/default/create_domain.py.erb
writeDomain('<%= node['weblogic-domain']['domain_home'] %>/<%= node['weblogic-domain']['domain_name'] %>')
closeTemplate()
  • Attribute

Attributeでは各デフォルト値を設定しています。

attributes/default.rb
default['weblogic-domain']['startmode'] = 'dev'
# default['weblogic-domain']['startmode'] = 'prod'
  • ['weblogic-domain']['domain_home']
  • ['weblogic-domain']['domain_name']
    • WebLogic Server ドメインの構成場所とドメインの名前を指定
attributes/default.rb
default['weblogic-domain']['domain_home'] = '/u01/app/oracle/config/domains'
default['weblogic-domain']['domain_name'] = 'mydomain'
  • Recipe

RecipeではWLSTをスクリプト・モードで実行しています。
-(参考)スクリプト・モード

recipes/create.rb
execute "wlst.sh create_#{node['weblogic-domain']['domain_name']}_domain.py" do
  environment "CONFIG_JVM_ARGS" => "-Djava.security.egd=file:/dev/./urandom"
  command <<-EOH
    . #{node['weblogic-domain']['wls_home']}/server/bin/setWLSEnv.sh
    #{node['weblogic-domain']['oracle_common']}/common/bin/wlst.sh #{node['weblogic-domain']['response_file_dir']}/create_#{node['weblogic-domain']['domain_name']}_domain.py
  EOH
  user node['weblogic-domain']['user']
  group node['weblogic-domain']['group']
  action :run
  creates "#{node['weblogic-domain']['domain_home']}/#{node['weblogic-domain']['domain_name']}/bin"
end
  • WLS_HOME/server/bin/setWLSEnv.shで、必要な環境変数を設定しています。
  • ORACLE_HOME/oracle_common/common/bin/wlst.sh WLSTスクリプトファイル(xxx.py)で、WLSTをスクリプト・モードとして実行しています。

Chefの実行イメージ

chef-oracle-weblogic-domain.gif

まとめ

WebLogic Serverの導入は構成ウィザードを用いたGUIによる対話的な操作と、今回利用したWLSTスクリプトによるサイレント実行が可能です。
WLSTスクリプトはドメイン構成情報をテンプレート化しているので、Chefと組み合わせての環境の冪等性を担保するInfrastructure as Codeとして便利に利用できます。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2