mariadb克隆

Posted Angus_yang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mariadb克隆相关的知识,希望对你有一定的参考价值。

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 '[email protected]#' |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=\"\[email protected] \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.

[email protected] 11:59:21>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jinri              |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.03 sec)

以上是关于mariadb克隆的主要内容,如果未能解决你的问题,请参考以下文章

GitGit 分支管理 ( 克隆远程分支 | 克隆 master 分支 git clone | 查看远程分支 git branch -a | 克隆远程分支 git checkout -b )(代码片段

Forge Viewer - 如何在场景中访问(或获取渲染/片段代理)克隆的网格?

Instagram 克隆。单击按钮时,为啥我不能回到上一个片段?

如何在多个页面使用同一个HTML片段

构建基因文库的目的和意义?

LAMP 建立 Wordpress 站点 Linux Apache MariaDB PHP