HDFS HA部署(多机)——配置文件




配置文件内容:

1、hadoop-env.sh

# The java implementation to use.
export JAVA_HOME=/usr/lib/jvm/java-6-sun


# The jsvc implementation to use. Jsvc is required to run secure datanodes.
#export JSVC_HOME=${JSVC_HOME}


export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-"/etc/hadoop"}


# Extra Java CLASSPATH elements.  Automatically insert capacity-scheduler.
for f in $HADOOP_HOME/contrib/capacity-scheduler/*.jar; do
  if [ "$HADOOP_CLASSPATH" ]; then
    export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$f
  else
    export HADOOP_CLASSPATH=$f
  fi
done


# The maximum amount of heap to use, in MB. Default is 1000.
#export HADOOP_HEAPSIZE=
#export HADOOP_NAMENODE_INIT_HEAPSIZE=""


# Extra Java runtime options.  Empty by default.
export HADOOP_OPTS="$HADOOP_OPTS -Djava.net.preferIPv4Stack=true"


# Command specific options appended to HADOOP_OPTS when specified
export HADOOP_NAMENODE_OPTS="-Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER:-INFO,RFAS} -Dhdfs.audit.logger=${HDFS_AUDIT_LOGGER:-INFO,NullAppender} $HADOOP_NAMENODE_OPTS"
export HADOOP_DATANODE_OPTS="-Dhadoop.security.logger=ERROR,RFAS $HADOOP_DATANODE_OPTS"


export HADOOP_SECONDARYNAMENODE_OPTS="-Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER:-INFO,RFAS} -Dhdfs.audit.logger=${HDFS_AUDIT_LOGGER:-INFO,NullAppender} $HADOOP_SECONDARYNAMENODE_OPTS"


# The following applies to multiple commands (fs, dfs, fsck, distcp etc)
export HADOOP_CLIENT_OPTS="-Xmx512m $HADOOP_CLIENT_OPTS"
#HADOOP_JAVA_PLATFORM_OPTS="-XX:-UsePerfData $HADOOP_JAVA_PLATFORM_OPTS"


# On secure datanodes, user to run the datanode as after dropping privileges
export HADOOP_SECURE_DN_USER=${HADOOP_SECURE_DN_USER}


# Where log files are stored.  $HADOOP_HOME/logs by default.
#export HADOOP_LOG_DIR=${HADOOP_LOG_DIR}/$USER


# Where log files are stored in the secure data environment.
export HADOOP_SECURE_DN_LOG_DIR=${HADOOP_LOG_DIR}/${HADOOP_HDFS_USER}


# The directory where pid files are stored. /tmp by default.
# NOTE: this should be set to a directory that can only be written to by 
#       the user that will run the hadoop daemons.  Otherwise there is the
#       potential for a symlink attack.
export HADOOP_PID_DIR=${HADOOP_PID_DIR}
export HADOOP_SECURE_DN_PID_DIR=${HADOOP_PID_DIR}


# A string representing this instance of hadoop. $US

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
HDFSHadoop分布式文件系统,它提供了Java API来进行文件读写操作。在HDFS中,文件被分成多个块并存储在不同的节点上,因此需要使用分布式文件系统的API来进行文件读写操作。 HDFS Java API提供了以下几个类来进行文件读写操作: 1. FileSystem:表示一个文件系统对象,可以通过它来获取文件系统的配置信息、创建文件、删除文件等操作。 2. Path:表示一个文件或目录的路径。 3. FSDataInputStream:表示一个输入流,可以用来读取HDFS中的文件。 4. FSDataOutputStream:表示一个输出流,可以用来向HDFS中写入数据。 下面是一个简单的示例代码,演示如何使用HDFS Java API进行文件读写操作: ```java import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; public class HdfsExample { public static void main(String[] args) throws Exception { // 创建一个Configuration对象,用于获取Hadoop配置信息 Configuration conf = new Configuration(); // 获取HDFS文件系统对象 FileSystem fs = FileSystem.get(conf); // 创建一个Path对象,表示要读取的文件路径 Path inputPath = new Path("/input/test.txt"); // 创建一个FSDataInputStream对象,用于读取文件 FSDataInputStream in = fs.open(inputPath); // 读取文件内容 byte[] buffer = new byte[1024]; int len = in.read(buffer); while (len > 0) { System.out.write(buffer, 0, len); len = in.read(buffer); } // 关闭输入流 in.close(); // 创建一个Path对象,表示要写入的文件路径 Path outputPath = new Path("/output/test.txt"); // 创建一个FSDataOutputStream对象,用于写入文件 FSDataOutputStream out = fs.create(outputPath); // 写入文件内容 String content = "Hello, HDFS!"; out.write(content.getBytes()); // 关闭输出流 out.close(); } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值