备注:
测试环境使用docker进行安装试用
1. 安装
a. Download mkdir ~/yugabyte && cd ~/yugabyte wget https://downloads.yugabyte.com/yb-docker-ctl && chmod +x yb-docker-ctlb. install docker ps && python --verions docker pull yugabytedb/yugabyte
docker pull yugabytedb/yugabyte
2. 创建数据库集群
备注:使用yb-docker-ctl 创建a. create./yb-docker-ctl create操作日志如下:docker run --name yb-master-n1 --privileged -p 7000:7000 --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/bin/yb-master --fs_data_dirs=/mnt/disk0,/mnt/disk1 --replication_factor=3 --master_addresses=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-master-n1:7100Adding node yb-master-n1docker run --name yb-master-n2 --privileged --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/bin/yb-master --fs_data_dirs=/mnt/disk0,/mnt/disk1 --replication_factor=3 --master_addresses=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-master-n2:7100Adding node yb-master-n2docker run --name yb-master-n3 --privileged --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/bin/yb-master --fs_data_dirs=/mnt/disk0,/mnt/disk1 --replication_factor=3 --master_addresses=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-master-n3:7100Adding node yb-master-n3docker run --name yb-tserver-n1 --privileged -p 9000:9000 -p 9042:9042 -p 6379:6379 --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/bin/yb-tserver --fs_data_dirs=/mnt/disk0,/mnt/disk1 --tserver_master_addrs=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-tserver-n1:9100 --yb_num_shards_per_tserver=2Adding node yb-tserver-n1docker run --name yb-tserver-n2 --privileged --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/bin/yb-tserver --fs_data_dirs=/mnt/disk0,/mnt/disk1 --tserver_master_addrs=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-tserver-n2:9100 --yb_num_shards_per_tserver=2Adding node yb-tserver-n2docker run --name yb-tserver-n3 --privileged --net yb-net --detach yugabytedb/yugabyte:latest /home/yugabyte/bin/yb-tserver --fs_data_dirs=/mnt/disk0,/mnt/disk1 --tserver_master_addrs=yb-master-n1:7100,yb-master-n2:7100,yb-master-n3:7100 --rpc_bind_addresses=yb-tserver-n3:9100 --yb_num_shards_per_tserver=2Adding node yb-tserver-n3PID Type Node URL Status Started At9666 tserver yb-tserver-n3 http://192.168.16.7:9000 Running 2018-02-11T02:23:04.064743772Z9498 tserver yb-tserver-n2 http://192.168.16.6:9000 Running 2018-02-11T02:23:03.799704303Z9368 tserver yb-tserver-n1 http://192.168.16.5:9000 Running 2018-02-11T02:23:03.537778672Z9231 master yb-master-n3 http://192.168.16.4:9000 Running 2018-02-11T02:23:03.2530083Z9135 master yb-master-n2 http://192.168.16.3:9000 Running 2018-02-11T02:23:03.003740203Z9053 master yb-master-n1 http://192.168.16.2:9000 Running 2018-02-11T02:23:02.746672273Z其中 cql service 端口 localhost:9042 redis localhost:6379b. 检测集群状态./yb-docker-ctl statusPID Type Node URL Status Started At9666 tserver yb-tserver-n3 http://192.168.16.7:9000 Running 2018-02-11T02:23:04.064743772Z9498 tserver yb-tserver-n2 http://192.168.16.6:9000 Running 2018-02-11T02:23:03.799704303Z9368 tserver yb-tserver-n1 http://192.168.16.5:9000 Running 2018-02-11T02:23:03.537778672Z9231 master yb-master-n3 http://192.168.16.4:9000 Running 2018-02-11T02:23:03.2530083Z9135 master yb-master-n2 http://192.168.16.3:9000 Running 2018-02-11T02:23:03.003740203Z9053 master yb-master-n1 http://192.168.16.2:9000 Running 2018-02-11T02:23:02.746672273Z
参考管理界面
admin ui
master ui
3. 数据库链接
a. cql I.连接 docker exec -it yb-tserver-n3 /home/yugabyte/bin/cqlshConnected to local cluster at 127.0.0.1:9042.[cqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4]Use HELP for help.cqlsh> describe keyspaces;system_schema system_auth systemcqlsh>II. 创建表CREATE KEYSPACE myapp;CREATE TABLE myapp.stock_market ( stock_symbol text, ts text, current_price float, PRIMARY KEY (stock_symbol, ts))III. insert dataINSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('AAPL','2017-10-26 09:00:00',157.41);INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('AAPL','2017-10-26 10:00:00',157);INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('FB','2017-10-26 09:00:00',170.63);INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('FB','2017-10-26 10:00:00',170.1);INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('GOOG','2017-10-26 09:00:00',972.56);INSERT INTO myapp.stock_market (stock_symbol,ts,current_price) VALUES ('GOOG','2017-10-26 10:00:00',971.91);IV. 查询数据SELECT * FROM myapp.stock_market WHERE stock_symbol = 'AAPL'; stock_symbol | ts | current_price--------------+---------------------+--------------- AAPL | 2017-10-26 09:00:00 | 157.41 AAPL | 2017-10-26 10:00:00 | 157b. redis I.连接 docker exec -it yb-tserver-n3 /home/yugabyte/bin/redis-cli II. 操作127.0.0.1:6379>127.0.0.1:6379> set name dalongOK127.0.0.1:6379> get name"dalong"
创建结果可以从UI界面查看
4. 类似工具
tidb cockroachdb vitess总之,数据库变化越来越大了,同时对于以前需要关注的分库分表,基本上已经不用管理,平台自己处理了,同时我们对于我们只需要关注业务实现官方也提供了kubernetes 的运行配置脚本
5. 参考资料
https://docs.yugabyte.com/quick-start/create-local-cluster/