• Neo4j 因果集群搭建及neo4j-java-driver连接


    搭建Neo4j因果集群

    1.下载企业版,当前是3.5.9版本

    https://neo4j.com/download-center/#enterprise

    2.配置,三个核心集群为例

    配置文件,conf/neo4j.conf

    192.168.0.11,neo4j.conf 

    dbms.mode=CORE
    dbms.connectors.default_listen_address=0.0.0.0
    dbms.connectors.default_advertised_address=192.168.0.11
    causal_clustering.minimum_core_cluster_size_at_formation=3
    causal_clustering.minimum_core_cluster_size_at_runtime=3
    causal_clustering.initial_discovery_members=192.168.0.11:5000,192.168.0.12:5000,192.168.0.13:5000

    192.168.0.12,neo4j.conf 

    dbms.mode=CORE
    dbms.connectors.default_listen_address=0.0.0.0
    dbms.connectors.default_advertised_address=192.168.0.12
    causal_clustering.minimum_core_cluster_size_at_formation=3
    causal_clustering.minimum_core_cluster_size_at_runtime=3
    causal_clustering.initial_discovery_members=192.168.0.11:5000,192.168.0.12:5000,192.168.0.13:5000

    192.168.0.13,neo4j.conf 

    dbms.mode=CORE
    dbms.connectors.default_listen_address=0.0.0.0
    dbms.connectors.default_advertised_address=192.168.0.13
    causal_clustering.minimum_core_cluster_size_at_formation=3
    causal_clustering.minimum_core_cluster_size_at_runtime=3
    causal_clustering.initial_discovery_members=192.168.0.11:5000,192.168.0.12:5000,192.168.0.13:5000

     3.分别启动

    bin目录,./neo4j start

    可以通过浏览器访问查看集群状态,http://192.168.0.11:7474

    neo4j-java-driver连接因果集群

    URI格式:bolt+routing://自定义域名

    private Driver createDriver( String virtualUri, String user, String password, ServerAddress... addresses )
    {
        Config config = Config.builder()
                .withResolver( address - > new HashSet<>( Arrays.asList( addresses ) ) )
                .build();
        return(GraphDatabase.driver( virtualUri, AuthTokens.basic( user, password ), config ) );
    }
    
    
    private void addPerson( String name )
    {
        String    username    = "neo4j";
        String    password    = "some password";
        try (Driver driver = createDriver( "bolt+routing://graph.neo4j.com", username, password,
                           ServerAddress.of( "192.168.0.11", 7687),
                           ServerAddress.of( "192.168.0.12", 8787 ), ServerAddress.of( "192.168.0.13", 9898 ) ) )
            {
                try (Session session = driver.session( AccessMode.WRITE ) )
                    {
                        session.run( "CREATE (a:Person {name: $name})", parameters( "name", name ) );
                    }
             }
    }
  • 相关阅读:
    ABP官方文档翻译 3.4 领域服务
    ABP官方文档翻译 3.3 仓储
    ABP官方文档翻译 3.2 值对象
    ABP官方文档翻译 3.1 实体
    ABP官方文档翻译 2.7 对象到对象的映射
    ABP官方文档翻译 2.6 定时
    bootstrap 源码中部分不了解的css属性
    vue 父组件调用子组件事件/子组件调用父组件方法
    js性能优化问题学习笔记
    js递归性能影响及解决方案
  • 原文地址:https://www.cnblogs.com/april-chen/p/11772164.html
Copyright © 2020-2023  润新知