如何编译调试yugabytedb

343 阅读1分钟

编译调试yugabytedb

开启掘金成长之旅!这是我参与「掘金日新计划 · 12 月更文挑战」的第2天,点击查看活动详情

编译yugabytedb

我们希望可以完整编译,目标是改代码,加日志,以及他们的单元测试可以快速跑起来,我折腾了一下午,终于编译通过。

  • 环境:Ubuntu 22.04 LTS
  • wget、curl、g++、python3、pip、autoconf、libtool(我的docker这些都没)
  • apt-get install locales
 git clone https://github.com/yugabyte/yugabyte-db.git ` 
 cd yugabyte-db
 ./yb_build.sh --debug --skip-java-build --export-compile-commands
 # 注意postgrepsql 需要en_US.UTF-8环境,否则启动失败,执行命令:即可解决
 locale-gen en_US.UTF-8 
 # 启动方式
cd bin
python  yugabyted start --ui=false --daemon=false

cassandra模式,CQL语法运行

bin/ycqlsh 127.0.1.1 9042 -u cassandra ,注意,默认密码为空,直接回车即可.

  • 如果遇到No appropriate Python interpreter found.需要降级python3为python2

image.png

 cassandra@ycqlsh> select cluster_name, data_center, rack from system.local
  cluster_name  | data_center | rack
 ---------------+-------------+-------
  local cluster | datacenter1 | rack1

对yugabyte的TTL回收机制还是很感兴趣,所以来测试一番

  INSERT INTO test.ttl_row(mainkey , ukey , value ) VALUES ( 'mk1','uk','value');
 cassandra@ycqlsh> create KEYSPACE test;
 cassandra@ycqlsh> create TABLE test.ttl_row ( mainkey varchar PRIMARY KEY ,ukey varchar ,value varchar );
 ​
 UPDATE test.ttl_row USING TTL 10 set value='value1' where mainkey='mk1';
 cassandra@ycqlsh> select * from test.ttl_row ;
  mainkey | ukey | value
 ---------+------+-------
      mk1 |   uk |  null
 ​

GC代碼分析

代碼分析:

 //事務GC
 -->[16080] maintenance_manager.cc:261:FindBestOp
 -->[16189] maintenance_manager.cc:90:Clear
 -->[16189] tablet_peer_mm_ops.cc:80:UpdateStats
 -->[16189] tablet_peer.cc:1032:GetGCableDataSize
 -->[16189] tablet_peer.cc:917:GetEarliestNeededLogIndex
 -->[16189] transaction_coordinator.cc:1743:PrepareGC
 //raft wal GC
  -->[16189] maintenance_manager.cc:90:Clear
  -->[16189] tablet_peer_mm_ops.cc:80:UpdateStats
   -->[16189] tablet_peer.cc:1032:GetGCableDataSize
    -->[16189] tablet_peer.cc:917:GetEarliestNeededLogIndex
     -->[16189] tablet.cc:3084:FlushIntentsDbIfNecessary
     -->[16189] tablet.cc:3074:MaxPersistentOpId
      -->[16189] tablet.cc:3054:MaxPersistentOpIdForDb
 ​

Postgres SQL 模式运行

待續