static void writeMyID(Properties properties) throws IOException {
    long myId = -1;

    Configuration conf = HBaseConfiguration.create();
    String myAddress = Strings.domainNamePointerToHostName(
      DNS.getDefaultHost(conf.get("hbase.zookeeper.dns.interface", "default"),
        conf.get("hbase.zookeeper.dns.nameserver", "default")));

    List<String> ips = new ArrayList<>();

    // Add what could be the best (configured) match
    ips.add(myAddress.contains(".") ? myAddress : StringUtils.simpleHostname(myAddress));

    // For all nics get all hostnames and IPs
    Enumeration<?> nics = NetworkInterface.getNetworkInterfaces();
    while (nics.hasMoreElements()) {
      Enumeration<?> rawAdrs = ((NetworkInterface) nics.nextElement()).getInetAddresses();
      while (rawAdrs.hasMoreElements()) {
        InetAddress inet = (InetAddress) rawAdrs.nextElement();
        ips.add(StringUtils.simpleHostname(inet.getHostName()));
        ips.add(inet.getHostAddress());
      }
    }

    for (Entry<Object, Object> entry : properties.entrySet()) {
      String key = entry.getKey().toString().trim();
      String value = entry.getValue().toString().trim();
      if (key.startsWith("server.")) {
        int dot = key.indexOf('.');
        long id = Long.parseLong(key.substring(dot + 1));
        String[] parts = value.split(":");
        String address = parts[0];
        if (addressIsLocalHost(address) || ips.contains(address)) {
          myId = id;
          break;
        }
      }
    }

    // Set the max session timeout from the provided client-side timeout
    properties.setProperty("maxSessionTimeout", conf.get(HConstants.ZK_SESSION_TIMEOUT,
      Integer.toString(HConstants.DEFAULT_ZK_SESSION_TIMEOUT)));

    if (myId == -1) {
      throw new IOException(
        "Could not find my address: " + myAddress + " in list of ZooKeeper quorum servers");
    }

    String dataDirStr = properties.get("dataDir").toString().trim();
    File dataDir = new File(dataDirStr);
    if (!dataDir.isDirectory()) {
      if (!dataDir.mkdirs()) {
        throw new IOException("Unable to create data dir " + dataDir);
      }
    }

    File myIdFile = new File(dataDir, "myid");
    PrintWriter w = new PrintWriter(myIdFile, StandardCharsets.UTF_8.name());
    w.println(myId);
    w.close();
  }
Start and schedule the purge task autopurge.purgeInterval is 0 by default,so in fact the
DatadirCleanupManager task will not be started to clean the logs by default. Config is
recommended only for standalone server.
hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/HQuorumPeer.java