1

Zookeeper で非常に厄介な問題が発生しているようです。独自の認証プロバイダーを作成してコンパイルすることができました。このプロバイダーは、次のように構成で設定されます。

authProvider.1=io.whatever.zookeeper.auth.ChefZkAuth

ルート znode に ACL を設定することができましたが、認証なしではクラスターに何も表示されません。これが私が望んでいたことです。私の問題は、認証しようとすると、次のようになることです。

2013-06-19 19:38:50,928 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@863] - got auth packet /127.0.0.1:45518
2013-06-19 19:38:50,934 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ChefZkAuth@21] -  >>>>>>>>>>>>>>>>>> /127.0.0.1 is connecting...
2013-06-19 19:38:50,934 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@873] - Caught runtime exception from AuthenticationProvider: chef due to java.lang.UnsupportedOperationException
2013-06-19 19:38:50,935 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@883] - Authentication failed for scheme: chef

そのため、私のプロバイダーが呼び出されているようです。しかし、何らかの理由で、起動時に Zookeeper によってロードされていません。これは、開始時にZookeeperが私に言っていることです:

radek@radek-virtual-machine:/opt/zookeeper/current/bin$ ./zkServer.sh start-foreground
JMX enabled by default
Using config: /opt/zookeeper/current/bin/../conf/zoo.cfg
2013-06-19 19:53:24,421 [myid:] - INFO  [main:QuorumPeerConfig@101] - Reading configuration from: /opt/zookeeper/current/bin/../conf/zoo.cfg
2013-06-19 19:53:24,428 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2013-06-19 19:53:24,429 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2013-06-19 19:53:24,430 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2013-06-19 19:53:24,430 [myid:] - WARN  [main:QuorumPeerMain@113] - Either no config or no quorum defined in config, running  in standalone mode
2013-06-19 19:53:24,452 [myid:] - INFO  [main:QuorumPeerConfig@101] - Reading configuration from: /opt/zookeeper/current/bin/../conf/zoo.cfg
2013-06-19 19:53:24,463 [myid:] - INFO  [main:ZooKeeperServerMain@95] - Starting server
2013-06-19 19:53:24,511 [myid:] - INFO  [main:Environment@100] - Server environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
2013-06-19 19:53:24,512 [myid:] - INFO  [main:Environment@100] - Server environment:host.name=radek-virtual-machine
2013-06-19 19:53:24,513 [myid:] - INFO  [main:Environment@100] - Server environment:java.version=1.7.0_21
2013-06-19 19:53:24,513 [myid:] - INFO  [main:Environment@100] - Server environment:java.vendor=Oracle Corporation
2013-06-19 19:53:24,514 [myid:] - INFO  [main:Environment@100] - Server environment:java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
2013-06-19 19:53:24,515 [myid:] - INFO  [main:Environment@100] - Server environment:java.class.path=/opt/zookeeper/current/bin/../build/classes:/opt/zookeeper/current/bin/../build/lib/*.jar:/opt/zookeeper/current/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper/current/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper/current/bin/../lib/netty-3.2.2.Final.jar:/opt/zookeeper/current/bin/../lib/log4j-1.2.15.jar:/opt/zookeeper/current/bin/../lib/jline-0.9.94.jar:/opt/zookeeper/current/bin/../lib/ChefZkAuth-1.0-SNAPSHOT.jar:/opt/zookeeper/current/bin/../zookeeper-3.4.5.jar:/opt/zookeeper/current/bin/../src/java/lib/*.jar:/opt/zookeeper/current/bin/../conf:
2013-06-19 19:53:24,515 [myid:] - INFO  [main:Environment@100] - Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
2013-06-19 19:53:24,516 [myid:] - INFO  [main:Environment@100] - Server environment:java.io.tmpdir=/tmp
2013-06-19 19:53:24,520 [myid:] - INFO  [main:Environment@100] - Server environment:java.compiler=<NA>
2013-06-19 19:53:24,521 [myid:] - INFO  [main:Environment@100] - Server environment:os.name=Linux
2013-06-19 19:53:24,521 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=amd64
2013-06-19 19:53:24,522 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=3.8.0-19-generic
2013-06-19 19:53:24,523 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=radek
2013-06-19 19:53:24,524 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=/home/radek
2013-06-19 19:53:24,525 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=/opt/zookeeper/zookeeper-3.4.5/bin
2013-06-19 19:53:24,548 [myid:] - INFO  [main:ZooKeeperServer@726] - tickTime set to 1000
2013-06-19 19:53:24,550 [myid:] - INFO  [main:ZooKeeperServer@735] - minSessionTimeout set to -1
2013-06-19 19:53:24,551 [myid:] - INFO  [main:ZooKeeperServer@744] - maxSessionTimeout set to -1
2013-06-19 19:53:24,636 [myid:] - INFO  [main:Login@293] - successfully logged in.
2013-06-19 19:53:24,654 [myid:] - INFO  [main:NIOServerCnxnFactory@94] - binding to port 0.0.0.0/0.0.0.0:2181
2013-06-19 19:53:24,692 [myid:] - INFO  [main:FileSnap@83] - Reading snapshot /tmp/zookeeper/version-2/snapshot.14
2013-06-19 19:53:24,720 [myid:] - INFO  [main:FileTxnSnapLog@240] - Snapshotting: 0x14 to /tmp/zookeeper/version-2/snapshot.14
2013-06-19 19:53:26,689 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@197] - Accepted socket connection from /127.0.0.1:45648
2013-06-19 19:53:26,789 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@793] - Connection request from old client /127.0.0.1:45648; will be dropped if server is in r-o mode
2013-06-19 19:53:26,791 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@832] - Client attempting to renew session 0x13f5d7d94460003 at /127.0.0.1:45648
2013-06-19 19:53:26,797 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@595] - Established session 0x13f5d7d94460003 with negotiated timeout 10000 for client /127.0.0.1:45648

そして、これが私のプロバイダーです:

package io.whatever.zookeeper.auth;

import org.apache.log4j.Logger;
import org.apache.zookeeper.data.Id;
import org.apache.zookeeper.server.ServerCnxn;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.server.auth.AuthenticationProvider;

public class ChefZkAuth implements AuthenticationProvider {

    private static Logger LOGGER = Logger.getLogger(ChefZkAuth.class);

    public String getScheme() {
        return "chef";
    }

    public KeeperException.Code
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
    {
        String id = cnxn.getRemoteSocketAddress().getAddress().toString();
        LOGGER.info(" >>>>>>>>>>>>>>>>>> " + id + " is connecting...");
        cnxn.getAuthInfo().add(new Id(getScheme(), id));
        return KeeperException.Code.OK;
    }

    public boolean matches(String id, String aclExpr) {
        return true;
    }

    public boolean isAuthenticated() {
        return true;
    }

    public boolean isValid(String id) {
        return true;
    }
}

ChefZkAuth-1.0-SNAPSHOT.jarクラスパスにあります。認証プロセス中に使用されていますが、登録されていません。

私は何を間違っていますか?サーバーの起動中にプロバイダーがロードされない理由は何ですか? Zookeeper 3.4.5 を使用しています。

4

1 に答える 1

0

プロバイダーからこの行を削除すると、どこかに到達しているようです:

cnxn.getAuthInfo().add(new Id(getScheme(), id));

それは働き始めます。必要なものはこれで十分だと思います。

于 2013-06-19T18:53:40.570 に答える