您好,登錄后才能下訂單哦!
小編給大家分享一下HDFS中pid文件存儲在哪,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
1. 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文件存儲在哪”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。