etcd集群搭建

mkdir -p /etc/etcd.d
mkdir -p /var/etcd/
mkdir -p /var/etcd/wal
vi /etc/etcd.d/etcd.conf
实例1配置文件
name: 'etcd1'
data-dir: '/var/etcd'
wal-log: '/var/etcd/wal'
snapshot-count: 10000
heartbeat-interval: 100
election-timeout: 1000
listen-peer-urls: 'http://0.0.0.0:2380'
listen-client-urls: 'http://0.0.0.0:2379'
max-snapshots: 5
max-wals: 5
cors:
initial-advertise-peer-urls: 'http://0.0.0.0:2380'
advertise-client-urls: 'http://0.0.0.0:2379'
initial-cluster: 'etcd1=http://172.17.0.10:2380,etcd2=http://172.17.0.11:2380,etcd3=http://172.17.0.12:2380'
initial-cluster-token: 'etcd'
initial-cluster-state: 'new'
strict-reconfig-check: false
enable-v3: true
enable-pprof: true
debug: false
logger: zap
log-outputs: [stderr]
实例2配置文件
name: 'etcd2'
data-dir: '/var/etcd'
wal-log: '/var/etcd/wal'
snapshot-count: 10000
heartbeat-interval: 100
election-timeout: 1000
listen-peer-urls: 'http://0.0.0.0:2380'
listen-client-urls: 'http://0.0.0.0:2379'
max-snapshots: 5
max-wals: 5
cors:
initial-advertise-peer-urls: 'http://0.0.0.0:2380'
advertise-client-urls: 'http://0.0.0.0:2379'
initial-cluster: 'etcd1=http://172.17.0.10:2380,etcd2=http://172.17.0.11:2380,etcd3=http://172.17.0.12:2380'
initial-cluster-token: 'etcd'
initial-cluster-state: 'new'
strict-reconfig-check: false
enable-v3: true
enable-pprof: true
debug: false
logger: zap
log-outputs: [stderr]

实例3配置文件
name: 'etcd3'
data-dir: '/var/etcd'
wal-log: '/var/etcd/wal'
snapshot-count: 10000
heartbeat-interval: 100
election-timeout: 1000
listen-peer-urls: 'http://0.0.0.0:2380'
listen-client-urls: 'http://0.0.0.0:2379'
max-snapshots: 5
max-wals: 5
cors:
initial-advertise-peer-urls: 'http://0.0.0.0:2380'
advertise-client-urls: 'http://0.0.0.0:2379'
initial-cluster: 'etcd1=http://172.17.0.10:2380,etcd2=http://172.17.0.11:2380,etcd3=http://172.17.0.12:2380'
initial-cluster-token: 'etcd'
initial-cluster-state: 'new'
strict-reconfig-check: false
enable-v3: true
enable-pprof: true
debug: false
logger: zap
log-outputs: [stderr]
启动
setsid etcd --config-file /etc/etcd.d/etcd.conf

查看集群节点

kafka命令备份

./kafka-producer-perf-test.sh –topic test –num-records 123 –record-size 1000 –producer-props bootstrap.servers=10.10.0.21:9092 –throughput 20000

./kafka-topics.sh –create –zookeeper 10.10.0.21:2181 –replication-factor 3 –partitions 3 –topic test

mysql 数据导入导出和一个坑

mysqldump 的导入导出比较多,这里记录一下mysql本地文件导入导出过程。

#!/bin/bash

echo "------------------------->"
echo -e "-->导出数据\n"
mysql='mysql -h127.0.0.1 -uxxx -ppwd@xxxx db'
out_file=/home/ubuntu/data_export/data.txt
echo "select * from world where msg='hello';" | $mysql >> ${out_file}

就是通过重定向mysql终端的输出到文件来实现。

myql导入上面格式的数据有load data的命令。

LOAD DATA LOCAL INFILE ‘/home/ubuntu/data_export/data.txt’ INTO TABLE world;

没有local的话,会在mysql服务器的本地路径寻找文件。

这种数据导入导出的方式有个坑需要注意,NULL 会转成字符串 NULL,然后导入的时候会转成一个有效的NULL字符串,这个需要处理下。