3.2.?Mysql_migration工具集安装

3.2.1. 安装mysql数据库
3.2.2. 安装MySQL Client Library
3.2.3. 安装UXDB Server
3.2.4. 安装Mysql_migration工具集

工具集通过MySQL Client Library远程访问MySQL,这里说明安装MySQL Client Library的方法(关键是要配置好环境变量)。当然安装工具集之前需要安装UXDB。

目前mysql迁移工具是基于mysql5.7的客户端开发库编译打包的,因此在测试时可按照如下方式搭建环境:

请在优炫数据库在线客户中心获取mysql压缩包,获取地址:http://www.uxsin.com/uxdb/login.php,压缩包中包含mysql客户端的安装包和mysql完整数据库的安装包。

3.2.1.?安装mysql数据库

  1. root用户解压:

    tar -xzvf  mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
  2. 重命名并移动到/usr/local:

    mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql
    mv mysql /usr/local
  3. 添加用户和组:

  4. 在/usr/local/mysql下创建data文件夹:

  5. 初始化数据库,记录自动生成密码:

    bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
  6. 修改/usr/local/mysql 当前目录的用户:

    # chown -R root:root ./
    # chown -R mysql:mysql data
  7. 复制my-default.cnf文件到etc/my.cnf:

    cd support-files/
    touch my-default.cnf
    chmod 777 ./my-default.cnf 
    cd ../
    cp support-files/my-default.cnf /etc/my.cnf
  8. 配置my.cnf:

    vim /etc/my.cnf

    内容如下:

    [mysqld]
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
     
    # These are commonly set, remove the # and set as required.
    basedir = /usr/local/mysql
    datadir = /usr/local/mysql/data
    socket = /tmp/mysql.sock
    log-error = /usr/local/mysql/data/error.log
    pid-file = /usr/local/mysql/data/mysql.pid
    tmpdir = /tmp
    port = 5186
    #lower_case_table_names = 1
    # server_id = .....
    # socket = .....
    #lower_case_table_names = 1
    max_allowed_packet=32M
    default-authentication-plugin = mysql_native_password
    #lower_case_file_system = on
    #lower_case_table_names = 1
    log_bin_trust_function_creators = ON
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M 
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  9. 开机自启,进入/usr/local/mysql/support-files进行设置:

    cd support-files/
    cp mysql.server /etc/init.d/mysql 
    chmod +x /etc/init.d/mysql
  10. 注册服务:

    chkconfig --add mysql 
    export PATH=/sbin:$PATH
    echo $PATH
    chkconfig  --list mysq
  11. 配置动态库路径,将路径/usr/local/mysql/lib添加到ld.so.conf:

    vim /etc/ld.so.conf
    sudo ldconfig
  12. 配置环境变量:

    vim /etc/profile
    source /etc/profile
  13. 启动并登录mysql服务:

    service mysql start
    mysql -u root -p
    alter user 'root'@'localhost' identified by '123456';

    基本命令:

    use mysql; //切换到mysql数据库
    show variables like '%skip_networking%'; //查数据库编码
    select user,authentication_string,host from user; //查看当前用户的相关信息
    update user set host='%' where user='root'; //root用户设置为远程登录
    flush privileges; //提交操作
    create database mysqldb; //创建数据库

3.2.2.?安装MySQL Client Library

  1. 对于linux6找到对应的安装包el6系列并下载(linux7则安装对应的el7系列):

    mysql-community-common-5.7.17-1.el6.x86_64.rpm
    mysql-community-libs-5.7.17-1.el6.x86_64.rpm
    mysql-community-client-5.7.17-1.el6.x86_64.rpm
    mysql-community-devel-5.7.17-1.el6.x86_64.rpm
  2. 安装对应的安装包:

    root# rpm -ivh mysql-community-common-5.7.17-1.el6.x86_64.rpm
    root# rpm -ivh mysql-community-libs-5.7.17-1.el6.x86_64.rpm
    root# rpm -ivh mysql-community-client-5.7.17-1.el6.x86_64.rpm
    root# rpm -ivh mysql-community-devel-5.7.17-1.el6.x86_64.rpm
  3. 检查/usr/lib64路径下是否存在一个名字为mysql的文件夹,它包含了刚才安装的动态库;

  4. 将路径/usr/lib64/mysql写入系统配置:

    找到目录/etc/ld.so.conf.d/,创建文件mysqlclient.conf,打开mysqlclient.conf,把mysql路径写入此文件并保存;

  5. 写入配置文件后,运行sudo ldconfig使得配置生效。

3.2.3.?安装UXDB Server

  1. 选择UXDB Server安装包,linux7是uxdb-server-linux7-x64,linux6则需要安装uxdb-server-linux6-x64;

  2. 进入安装包后,直接运行./install.sh可以按照提示自动安装UXDB,关于UXDB的安装配置可以参阅《优炫数据库安装手册 V2.1》;

  3. 假设安装根目录是/home/uxdb/uxdbinstall,那么在/home/uxdb/uxdbinstall/dbsql/bin下面可以找到UXDB的各种工具集;

  4. 把/home/uxdb/uxdbinstall/dbsql/bin写入PATH环境变量:

    uxdb$ vi ~/.bashrc

    在bashrc中最后一行写入:

    export LD_LIBRARY_PATH=/usr/lib64/mysql:$LD_LIBRARY_PATH
  5. 写入环境变量后执行下面的命令,确保对本Shell生效或者重新打开一个Shell就可以在新Shell生效:

    source ~/.bashrc
  6. 在Shell中直接敲ux_config可以看到打印出一些安装配置信息,证明UXDB Server安装成功。

3.2.4.?安装Mysql_migration工具集

  1. 解压安装包mysql_migration_v2.0.tar.gz得到目录mysql_migration_v2.0;

  2. 在目录mysql_migration_v2.0下面运行./install.sh就安装到UXDB了;

  3. 安装过程中,如果出现打印ux_config命令不存在的情况,请确认UXDB Server已经安装并且PATH环境变量已经配置;

  4. 假设UXDB Server的安装根目录为/home/uxdb/uxdbinstall那么在/home/uxdb/uxdbinstall/dbsql/bin/mysql_migration能看见mysql_migration工具集的4个工具;

  5. 可以把/home/uxdb/uxdbinstall/dbsql/bin/mysql_migration写入PATH环境变量。

XML 地图 | Sitemap 地图