You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/11/01 21:23:40 UTC
[4/5] git commit: Moved opscenter into it's own node
Moved opscenter into it's own node
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/fad471a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/fad471a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/fad471a0
Branch: refs/heads/key-row-sharding
Commit: fad471a09881eaedd95de974b416c7b9e411e0e4
Parents: fb03144
Author: Todd Nine <tn...@apigee.com>
Authored: Sat Nov 1 12:54:50 2014 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Sat Nov 1 14:23:16 2014 -0600
----------------------------------------------------------------------
.../main/dist/init_instance/init_db_server.sh | 7 +-
.../dist/init_instance/init_opscenter_server.sh | 41 ++-
.../dist/init_instance/install_cassandra.sh | 9 -
.../init_instance/install_opscenter_agent.sh | 7 +
.../src/main/groovy/configure_opscenter.groovy | 45 ++-
.../groovy/configure_opscenter_agent.groovy | 4 +-
stack/awscluster/ugcluster-cf.json | 275 ++++++++++++++++++-
7 files changed, 328 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fad471a0/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_db_server.sh b/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
index 42a7ebf..25ca6bf 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
@@ -63,13 +63,14 @@ cd /usr/share/usergrid/init_instance
cd /usr/share/usergrid/init_instance
./install_cassandra.sh
-cd /usr/share/usergrid/init_instance
-./install_opscenter_agent.sh
-
# Use the CQL to crate the keyspaces
cd /usr/share/usergrid/init_instance
./create_keyspaces.sh
+# Install the opscenter agent
+cd /usr/share/usergrid/init_instance
+./install_opscenter_agent.sh
+
# tag last so we can see in the console that the script ran to completion
cd /usr/share/usergrid/scripts
groovy tag_instance.groovy
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fad471a0/stack/awscluster/src/main/dist/init_instance/init_opscenter_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_opscenter_server.sh b/stack/awscluster/src/main/dist/init_instance/init_opscenter_server.sh
index 42a7ebf..3780c6a 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_opscenter_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_opscenter_server.sh
@@ -60,15 +60,42 @@ cd /usr/share/usergrid/init_instance
./install_oraclejdk.sh
# Install and stop Cassandra
-cd /usr/share/usergrid/init_instance
-./install_cassandra.sh
+pushd /etc/apt/sources.list.d
-cd /usr/share/usergrid/init_instance
-./install_opscenter_agent.sh
+curl -L http://debian.datastax.com/debian/repo_key | apt-key add -
-# Use the CQL to crate the keyspaces
-cd /usr/share/usergrid/init_instance
-./create_keyspaces.sh
+sudo cat >> cassandra.sources.list << EOF
+deb http://debian.datastax.com/community stable main
+EOF
+
+apt-get update
+apt-get -y --force-yes install libcap2 cassandra=1.2.19
+/etc/init.d/cassandra stop
+
+mkdir -p /mnt/data/cassandra
+chown cassandra /mnt/data/cassandra
+
+# Wait for other instances to start up
+cd /usr/share/usergrid/scripts
+groovy registry_register.groovy opscenter
+
+#TODO make this configurable for the box sizes
+#Set or min/max heap to 8GB
+sed -i.bak s/calculate_heap_sizes\(\)/MAX_HEAP_SIZE=\"8G\"\\nHEAP_NEWSIZE=\"1200M\"\\n\\ncalculate_heap_sizes\(\)/g /etc/cassandra/cassandra-env.sh
+
+cd /usr/share/usergrid/scripts
+groovy configure_opscenter.groovy > /etc/cassandra/cassandra.yaml
+/etc/init.d/cassandra start
+
+
+#Install the opscenter service
+# Install opscenter
+echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/datastax.community.list
+
+apt-get update
+apt-get --force-yes -y install opscenter
+
+sudo service opscenterd start
# tag last so we can see in the console that the script ran to completion
cd /usr/share/usergrid/scripts
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fad471a0/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh b/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
index 9e99255..7a58b97 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
@@ -48,15 +48,6 @@ cd /usr/share/usergrid/scripts
groovy configure_cassandra.groovy > /etc/cassandra/cassandra.yaml
/etc/init.d/cassandra start
-# Install opscenter
-echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/datastax.community.list
-
-
-
-apt-get update
-apt-get --force-yes -y install opscenter
-
-sudo service opscenterd start
popd
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fad471a0/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh b/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh
index 17ec780..5e2ec4b 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh
@@ -31,8 +31,15 @@ sudo apt-get install datastax-agent
cd /usr/share/usergrid/scripts
+
+#Wait for the opscenter node to come up
+groovy wait_for_instances.groovy opscenter 1
+
+#Wait for opscenter to come up
+
groovy configure_opscenter_agent.groovy > /var/lib/datastax-agent/conf/address.yaml
+sudo service datastax-agent stop
sudo service datastax-agent start
popd
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fad471a0/stack/awscluster/src/main/groovy/configure_opscenter.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_opscenter.groovy b/stack/awscluster/src/main/groovy/configure_opscenter.groovy
index 946e801..b9239a1 100644
--- a/stack/awscluster/src/main/groovy/configure_opscenter.groovy
+++ b/stack/awscluster/src/main/groovy/configure_opscenter.groovy
@@ -1,19 +1,22 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License.
- * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * * Licensed to the Apache Software Foundation (ASF) under one
+ * * or more contributor license agreements. See the NOTICE file
+ * * distributed with this work for additional information
+ * * regarding copyright ownership. The ASF licenses this file
+ * * to you under the Apache License, Version 2.0 (the
+ * * "License"); you may not use this file except in compliance
+ * * with the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing,
+ * * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * KIND, either express or implied. See the License for the
+ * * specific language governing permissions and limitations
+ * * under the License.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
*/
@@ -28,31 +31,19 @@ import com.amazonaws.services.simpledb.model.*
String hostName = (String)System.getenv().get("PUBLIC_HOSTNAME")
-String clusterName = (String)System.getenv().get("CASSANDRA_CLUSTER_NAME")
-
-
// build seed list by listing all Cassandra nodes found in SimpleDB domain with our stackName
-NodeRegistry registry = new NodeRegistry();
-
-def selectResult = registry.searchNode('cassandra')
-def seeds = ""
-def sep = ""
-for (host in selectResult) {
- seeds = "${seeds}${sep}${host}"
- sep = ","
-}
def cassandraConfig = """
-cluster_name: '${clusterName}'
+cluster_name: 'opscenter'
listen_address: ${hostName}
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- - seeds: "${seeds}"
+ - seeds: "${hostName}"
auto_bootstrap: false
num_tokens: 256
hinted_handoff_enabled: true
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fad471a0/stack/awscluster/src/main/groovy/configure_opscenter_agent.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_opscenter_agent.groovy b/stack/awscluster/src/main/groovy/configure_opscenter_agent.groovy
index 741f551..dfde6e0 100644
--- a/stack/awscluster/src/main/groovy/configure_opscenter_agent.groovy
+++ b/stack/awscluster/src/main/groovy/configure_opscenter_agent.groovy
@@ -36,7 +36,7 @@ String domain = stackName
NodeRegistry registry = new NodeRegistry();
// build seed list by listing all Cassandra nodes found in SimpleDB domain with our stackName
-def selectResult = registry.searchNode('cassandra')
+def selectResult = registry.searchNode('opscenter')
def opsCenterNode = selectResult[0]
@@ -44,7 +44,7 @@ def opsCenterNode = selectResult[0]
def clientconfig = """
-stomp_interface: : ${opsCenterNode}
+stomp_interface: ${opsCenterNode}
"""
println clientconfig
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fad471a0/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 17d07f8..430c9fe 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -149,6 +149,29 @@
"Default": "1",
"MinValue": "1"
},
+ "OpsCenterInstanceType": {
+ "Description": "Instance type for Opscenter server",
+ "Type": "String",
+ "Default": "m3.large",
+ "AllowedValues": [
+ "t1.micro",
+ "m1.small",
+ "m1.medium",
+ "m1.large",
+ "m3.large",
+ "m1.xlarge",
+ "m3.xlarge",
+ "m3.2xlarge",
+ "c3.4xlarge"
+ ],
+ "ConstraintDescription": "must be valid instance type."
+ },
+ "OpsCenterNumServers": {
+ "Description": "Minimum number of opscenter servers. There should only be one",
+ "Type": "Number",
+ "Default": "1",
+ "MinValue": "1"
+ },
"InstallYourkit": {
"Description": "Install the yourkit remote profiling agent into tomcat. Valid values are 'true' or 'false'",
"Type": "String",
@@ -401,6 +424,196 @@
}
}
},
+ "OpsCenterUser": {
+ "Type": "AWS::IAM::User",
+ "Properties": {
+ "Path": "/",
+ "Policies": [
+ {
+ "PolicyName": "root",
+ "PolicyDocument": {
+ "Statement": [
+ {
+ "Effect": "Allow",
+ "Action": "*",
+ "Resource": "*"
+
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ "OpsCenterKey": {
+ "Type": "AWS::IAM::AccessKey",
+ "Properties": {
+ "UserName": {
+ "Ref": "OpsCenterUser"
+ }
+ }
+ },
+ "OpsCenterAutoScalingLaunchConfiguration":{
+ "Type":"AWS::AutoScaling::LaunchConfiguration",
+ "Properties":{
+ "UserData":{
+ "Fn::Base64":{
+ "Fn::Join":[
+ "",
+ [
+ "#!/bin/bash -ex\n",
+ "# OPSCENTER NODE STARTUP \n",
+ "exec >/var/log/usergrid-bootstrap.log 2>&1\n",
+ "\n",
+ "mkdir -p /usr/share/usergrid\n",
+ "\n",
+ "# create script that sets our environment variables\n",
+ "cat >/etc/profile.d/usergrid-env.sh <<EOF\n",
+ "alias sudo='sudo -E'\n", "\n",
+ "export TYPE=opscenter\n",
+ "export STACK_NAME=", { "Ref":"AWS::StackName" }, "\n", "\n",
+ "export PUBLIC_HOSTNAME=`(curl -s http://169.254.169.254/latest/meta-data/public-hostname)`\n",
+ "export INTERNAL_HOSTNAME=`(curl http://169.254.169.254/latest/meta-data/local-ipv4)`\n",
+ "\n",
+ "export EC2_INSTANCE_ID=`ec2metadata --instance-id`\n",
+ "export EC2_REGION=", { "Ref":"AWS::Region" },
+ "\n",
+ "export EC2_URL=https://ec2.amazonaws.com/\n",
+ "\n",
+ "export OPSCENTER_SECURITY_GROUP_NAME=", { "Ref":"OpsCenterSecurityGroup" }, "\n",
+ "\n",
+ "\n",
+ "export CASSANDRA_CLUSTER_NAME=", { "Ref":"CassClusterName" }, "\n",
+ "export CASSANDRA_NUM_SERVERS=", { "Ref":"CassNumServers" }, "\n",
+ "export GRAPHITE_NUM_SERVERS=", { "Ref":"GraphiteNumServers" }, "\n",
+ "export CASSANDRA_KEYSPACE_NAME=usergrid", "\n",
+ "export CASSANDRA_REPLICATION_FACTOR=", { "Ref":"CassReplicationFactor" }, "\n",
+ "\n",
+ "export RELEASE_BUCKET=", { "Ref":"ReleaseBucket" }, "\n",
+ "\n",
+ "EOF\n",
+ "\n",
+ "# put AWS creds in environment\n",
+ "cat >/etc/profile.d/aws-credentials.sh <<EOF\n",
+ "export AWS_ACCESS_KEY=", { "Ref":"CassKey" }, "\n",
+ "export AWS_SECRET_KEY=", { "Fn::GetAtt":[ "CassKey", "SecretAccessKey" ] }, "\n",
+ "EOF\n",
+ "\n",
+ "# put AWS creds Priam's config file\n",
+ "cat >/etc/awscredential.properties <<EOF\n",
+ "AWSACCESSID=", { "Ref":"CassKey" }, "\n",
+ "AWSKEY=", { "Fn::GetAtt":[ "CassKey", "SecretAccessKey" ] },
+ "\n",
+ "EOF\n",
+ "\n",
+ "# setup s3cmd (will be installed by init script) \n",
+ "cat >/etc/s3cfg <<EOF\n",
+ "access_key=", { "Ref":"CassKey" }, "\n",
+ "secret_key=", { "Fn::GetAtt":[ "CassKey", "SecretAccessKey" ] },
+ "\n",
+ "EOF\n",
+ "chmod 644 /etc/s3cfg\n",
+ "ln -s /etc/s3cfg ~ubuntu/.s3cfg\n",
+ "ln -s /etc/s3cfg ~root/.s3cfg\n",
+ "\n",
+ "# download usergrid and init script bundle from S3\n",
+ "wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | apt-key add -\n",
+ "wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list\n",
+ "apt-get update\n",
+ "apt-get -y install s3cmd\n",
+ "cd /usr/share/usergrid\n",
+ "s3cmd --config=/etc/s3cfg get s3://", { "Ref":"ReleaseBucket" }, "/awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+ "tar xvf awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+ "rm -fr awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+ "chmod 755 ./init_instance/*.sh\n",
+ "cd ./init_instance\n",
+ "# init as an opscenter node \n",
+ "sh ./init_opscenter_server.sh\n"
+ ]
+ ]
+
+ }
+ },
+ "KeyName":{
+ "Ref":"KeyPair"
+ },
+ "ImageId":{
+ "Fn::FindInMap":[
+ "AWSRegionArch2AMI",
+ {
+ "Ref":"AWS::Region"
+ },
+ {
+ "Fn::FindInMap":[
+ "AWSInstanceType2Arch",
+ {
+ "Ref":"OpsCenterInstanceType"
+ },
+ "Arch"
+ ]
+ }
+ ]
+ },
+ "InstanceType":{
+ "Ref":"OpsCenterInstanceType"
+ },
+ "IamInstanceProfile":{
+ "Ref":"RootInstanceProfile"
+ },
+ "SecurityGroups":[
+ {
+ "Ref":"OpsCenterSecurityGroup"
+ }
+ ]
+
+ }
+ },
+ "OpsCenterAutoScalingGroup": {
+ "Type": "AWS::AutoScaling::AutoScalingGroup",
+ "Version": "2014-07-24",
+ "Properties": {
+ "AvailabilityZones": [
+ {
+ "Fn::FindInMap": [
+ "TwoAZs",
+ {
+ "Ref": "AWS::Region"
+ },
+ "AZ1"
+ ]
+ },
+ {
+ "Fn::FindInMap": [
+ "TwoAZs",
+ {
+ "Ref": "AWS::Region"
+ },
+ "AZ2"
+ ]
+ }
+ ],
+ "LaunchConfigurationName": {
+ "Ref": "OpsCenterAutoScalingLaunchConfiguration"
+ },
+ "MinSize": {
+ "Ref": "OpsCenterNumServers"
+ },
+ "MaxSize": {
+ "Ref": "OpsCenterNumServers"
+ },
+ "NotificationConfiguration": {
+ "TopicARN": {
+ "Ref": "NotificationTopic"
+ },
+ "NotificationTypes": [
+ "autoscaling:EC2_INSTANCE_LAUNCH",
+ "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
+ "autoscaling:EC2_INSTANCE_TERMINATE",
+ "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
+ ]
+ }
+ }
+ },
"RestUser": {
"Type": "AWS::IAM::User",
"Properties": {
@@ -1372,18 +1585,21 @@
}
}
},
- "AllowAllToCassOnPort8888": {
- "Type": "AWS::EC2::SecurityGroupIngress",
- "Properties": {
- "GroupName": {
- "Ref": "CassSecurityGroup"
- },
- "IpProtocol": "tcp",
- "FromPort": "8888",
- "ToPort": "8888",
- "CidrIp": "0.0.0.0/0"
- }
- },
+ "AllowOpsCenterToCassOnAllPorts": {
+ "Type": "AWS::EC2::SecurityGroupIngress",
+ "Properties": {
+ "GroupName": {
+ "Ref": "CassSecurityGroup"
+ },
+ "IpProtocol": "tcp",
+ "FromPort": "1",
+ "ToPort": "65535",
+ "SourceSecurityGroupName": {
+ "Ref": "OpsCenterSecurityGroup"
+ }
+ }
+ },
+
"RestSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
@@ -1465,6 +1681,41 @@
"Ref": "RestSecurityGroup"
}
}
+ },
+ "OpsCenterSecurityGroup": {
+ "Type": "AWS::EC2::SecurityGroup",
+ "Properties": {
+ "GroupDescription": "Opscenter Machines",
+ "SecurityGroupIngress": [
+ {
+ "IpProtocol": "tcp",
+ "FromPort": "22",
+ "ToPort": "22",
+ "CidrIp": "0.0.0.0/0"
+ },
+ {
+ "IpProtocol": "tcp",
+ "FromPort": "8888",
+ "ToPort": "8888",
+ "CidrIp": "0.0.0.0/0"
+ }
+ ]
+ }
+ },
+ "AllowCassToOpscenterAllPorts": {
+ "Type": "AWS::EC2::SecurityGroupIngress",
+ "Properties": {
+ "GroupName": {
+ "Ref": "OpsCenterSecurityGroup"
+ },
+ "IpProtocol": "tcp",
+ "FromPort": "0",
+ "ToPort": "65535",
+ "SourceSecurityGroupName": {
+ "Ref": "CassSecurityGroup"
+ }
+ }
}
+
}
}