容器部署
容器部署
拉取鏡像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 子句,所有的記錄都將被刪除!
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/32858.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...
閱讀 371·2023-04-25 16:38
閱讀 1482·2021-09-26 09:46
閱讀 3326·2021-09-08 09:35
閱讀 2779·2019-08-30 12:54
閱讀 3249·2019-08-29 17:06
閱讀 1017·2019-08-29 14:06
閱讀 3344·2019-08-29 13:00
閱讀 3466·2019-08-28 17:53