本記事では、OBKV-Table の使用中によくある質問とその原因および解決策について説明します。
IDEA開発ツールに関するよくある質問
ObTableClientのJARファイルが見つからない
Exception in thread "main" java.lang.NoClassDefFoundError: com/alipay/oceanbase/rpc/ObTableClient
at com.oceanbase.example.KVClient.initial(KVClient.java:46)
at com.oceanbase.example.SimpleKVDemo.main(SimpleKVDemo.java:25)
Caused by: java.lang.ClassNotFoundException: com.alipay.oceanbase.rpc.ObTableClient
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 2 more
Process finished with exit code 1
原因
pom.xmlで指定したobkv-table-clientの依存ファイルが見つかりません。ローカルのMavenリポジトリにダウンロードされていない可能性があります。クライアントのJARファイルのフルパスは次のとおりです。~/.m2/repository/com/oceanbase/obkv-table-client/0.1.0/obkv-table-client-0.1.0.jar解決策
IDEAのMaven設定で、Local repositoryにローカルリポジトリのパスが設定されているか確認してください。
Javaクライアントの初期化失敗
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Sofa-Middleware-Log:WARN [oceanbase-table-client] No log util is usable, Default app logger will be used.
... ...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'proxyro'@'xxx.xxx.xxx.xxx' (using password: YES)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
... ...
原因
例ではproxyroユーザーのパスワードが設定されていません。つまり、クライアントの初期化時に
setSysUserName関数で指定したユーザーにパスワードが設定されていない状態です。obTableClient.setSysUserName("proxyro@sys"); // e.g. proxyro@sys obTableClient.setSysPassword("proxyro@passwd");解決策
OBClientまたはMySQLクライアントを使用してOceanBaseクラスタにログインすることができます(詳細については、OBClientを使用してOceanBaseテナントに接続するおよびMySQLクライアントを使用してOceanBaseデータベースに接続するを参照してください)。クラスタにログインした後、以下のステートメントを実行してproxyroのパスワードを設定します。
grant select on oceanbase.* to proxyro identified by 'xxx'; // 'xxx' は設定するパスワードです。任意に設定してください。
database empty エラー
java.lang.IllegalArgumentException: database is empty. url=http://ip:port/services?Action=ObRootServiceInfo&User_ID=admin&UID=admin&ObRegion=ocp
at com.alipay.oceanbase.rpc.ObTableClient.setParamURL(ObTableClient.java:1396)
at com.oceanbase.example.KVClient.initial(KVClient.java:48)
at com.oceanbase.example.SimpleKVDemo.main(SimpleKVDemo.java:25)
fail to init KV client, java.lang.IllegalArgumentException: database is empty. url=http://ip:port/services?Action=ObRootServiceInfo&User_ID=admin&UID=admin&ObRegion=ocp
原因
Javaクライアントを初期化する際に、
setParamURL関数の入力URLにデータベースを指定していません。解決策
URLに、アクセス先のデータベースを指定してください。
obTableClient.setParamURL("http://ip:port/services?Action=ObRootServiceInfo&User_ID=xxx&UID=xxx&ObRegion=xxx&database=test");
table not existエラー
com.alipay.oceanbase.rpc.exception.ObTableNotExistException: table not exist: kv_table
at com.alipay.oceanbase.rpc.location.LocationUtil.getTableEntryFromResultSet(LocationUtil.java:622)
at com.alipay.oceanbase.rpc.location.LocationUtil.getTableEntryFromRemote(LocationUtil.java:384)
at com.alipay.oceanbase.rpc.location.LocationUtil.access$200(LocationUtil.java:50)
at com.alipay.oceanbase.rpc.location.LocationUtil$1$1.execute(LocationUtil.java:313)
at com.alipay.oceanbase.rpc.location.LocationUtil$1$1.execute(LocationUtil.java:309)
at com.alipay.oceanbase.rpc.location.LocationUtil.callTableEntryRefresh(LocationUtil.java:264)
at com.alipay.oceanbase.rpc.location.LocationUtil.access$300(LocationUtil.java:50)
at com.alipay.oceanbase.rpc.location.LocationUtil$1.execute(LocationUtil.java:308)
at com.alipay.oceanbase.rpc.location.LocationUtil$1.execute(LocationUtil.java:305)
at com.alipay.oceanbase.rpc.location.LocationUtil.callTableEntryRefreshWithPriority(LocationUtil.java:133)
at com.alipay.oceanbase.rpc.location.LocationUtil.loadTableEntryWithPriority(LocationUtil.java:304)
at com.alipay.oceanbase.rpc.ObTableClient.refreshTableEntry(ObTableClient.java:753)
at com.alipay.oceanbase.rpc.ObTableClient.getOrRefreshTableEntry(ObTableClient.java:702)
at com.alipay.oceanbase.rpc.ObTableClient.getTable(ObTableClient.java:839)
at com.alipay.oceanbase.rpc.ObTableClient.execute(ObTableClient.java:424)
at com.alipay.oceanbase.rpc.ObTableClient.execute(ObTableClient.java:400)
at com.alipay.oceanbase.rpc.ObTableClient.insert(ObTableClient.java:1060)
at com.alipay.oceanbase.rpc.table.AbstractTable.insert(AbstractTable.java:52)
at com.oceanbase.example.KVClient.put(KVClient.java:81)
at com.oceanbase.example.SimpleKVDemo.main(SimpleKVDemo.java:40)
fail to put kv data, com.alipay.oceanbase.rpc.exception.ObTableNotExistException: table not exist: kv_table
原因
クライアントのsetParamURLで指定したデータベース内に、
kv_tableテーブルが存在しません。注意
kv_tableは、この例でエラーとなるテーブル名です。参考用であり、実際の場合はそれぞれの環境に準じてください。
解決策
setParamURLで指定したデータベースには、クライアントインターフェースで操作するテーブルが存在している必要があります。
コマンドライン開発に関するよくある質問
sofaなどの依存パッケージが見つからない
$mvn compile -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building simple-kv-demo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.oceanbase:obkv-table-client:jar:0.1.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ simple-kv-demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ simple-kv-demo ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 3 source files to /home/admin/github/obkv-table-client-java/example/simple-kv-demo/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[21,35] package com.alipay.sofa.common.code does not exist
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[22,34] package com.alipay.sofa.common.log does not exist
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[23,17] package org.slf4j does not exist
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[28,19] cannot find symbol
symbol: class LogCode2Description
location: class com.oceanbase.example.LoggerFactory
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[31,19] cannot find symbol
symbol: class Logger
location: class com.oceanbase.example.LoggerFactory
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[38,19] cannot find symbol
symbol: class Logger
location: class com.oceanbase.example.LoggerFactory
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[28,45] cannot find symbol
symbol: variable LogCode2Description
location: class com.oceanbase.example.LoggerFactory
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[35,16] cannot find symbol
symbol: variable LoggerSpaceManager
location: class com.oceanbase.example.LoggerFactory
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project simple-kv-demo: Compilation failure
at org.apache.maven.lifecycle.internal.MojoE
原因
pom.xmlの依存関係で指定されたJARパッケージが、ローカルパス上の最新バージョンではない可能性があります。解決策
プロジェクトの依存関係にあるローカルのMavenリポジトリパッケージをクリーンアップして、再コンパイルします。
mvn dependency:purge-local-repository
Demoの使用上の注意事項
GitHub公式サイトのdemoをそのまま使用して調査・テストを行う場合は、demoプロジェクトのすべての依存関係をパッケージ化してから実行してください。全依存関係のパッケージ化には、demoのpom.xmlファイルを修正する必要があります。 obkv-table-client-java/example/simple-kv-demoを例にすると、pom.xmlに以下の内容を追加します:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.oceanbase.example.SimpleKVDemo</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
修正後、再度パッケージ化します:
mvn clean package
最後に実行します:
java -cp ./target/simple-kv-demo-1.0-SNAPSHOT-jar-with-dependencies.jar com.oceanbase.example.SimpleKVDemo
説明
クライアントの使用参考Demoはexampleでご覧いただけます。
モニタリングに関するよくある質問
OBKV-Tableのモニタリング指標にヒストグラムはありますか?
OBKV-Tableでは、P99などのパフォーマンス指標を確認するためにヒストグラムを使用できます。ユーザーはV$OB_QUERY_RESPONSE_TIME_HISTOGRAMビューを参照し、Prometheusと組み合わせて各操作のP95、P99などのパフォーマンス指標を集計できます。
関連する監視指標の確認方法については、OBKV-Tableの監視指標を参照してください。