Tag Archives: Hadoop

Solution of server not running yetexception in HBase

I encountered a server not running yetexception error while working today. The symptom is that it is normal to enter HBase shell, but this error will be thrown when executing any instruction.

There is no error message when checking the log. At first I thought there was HBase process not up, but the JPS command showed that all started.

It’s a little tricky.. Because the test server was restarted a few days ago, and then I did some other work on it. So it is suspected that the problem is port occupancy.. However.. Neither..

I had no choice, so I moved out the ultimate solution: reloading Hadoop and HBase. After the official configuration is completed. HBase is miraculously good..

I once suspected that it was my configuration.. However.. Neither..

Finally found a solution on the Internet, because Hadoop is in a safe mode. So HBase operation will be abnormal. I’m not sure how it works. The solution is to manually exit safe mode

./hadoop dfsadmin -safemode leave 

Then restart HBase and solve the problem

Common errors and solutions in MapReduce stage

1) Package guide is error prone. Especially text and combinetextinputformat. 2) The first input parameter in mapper must be longwritable or nullwritable, not intwritable.
the error reported is a type conversion exception.
3) java.lang.Exception : java.io.IOException : Legal partition for 13926435656 (4), indicating that partition
is not matched with the number of reducetask, so adjust the number of reducetask. 4) If the number of partitions is not 1, but reductask is 1, do you want to execute the partitioning process. The answer is: no partitioning.
Because in the source code of maptask, the premise of partition execution is to determine whether the number of reducenums is greater than 1. No more than 1 is definitely not implemented.
5) import the jar package compiled in Windows environment into linux environment to run,
Hadoop jar wc.jar com.atguigu.mapreduce . wordcount.WordCountDriver /User/atguigu/
/user/atguigu/output
reports the following error:
exception in thread “main” java.lang.UnsupportedClassVersionError :
com/atguigu/mapreduce/wordcount/WordCountDriver : Unsupported major.minor Version 52.0
the reason is that jdk1.7 is used in Windows environment and JDK1.8 is used in Linux environment.
Solution: unified JDK version.
6) cache pd.txt In the case of small files, the report cannot be found pd.txt File
reason: most of them are path writing errors. There is also to check pd.txt.txt It’s a matter of time. There are also some computers that write relative paths
that cannot be found pd.txt , which can be changed to absolute path. 7) Report type conversion exception.
It’s usually a writing error when setting the map output and final output in the driver function.
If the key output from map is not sorted, an exception of type conversion will be reported.
8) running in cluster wc.jar An error occurred when unable to get the input file.
Reason: the input file of wordcount case cannot be placed in the root directory of HDFS cluster.
9) the following related exceptions appear
exception in thread “main” java.lang.UnsatisfiedLinkError :
org.apache.hadoop . io.nativeio.NativeIO

W

i

n

d

o

w

s

.

a

c

c

e

s

s

0

(

L

j

a

v

a

/

l

a

n

g

/

S

t

r

i

n

g

;

I

)

Z

a

t

o

r

g

.

a

p

a

c

h

e

.

h

a

d

o

o

p

.

i

o

.

n

a

t

i

v

e

i

o

.

N

a

t

i

v

e

I

O

Windows.access0 (Ljava/lang/String;I)Z at org.apache.hadoop . io.nativeio.NativeIO

Windows.access0 (Ljava/lang/String; I) Zatorg.apache.hadoop . io.nativeio.NativeIOWindows .access0(Native Method)
at org.apache.hadoop . io.nativeio.NativeIO $ Windows.access ( NativeIO.java:609 )
at org.apache.hadoop . fs.FileUtil.canRead ( FileUtil.java:977 )
java.io.IOException : Could not locate executable null\bin\ winutils.exe in the Hadoop binaries.
at org.apache.hadoop . util.Shell.getQualifiedBinPath ( Shell.java:356 )
at org.apache.hadoop . util.Shell.getWinUtilsPath ( Shell.java:371 )
at org.apache.hadoop . util.Shell .( Shell.java:364 )
solution: copy hadoop.dll File to the windows directory C::?Windows?System32. Some students need to modify the Hadoop source code.
Scheme 2: create the following package name and NativeIO.java Copy to the package name
10) when customizing the output format, note that the close method in recordwirter must close the stream resource. Otherwise, the data in the output file is empty.
@Override
public void close(TaskAttemptContext context) throws IOException,
InterruptedException {
if (atguigufos != null) {
atguigufos.close ();
}
if (otherfos != null) {
otherfos.close ();
} }

