Permalink
Browse files

New mysql_node_external job

For connecting to a 3rd party/remote mysqld service that's already
running.  Mysql node management database support sqlite and mysql
now.
  • Loading branch information...
1 parent 16d1778 commit c709adfe7b62c4b7adfda45cb8a9b29e47210be7 David Stevenson and Matt Royal committed Apr 10, 2013
@@ -0,0 +1,16 @@
+<%
+service = "mysql"
+plan_enabled = properties.service_plans && properties.service_plans.send(service.to_sym)
+plan = properties.plan || "100"
+plan_conf = plan_enabled && properties.service_plans.send(service.to_sym).send(plan.to_sym).configuration
+
+node = properties.mysql_node
+supported_versions = node.supported_versions
+%>
+
+check process mysql_node
+ with pidfile /var/vcap/sys/run/mysql_node/mysql_node.pid
+ start program "/var/vcap/jobs/mysql_node_external/bin/mysql_node_ctl start"
+ stop program "/var/vcap/jobs/mysql_node_external/bin/mysql_node_ctl stop" with timeout 60 seconds
+ group vcap
+ group node
@@ -0,0 +1,15 @@
+---
+name: mysql_node_external
+
+templates:
+ mysql_node_ctl: bin/mysql_node_ctl
+ mysql_node.yml.erb: config/mysql_node.yml
+ syslog_forwarder.conf.erb: config/syslog_forwarder.conf
+
+packages:
+ - common
+ - mysql_node_ng
+ - mysqlclient
+ - ruby
+ - ruby_next
+ - syslog_aggregator
@@ -0,0 +1,52 @@
+---
+<%
+service = "mysql"
+plan_enabled = properties.service_plans && properties.service_plans.send(service.to_sym)
+plan = properties.plan || "100"
+plan_conf = plan_enabled && properties.service_plans.send(service.to_sym).send(plan.to_sym).configuration
+connection_pool_size = plan_enabled && plan_conf.connection_pool_size
+node = properties.mysql_node
+nats_props = properties.send(properties.nats_props || "nats")
+nats = "nats://#{nats_props.user}:#{nats_props.password}@#{nats_props.address}:#{nats_props.port}"
+external_db = node.external_db
+external_db.port ||= 3306
+%>
+capacity: <%= plan_enabled && plan_conf.capacity || 200 %>
+plan: '<%= plan %>'
+local_db: mysql://<%= external_db.user %>:<%= external_db.password %>@<%= external_db.address %>:<%= external_db.port %>/mgmt
+base_dir: /var/vcap/store/mysql
+mbus: <%= nats %>
+index: <%= spec.index %>
+logging:
+ level: debug
+ file: /var/vcap/sys/log/mysql_node_external/mysql_node.log
+ <% if properties.syslog_aggregator %>
+ syslog: vcap.mysql_node
+ <% end %>
+pid: /var/vcap/sys/run/mysql_node/mysql_node.pid
+node_id: <%= "#{service}_node_#{plan}_#{spec.index}" %>
+default_version: "5.5"
+supported_versions: ["5.5"]
+
+max_db_size: <%= plan_enabled && plan_conf.max_db_size || 128 %>
+max_long_query: <%= plan_enabled && plan_conf.max_long_query || 3 %>
+max_long_tx: <%= plan_enabled && plan_conf.max_long_tx || 0 %>
+kill_long_tx: <%= plan_enabled && !plan_conf.kill_long_tx.nil? ? plan_conf.kill_long_tx : 'true' %>
+max_user_conns: <%= plan_enabled && plan_conf.max_clients || 20 %>
+mysql:
+ "5.5":
+ host: "<%= external_db.address %>"
+ port: <%= external_db.port %>
+ user: "<%= external_db.user %>"
+ pass: "<%= external_db.password %>"
+ mysqldump_bin: "/var/vcap/packages/mysql55/bin/mysqldump"
+ mysql_bin: "/var/vcap/packages/mysql55/bin/mysql"
+connection_pool_size:
+ min: <%= connection_pool_size && connection_pool_size.min || 5 %>
+ max: <%= connection_pool_size && connection_pool_size.max || 10 %>
+connection_wait_timeout: <%= plan_enabled && plan_conf.connection_wait_timeout || 10 %>
+migration_nfs: <%= properties.service_migration && properties.service_migration.mount_point ? properties.service_migration.mount_point : "/var/vcap/services_migration" %>
+gzip_bin: /bin/gzip
+z_interval: <%= node.z_interval || 30 %>
+max_nats_payload: <%= nats_props.max_payload || 1048576 %>
+op_time_limit: <%= node.op_time_limit || 6 %>
@@ -0,0 +1,93 @@
+#!/bin/bash
+<%
+service = "mysql"
+lifecycle = properties.service_lifecycle
+
+plan_enabled = properties.service_plans && properties.service_plans.send(service.to_sym)
+plan = properties.plan || "100"
+if plan_enabled
+ plan_conf = properties.service_plans.send(service.to_sym).send(plan.to_sym).configuration
+ capacity = plan_conf.capacity || -1
+end
+%>
+export PATH=/var/vcap/packages/ruby/bin:$PATH
+
+COMMON_DIR=/var/vcap/store/mysql_common
+RUN_DIR=/var/vcap/sys/run/mysql_node
+LOG_DIR=/var/vcap/sys/log/mysql_node
+PIDFILE=$RUN_DIR/mysql_node.pid
+JOB_DIR=/var/vcap/jobs/mysql_node_external
+MY_LD_FILE=/etc/ld.so.conf.d/mysql.conf
+<% if lifecycle and lifecycle.nfs_server %>
+SNAPSHOT_DIR=<%= lifecycle.mount_point || "/var/vcap/services_snapshot" %>
+MT_OPTS="-t nfs"
+MT_EXPORT=<%= lifecycle.nfs_server.address %>:<%= lifecycle.nfs_server.export_dir %>
+<% end %>
+
+source /var/vcap/packages/common/utils.sh
+
+case $1 in
+
+ start)
+ pid_guard $PIDFILE "MySQL node"
+
+ mkdir -p $RUN_DIR
+ mkdir -p $LOG_DIR
+
+ echo $$ > $PIDFILE
+
+ <% if properties.syslog_aggregator %>
+ /var/vcap/packages/syslog_aggregator/setup_syslog_forwarder.sh $JOB_DIR/config
+ <% end %>
+
+ echo "/var/vcap/packages/mysqlclient/lib/mysql" > $MY_LD_FILE
+ echo "/var/vcap/packages/mysql/lib/mysql" >> $MY_LD_FILE
+
+ /sbin/ldconfig
+
+ <% if lifecycle && lifecycle.nfs_server %>
+ mkdir -p $SNAPSHOT_DIR
+ check_mount "$MT_OPTS" "$MT_EXPORT" "$SNAPSHOT_DIR"
+ <% end %>
+
+ chmod +x $JOB_DIR/config/mysql_backup
+ $JOB_DIR/config/mysql_backup start
+
+ mkdir -p $COMMON_DIR/bin
+ mkdir -p $COMMON_DIR/config
+ rsync -arl $JOB_DIR/bin/warden_service_ctl $COMMON_DIR/bin
+ rsync -arl $JOB_DIR/bin/my*.shutdown $COMMON_DIR/bin
+ rsync -arl /var/vcap/packages/common/utils.sh $COMMON_DIR/bin
+ chmod -R 755 $COMMON_DIR/bin
+ rsync $JOB_DIR/config/my*.cnf $COMMON_DIR/config
+ rsync $JOB_DIR/config/warden_mysql_init $COMMON_DIR/config
+ chmod 755 $COMMON_DIR/config
+ chmod 644 $COMMON_DIR/config/*
+
+ exec /var/vcap/packages/mysql_node_ng/services/ng/mysql/bin/mysql_node \
+ -c $JOB_DIR/config/mysql_node.yml \
+ >>$LOG_DIR/mysql_node.stdout.log \
+ 2>>$LOG_DIR/mysql_node.stderr.log
+
+ ;;
+
+ stop)
+ kill_and_wait $PIDFILE 60
+
+ chmod +x $JOB_DIR/config/mysql_backup
+ $JOB_DIR/config/mysql_backup stop
+ <% if lifecycle && lifecycle.nfs_server %>
+ umount $SNAPSHOT_DIR
+ <% end %>
+
+ rm $MY_LD_FILE
+ /sbin/ldconfig
+
+ ;;
+
+ *)
+ echo "Usage: mysql_node_ctl {start|stop}"
+
+ ;;
+
+esac
@@ -0,0 +1,25 @@
+<% if properties.syslog_aggregator %>
+$ModLoad imuxsock # local message reception (rsyslog uses a datagram socket)
+$MaxMessageSize 4k # default is 2k
+$WorkDirectory /var/vcap/sys/rsyslog/buffered # where messages should be buffered on disk
+
+# Forward vcap messages to the aggregator
+#
+$ActionResumeRetryCount -1 # Try until the server becomes available
+$ActionQueueType LinkedList # Allocate on-demand
+$ActionQueueFileName agg_backlog # Spill to disk if queue is full
+$ActionQueueMaxDiskSpace 32m # Max size for disk queue
+$ActionQueueLowWaterMark 2000 # Num messages. Assuming avg size of 512B, this is 1MiB.
+$ActionQueueHighWaterMark 8000 # Num messages. Assuming avg size of 512B, this is 4MiB. (If this is reached, messages will spill to disk until the low watermark is reached).
+$ActionQueueTimeoutEnqueue 0 # Discard messages if the queue + disk is full
+$ActionQueueSaveOnShutdown on # Save in-memory data to disk if rsyslog shuts down
+:programname, startswith, "vcap." @@<%= properties.syslog_aggregator.address %>:<%= properties.syslog_aggregator.port %>
+
+# Log vcap messages locally, too
+#$template VcapComponentLogFile, "/var/log/%programname:6:$%/%programname:6:$%.log"
+#$template VcapComponentLogFormat, "%timegenerated% %syslogseverity-text% -- %msg%\n"
+#:programname, startswith, "vcap." -?VcapComponentLogFile;VcapComponentLogFormat
+
+# Prevent them from reaching anywhere else
+:programname, startswith, "vcap." ~
+<% end %>
@@ -9,5 +9,6 @@ cp -a * ${BOSH_INSTALL_TARGET}
bundle_cmd=/var/vcap/packages/ruby/bin/bundle
$bundle_cmd config build.do_sqlite3 --with-sqlite3-dir=/var/vcap/packages/sqlite
$bundle_cmd config build.mysql2 --with-mysql-dir=/var/vcap/packages/mysqlclient --with-mysql-include=/var/vcap/packages/mysqlclient/include/mysql
+ $bundle_cmd config build.do_mysql --with-mysql-dir=/var/vcap/packages/mysqlclient --with-mysql-include=/var/vcap/packages/mysqlclient/include/mysql
$bundle_cmd install --local --deployment --without=development test
)
@@ -7,6 +7,7 @@ cp -a * ${BOSH_INSTALL_TARGET}
cd ${BOSH_INSTALL_TARGET}/services/ng/mysql
/var/vcap/packages/ruby/bin/bundle config build.do_sqlite3 --with-sqlite3-dir=/var/vcap/packages/sqlite
/var/vcap/packages/ruby/bin/bundle config build.mysql2 --with-mysql-dir=/var/vcap/packages/mysqlclient --with-mysql-include=/var/vcap/packages/mysqlclient/include/mysql
+ /var/vcap/packages/ruby/bin/bundle config build.do_mysql --with-mysql-dir=/var/vcap/packages/mysqlclient --with-mysql-include=/var/vcap/packages/mysqlclient/include/mysql
/var/vcap/packages/ruby/bin/bundle install --local --deployment
cd ${BOSH_INSTALL_TARGET}/warden

0 comments on commit c709adf

Please sign in to comment.