chmod 400 SeniorServer.pem Server: ssh -i "SeniorServer.pem" ec2-user@ec2-54-149-37-172.us-west-2.compute.amazonaws.com password for root:qwe123456 server2: ssh -i "senior_design_victor.pem" ec2-user@ec2-54-69-160-179.us-west-2.compute.amazonaws.com controller: ssh -i "zheng.pem" ec2-user@ec2-52-34-59-51.us-west-2.compute.amazonaws.com DB: mysql -h seniordesign.c9btkcvedeon.us-west-2.rds.amazonaws.com -P 3306 -u root -p username: root password: qwe123456 use command "screen" to keep running server codes and controller codes on AWS screen #create a new screen session screen -ls #check running screens screen -r screenID #resume to a screen screen -X -S screenID kill #end a screen MySQL: create table transaction (username varchar(20), history varchar(20)); insert into property (username,password,money) values ("client1","123",100); To create more replicated server/db: Master (RDS) - all in mysql, no Bash - remember to remove [] from statements 1. Create new slave CREATE USER '[SLAVE USERNAME]'@'%' IDENTIFIED BY '[SLAVE PASSWORD]'; 2. Give it access GRANT REPLICATION SLAVE ON *.* TO '[SLAVE USERNAME]'@'%'; Slave (Server) - 1. [Bash] Import the database from master mysqldump -h seniordesign.c9btkcvedeon.us-west-2.rds.amazonaws.com -u root -p senior_design > dump.sql 2. [Bash] Import the dump.sql into your database mysql senior_design < dump.sql 3. [Bash] Edit the /etc/my.cnf - will require root access, add the follow lines **Remember to keep server-id different (currently using 10, so next is 11, etc...) # Give the server a unique ID server-id = #CHANGE THIS NUMBER# # # Ensure there's a relay log relay-log = /var/lib/mysql/mysql-relay-bin.log # # Keep the binary log on log_bin = /var/lib/mysql/mysql-bin.log replicate_do_db = senior_design 4. [Bash] Restart mysqld service mysqld restart Master-Slave Connection Creation 1. On master (RDS) - type show master status; ** We will need to keep note of File and Position +----------------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +----------------------------+----------+--------------+------------------+-------------------+ | mysql-bin-changelog.010934 | 400 | | | | +----------------------------+----------+--------------+------------------+-------------------+ 2. On the slave, enter mysql then enter CHANGE MASTER TO MASTER_HOST='seniordesign.c9btkcvedeon.us-west-2.rds.amazonaws.com', MASTER_USER='[SLAVE NAME]', MASTER_PASSWORD='[SLAVE PWD]', MASTER_LOG_FILE='[MASTER FILE] ', MASTER_LOG_POS= [MASTER POSITION]; 3. On the slave, enter "START SLAVE;" 4. Make sure the slave started - "SHOW SLAVE STATUS\G;" 5. You can always triple check by adding a new row to senior_design in master then see if it updates in slave. TROUBLESHOOTING - If for some reason you mess up the slave in step 2. [mysql] on the slave side reset slave; then repeat step 2 - 5 - If in SHOW SLAVE STATUS\G shows error try STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; START SLAVE; error should be gone, but this will only skip the error; the error may still re-appear use senior_design; select count(*) from property; Slave user pass: Slave 1 - username: slave1 pass: slave1pwd Slave 2 - username: slave2 pass: [slave2] CHANGE MASTER TO MASTER_HOST='seniordesign.c9btkcvedeon.us-west-2.rds.amazonaws.com', MASTER_USER='slave1', MASTER_PASSWORD='slave1pwd', MASTER_LOG_FILE='mysql-bin-changelog.011030', MASTER_LOG_POS= 400; CHANGE MASTER TO MASTER_HOST='seniordesign.c9btkcvedeon.us-west-2.rds.amazonaws.com', MASTER_USER='slave2', MASTER_PASSWORD='[slave2]', MASTER_LOG_FILE='mysql-bin-changelog.011030', MASTER_LOG_POS= 400;
Recent Comments