Solve the problem of unable to start under zookeeper Linux

When installing zookeeper under Linux, the following error occurs:

[ hadoop@hadoop-master bin]$ ./ zkServer.sh start

JMX disabled by user request

Using config: /opt/zookeeper-3.3.3/bin/../conf/ zoo.cfg

Starting zookeeper …

STARTED

[ hadoop@hadoop-master bin]$ 2011-07-05 10:33:57,587 – INFO [ main:QuorumPeerConfig@90 ] – Reading configuration from: /opt/zookeeper-3.3.3/bin/../conf/ zoo.cfg

2011-07-05 10:33:57,596 – WARN [ main:QuorumPeerMain@105 ] – Either no config or no quorum defined in config, running in standalone mode

Exception in thread “main” java.lang.NoSuchMethodError : method java.lang.management . ManagementFactory.getPlatformMBeanServer with signature () Ljavax.management.MBeanServer ; was not found.

at org.apache.zookeeper . jmx.ManagedUtil.registerLog4jMBeans ( ManagedUtil.java:48 )

at org.apache.zookeeper . server.ZooKeeperServerMain.initializeAndRun ( ZooKeeperServerMain.java:73 )

at org.apache.zookeeper . server.ZooKeeperServerMain.main ( ZooKeeperServerMain.java:51 )

at org.apache.zookeeper . server.quorum.QuorumPeerMain .initializeAndRun( QuorumPeerMain.java:108 )

at org.apache.zookeeper . server.quorum.QuorumPeerMain .main( QuorumPeerMain.java:76 )

Found, not found java.lang.management The next way. If you are using the standard JDK, such an error should not occur. So check it out zkServer.sh Script. It is found that the script to start the Java program is as follows:

Bash code

java “- Dzookeeper.log.dir= ${ZOO_ LOG_ DIR}” “- Dzookeeper.root.logger= ${ZOO_ LOG4J_ PROP}” \

-cp “$CLASSPATH” $JVMFLAGS $ZOOMAIN “$ZOOCFG” &

Executing Java command directly under Linux, the output is as follows:

Bash code

[ hadoop@hadoop-master bin]$ java

Usage: gij [OPTION] … CLASS [ARGS] …

to invoke CLASS.main , or

gij -jar [OPTION] … JARFILE [ARGS] …

to execute a jar file

