容器部署
容器部署
拉取镜像docker pull cockroachdb/cockroach:v2.0.1创建网络
docker network create -d bridge roachnet
查看网络(不清楚为什么没有docker0,或者docker0和eb330591e579的关系)
# docker network ls NETWORK ID NAME DRIVER SCOPE eb330591e579 bridge bridge local 95d2d6473765 host host local 8edade4ef56f none null local 7e50fa75c534 roachnet bridge local运行容器
docker run -d --name=roach1 --hostname=roach1 --net=roachnet -p 26257:26257 -p 8080:8080 -v "${PWD}/cockroach-data/roach1:/cockroach/cockroach-data" cockroachdb/cockroach:v2.0.1 start --insecure验证集群 bug 了docker run -d --name=roach2 --hostname=roach2 --net=roachnet -v "${PWD}/cockroach-data/roach2:/cockroach/cockroach-data" cockroachdb/cockroach:v2.0.1 start --insecure --join=roach1
docker run -d --name=roach3 --hostname=roach3 --net=roachnet -v "${PWD}/cockroach-data/roach3:/cockroach/cockroach-data" cockroachdb/cockroach:v2.0.1 start --insecure --join=roach1
[root@log-test cockroach-data]# docker exec -it roach1 ./cockroach sql --insecure # Welcome to the cockroach SQL interface. # All statements must be terminated by a semicolon. # To exit: CTRL + D. # # Server version: CockroachDB CCL v2.0.1 (x86_64-unknown-linux-gnu, built 2018/04/23 18:39:21, go1.10) (same version as client) # Cluster ID: 0721d2db-a3a1-4a87-96f2-7b35ee4a4b86 fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1b0abb7] runtime stack: runtime.throw(0x2485b32, 0x2a) /usr/local/go/src/runtime/panic.go:619 +0x81 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:372 +0x28e goroutine 1 [syscall]: non-Go function pc=0x1b0abb7 non-Go function pc=0x1b0ad81 non-Go function pc=0x1b0a344 non-Go function pc=0x72e5af runtime.cgocall(0x1b0a300, 0xc420657820, 0x2480f4f) /usr/local/go/src/runtime/cgocall.go:128 +0x64 fp=0xc4206577d8 sp=0xc4206577a0 pc=0x6d60c4 github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/unix._C2func_go_libedit_init(0x0, 0x7f5986e59210, 0xc4200ba438, 0x7f5986e54000, 0x7f5986e54280, 0x7f5986e54500, 0x0, 0x0, 0x0, 0x0) _cgo_gotypes.go:200 +0x5c fp=0xc420657820 sp=0xc4206577d8 pc=0x1aa10ac github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/unix.InitFiles.func3(0x0, 0x7f5986e59210, 0xc4200ba438, 0x7f5986e54000, 0x7f5986e54280, 0x7f5986e54500, 0x0, 0xc420657930, 0x16b03db, 0x274de80) /go/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/unix/editline_unix.go:93 +0x19e fp=0xc420657880 sp=0xc420657820 pc=0x1aa425e github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/unix.InitFiles(0x243bd49, 0x9, 0x1, 0xc4200ba000, 0xc4200ba008, 0xc4200ba048, 0x0, 0x0, 0x0) /go/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/unix/editline_unix.go:93 +0x482 fp=0xc4206579c8 sp=0xc420657880 pc=0x1aa2462 github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit.InitFiles(0x243bd49, 0x9, 0x6ff101, 0xc4200ba000, 0xc4200ba008, 0xc4200ba048, 0xc420000180, 0x2568c10, 0xc42003ca80) /go/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/editline_unix.go:15 +0x63 fp=0xc420657a20 sp=0xc4206579c8 pc=0x1aa5dd3 github.com/cockroachdb/cockroach/pkg/cli.runInteractive(0xc420471900, 0x0, 0x0) /go/src/github.com/cockroachdb/cockroach/pkg/cli/sql.go:1062 +0x41a fp=0xc420657bf8 sp=0xc420657a20 pc=0x1aceb3a github.com/cockroachdb/cockroach/pkg/cli.runTerm(0x3658dc0, 0xc420044400, 0x0, 0x1, 0x0, 0x0) /go/src/github.com/cockroachdb/cockroach/pkg/cli/sql.go:1179 +0x159 fp=0xc420657c50 sp=0xc420657bf8 pc=0x1acf349 github.com/cockroachdb/cockroach/pkg/cli.MaybeDecorateGRPCError.func1(0x3658dc0, 0xc420044400, 0x0, 0x1, 0x0, 0x0) /go/src/github.com/cockroachdb/cockroach/pkg/cli/error.go:39 +0x5a fp=0xc420657cc8 sp=0xc420657c50 pc=0x1ae4c9a github.com/cockroachdb/cockroach/vendor/github.com/spf13/cobra.(*Command).execute(0x3658dc0, 0xc420044390, 0x1, 0x1, 0x3658dc0, 0xc420044390) /go/src/github.com/cockroachdb/cockroach/vendor/github.com/spf13/cobra/command.go:698 +0x46d fp=0xc420657d70 sp=0xc420657cc8 pc=0x1a727cd github.com/cockroachdb/cockroach/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x3655460, 0x6, 0x0, 0xc420657ee8) /go/src/github.com/cockroachdb/cockroach/vendor/github.com/spf13/cobra/command.go:783 +0x2e4 fp=0xc420657ea0 sp=0xc420657d70 pc=0x1a72f44 github.com/cockroachdb/cockroach/vendor/github.com/spf13/cobra.(*Command).Execute(0x3655460, 0x18, 0xc420657f00) /go/src/github.com/cockroachdb/cockroach/vendor/github.com/spf13/cobra/command.go:736 +0x2b fp=0xc420657ed0 sp=0xc420657ea0 pc=0x1a72c3b github.com/cockroachdb/cockroach/pkg/cli.Run(0xc4200a4160, 0x2, 0x2, 0xc4200b6010, 0xc420558000) /go/src/github.com/cockroachdb/cockroach/pkg/cli/cli.go:156 +0x6d fp=0xc420657ef8 sp=0xc420657ed0 pc=0x1aad83d github.com/cockroachdb/cockroach/pkg/cli.Main() /go/src/github.com/cockroachdb/cockroach/pkg/cli/cli.go:51 +0x15d fp=0xc420657f78 sp=0xc420657ef8 pc=0x1aad3cd main.main() /go/src/github.com/cockroachdb/cockroach/main.go:27 +0x20 fp=0xc420657f88 sp=0xc420657f78 pc=0x1b00f20 runtime.main() /usr/local/go/src/runtime/proc.go:198 +0x212 fp=0xc420657fe0 sp=0xc420657f88 pc=0x701562 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420657fe8 sp=0xc420657fe0 pc=0x72f8e1 goroutine 20 [syscall]: os/signal.signal_recv(0x0) /usr/local/go/src/runtime/sigqueue.go:139 +0xa6 os/signal.loop() /usr/local/go/src/os/signal/signal_unix.go:22 +0x22 created by os/signal.init.0 /usr/local/go/src/os/signal/signal_unix.go:28 +0x41 goroutine 5 [chan receive]: github.com/cockroachdb/cockroach/pkg/util/log.flushDaemon() /go/src/github.com/cockroachdb/cockroach/pkg/util/log/clog.go:1131 +0xf1 created by github.com/cockroachdb/cockroach/pkg/util/log.init.0 /go/src/github.com/cockroachdb/cockroach/pkg/util/log/clog.go:592 +0x110 goroutine 6 [chan receive]: github.com/cockroachdb/cockroach/pkg/util/log.signalFlusher() /go/src/github.com/cockroachdb/cockroach/pkg/util/log/clog.go:601 +0x105 created by github.com/cockroachdb/cockroach/pkg/util/log.init.0 /go/src/github.com/cockroachdb/cockroach/pkg/util/log/clog.go:593 +0x128 goroutine 22 [select, locked to thread]: runtime.gopark(0x2569e48, 0x0, 0x2436d0b, 0x6, 0x18, 0x1) /usr/local/go/src/runtime/proc.go:291 +0x11a runtime.selectgo(0xc420476f50, 0xc4204884e0) /usr/local/go/src/runtime/select.go:392 +0xe50 runtime.ensureSigM.func1() /usr/local/go/src/runtime/signal_unix.go:549 +0x1f4 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2361 +0x1二进制文件部署
部署
下载
wget -qO- https://binaries.cockroachdb.... | tar xvz
拷贝
cp -i cockroach-v2.0.1.linux-amd64/cockroach /usr/local/bin
授权
chmod a+x /usr/local/bin/cockroach
部署
# cockroach start --insecure --host=0.0.0.0 --http-host=0.0.0.0 --http-port=8081 --port=26257 * * WARNING: RUNNING IN INSECURE MODE! * * - Your cluster is open for any client that can access localhost. * - Any user, even root, can log in without providing a password. * - Any user, connecting as root, can read or write any data in your cluster. * - There is no network encryption nor authentication, and thus no confidentiality. * * Check out how to secure your cluster: https://www.cockroachlabs.com/docs/v2.0/secure-a-cluster.html * CockroachDB node starting at 2018-04-28 08:22:34.397265926 +0000 UTC (took 0.7s) build: CCL v2.0.1 @ 2018/04/23 18:39:21 (go1.10) admin: http://0.0.0.0:8081 sql: postgresql://root@localhost:26257?sslmode=disable logs: /home/msxu/cockroach-v2.0.1.linux-amd64/cockroach-data/logs temp dir: /home/msxu/cockroach-v2.0.1.linux-amd64/cockroach-data/cockroach-temp258550286 external I/O path: /home/msxu/cockroach-v2.0.1.linux-amd64/cockroach-data/extern store[0]: path=/home/msxu/cockroach-v2.0.1.linux-amd64/cockroach-data status: restarted pre-existing node clusterID: 0fe058a5-9f6b-47c0-a061-3c043d7d7100 nodeID: 1helm 部署
git clone https://github.com/helm/chart...
https://github.com/kubernetes...
helm install --name ckdb01 http://172.16.59.153:10806/charts/cockroachdb-1.1.0.tgz --set Image=172.16.59.153/devops/cockroach --set StorageClass=csi-lvm
NOTES: CockroachDB can be accessed via port 26257 (or whatever you set the GrpcPort value to) at the following DNS name from within your cluster: ckdb02-public.default.svc.cluster.local Because CockroachDB supports the PostgreSQL wire protocol, you can connect to the cluster using any available PostgreSQL client. For example, you can open up a SQL shell to the cluster by running: kubectl run -it --rm cockroach-client --image=cockroachdb/cockroach --restart=Never --command -- ./cockroach sql --insecure --host ckdb02-cockroachdb-public.default From there, you can interact with the SQL shell as you would any other SQL shell, confident that any data you write will be safe and available even if parts of your cluster fail. Finally, to open up the CockroachDB admin UI, you can port-forward from your local machine into one of the instances in the cluster: kubectl port-forward ckdb02-cockroachdb-0 8080 Then you can access the admin UI at http://localhost:8080/ in your web browser. For more information on using CockroachDB, please see the project"s docs at https://www.cockroachlabs.com/docs/
kubectl run -it --rm cockroach-client --image=172.16.59.153/devops/cockroach --restart=Never --command -- ./cockroach sql --insecure --host ckdb02-cockroachdb-public.default
kubectl run -it --rm cockroach-client
--image=172.16.59.153/devops/cockroach:v2.0.0 --restart=Never --command -- ./cockroach sql --insecure --host ckdb02-cockroachdb-public.defaultcockroachDB 操作
进入
cockroach sql --insecure
显示所有库
show databases;
选择库:
use 库名;
显示数据库下的所有表:
show tables;
查看表基本结构语句DESCRIBE
DESCRIBE 表名SHOW CREATE TABLE 表名
实际中我一般使用DESC 表名来查看表的结构,我们可以查出各字段的字段名,数据类型,完整性约束条件。这种查询是用表格来显示表结构的,所以看起来比较漂亮,但是查出来的内容不是太多;
使用SHOW CREATE TABLE 表名来查看表的结构,除了查出上面的信息之外,还可以查出表的存储引擎(ENGINE),自增的当前值,字符编码等信息。可以用G来结尾,使得结果容易阅读
DELETE 语句用于删除表中的行。
DELETE FROM table_name
WHERE some_column=some_value;delete from tmptables where 1=1
lamp 请注意 SQL DELETE 语句中的 WHERE 子句! WHERE 子句规定哪条记录或者哪些记录需要删除。如果您省略了 WHERE 子句,所有的记录都将被删除!
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/28069.html
容器部署 容器部署 拉取镜像 docker pull cockroachdb/cockroach:v2.0.1 创建网络 docker network create -d bridge roachnet 查看网络(不清楚为什么没有docker0,或者docker0和eb330591e579的关系) # docker network ls NETWORK ID NAME ...
摘要:日前,我司联合创始人兼黄东旭接受了开源中国的开源访谈,公开解读了的探索之路及未来方向。应用场景上在行业内使用更广泛,目前涉及互联网游戏金融政府电信制造业等多个领域。目前也与包括腾讯云在内的多家公有云平台完成了整合,提供公有云数据库服务。 日前,我司联合创始人兼 CTO 黄东旭接受了开源中国的【开源访谈】,公开解读了 TiDB 的探索之路及未来方向。本文为专访实录~ :) 记者:王练 口...
摘要:同时,目录层还可以将表的元数据转换到该二进制前缀。默认有一个根目录,目录名叫,包含所有层用到的所有键,下层目录叫做,用于区数据和元数据。 日常吐槽 国外文章也不是都是好文章啊,不要见到英文就觉得高大上了…… 前言 越来越多的关系型数据库底层选择基于KV构建,例如TiDB的TiKV(RocksDB),cockroach的levelDB,MySQL的tokudb,以及被苹果墙掉的Found...
阅读 1295·2021-11-11 11:00
阅读 2963·2021-09-24 09:47
阅读 4793·2021-09-22 15:53
阅读 917·2021-09-10 10:50
阅读 3176·2021-09-01 11:40
阅读 1125·2019-08-30 15:55
阅读 441·2019-08-30 12:49
阅读 1005·2019-08-29 17:12