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 root@192.168.50.160:/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. root@192.168.50.160'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)