oracle有克隆安装,事实上mysql/mariadb相似。仅仅需简单几步就能够直接在异机直接启动.
环境:
node01安装完毕的mariadb;
node02一个新机器
如今将node01克隆到node02机器 --1.node02准备环境 #yum remove mysql-libs #yum -y install cmake gcc gcc-c++ autoconf automake zlib* libxml* \
ncurses ncurses-devel libtool-ltdl-devel* make bison bison-devel libaio #groupadd mysql && useradd -g mysql mysql -s /sbin/nologin && echo 'mysql01!@#' |passwd --stdin mysql #vi + /etc/security/limits.conf mysql soft nproc 2047
mysql hard nproc 16384
mysql soft nofile 1024
mysql hard nofile 65536 --2.node01正常关闭数据库 # mysqlshutdownv.sh
mysql port is 33107
close mysql service
--------------------------------------------
mysql shutdown....Wait a minute...
****MYSQL SUCESS CLOSE**** ---3.node01打包 tar czvf mysql.tar.gz /data/ --4.传输到node02 # scp -r -p -P 22 /root/mysql.tar.gz [email protected]:/backup
The authenticity of host '192.168.50.160 (192.168.50.160)' can't be established.
RSA key fingerprint is 74:5d:47:c0:f8:cf:e7:bb:8c:76:94:4f:0d:6b:ea:c8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.50.160' (RSA) to the list of known hosts.
[email protected]'s password:
mysql.tar.gz 100% 131MB 43.6MB/s 00:03 --5.解压和改动权限 #cd /backup # tar zxvf mysql.tar.gz -C /data/ # ls /data/
data --移动文件夹到上一层
# cd /data/data/ && mv mysql/ ../ && mv ocpyang/ ../ && ls /data/data/ && ls /data/mysql/ && ls /data/ocpyang # rm -rf /data/data #chown -R mysql /data/mysql && chgrp -R mysql /data/mysql --6.链接必要文件 ##链接文件
#ln -fs /data/mysql/my.cnf /etc/my.cnf; ll /etc/my.cnf #cd /data/mysql/&& cp support-files/mysql.server /etc/init.d/mysql && chkconfig mysql on --7.改动my.cnf文件
#vi /etc/my.cnf :%s/node01/node02/g --8.改动环境变量 # vi ~/.bash_profile #ocpyang set
alias date='date "+%Y-%m-%d %H:%M:%S" '
alias mysql="mysql -hlocalhost -uroot -ppassword --auto-rehash --prompt=\"\u@node02 \R:\m:\s>\" "
alias errorlog="cat /data/mysql/mysql_logs/error_log/error.log"
alias mycnf="cd /data/mysql"
export PATH=/data/mysql/scripts:$PATH #source ~/.bash_profile #chmod 755 /data/ocpyang/*
#echo "export PATH=/data/ocpyang:\$PATH">>~/.bash_profile #source ~/.bash_profile --9.启动mysql #chown -R mysql /data/mysql; chgrp -R mysql /data/mysql #/data/mysql/bin/mysqld_safe --datadir='/data/mysql/data' & # mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.10-MariaDB-log Source distribution Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. root@node02 11:59:21>show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| jinri |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.03 sec)