-
Notifications
You must be signed in to change notification settings - Fork 25
Feature/external deployment replication #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d1f6f8f
5d7bade
613385f
7fc1b2d
779e21a
9f4ac12
497a3ea
e73c6e1
6b714c4
6ee7890
b849675
a2efa0e
c2934a1
51b3aae
c391e05
117756c
1d09c72
c450ef2
84d8748
0a93bef
c0dffcd
4891d9a
9f76762
78462dc
af6ccba
2280371
2a78777
729de86
871ab36
567148f
e7e175a
3592804
d224d85
d2984b8
94a31ae
16df4e0
7809db2
7cb7798
07e0f19
6ac1cf7
e3f16ff
e0ca363
925b51a
6b54ee7
d70873f
839a107
e645f79
6da083c
cde015a
dad679a
bb9a380
e69382e
63d748a
1fdba47
70d9c77
abe8530
334fa41
c3a00e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| check process pxc-replicator | ||
| with pidfile /var/vcap/sys/run/bpm/pxc-replicator/pxc-replicator.pid | ||
| start program "/var/vcap/jobs/bpm/bin/bpm start pxc-replicator" | ||
| stop program "/var/vcap/jobs/bpm/bin/bpm stop pxc-replicator" | ||
| group vcap |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| --- | ||
| name: pxc-replicator | ||
|
|
||
| templates: | ||
| bpm.yml.erb: config/bpm.yml | ||
| config/config.yml.erb: config/config.yml | ||
|
|
||
| packages: | ||
| - percona-xtradb-cluster-8.0 | ||
| - percona-xtradb-cluster-8.4 | ||
| - pxc-replicator | ||
|
|
||
| consumes: | ||
| - name: mysql-backup-user-creds | ||
| type: mysql-backup-user-creds | ||
| optional: true | ||
| - name: source | ||
| type: mysql | ||
| optional: true | ||
| - name: target | ||
| type: mysql | ||
| optional: true | ||
|
|
||
| properties: | ||
| #SOURCE | ||
| source_admin_username: | ||
| description: | | ||
| this is here for compatibility with older deployments of the pxc-release. | ||
| If provided it will be used to create, authorize the `mysql-backup-user` on the source instance | ||
| source_admin_password: | ||
| description: | | ||
| this is here for compatibility with older deployments of the pxc-release. | ||
| If provided it will be used to create, authorize the `mysql-backup-user` on the source instance | ||
| mysql_backup_username: | ||
| description: 'a replication enabled user that exists on the source mysql. It requires permissions to do a full `mysqldump --all-databases --events --triggers --routines --single-transaction` of the source instance. If specified alongside source_admin_username && source_admin_password this user will automatically be generated and provided with the right permissions. ' | ||
| mysql_backup_password: | ||
| description: 'password to use for connection to source instance. If specified alongside source_admin_username && source_admin_password this user will automatically be generated and provided with the right permissions.' | ||
|
|
||
| #SOURCE TLS/CONNECTION | ||
| source_tls.ca: | ||
| description: ca certificate in pem format to validate the source instance | ||
| source_host: | ||
| description: 'hostname of the source database instance' | ||
| source_port: | ||
| default: 3306 | ||
|
|
||
| #TARGET | ||
| target_admin_username: | ||
| description: | | ||
| the admin user for the target of the replication. It will be used to connect and setup the replication | ||
| connection | ||
| target_admin_password: | ||
| description: | | ||
| the admin user for the target of the replication. It will be used to connect and setup the replication | ||
| connection | ||
| #TARGET TLS/CONNECTION | ||
| target_host: | ||
| description: 'hostname of the target database instance' | ||
| target_port: | ||
| default: 3306 | ||
| target_tls.ca: | ||
| description: ca certificate in pem format to validate the target instance | ||
|
|
||
| #GENERAL | ||
| clean_expired_backups: | ||
| description: | | ||
| To setup replication, pxc replicator will run an initial sync that takes a backup via mysqldump of the source. Re-Syncing is necessary in some cases where the replication breaks in a way where the incoming transactions from the source do not cleanly apply. | ||
| Enabling this setting will cleanup "expired" backups once the contained GTID is too old to reconnect the target with the source. When multiple viable backups are cached, only the latest viable backup is kept. | ||
| default: true | ||
| mysql_version: | ||
| description: 'the version of mysql deployed for source and target. Both deployments should use the same version.' | ||
| default: 8.4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| processes: | ||
| - name: pxc-replicator | ||
| executable: /var/vcap/packages/pxc-replicator/bin/replicator | ||
| args: | ||
| - -config=/var/vcap/jobs/pxc-replicator/config/config.yml | ||
| - -data-dir=/var/vcap/data/pxc-replicator/data | ||
| - -dump-dir=/var/vcap/data/pxc-replicator/dumps | ||
| - -mysql-bin-path=/var/vcap/packages/percona-xtradb-cluster-<%= p('mysql_version') -%>/bin/ | ||
| - -mysql-version=<%= p('mysql_version') %> | ||
| additional_volumes: | ||
| - path: /var/vcap/data/pxc-replicator/data | ||
| writable: true | ||
| - path: /var/vcap/data/pxc-replicator/dumps | ||
| writable: true | ||
| - path: /var/vcap/data/pxc-mysql | ||
| mount_only: true | ||
| writable: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| <%- | ||
| source_creds = {} | ||
| fallback = true | ||
| if_link('mysql-backup-user-creds') do |link| | ||
| link.if_p('mysql_backup_username','mysql_backup_password') do |user,pass| | ||
| source_creds = { 'username' => user, 'password' => pass } | ||
| fallback = false | ||
| end | ||
| end | ||
| if fallback | ||
| if_p('mysql_backup_username', 'mysql_backup_password') do |user,pass| | ||
| source_creds = { 'username' => user, 'password' => pass } | ||
| end | ||
| end | ||
| if_p('source_admin_username', 'source_admin_password') do |user,pass| | ||
| source_creds["admin_username"] = user | ||
| source_creds["admin_password"] = pass | ||
| end | ||
| -%> | ||
| version: <%= p('mysql_version') %> | ||
| source: | ||
| name: source | ||
| <%- | ||
| if_link('source') do |link| | ||
| tls = {} | ||
| link.if_p('tls.client.ca') do |val| | ||
| tls["ca"] = val | ||
| end.else do | ||
| if_p('source_tls.ca') do |val| | ||
| tls["ca"] = val | ||
| end | ||
| end | ||
| -%> | ||
| #link config | ||
| host: <%= link.address %> | ||
| port: <%= link.p('port') %> | ||
| version: <%= link.p('mysql_version') %> | ||
| creds: <%= JSON.dump(source_creds) %> | ||
| tls: <%= JSON.dump(tls) %> | ||
| <%- | ||
| end.else do | ||
| -%> | ||
| #manual config | ||
| host: <%= p('source_host') %> | ||
| port: <%= p('source_port') %> | ||
| version: <%= p('mysql_version') %> | ||
| creds: <%= JSON.dump(source_creds) %> | ||
| tls: <%= JSON.dump(tls) %> | ||
| <%- | ||
| end | ||
| -%> | ||
| #TARGET | ||
| target: | ||
| name: target | ||
| <%- | ||
| target_creds = { | ||
| "admin_username" => p('target_admin_username'), | ||
| "admin_password" => p('target_admin_password'), | ||
| } | ||
| if_link('target') do |link| | ||
| tls = {} | ||
| link.if_p('tls.client.ca') do |ca| | ||
| tls["ca"] = ca | ||
| end.else do | ||
| if_p("target_tls.ca") do |ca| | ||
| tls["ca"] = ca | ||
| end | ||
| end | ||
| -%> | ||
| version: <%= link.p('mysql_version') %> | ||
| host: localhost | ||
| port: <%= link.p('port') %> | ||
| creds: <%= JSON.dump(target_creds) %> | ||
| tls: <%= JSON.dump(tls) %> | ||
| <%- | ||
| end.else do | ||
| -%> | ||
| host: <%= p('target_host') %> | ||
| port: <%= p('target_port') %> | ||
| version: <%= p('mysql_version') %> | ||
| creds: <%= JSON.dump(target_creds) %> | ||
| tls: <%= JSON.dump(tls) %> | ||
| <%- end -%> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-replicator? | ||
| value: | ||
| name: pxc-replicator | ||
| release: pxc | ||
| properties: {} | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/engine_config?/binlog?/enable_gtid_mode? | ||
| value: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/engine_config?/server_id? | ||
| value: 1 | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/engine_config?/binlog?/enable_gtid_mode | ||
| value: true | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/provides? | ||
| value: | ||
| mysql-backup-user-creds: | ||
| as: source-creds | ||
| shared: true | ||
| mysql: | ||
| as: replica-source | ||
| shared: true | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/mysql_backup_username? | ||
| value: ((mysql_backup_user.username)) | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/mysql_backup_password? | ||
| value: ((mysql_backup_user.password)) | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/mysql_backup_allowed_remote_hosts? | ||
| value: '%' | ||
|
|
||
| - type: replace | ||
| path: /variables/name=mysql_backup_user? | ||
| value: | ||
| name: mysql_backup_user | ||
| type: user | ||
| parameters: | ||
| length: 32 | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/engine_config?/server_id? | ||
| value: 2 | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/engine_config?/binlog?/enable_gtid_mode? | ||
| value: true | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/provides?/mysql? | ||
| value: | ||
| as: replica-target | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/mysql_version? | ||
| value: '8.4' | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-replicator/properties/mysql_version? | ||
| value: '8.4' | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-replicator/properties/target_admin_username? | ||
| value: 'root' | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-replicator/properties/target_admin_password? | ||
| value: ((cf_mysql_mysql_admin_password)) | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/tls?/client?/ca | ||
| value: ((mysql_server_certificate.ca)) | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-replicator/consumes? | ||
| value: | ||
| source: | ||
| from: replica-source | ||
| deployment: ((source_deployment_name)) | ||
| target: | ||
| from: | ||
| replica-target | ||
| mysql-backup-user-creds: | ||
| from: source-creds | ||
| deployment: ((source_deployment_name)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/azs? | ||
| value: ((azs)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - type: replace | ||
| path: /name | ||
| value: ((deployment_name)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/networks? | ||
| value: [{name: ((network_name))}] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/persistent_disk? | ||
| value: ((persistent_disk_size)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/vm_extensions? | ||
| value: ((vm_extensions)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/vm_type? | ||
| value: ((vm_type)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - type: replace | ||
| path: /instance_groups/name=mysql/jobs/name=pxc-mysql/properties/mysql_version? | ||
| value: "8.4" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/usr/bin/env bash | ||
| set -ex | ||
|
|
||
| source /var/vcap/packages/golang-1-linux/bosh/compile.env | ||
|
|
||
| cd pxc-replicator | ||
| mkdir -p "${BOSH_INSTALL_TARGET}/bin" | ||
| GOOS=linux GOARCH=amd64 go build -mod=vendor -o "${BOSH_INSTALL_TARGET}/bin/replicator" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to hardcode the GOOS/GOARCH here? Since BOSH compiles packages directly on the target stemcell, hardcoding If you drop the env vars, you can also use Go's mkdir -p "${BOSH_INSTALL_TARGET}/bin"
go build -C pxc-replicator -mod=vendor -o "${BOSH_INSTALL_TARGET}/bin/replicator" . |
||
| cd - | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| name: pxc-replicator | ||
| dependencies: | ||
| - golang-1-linux | ||
| files: | ||
| - pxc-replicator/**/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to fail on an error:
NameError: undefined local variable or method `tls' for an instance of Bosh::Template::EvaluationContext