Centos7 mysql和sqoop数据迁移
准备工作
SQOOP
MYSQL
链接:https://pan.baidu.com/s/1bmZ1ZOw4NN8_U1N9ZLVcxg 提取码:gykw
一、mysql安装
1.禁用加速组件
vi /etc/yum/pluginconf.d/fastestmirror.conf
由enabled = 1修改为enabled = 0 意思是禁用它
2.禁用插件
vi /etc/yum.conf
修改为plugins=0 不使用插件
3.清除缓存并重新构建yum 源
yum clean all yum clean dbcache yum makecache
4.下载wget
yum -y install wget
5.配置国内镜像源
cd /etc/yum.repos.d mv CentOS-Base.repo CentOS-Base.repo.bak wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
6.下载mysql
hostnamectl 下载网址:https://dev.mysql.com/downloads/ 你可以直接通过我给的mysql来进行安装 上传文件之后 sudo rpm -Uvh mysql80-community-release-el7-7.noarch.rpm sudo yum install mysql-community-server 开启服务 systemctl start mysqld 查看状态 systemctl status mysqld
7.修改默认密码
1.取出默认密码 sudo grep 'temporary password' /var/log/mysqld.log 2.登录 mysql -uroot -p 3.改密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; 4.查看你的密码组 SHOW VARIABLES LIKE 'validate_password%'; 5.修改密码验证等级 set global validate_password.policy=LOW; set global validate_password.length=6; 6.修改我们自己的密码 ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
8.创建远程访问用户
建用户 create user 'root'@'%' identified with mysql_native_password by '123456'; 赋权限 grant all privileges on *.* to 'root'@'%' with grant option; 刷新用户权限 flush privileges;
9.如果有firewalld服务
没开启的话先开启服务 systemctl start firewalld 查看状态 systemctl status firewalld 开启3306端口 firewall-cmd --zone=public --add-port=3306/tcp --permanent 重新载入 firewall-cmd --reload
10.配置utf-8编码
vim /etc/my.cnf #加进去 character_set_server=utf8 init_connect='SET NAMES utf8' 重启服务 systemctl restart mysqld
二、数据迁移
上传文件包 tar -zxvf sqoop-1.4.2.bin__had.gz mv sqoop-1.4.2.bin__hadoop-2.0.0-alpha sqoop rm -rf sqoop-1.4.2.bin__hadoop-2.0.0-alpha sqoop cd conf ls 复制文件 cp sqoop-env-template.sh sqoop-env.sh 配置.sh export HADOOP_HOME=/software/hadoop export HADOOP_COMMON_HOME=/software/hadoop export HADOOP_MAPRED_HOME=/software/hadoop 修改配置文件 vi /etc/profile export SQOOP_HOME=/software/sqoop export PATH=.:$SQOOP_HOME/bin:$PATH source /etc/profile 在这里要注意因为所提供的压缩包里面JAR不全,需要将其放入 mysql-connector-java放在这里
剩下两个放在外面
依据自己的来试一试吧 sqoop export --connect jdbc:mysql://192.168.2.125:3306/sqoop_db --username root --password 123456 --table test --export-dir /test/ --input-fields-terminated-by ','