静态IP配置
vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE = Ethernet
PROXY_METHOD = none
BROWSER_ONLY = no
BOOTPROTO = static
IPADDR = 192.168 .18.128
NETMASK = 255.255 .255.0
GATEWAY = 192.168 .18.2
DEFROUTE = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = yes
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_FAILURE_FATAL = no
IPV6_ADDR_GEN_MODE = stable-privacy
NAME = ens33
UUID = 2c2371f1-ef29-4514-a568-c4904bd11130
DEVICE = ens33
ONBOOT = true
DNS1 = 114.114 .114.114
systemctl restart network
ClickHouse配置
cd /usr/local/src
wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-client-22.2.2.1-2.noarch.rpm
wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-common-static-22.2.2.1-2.x86_64.rpm
wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-common-static-dbg-22.2.2.1-2.x86_64.rpm
wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-server-22.2.2.1-2.noarch.rpm
yum -y localinstall *.rpm
sudo systemctl enable clickhouse-server
sudo systemctl start clickhouse-server
sudo systemctl status clickhouse-server
vim /etc/clickhouse-server/config.xml
< listen_host> ::< /listen_host>
vim /etc/clickhouse-server/users.xml
< password> default< /password>
sudo systemctl restart clickhouse-server
SpringBoot集成ClickHouse
example.sql
CREATE TABLE ` default` .example (
uuid VARCHAR( 100 )
) ENGINE = Log;
pom.xml
< dependency>
< groupId> com.baomidou</ groupId>
< artifactId> mybatis-plus-boot-starter</ artifactId>
< version> 3.3.2</ version>
</ dependency>
< dependency>
< groupId> com.baomidou</ groupId>
< artifactId> mybatis-plus-extension</ artifactId>
< version> 3.3.2</ version>
</ dependency>
< dependency>
< groupId> com.clickhouse</ groupId>
< artifactId> clickhouse-jdbc</ artifactId>
< version> 0.6.0-patch4</ version>
</ dependency>
< dependency>
< groupId> org.lz4</ groupId>
< artifactId> lz4-java</ artifactId>
< version> 1.8.0</ version>
</ dependency>
< dependency>
< groupId> com.github.luben</ groupId>
< artifactId> zstd-jni</ artifactId>
< version> 1.5.5-5</ version>
</ dependency>
< dependency>
< groupId> org.apache.httpcomponents.client5</ groupId>
< artifactId> httpclient5</ artifactId>
< version> 5.3.1</ version>
</ dependency>
< dependency>
< groupId> com.baomidou</ groupId>
< artifactId> dynamic-datasource-spring-boot-starter</ artifactId>
< version> 3.3.6</ version>
</ dependency>
< dependency>
< groupId> org.projectlombok</ groupId>
< artifactId> lombok</ artifactId>
< version> 1.18.32</ version>
< scope> provided</ scope>
</ dependency>
application.yml
spring :
application :
name : Elastic- Batch
datasource :
type : com.zaxxer.hikari.HikariDataSource
dynamic :
primary : clickhouse
datasource :
clickhouse :
driver-class-name : com.clickhouse.jdbc.ClickHouseDriver
url : jdbc: clickhouse: //192.168.15.128: 8123/default
name : default
password : default
clickhouse-2 :
driver-class-name : com.clickhouse.jdbc.ClickHouseDriver
url : jdbc: clickhouse: //192.168.15.128: 8123/default
name : default
password : default
Example.java
@Data
@Builder
public class Example {
private String uuid;
}
ExampleMapper.java
@DS ( value = "clickhouse" )
@Mapper
public interface ExampleMapper extends BaseMapper < Example > {
}
Application.java
@SpringBootApplication
public class Application {
public static void main ( String [ ] args) {
SpringApplication . run ( Application . class , args) ;
}
@Resource
private ExampleMapper exampleMapper;
@PostConstruct
public void mock ( ) {
exampleMapper. insert (
Example . builder ( )
. uuid ( UUID . randomUUID ( ) . toString ( ) . toUpperCase ( Locale . ROOT ) . replace ( "-" , "" ) )
. build ( )
) ;
}
}