25.2.2.3. 非群集的受管域

25.2.2.3.1. 启动一个实例作为域控制器
概述

本节涵盖在 Red Hat AMI(Amazon Machine Image)上启动非群集 JBoss EAP 6 受管域的步骤。

过程 25.3. 在 Red Hat AMI(Amazon Machine Image)上启动非群集 JBoss EAP 6 受管域。

  1. 在 Security Group 标签页里,允许所有流量。如果需要的话用 Red Hat 企业版 Linux 的内置防火墙功能来限制访问。
  2. 设置 VPC 的公共子网为 running
  3. 选择一个静态 IP 地址。
  4. 配置 User Data 字段。可配置的参数位于:第 25.4.1 节 “永久性的配置参数”第 25.4.2 节 “自定义脚本参数”。关于 Amazon EC2 上域控制器发现的进一步信息,请参考 第 25.2.2.3.4 节 “配置 Amazon EC2 上的域控制器发现和失效切换”

    例 25.4. 『User Data』字段示例

    这个例子展示了非群集 JBoss EAP 6 受管域的“User Data” 字段。用户 admin 的密码已被设置为 adminpwd
    ## password that will be used by slave host controllers to connect to the domain controller
    JBOSSAS_ADMIN_PASSWORD=admin
    
    ## subnet prefix this machine is connected to
    SUBNET=10.0.0.
    
    ## S3 domain controller discovery setup
    # JBOSS_DOMAIN_S3_SECRET_ACCESS_KEY=<your secret key>
    # JBOSS_DOMAIN_S3_ACCESS_KEY=<your access key>
    # JBOSS_DOMAIN_S3_BUCKET=<your bucket name>
    
    #### to run the example no modifications below should be needed ####
    JBOSS_DOMAIN_CONTROLLER=true
    PORTS_ALLOWED="9999 9990 9443"
    JBOSS_IP=`hostname | sed -e 's/ip-//' -e 'y/-/./'` #listen on public/private EC2 IP address
    
    cat > $USER_SCRIPT << "EOF"
    ## Get the application to be deployed from an Internet URL
    # mkdir -p /usr/share/java/jboss-ec2-eap-applications
    # wget https://<your secure storage hostname>/<path>/<app name>.war -O /usr/share/java/jboss-ec2-eap-applications/<app name>.war
    
    ## Create a file of CLI commands to be executed after starting the server
    cat> $USER_CLI_COMMANDS << "EOC" 
    
    # Add the modcluster subsystem to the default profile to set up a proxy
    /profile=default/subsystem=web/connector=ajp:add(name=ajp,protocol=AJP/1.3,scheme=http,socket-binding=ajp)
    /:composite(steps=[ {"operation" => "add", "address" => [ ("profile" => "default"), ("subsystem" => "modcluster") ] },{ "operation" => "add", "address" => [ ("profile" => "default"), ("subsystem" => "modcluster"), ("mod-cluster-config" => "configuration") ], "advertise" => "false", "proxy-list" => "${jboss.modcluster.proxyList}", "connector" => "ajp"}, { "operation" => "add", "address" => [ ("profile" => "default"), ("subsystem" => "modcluster"), ("mod-cluster-config" => "configuration"), ("dynamic-load-provider" => "configuration") ]}, { "operation" => "add", "address" => [ ("profile" => "default"), ("subsystem" => "modcluster"), ("mod-cluster-config" => "configuration"), ("dynamic-load-provider" => "configuration"), ("load-metric" => "busyness")], "type" => "busyness"} ])
    
    # Deploy the sample application from the local filesystem
    deploy /usr/share/java/jboss-ec2-eap-samples/hello.war --server-groups=main-server-group
    EOC
    
    ## this will workaround the problem that in a VPC, instance hostnames are not resolvable
    echo -e "127.0.0.1\tlocalhost.localdomain localhost" > /etc/hosts
    echo -e "::1\tlocalhost6.localdomain6 localhost6" >> /etc/hosts
    for (( i=1 ; i<255 ; i++ )); do
       echo -e "$SUBNET$i\tip-${SUBNET//./-}$i" ;
    done >> /etc/hosts
    
    EOF
    
    
  5. 对于产品实例

    对于产品实例,在 User Data 字段的 USER_SCRIPT 行下面添加下列内容,确保在引导时进行安全更新。
    yum -y update

    注意

    yum -y update 应该经常运行以应用安全修复和增强。
  6. 启动 Red Hat AMI 实例。
结果

已在 Red Hat AMI 上配置并启动非群集的 JBoss EAP 6 受管域。