请问一下我想调试一下tikv的代码
看部署的时候一般都是启动3个tikv的节点,请问一下如果只启动一个tikv可以吗?会不会有什么影响呢
tidb小白一枚,才入坑
副本设置成1才能只启动一个tikv节点,默认副本是3,1个tikv无法对外提供服务
请问一下怎么设置呢,我tidb,tikv和pd都是自己编译出来的。
因为主要是自己调试熟悉代码,感觉并不需要多副本,一个tikv理论上就够了
恭喜啊,你成功编译出来了。
https://docs.pingcap.com/zh/tidb/stable/dynamic-config#在线修改-pd-配置
replication.max-replicas 用于设置副本的数量
pd的配置里面有个设置。可以在线修改,也可以tiup cluster edit-config 在文件中设置。
直接连到tidb
查看配置
SHOW config WHERE NAME LIKE ‘replication.max-replicas’
修改配置
SET config pd replication.max-replicas=1;
我是重新装了一个虚拟机,干净的环境上编译才通过的。估计以前的环境做了太多编译工作,导致会有一些冲突
cool
tiup应该是安装的的才有,编译的貌似木有这个东西
从tidb连进去,在线修改也可以。
或者装一个tiup也用不了几分钟,很快的。
我看调试文档,说单独调试tikv,可以只用pd和tikv。tidb都可以不要。
建表,插入数据啥的,tidb不要可以么?我看文档mysql连的不就是tidb么?装tiup,那怎么用自己编译的启动呢
不要tidb可以使用tikv-client来连接tikv,当tikv就是个带事务的kv存储来用。
后一个问题想想确实有点麻烦。还是从tidb连接去吧。或者修改pd配置文件算了。
[root@tidb1 conf]# pwd
/tidb-deploy/pd-2379/conf
[root@tidb1 conf]# cat pd.toml
# WARNING: This file is auto-generated. Do not edit! All your modification will be overwritten!
# You can use 'tiup cluster edit-config' and 'tiup cluster reload' to update the configuration
# All configuration items you want to change can be added to:
# server_configs:
# pd:
# aa.b1.c3: value
# aa.b2.c4: value
正式部署的时候会由tiup生成这个配置文件,还不建议你修改它。但编译的话,没有tiup,还不如直接改这个文件,再重启pd。可能更快。
pd下有一个config.toml文件,我看看说明怎么改一下
tidb的配置需要修改么
我看到config.toml了,看一下怎么修改
安装我看可以配置一个topo.yaml,在里面进行配置
这个是不是就在pd里面的配置就行呢。这个config.toml和集群的配置文件是不是相同的呢
对,在topo.yaml里面的设置和pd相关的,其实最后会写道这个pd.toml里面去。
tidb和tikv都有对应的配置文件,内容也是topo.yaml里面的内容,自动生成好进每个组件的配置文件里面去的。
比如我在topo.yaml里面的设置:
server_configs:
tidb:
experimental.allow-expression-index: true
performance.enforce-mpp: true
tikv: {}
pd:
tso-update-physical-interval: 1ms
pd.toml内容如下:
tso-update-physical-interval = "1ms"
tidb.toml内容如下:
[experimental]
allow-expression-index = true
[performance]
enforce-mpp = true
也就是格式有些变化。格式的确认可以在github上找这两个文件的标准配置参考一下。
[root@tidb1 bin]# ./pd-server --help
Placement Driver server
Usage:
pd-server [flags]
pd-server [command]
Available Commands:
help Help about any command
services Run services, for example, tso, resource_manager
Flags:
--advertise-client-urls string advertise urls for client traffic (default '${client-urls}')
--advertise-peer-urls string advertise urls for peer traffic (default '${peer-urls}')
--cacert string path of file that contains list of trusted TLS CAs
--cert string path of file that contains X509 certificate in PEM format
--client-urls string urls for client traffic
--config string config file
--config-check check config file validity and exit
--data-dir string path to the data directory (default 'default.${name}')
--force-new-cluster force to create a new one-member cluster
-h, --help help for pd-server
--initial-cluster string initial cluster configuration for bootstrapping, e,g. pd=http://127.0.0.1:2380
--join string join to an existing cluster (usage: cluster's '${advertise-client-urls}'
--key string path of file that contains X509 key in PEM format
--log-file string log file path
-L, --log-level string log level: debug, info, warn, error, fatal (default 'info') (default "info")
--metrics-addr string prometheus pushgateway address, leaves it empty will disable prometheus push
--name string human-readable name for this pd member
--peer-urls string urls for peer traffic
-V, --version print version information and exit
Use "pd-server [command] --help" for more information about a command.
只要你编译出来的pd-server能看到下面这个参数
--config string config file
就应该能通过这个参数设置pd.toml文件
完整的启动参数进程参数,我也给你一个,供参考:
bin/pd-server --name=pd-172.21.16.10-2379 --client-urls=http://0.0.0.0:2379 --advertise-client-urls=http://172.21.16.10:2379 --peer-urls=http://0.0.0.0:2380 --advertise-peer-urls=http://172.21.16.10:2380 --data-dir=/tidb-data/pd-2379 --initial-cluster=pd-172.21.16.10-2379=http://172.21.16.10:2380,pd-172.21.16.17-2379=http://172.21.16.17:2380,pd-172.21.0.143-2379=http://172.21.0.143:2380 --config=conf/pd.toml --log-file=/tidb-deploy/pd-2379/log/pd.log
部署时候直接就写一个tikv就没问题,虽然参数也是设置为3副本单不影响使用
我主要是调试tikv,所以只用一个感觉方便一些
目前能起来,mysql可以连接。具体做法是:
1.启动pd服务
nohup ./pd-server --data-dir=pd --log-file=pd.log &
可以使用
netstat -anp | grep 2379
查看是否启动,2379是默认端口
2.启动tikv(关于端口,在配置文件config.rs中默认就是20160,)
nohup ./tikv-server --pd-endpoints=“127.0.0.1:2379” --addr=“127.0.0.1:20160” --data-dir=tikv1 --log-file=tikv1.log &
3.启动tidb
nohup ./tidb-server --store=tikv --path=“127.0.0.1:2379” --log-file=tidb.log &
查看是否启动
netstat -anp | grep 4000
使用mysql访问
mysql -h 127.0.0.1 -P 4000 -u root