wuqiong818 commented on issue #33565:
URL:
https://github.com/apache/shardingsphere/issues/33565#issuecomment-2461464495
hello,Here's how i do it.
### my image
i use docker start proxys,and this image written myself.The image contains
some third-party packages, such as mysql connection、grpc ...
Image Name is yiwuqiong/sharding-etcd. You can search for this image on
docker hub.
我的docker run command is
`docker run -d \
--name shardingproxy1 \
-p 3307:3307 \
-e JVM_OPTS='-Xms256m -Xmx400m -Xss1m' \
-v /home/wangye/sharding/conf/:/opt/shardingsphere-proxy/conf \
yiwuqiong/sharding-etcd:3.0`
### my global.yaml
`mode:
type: Cluster
repository:
type: etcd
props:
namespace: governance_ds
server-lists: http://124.156.192.247:30004
props:
timeToLiveSeconds: 30
connectionTimeout: 30
authority:
users:
- user: root@%
password: root
privilege:
type: ALL_PERMITTED
props:
sql-show: true`
### my database-sharding.yaml
databaseName: sharding_db
dataSources:
server_order0:
url: jdbc:mysql://124.156.192.247:19290/db_order
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
server_order1:
url: jdbc:mysql://124.156.192.247:62195/db_order
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:
- !SHARDING
autoTables:
t_order: #一对多,需要使用算法进行映射 自动分片
actualDataSources: server_order${0..1}
shardingStrategy:
standard:
shardingColumn: order_no
shardingAlgorithmName: order_table_mod
keyGenerateStrategy:
column: id #表中需要留好列,shardingSphere不会帮助我们进行创建
keyGeneratorName: snowflake
t_order_item:
actualDataSources: server_order${0..1}
shardingStrategy:
standard:
shardingColumn: order_no
shardingAlgorithmName: order_item_table_mod
keyGenerateStrategy:
column: id #表中需要留好列,shardingSphere不会帮助我们进行创建
keyGeneratorName: snowflake
bindingTables:
- t_order, t_order_item
shardingAlgorithms:
order_table_mod:
type: MOD
props:
sharding-count: 20
order_item_table_mod:
type: MOD
props:
sharding-count: 20
keyGenerators:
snowflake:
type: SNOWFLAKE
props:
worker-id: 1000 # 工作机器唯一标识,集群模式下自动生成,保证唯一
max-vibration-offset: 19
max-tolerate-time-difference-milliseconds: 10
#最大容器时钟回退时间,时钟回拨超过这个时间会报错
- !BROADCAST
tables: # 广播表规则列表
- t_dict
### operational process
When I start the proxy container, I see the following error message by
docker logs <container_name> :
we find java version: java21, full_version=21.0.4,
full_path=/opt/java/openjdk/bin/java
unadapted java version, please notice...
The classpath is
/opt/shardingsphere-proxy/conf:/opt/shardingsphere-proxy/conf:.:/opt/shardingsphere-proxy/lib/*:/opt/shardingsphere-proxy/ext-lib/*
main class org.apache.shardingsphere.proxy.Bootstrap -1
/opt/shardingsphere-proxy/conf 0.0.0.0 false
[INFO ] 2024-11-07 06:57:11.496 [main] i.v.c.spi.resolver.ResolverProvider -
Using the default address resolver as the dns resolver could not be loaded
[WARN ] 2024-11-07 06:57:40.288 [main]
o.a.s.m.m.c.w.ClusterWorkerIdGenerator - It is unnecessary to configure
worker-id in cluster mode, system assigned worker-id was 1
[ERROR] 2024-11-07 06:57:43.693 [main]
o.a.s.d.p.c.l.PipelineContextManagerLifecycleListener - Dispatch enable
pipeline job start event failed
java.lang.IllegalArgumentException: Unsupported cluster type: etcd
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory$RegistryCenterHolder.lambda$createRegistryCenter$0(PipelineAPIFactory.java:150)
at
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:44)
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory$RegistryCenterHolder.createRegistryCenter(PipelineAPIFactory.java:150)
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory$RegistryCenterHolder.<init>(PipelineAPIFactory.java:141)
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory$RegistryCenterHolder.lambda$getInstance$1(PipelineAPIFactory.java:155)
at
java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory$RegistryCenterHolder.getInstance(PipelineAPIFactory.java:155)
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory.getRegistryCenter(PipelineAPIFactory.java:109)
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory$ElasticJobAPIHolder.<init>(PipelineAPIFactory.java:123)
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory$ElasticJobAPIHolder.lambda$getInstance$0(PipelineAPIFactory.java:130)
at
java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory$ElasticJobAPIHolder.getInstance(PipelineAPIFactory.java:130)
at
org.apache.shardingsphere.data.pipeline.core.job.api.PipelineAPIFactory.getJobConfigurationAPI(PipelineAPIFactory.java:89)
at
org.apache.shardingsphere.data.pipeline.core.listener.PipelineContextManagerLifecycleListener.dispatchEnablePipelineJobStartEvent(PipelineContextManagerLifecycleListener.java:74)
at
org.apache.shardingsphere.data.pipeline.core.listener.PipelineContextManagerLifecycleListener.onInitialized(PipelineContextManagerLifecycleListener.java:65)
at
org.apache.shardingsphere.mode.manager.ContextManager.<init>(ContextManager.java:75)
at
org.apache.shardingsphere.mode.manager.cluster.ClusterContextManagerBuilder.build(ClusterContextManagerBuilder.java:64)
at
org.apache.shardingsphere.proxy.initializer.BootstrapInitializer.createContextManager(BootstrapInitializer.java:62)
at
org.apache.shardingsphere.proxy.initializer.BootstrapInitializer.init(BootstrapInitializer.java:53)
at org.apache.shardingsphere.proxy.Bootstrap.main(Bootstrap.java:64)
[WARN ] 2024-11-07 06:57:43.694 [main]
o.a.s.s.c.j.s.c.StatisticsCollectJobWorker - Can not collect statistics because
of unsupported cluster type: etcd
[INFO ] 2024-11-07 06:57:45.999 [main] o.a.s.p.v.ShardingSphereProxyVersion
- Database type is `MySQL`, version is `8.0.40`, database name is `sharding_db`
[INFO ] 2024-11-07 06:57:46.001 [main] o.a.s.p.frontend.ssl.ProxySSLContext
- Proxy frontend SSL/TLS is not enabled.
[INFO ] 2024-11-07 06:57:46.295 [main] o.a.s.p.frontend.ShardingSphereProxy
- ShardingSphere-Proxy Cluster mode started successfully
[ERROR] 2024-11-07 06:57:51.335 [Etcd-EventListener-0]
o.a.s.m.r.c.etcd.EtcdRepository - Dispatch event failed
java.util.concurrent.CompletionException: java.lang.NullPointerException:
Cannot invoke "String.split(String)" because "attributes" is null
at
java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at
java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at
java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.NullPointerException: Cannot invoke
"String.split(String)" because "attributes" is null
at
org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMetaData.<init>(ProxyInstanceMetaData.java:52)
at
org.apache.shardingsphere.infra.instance.metadata.InstanceMetaDataFactory.create(InstanceMetaDataFactory.java:41)
at
org.apache.shardingsphere.mode.manager.cluster.event.builder.ComputeNodeOnlineDispatchEventBuilder.createInstanceEvent(ComputeNodeOnlineDispatchEventBuilder.java:66)
at
org.apache.shardingsphere.mode.manager.cluster.event.builder.ComputeNodeOnlineDispatchEventBuilder.build(ComputeNodeOnlineDispatchEventBuilder.java:57)
at
org.apache.shardingsphere.mode.manager.cluster.listener.GlobalMetaDataChangedListener.onChange(GlobalMetaDataChangedListener.java:39)
at
org.apache.shardingsphere.mode.repository.cluster.etcd.EtcdRepository.lambda$dispatchEvent$3(EtcdRepository.java:191)
at
java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
... 3 common frames omitted
[ERROR] 2024-11-07 06:57:57.339 [Etcd-EventListener-0]
c.g.common.eventbus.EventBus.default - Exception thrown by subscriber method
renew(org.apache.shardingsphere.mode.event.dispatch.state.compute.WorkerIdEvent)
on subscriber
org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ComputeNodeStateSubscriber@3dd570c3
when dispatching event:
org.apache.shardingsphere.mode.event.dispatch.state.compute.WorkerIdEvent@2322bbce
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()"
because "workerId" is null
at
org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext.lambda$updateWorkerId$1(ComputeNodeInstanceContext.java:123)
at
java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at
java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at
java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at
java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at
java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at
java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at
java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at
org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext.updateWorkerId(ComputeNodeInstanceContext.java:123)
at
org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.ComputeNodeStateSubscriber.renew(ComputeNodeStateSubscriber.java:78)
at
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at
com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:85)
at com.google.common.eventbus.Subscriber
$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:142)
at
com.google.common.eventbus.Subscriber.lambda$dispatchEvent$0(Subscriber.java:71)
at
com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
at
com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:68)
at
com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:109)
at com.google.common.eventbus.EventBus.post(EventBus.java:270)
at
org.apache.shardingsphere.infra.util.eventbus.EventBusContext.post(EventBusContext.java:44)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at
org.apache.shardingsphere.mode.manager.cluster.listener.GlobalMetaDataChangedListener.onChange(GlobalMetaDataChangedListener.java:39)
at
org.apache.shardingsphere.mode.repository.cluster.etcd.EtcdRepository.lambda$dispatchEvent$3(EtcdRepository.java:191)
at
java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]