Article Directory
Environmental preparation
I chose centos7 docker pull centos:centos7
, which already comes with python27, so I only need to install jdk8.
Download jdk from Oracle official website , pay attention to choose ARM, x86, x64, mine is x64
docker run -it --name hello_datax centos:centos7
Start the containermkdir modules
Andmkdir softwares
, create a directory to put the compressed package and pressurized folderdocker cp E:\MyWork\MyDevelopmentTools\Java\jdk-8u271-linux-x64.tar.gz hello_datax:/opt/softwares
Pass the compressed package into the containertar -zxvf /opt/softwares/jdk-8u271-linux-x64.tar.gz -C /opt/modules/
Unzip to the specified location- Add environment variables
vi /root/.bashrc
and cannot be placed in /etc/profile, because docker will fail every time the container is restarted
# JAVA_HOME
export JAVA_HOME=/opt/modules/jdk1.8.0_271
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/sbin
java -version
Successfully installed jdk8
Download and install
- Download DataX ,
docker cp E:\MyWork\MyDevelopmentTools\datax.tar.gz hello_datax:/opt/softwares
Copy to containertar -zxvf /opt/softwares/datax.tar.gz -C /opt/modules/
Unzip to the specified locationcd /opt/modules/datax
Enter the directory under datapython ./bin/datax.py ./job/job.json
Execute test job
Solve Chinese Garbled in CentOS7
Write test
vi ./job/stream2stream.json
The same is to create a file under the job in the datax directory, and write the following content
{
"job": {
"content": [
{
"reader": {
"name": "streamreader",
"parameter": {
"sliceRecordCount": 10,
"column": [
{
"type": "long",
"value": "10"
},
{
"type": "string",
"value": "hello,你好,世界-DataX"
}
]
}
},
"writer": {
"name": "streamwriter",
"parameter": {
"encoding": "UTF-8",
"print": true
}
}
}
],
"setting": {
"speed": {
"channel": 5
}
}
}
}
python ./bin/datax.py ./job/stream2stream.json
carried out