Skip to content

Latest commit

 

History

History
117 lines (116 loc) · 3.19 KB

install_coreos_mysql.md

File metadata and controls

117 lines (116 loc) · 3.19 KB

Step install CoreOS and Migrate MySQL


Table of Content


0. change user in database login allow any host [ '%' ]

1. install CoreOS

after boot

sudo openssl passwd -1 > cloud_config.yml

edit file cloud_config.yml

vi cloud_config.yml

in file cloud_config.yml

#cloud-config
users:
    - name: username
      passwd: TEXT IN THIS FILE
      groups:
        - sudo 
        - docker
hostname: mysql-newhost

install CoreOS

sudo coreos-install -d /dev/sda -C stable -c cloud_config.yml

if error GPG Key use new coreos-install

wget https://raw.githubusercontent.com/coreos/init/master/bin/coreos-install
chomd +x coreos-install
sudo ./coreos-install -d /dev/sda -C stable -c cloud_config.yml

2. install docker-compose

sudo su -
mkdir -p /opt/bin
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m`  > /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose

3. copy /var/lib/mysql from db old host to CoreOS

in old host

stop service mysql

service mysql stop

cd to /var/lib/

cd /var/lib/

tar file

tar -zcvf mysql_backup.tar.gz mysql

send file to core os host

scp mysql_backup.tar.gz username@IPNEWHOST:PATH TO SAVEFILE (Ex. /home/username/)

in new host

un tar file

tar -zxvf mysql_backup.tar.gz

change name folder

cp -rf mysql mysql_server1

4. remove ib log file

rm mysql_server1/ib_logfile0;
rm mysql_server1/ib_logfile1;

5. create docker-compose.yml

(if root is setting allow any host remove enviroment setting in file docker-compose.yml or comment by # )

example docker-compose.yml

mysql_server_01:
  image: mysql:5.6
  container_name: mysql-server-01
  restart: always
  environment:
    - MYSQL_ROOT_HOST=%
    - MYSQL_ROOT_PASSWORD=PASSWORD
  ports:
    - "3308:3306"
  volumes:
    - "/home/iserl/mysql_server1:/var/lib/mysql"

6. start with docker-compose up -d

docker-compose up -d

Test Connection

mysql -h IPNEWSERVER -P port -u root -pPASSWORD