{"id":29670395,"url":"https://github.com/percona/training-aws","last_synced_at":"2025-07-22T19:36:04.510Z","repository":{"id":46917483,"uuid":"308674478","full_name":"percona/training-aws","owner":"percona","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-18T11:54:34.000Z","size":5655,"stargazers_count":4,"open_issues_count":8,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-18T15:51:54.280Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/percona.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-10-30T15:43:55.000Z","updated_at":"2025-07-18T11:54:38.000Z","dependencies_parsed_at":"2023-11-10T12:43:07.621Z","dependency_job_id":"0da8a36f-c293-4982-bbe8-657cfb86e76a","html_url":"https://github.com/percona/training-aws","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/percona/training-aws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percona%2Ftraining-aws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percona%2Ftraining-aws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percona%2Ftraining-aws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percona%2Ftraining-aws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/percona","download_url":"https://codeload.github.com/percona/training-aws/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percona%2Ftraining-aws/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266561529,"owners_count":23948632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-22T19:36:03.687Z","updated_at":"2025-07-22T19:36:04.501Z","avatar_url":"https://github.com/percona.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Percona Training AWS Scripts\n\n## AMI List\n\n```\nami-0c2adaf7cfbf731ec - Centos 7 / MongoDB 4.4 (old)\nami-0b02004363780dd42 - Centos 7 MySQL\nami-0f5dcffa34c281c1a - Rocky 9 MySQL\nami-0ad8bfd4b10994785 - Centos 9 MySQL / MongoDB 7.0 / MongoDB Operator\n```\n\nThe MongoDB AMI is available only in `us-west-2` region at this time. \n\n* If the latest AMI doesn't work, try the previous AMI\n  * Leave off `-i` and the script will show you all available AMIs in this region:\n```\n\n$ ./start-instances.php -a ADD -r eu-west-1 -p TREK -c 6 -m db1\nYou must set the AMI to use for the training instances.\nThe following Percona-Training AMIs were found in the 'eu-west-1' region:\n\nName                           - AMI\nPercona-Training-20200321-AMI  - ami-0e8223fee4b885841\nPercona-Training-20200710-AMI  - ami-0b02004363780dd42\n...\n\n```\n\n## Installation\n\n### Packages required\n\nYou need PHP 7.2+ on your laptop to run the scripts. Also AWS CLI and Ansible are required.\n\nOn Mac, easy with Homebrew:\n\n```\n$ brew install php@7.2 ansible awscli composer\n```\n\nOn Linux the following packages are required:\n\n```\n$ sudo apt-get install php7.2 php-xml php-mbstring ansible awscli composer\n```\n\nAfter you install composer, install all necessary PHP packages:\n\n```\n$ composer install\n```\n\nThis will create a `vendor/` directory, with all the 3rd party libraries needed.\n\n### AWS Credentials\n\nMake sure you have your `~/.aws/credentials` configured:\n\n```\n$ cat ~/.aws/credentials \n[default]\naws_access_key_id = ...\naws_secret_access_key = ...\n```\n\n## Set Up Notes\n\nNOTE: `TREK` is used below as an example. Use a \"short code\" that represents your client during training. Examples: `DELL` if you were training Dell Co.\n\n### Machine Types\n\nThere are multiple \"machine types\" which are used in different training courses:\n  * `db1`: Used for the 'Scaling and Optimization' course. Exercises in the various chapters can be executed on db1. The 'MyMovies' chapter is a team-building exercise. You would assign 2-3 students for each db1 instance. This instance is also used for 'Operations and Troubleshooting' when doing xtrabackup labs, and functions as the master all master/slave exercises.\n  * `db2`: This machine type is used as the slave instance for all all master/slave exercises.\n  * `scoreboard`: This is for the MyMovies competition. Ansible will handle 100% of the configuration. You simply need to open the page in your browser (port 8080) and display on projector/monitor for students to see.\n  * `app`: This instance serves as sysbench, docker, and proxysql for the XtraDB Cluster and Group Replication tutorials. Each student should get 1 app instance.\n  * `mysql1`, `mysql2`, `mysql3`: These instances are used in the XtraDB Cluster and Group Replication tutorials. Each student should get 1 of each of these.\n  * `node1`: This instance is used in the K8S Operator tutorials. Each student should receive 1 of these.\n  * `mongodb`: This instance has the Percona Server for MongoDB packages. Each student should receive 1 of these for the MongoDB training.\n\nThere are 2 machine type aliases, `gr` and `pxc`, both are aliases for all 4 types: `app`, `mysql1`, `mysql2`, and `mysql3`\n\n## Set Up Instances\n\n### 1. Ensure DynamoDB table exists\n\nMake sure there is a DynamoDB table created on the `us-east-1` region called `percona_training_servers`. This is used to support the training backed but sometimes is deleted. If it is not there, create it with the following structure:\n\n* `Partition Key`: `teamTag` (String)\n* `Sort Key`: `teamID` (Number)\n\n### 2. Create a new VPC\n\nAll instances need to run inside a VPC. The VPC will launch with a single subnet of 10.11.0.0/16 with outbound internet capabilities.\n\n```\n./setup-vpc.php -a ADD -r eu-west-1 -p TREK\n```\n\nThis will create a VPC in the `eu-west-1` region named `Percona-Training-TREK`. It will create all necessary security group rules for allowing SSH (22), HTTP (80), HTTP-SSL (443), and HTTP-ALT (8080).\n\n### 3. Add/Start EC2 Instances\n\nUsing the same suffix (TREK in this case) we can launch instances inside the above VPC:\n\n```\n./start-instances.php -a ADD -r eu-west-1 -p TREK -c 6 -m db1 -i ami-9f10fbec\n```\n\nThe above example will launch 6 instances of the db1 image in the VPC. They will be named `Percona-Training-TREK-db1-T[1-6]`.\n\nIf you need to launch other instance types, simply repeat the above command and change the `-m` parameter.\n\n### 3a. Launch multiple instance types\n\nYou can launch multiple instance types at the same time. Separate each type with `,` or use the two aliases.\n\n```\n-- Launch 4 complete setups for use in the PXC tutorial. A total of 16 (4 teams, each with 4 servers) EC2 instances will be created.\n./start-instances.php -a ADD -r eu-west-1 -p TREK -c 4 -m pxc -i ami-014230ad6c3e10ec2\n\n-- Launch 7 setups for Operations class, db1 and db2. This will launch 14 instances total.\n./start-instances.php -a ADD -r us-west-2 -p TREK -c 7 -m db1,db2 -i ami-014230ad6c3e10ec2\n```\n\n### 3b. Add More Instances\n\nIf you need to add more instances (i.e.: more teams, or more students) you can do so using the `-o` (offset) to make sure the numbers match up. `-c ` is the number of instances to add.\n\n```\n./start-instances.php -a ADD -r eu-west-1 -p TREK -c 1 -o 6 -m db1 -i ami-9f10fbec\n```\n\nIn this example, the offset `-o` is 6. The next numbered instance will start at 7. The above command will launch 1 `-c 1` more instance named `Percona-Training-TREK-db1-T7`\n\n### 4. Generate `ansible_hosts` and configure hosts\n\nOnce all machines are up and running, we can generate an `ansible_hosts` file, which we can use to provision the servers.\n\n```\n./start-instances.php -a GETANSIBLEHOSTS -r eu-west-1 -p TREK \u003e ansible_hosts_trek\n```\n\nThere is only 1 ansible playbook: `hosts.yml`. This playbook contains tasks for all of the different machine types by adding/removing yum repos, configuring the */etc/hosts* file, installing necessary software packages, checking out git repos, and much more.\n\nYou can re-run this playbook as needed. That's the nice thing about ansible; it only changes what needs to be changed to set a specific state.\n\nIdeally, though, you would create all of your machine types then run this playbook only once.\n\n```\n# ansible-playbook -i ansible_hosts_trek hosts.yml\n```\n\nIf you add additional servers and need to provision them, you need to repeat the `GETANSIBLEHOSTS` command, and also repeat the `ansible-playbook` command. But you can specify a single server to make ansible go faster:\n\n```\n# ansible-playbook -i ansible_hosts_trek hosts.yml --limit mysql1-T7    // Provision the mysql1-T7 server only\n\n# ansible-playbook -i ansible_hosts_trek hosts.yml --limit T7    // Provision all servers from Team 7\n```\n\n### 5. Teams and Connecting to Instances\n\nLoad the following URL to your presentation screen, and/or share the URL within chat, substituting XXXX for your \"prefix\":\n\nhttp://percona-training.s3-website-us-east-1.amazonaws.com/?tag=XXXX\n\nThis will display all servers created for each team, along with their public and private IP addresses.\n\nHave the students download the keys .zip file from the URL at the bottom of this page. Mac/Linux users must `chmod 600 Percona-Training.key`\n\nNext, assign teams. Just point at each student and say \"You are team 1, you are team 2, etc\".\n_Exception:_ For the MyMovies competition, assign 2 students per 1 team.\n\nOnce the keys and teams are distributed, students can connect to instances.\n\nThe SSH username is usually `ec2-user` but depending on the AMI it can be different (e.g. `centos`). There is **NO password**. Windows/Putty users can use the PPK file.\n\n### 6. Removing Instances\n\nAfter the training is done, you need to remove the instances and the VPC\n\n```\n./start-instances.php -a DROP -r eu-west-1 -i ami-9f80fbec -p TREK\n```\n\nUnfortunately, you need to manually remove the VPC in the AWS web-console interface:\n\n- Go to https://aws.amazon.com\n- Go to the region where you created the instances\n- Click `VPC`\n- Go to `Your VPCs`\n- Select the VPC (in the example named `Percona-Training-TREK`) and click `Delete VPC`. \n\nThis will delete all the VPCs, subnets, gateways...\n\n## Alternate Setup\n\nFor the *Scaling and Optimization* class, the students might find it more beneficial to have their own instance on which to run the query tuning exercises. This is a bit more work for you, the instructor, but is easially managed thanks to the scripts above. Here is an example timeline for this setup:\n\n* Day 0: Some time before day 1, you know only 14 students will be attending. Create 15 DB1 instances (one additional for instructor). This will be 14 teams, one student per team. Run ansible as normal.\n* Day 1 (Class): Distribute servers as normal. Assign each student to their own team. Do exercises as normal.\n* Day 1 (Hotel): Destroy all 15 instances. Create 7 DB1 instances for 7 teams, 2 students per team, and 1 scoreboard instance. Run ansible as normal.\n* Day 2 (Class): Re-distribute servers as IPs will change. Assign students, in pairs, to new teams. Run My-Movies exercise.\n* Day 2 (Hotel): Destroy everything. If your class is continuing with *Operations and Troubleshooting*, re-launch 15 DB1 and 15 DB2 instances. Run ansible as normal.\n* Day 3 (Class): Again, re-distribute servers. Run remainder of class/exercises as normal.\n\n## Tutorials/Exercises\n\nPages are live-generated. Source is under the `gh-pages` branch of https://github.com/percona/training-material\n\n* Source/Replica Tutorial (Exercises for MySQL Operations \u0026 Troubleshooting)\n* ProxySQL Tutorial\n* Mesosphere Tutorial\n* Percona XtraDB Cluster Tutorial\n* Orchestrator Tutorial\n* PostgreSQL Tutorial\n* PMM Tutorial\n\n## MyMovies Exercise\n\n* Launch 1 db1 instance for each team, and 1 [scoreboard](https://github.com/percona/training-mymovies/blob/master/scoreboard/README.md) that is shared.\n* Scoreboard will hit 3 different pages on all dbX instances \n* Teams compete to who can get the app to perform better\n* Check app files under /var/www/html on each instance for the app's PHP code\n* The `mymovies` app runs on port 80 of each `db1` instance (httpd)\n* The `scoreboard` is a Nodejs app listening on port 8080 of the `scoreboard` server\n* [Solutions](https://github.com/percona/training-material/blob/master/slides/modules/my_movies/my_movies_solutions.md)\n\n## Survey\n\nAt the end of the training, share a survey with the participants\n\n1. Create a PDF of your slides. everything in 1 PDF.\n2. Upload PDF to Google Drive\n3. Create share “if have the link” of the PDF\n4. Clone the [survey](https://docs.google.com/forms/d/12GCDBdzwGrOaM-MA3lxJziPUtkL37mDGWVvn41aMlDw/edit), click Settings, Presentation, edit Confirmation message. Paste in URL of PDF.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercona%2Ftraining-aws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpercona%2Ftraining-aws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercona%2Ftraining-aws/lists"}