Try `gij –help’ for more information.

Obviously, zkServer.sh Incorrect java used. Use the Java of Gij. To solve this problem, simply change the script to:

Bash code

$JAVA_ HOME/bin/java “- Dzookeeper.log.dir= ${ZOO_ LOG_ DIR}” “- Dzookeeper.root.logger= ${ZOO_ LOG4J_ PROP}” \

-cp “$CLASSPATH” $JVMFLAGS $ZOOMAIN “$ZOOCFG” &

After this modification, it can run normally.

It is mainly to replace the system’s own Java path, so that he can identify his own installed Java (it’s better to delete the system’s own JDK before installing software)

Starting zookeeper to report an error already running as process

An error was reported when starting zookeeper today:

[ root@hadoop-one zookeeper-3.4.5]# bin/ zkServer.sh start
JMX enabled by default
Using config: /root/zookeeper/zookeeper-3.4.5/bin/../conf/ zoo.cfg
Starting zookeeper … already running as process 947..

Looking at the next 947 process, it is found that it is a Linux system process and should not conflict. I also checked several port numbers that zookeeper will use, and none of them is occupied.

Then open bin/ zkServer.sh Start the script and search the place where the above sentence will be thrown:

    echo  -n "Starting zookeeper ... "
    if [ -f $ZOOPIDFILE ]; then
      if kill -0 `cat $ZOOPIDFILE` > /dev/null 2>&1; then
         echo $command already running as process `cat $ZOOPIDFILE`.
         exit 0
      fi
    fi

When you see $zoopidfile, you think that the process ID file already exists, causing it to fail to start.

Go to dataDir and have a look. Sure enough, there is a zookeeper_ server.pid The last revision was a few days ago. Because the machine was shut down due to abnormal power failure last time, it probably caused the residue of this PID file.

Delete, restart, OK.

Summary of Hadoop error handling methods

1. Error message:

org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /home/maclaren/data/hadoopTempDir/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.
        at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:290)
        at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:87)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:311)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:292)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:201)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:279)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:956)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:965)

>
Change the hadoop. TMP. Dir value of core-site. XML, or make sure to format the NameNode the first time you initialize it, otherwise an error will be reported.
So, be sure to clear all contents of the directory specified by hadoop.temp.dir, and then run
sh hadoop namenode-format

2. Error message:

org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Not able to place enough replicas, still in need of 1

>
The size of dfs.block.size must be set to the right size. I ran it on my laptop and set it to 1024. Modify the HDFS – core. XML

<property>
<name>dfs.block.size</name>
<value>1024</value>
</property>

3. Error message:

org.apache.hadoop.ipc.RPC$VersionMismatch: Protocol org.apache.hadoop.hdfs.protocol.ClientProtocol version mismatch.

>

Replace hadoop-core-0.20-append-r1056497.jar in $HBASE_HOME/lib with hadoop-0.20.2-core-jar

4. Error message:

Caused by: java.io.IOException: Call to /192.168.1.147:9000 failed on local exception: java.io.EOFException
	at org.apache.hadoop.ipc.Client.wrapException(Client.java:1107)
	at org.apache.hadoop.ipc.Client.call(Client.java:1075)
	at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:225)
	at $Proxy8.getProtocolVersion(Unknown Source)
	at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:396)
	at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:379)
	at org.apache.hadoop.hdfs.DFSClient.createRPCNamenode(DFSClient.java:119)
	at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:238)
	at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:203)
	at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:89)
	at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1386)
	at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:66)
	at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1404)
	at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:254)
	at org.springframework.data.hadoop.fs.HdfsResourceLoader.<init>(HdfsResourceLoader.java:82)
	... 21 more

>

The client Hadoop JAR is not the same as the server JAR. Hdfs-site.xml
Because Eclipse uses Hadoop plug-in to submit jobs, will default to DrWho identity to write the job to the HDFS file system, the corresponding is HDFS /user/hadoop, because DrWho users do not have access to Hadoop directory, so the exception occurs. $hadoop fs-chmod 777 /user/hadoop
$hadoop fs-chmod 777 /user/hadoop

Ganglia cannot access: you don’t have permission to access / ganglia on this server

Ganglia cannot access: You don’t have permission to access/Ganglia on this server


requires all granted
insert image description in the flume directory
[root@centos04 flume]# vim /etc/httpd/conf.d/ganglia.conf
Save exit Esc -& GT; :wq!
then restart it:
sudo service HTTPD restart
sudo service gmetad restart
sudo service gmond restart
Visit http://192.168.56.136/ganglia again, success

Hadoop download and install cloudera virtual machine (VM)

1.  Install VirtualBox.  Go to https://www.virtualbox.org/wiki/Downloads to download and install VirtualBox for your computer. For Windows, select the link “VirtualBox 5.1.4 for Windows hosts x86/amd64”.
2.  Download the Cloudera VM.  Download the Cloudera VM fromhttps://downloads.cloudera.com/demo_vm/virtualbox/cloudera-quickstart-vm-5.4.2-0-virtualbox.zip. The VM is over 4GB, so will take some time to download.
3.  Unzip the Cloudera VM:
Right-click cloudera-quickstart-vm-5.4.2-0-virtualbox.zip and select “Extract All…”
4.  Start VirtualBox.
5.  Begin importing. Import the VM by going to File -> Import Appliance

6.  Click the Folder icon.


7.  Select the cloudera-quickstart-vm-5.4.2-0-virtualbox. ovf from the Folder where you unzipped the VirtualBox VM and click Open.

8.  Click Next to proceed.

9.  Click Import.

10.  The virtual machine image will be imported.  This can take several minutes.

11.  Launch Cloudera VM.  When the importing is finished, the quickstart-vm-5.4.2-0 VM will appear on the left in the VirtualBox window. Select it and click the Start button to launch the VM.

12.  Cloudera VM booting.  It will take several minutes for the Virtual Machine to start. The booting process takes a long time since many Hadoop tools are started.

13.  The Cloudera VM desktop.  Once the booting process is complete, the desktop will appear with a browser.

Why can’t Scala shell enter Q to exit

In general, most shell command Windows, such as Python, Scala, some non-relational databases, etc., can be logged out by CTRL + D or CTRL + Z, CTRL + C, which is the most effective method.
If you don’t use the above mandatory exit command, you can also use Quit, exit, etc. However, when I use scala2.12 version, I find that Quit, exit, and Q are all difficult to make. After looking up the data, it can be seen that it is new
Version Scala’s exit command needs to be preceded by a ‘:’, i.e. : Q, : Quit, or sys.exit.
 
Original: http://www.cnblogs.com/mszw/p/6931696.html

Solutions to the problem of “there are stopped jobs” in Linux

Typing exit or logout in a Linux shell sometimes says “There are stopped Jobs” because pressing Ctrl+Z caused the program or process to suspend. It can be enabled by command typing or run in the background.

Enter the command JOBS in the shell to see a list of stopped processes
Enter the command JOBS-l to display a detailed list of stopped processes
A stopped process can be killed or activated with the following command:
Kill: Kill %1 (%1 is the process number of the job to be killed)
Activation: fg %1 (%1 is the process number of the job to be activated)
Fg represents foreground, which wakens the process of suspended

Introduction of Hadoop HDFS and the use of basic client commands

HDFS basic functions
Basic function
has the basic operation function of file system;

file blocks for unit store the data in different machine disk
the default 128 MB large data slices, 3 copies of the
the NameNode master node: virtual directory maintenance, management of child nodes (Secondly the NameNode) storage resources scheduling, and the client interaction
the DataNode from multiple nodes: save the data, register when they start with the master node, the master node can know the information of it, convenient later call
(DataNode from cluster nodes to meet the basic conditions: Linux01, 02 01… The IP domain name between the secret set. Because nodes communicate with each other)
Linux01:NameNode DataNode
Linux02:DataNode
Linux03:DataNode
Use of client base commands

    location bin/HDFS DFS among them are some commands to upload: HDFS DFS – put./to/(the front is a local path, followed by HDFS path) directory: HDFS DFS – ls/(files in the directory view points, and other road king in the same way) to create folders: HDFS DFS – mkdir/data (create the folder in the root directory) to check the file content: HDFS DFS – cat file path from HDFS download: HDFS DFS get /data/1.txt/(HDFS path in front followed by local path)

Linux Mint installs Hadoop environment

Using Hadoop-Language-2.8.4.jar, the command is as follows: ./share/hadoop/tools/lib/hadoop – streaming – 2.8.4. Jar – input/Mr – – the output/input/* Mr – output – the file/home/LZH/external/Mapper. Py – Mapper ‘Mapper. Py’ – the file/home/LZH/external/Reducer. Py – Reducer ‘Reducer.py’
Problem 1: bash:/share/hadoop/tools/lib/hadoop – streaming – 2.8.4. Jar: Permission denied
Solution: expand the file permissions, chmod -r 777/share/hadoop/tools/lib/hadoop – streaming – 2.8.4. Jar
Invalid File (bad Magic Number): Exec format Error
Solution: I was careless, and the command omitted the hadoop JAR in the front, and added it, namely: Hadoop jar./share/hadoop/tools/lib/hadoop – streaming – 2.8.4. Jar – input/Mr – – the output/input/* Mr – output – the file/home/LZH/external/Mapper. Py – Mapper ‘Mapper. Py’ – the file/home/LZH/external/Reducer. Py – Reducer ‘Reducer.py’
Problem 3 May be encountered: Mapper.py and reduc. py have to be turned to executable. Chmod +x filename modification permission is executable
When writing MapReduce in Python, it’s a good idea to start with: #! The /usr/bin/env python statement
And finally it works

Hadoop worked fine, but for other reasons, I pressed the power button to force a shutdown, huh?After starting start-up, start start-up all-sh, and then JPS check that there is a missing Datanode in Hadoop, FS-LS/Input, it is found that it cannot connect to 127.0.0.1. Restart hadoop again when starting Hadoop, it is found that it can also create folders by running the command Hadoop, FS-LS/Input, but there is a problem 3 when putting file: Put the File/input/inputFile. TXT. _COPYING_ could only be replicated to 0 home nodes minReplication (= 1). There are 0 datanode (s) running and no node (s) are excluded in this operation.
At this point, stop-all.sh discovers no Proxyserver to stop and no Datanode to stop. (pro test the first solution is successful)
Reason 1: Every time the Namenode Format creates a namenodeId again, while under Hadoop.tmp. dir contains the ID generated by the last format. The Namenode format cleans up the data under the Namenode, but does not clean up the data under the Datanode, which causes failure at startup.
Here are two solutions:

rm -rf /opt/hadoop/ DFS /name/*
rm -rf/rf /hadoop/ DFS /name/*
remove the contents of the “DFS. Datand. data.dir”
rm-rf /opt/hadoop/ DFS /data/*
2) delete files beginning with “hadoop” under “hadoop.tmp.dir”
rm-rf /apt/hadoop/ TMP /hadoop*
3) reformat hadoop
hadoop namenode-format
4) start hadoop
The disadvantage of the start-all-sh
scheme is that all the important data on the original cluster is gone. Therefore, the second scheme is recommended:
1) modify the namespaceID of each Slave so that it is consistent with the Master’s namespaceID.
or
2) modify the Master’s namespaceID to match the Slave’s namespaceID.
Master “namespaceID” located in the “/ opt/hadoop/DFS/name/current/VERSION” file, the Slave “namespaceID” is located in the “//opt/hadoop/DFS/data/current/VERSION” file.

reason 2: the problem is that hadoop USES the mapred and DFS process Numbers on the datanode when it stops. While the default process number is saved under/TMP, Linux defaults to delete files in this directory every once in a while (usually a month or 7 days). Therefore, after deleting the two files of Hadoop-Hadoop-Jobtracker. pid and Hadoop-Hadoop-Namenode. Pid, the Namenode will naturally not find the two processes on the Datanode.
configuring export HADOOP_PID_DIR in the configuration file hadoop_env.sh solves this problem.
In the configuration file, the default path for HADOOP_PID_DIR is “/var/hadoop/pids”, we will manually create a “Hadoop” folder in the “/var” directory, if it already exists, do not create it, remember to chown the permissions to hadoop users. Then kill the process of the Datanode and Tasktracker in Slave (kill -9 process number), restart -all.sh and stop-all.sh without a “No Datanode to stop”, indicating that the problem has been solved.

Run.sh: Bash:./run.sh: Permission denied
Solutions:
Use the command chmod to modify the directory. Sh permissions can be
Such as chmod u + x *. Sh
A Container killed on requisition.exit code is 143.
I just ran out of memory. There are two ways to solve it perfectly:
1. Several more Mapper and Reducer are specified during the runtime:
-d mapred.map.tasks=10 \ #command [genericOptions] [commandOptions]
-d mapred.reduce.tasks=10 \ # note that -d is genericOptions,
before the other parameters
– numReduceTasks 10
2. Modify yarn-site.xml to add the following attributes:

<property>
   <name>yarn.nodemanager.vmem-check-enabled</name>
   <value>false</value>
   <description>Whether virtual memory limits will be enforced for containers</description>
</property>

<property>
   <name>yarn.nodemanager.vmem-pmem-ratio</name>
   <value>4</value>
   <description>Ratio between virtual memory to physical memory when setting memory limits for containers</description>
</property> 

Reference:

[Python] Implement Hadoop MapReduce program in Python: calculate the mean and variance of a set of data

PySpark ERROR Shell: Failed to locate the winutils binary in the hadoop binary path

after terminal input PySpark, the following error occurs:

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path
java.io.IOException: Could not locate executable C:\ hadox-3.1.2 \bin\winutils. Exe in the hadoop binaries.

problem analysis: the winutils.exe file is missing in the hadoop/bin folder.

solution:

1. Check the hadoop/bin folder, and find that there is really no winutils.exe file.

my Hadoop version is 3.1.2 binary, downloaded from the website: https://hadoop.apache.org/releases.html.

2, download the file winutils.exe. Download address is https://github.com/steveloughran/winutils.

my Hadoop version is 3.1.2. Select the file winutils. Exe in hadoop-3.0.0/bin in the webpage and download it and put it into the Hadoop /bin folder.

3, re-enter pyspark on the terminal. Success!