小编给大家分享一下HDFS中pid文件存储在哪,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
pid文件默认存储在/tmp目录中,pid文件的内容为进程号
[hadoop@hadoop002 ~]$ cd /tmp
[hadoop@hadoop002 tmp]$ pwd
/tmp
[hadoop@hadoop002 tmp]$ ll
total 132
drwxrwxr-x. 4 hadoop hadoop 4096 May 22 12:46 hadoop-hadoop
-rw-rw-r--. 1 hadoop hadoop 5 May 23 11:00 hadoop-hadoop-datanode.pid
-rw-rw-r--. 1 hadoop hadoop 5 May 23 11:00 hadoop-hadoop-namenode.pid
-rw-rw-r--. 1 hadoop hadoop 5 May 23 11:00 hadoop-hadoop-secondarynamenode.pid
drwxr-xr-x. 2 hadoop hadoop 4096 May 23 13:17 hsperfdata_hadoop
drwxrwxr-x. 3 hadoop hadoop 4096 May 23 11:00 Jetty_0_0_0_0_50070_hdfs____w2cu08
drwxrwxr-x. 4 hadoop hadoop 4096 May 23 11:05 Jetty_0_0_0_0_8042_node____19tj0x
drwxrwxr-x. 3 hadoop hadoop 4096 May 23 11:01 Jetty_hadoop002_50090_secondary____.xoi5bj
drwxrwxr-x. 4 hadoop hadoop 4096 May 23 11:05 Jetty_hadoop002_8088_cluster____jy43fd
drwxrwxr-x. 3 hadoop hadoop 4096 May 22 12:43 Jetty_localhost_33164_datanode____.86mfre
drwxrwxr-x. 3 hadoop hadoop 4096 May 21 16:31 Jetty_localhost_34452_datanode____57ccs7
drwxrwxr-x. 3 hadoop hadoop 4096 May 22 13:28 Jetty_localhost_35801_datanode____1320ou
drwxrwxr-x. 3 hadoop hadoop 4096 May 22 11:14 Jetty_localhost_41633_datanode____.reuty8
drwxrwxr-x. 3 hadoop hadoop 4096 May 21 17:17 Jetty_localhost_43514_datanode____do382o
drwxrwxr-x. 3 hadoop hadoop 4096 May 23 11:00 Jetty_localhost_54437_datanode____.slqxa8
drwxrwxr-x. 3 hadoop hadoop 4096 May 22 12:24 Jetty_localhost_55741_datanode____.cj1ayt
drwxrwxr-x. 3 hadoop hadoop 4096 May 22 12:18 Jetty_localhost_55901_datanode____.91pz3
drwxrwxr-x. 3 hadoop hadoop 4096 May 22 13:36 Jetty_localhost_59457_datanode____.gif7tz
drwxrwxr-x. 3 hadoop hadoop 4096 May 22 11:28 Jetty_localhost_59865_datanode____dj2ere
drwx------. 2 root root 4096 May 23 10:55 keyring-dOEsWO
drwx------. 2 root root 4096 Apr 21 02:20 keyring-fR5f6f
drwx------. 2 root root 4096 Apr 21 02:13 keyring-jZCkKD
drwx------. 2 root root 4096 Apr 20 20:07 keyring-RWPvsu
drwx------. 2 root root 4096 May 21 16:18 keyring-Rythlk
drwx------. 2 root root 4096 Apr 25 14:13 keyring-zrMZWC
srwxrwxrwx. 1 mysql mysql 0 Apr 25 14:17 mysql.sock
drwx------. 2 gdm gdm 4096 May 23 10:55 orbit-gdm
drwx------. 2 root root 4096 May 23 10:56 orbit-root
drwx------. 2 gdm gdm 4096 May 23 10:56 pulse-aQWRK1os9K8n
drwx------. 2 root root 4096 May 23 10:55 pulse-Zd56fb7r0ESa
drwx------. 2 root root 4096 May 23 10:55 virtual-root.OV7MJo
drwx------. 2 root root 4096 May 21 16:18 virtual-root.q1Shey
-rw-rw-r--. 1 hadoop hadoop 5 May 23 11:05 yarn-hadoop-nodemanager.pid
-rw-rw-r--. 1 hadoop hadoop 5 May 23 11:05 yarn-hadoop-resourcemanager.pid
[hadoop@hadoop002 tmp]$
[hadoop@hadoop002 tmp]$ cat hadoop-hadoop-datanode.pid
2619
[hadoop@hadoop002 tmp]$
2. 修改HADOOP_PID_DIR文件的路径
正常在生产上 pid文件是不能放在/tmp目录的,因为/tmp下面的pid文件一个月会自动删除一次。所以我们把tmp目录建在/data/hadoop目录下面:
2.1 查看 /opt/software/hadoop/sbin/hadoop-daemon.sh 文件,发现hadoop查找pid是根据 HADOOP_PID_DIR 环境变量获取的。
[hadoop@hadoop002 tmp]$ cat /opt/software/hadoop/sbin/hadoop-daemon.sh |grep pid
# HADOOP_PID_DIR The pid files are stored. /tmp by default.
pid=$HADOOP_PID_DIR/hadoop-$HADOOP_IDENT_STRING-$command.pid
if [ -f $pid ]; then
if kill -0 `cat $pid` > /dev/null 2>&1; then
echo $command running as process `cat $pid`. Stop it first.
echo $! > $pid
if [ -f $pid ]; then
TARGET_PID=`cat $pid`
rm -f $pid
[hadoop@hadoop002 tmp]$
2.2 以root创建/data/hadoop/tem 目录
[hadoop@hadoop002 hadoop]$ exit #退出hadoop
logout
[root@hadoop002 software]# cd /
[root@hadoop002 /]#
[root@hadoop002 /]# mkdir data
[root@hadoop002 /]# cd data/
[root@hadoop002 data]# mkdir hadoop
[root@hadoop002 data]# cd hadoop/
[root@hadoop002 hadoop]# mkdir tmp
[root@hadoop002 hadoop]# ll
total 4
drwxr-xr-x. 2 root root 4096 May 23 14:11 tmp
2.3 /data/hadoop/tem目录授权
[root@hadoop002 hadoop]# chmod 777 tmp
[root@hadoop002 hadoop]# ll
total 4
drwxrwxrwx. 2 root root 4096 May 23 14:11 tmp
2.4 修改 /opt/software/hadoop/etc/hadoop/hadoop-env.sh文件里面HADOOP_PID_DIR的环境变量
[hadoop@hadoop002 hadoop]$ pwd
/opt/software/hadoop/etc/hadoop
[hadoop@hadoop002 hadoop]$ vi hadoop-env.sh
#export HADOOP_PID_DIR=${HADOOP_PID_DIR} #注释这行
export HADOOP_PID_DIR=/data/hadoop/tmp #添加新路径
编辑好后,保存退出。
2.5 重启 sbin/start-dfs.sh
#先停止hadoop服务
[hadoop@hadoop002 sbin]$ sh stop-dfs.sh
Stopping namenodes on [hadoop002]
hadoop002: no namenode to stop
hadoop002: no datanode to stop
Stopping secondary namenodes [hadoop002]
hadoop002: no secondarynamenode to stop
#再启动hadoop服务
[hadoop@hadoop002 sbin]$ sh start-dfs.sh
Starting namenodes on [hadoop002]
hadoop002: starting namenode, logging to /opt/software/hadoop-2.8.1/logs/hadoop-hadoop-namenode-hadoop002.out
hadoop002: starting datanode, logging to /opt/software/hadoop-2.8.1/logs/hadoop-hadoop-datanode-hadoop002.out
Starting secondary namenodes [hadoop002]
hadoop002: starting secondarynamenode, logging to /opt/software/hadoop-2.8.1/logs/hadoop-hadoop- secondarynamenode-hadoop002.out
[hadoop@hadoop002 sbin]$
#重启之前,tmp目录下没有文件
[root@hadoop002 ~]# cd /data/hadoop/tmp/
[root@hadoop002 tmp]# ll
total 0
#重启之后,tmp目录下生成了pid文件
[root@hadoop002 tmp]# ll
total 12
-rw-rw-r--. 1 hadoop hadoop 5 May 23 14:17 hadoop-hadoop-datanode.pid
-rw-rw-r--. 1 hadoop hadoop 5 May 23 14:17 hadoop-hadoop-namenode.pid
-rw-rw-r--. 1 hadoop hadoop 5 May 23 14:17 hadoop-hadoop-secondarynamenode.pid
以上是“HDFS中pid文件存储在哪”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网行业资讯频道!