1.從老系統(tǒng)備份出DB數(shù)據(jù)和用戶(hù)頭像文件
1.1.備份App MariaDB
mysqldump -uroot -proot@root密碼?-d?數(shù)據(jù)庫(kù)名 >/home/honsen/databackup/honsen_table_backup.sql
mysqldump -uroot -proot@root密碼?--allow-keywords --flush-logs --default-character-set=utf8 --set-charset? -t 數(shù)據(jù)庫(kù)名?>/home/honsen/databackup/honsen_data_backup.sql
1.2.備份Redis數(shù)據(jù)
cp /var/redis/dump.rdb/home/honsen/databackup/dump.rdb
1.3.備份用戶(hù)頭像文件
cd /var/www/honsen_api/public/uploads/avatar
tar -zcvf /home/honsen/databackup/usericons.tar.gz *
1.4.下載備份文件至個(gè)人PC
cd /home/honsen/databackup
sz -y honsen_table_backup.sqlhonsen_data_backup.sql admin_table_backup.sql admin_data_backup.sql dump.rdbusericons.tar.gz
1.5.備份Admin MariaDB
mysqldump -uroot -proot@root密碼?-d?管理系統(tǒng)數(shù)據(jù)庫(kù)名 ?>/home/honsen/databackup/admin_table_backup.sql
mysqldump -uroot -proot@root密碼?--allow-keywords --flush-logs --default-character-set=utf8 --set-charset? -t ?管理系統(tǒng)數(shù)據(jù)庫(kù)名 >/home/honsen/databackup/admin_data_backup.sql
2.將DB數(shù)據(jù)和用戶(hù)頭像文件導(dǎo)入到openshift集群環(huán)境
2.1. 導(dǎo)入MariaDB數(shù)據(jù)庫(kù)表&數(shù)據(jù)到openshift集群環(huán)境?
????1)將honsen_table_backup.sql、honsen_data_backup.sql拷貝至mariadb對(duì)應(yīng)的NAS mount目錄/mnt/ali-nas/mariadb
????2)OpenShift web Console下進(jìn)入honsen project, mariadb pod的Terminal:
???????? ?? cd /var/lib/mysql/data
???????? ?? ls -la
???????? ?? mysql -uroot
??????MariaDB> use 數(shù)據(jù)庫(kù)名;
??????MariaDB> source /var/lib/mysql/data/honsen_table_backup.sql;
??????MariaDB> source /var/lib/mysql/data/honsen_data_backup.sql;??????????? ??
? ? ? MariaDB> show tables;?
2.2. 導(dǎo)入Redis數(shù)據(jù)到openshift集群環(huán)境
????1)OpenShift web Console下進(jìn)入honsen project, 進(jìn)入Monitoring,點(diǎn)擊redis的Deployment,然后scale down到0
????2)將dump.rdb拷貝至redis對(duì)應(yīng)的pv目錄/mnt/ali-nas/redis
? ? 3)OpenShift web Console重新將redis的Deployment scale down到1
? ? 4)OpenShift web Console下進(jìn)入Monitoring唧垦,點(diǎn)擊redis的Pod尿庐,進(jìn)入Terminal:
???????? ?? cd /var/lib/redis/data
???????? ?? ls -la
???????? ?? //注意查看dump.rdb文件的大小
???????? ?? redis-cli -a
???????? ?? 127.0.0.1:6379> keys *? //查看所有的key
2.3. 導(dǎo)入用戶(hù)頭像文件到openshift集群環(huán)境
????1)usericons.tar.gz拷貝至mariadb對(duì)應(yīng)的pv目錄/mnt/ali-nas/usericons:
???????? ?? tar xzf usericons.tar.gz?????
2.4. 導(dǎo)入AdminMariaDB數(shù)據(jù)庫(kù)表&數(shù)據(jù)到openshift集群環(huán)境?
????1)將admin_table_backup.sql工育、admin_data_backup.sql拷貝至mariadb對(duì)應(yīng)的pv目錄/mnt/ali-nas/admindb
????2)OpenShift web Console下進(jìn)入honsen project, 進(jìn)入adminmariadb pod的Terminal:
???????? ?? ls -la /var/lib/mysql/data
???????? ?? mysql -uroot
??????MariaDB> use admindb;
??????MariaDB> source /var/lib/mysql/data/admin_table_backup.sql;
??????MariaDB> source /var/lib/mysql/data/admin_data_backup.sql;????????????? ??
???????? ?? MariaDB> show tables;