KingbaseES 如何开启并进入数据库
关键字:
KingbaseES、sys_ctl、ksql
一、数据库启动前环境检测
1.1 查看kingbase用户环境变量配置
图1-1 查看.bashrc环境变量配置
1.2 应用环境变量
[kingbase@node1 ~]$ source .bashrc
[kingbase@node1 ~]$ which ksql
/opt/Kingbase/ES/V8R6_021/Server/bin/ksql
[kingbase@node1 ~]$ which sys_ctl
/opt/Kingbase/ES/V8R6_021/Server/bin/sys_ctl
1.3 查看数据库数据存储路径
在数据库软件包安装目录的Logs目录下查看相关的日志,可以获取到数据库数据存储路径,如下图1-2所示:
图1-2 查看数据库数据存储路径
1.4 查看数据库配置文件信息
根据实际的业务场景,调整数据库的默认配置。
图1-3 kingbase.conf 配置信息
二、启动数据库服务
2.1 查看启动工具(sys_ctl)帮助信息
[kingbase@node1 ~]$ sys_ctl --help
sys_ctl is a utility to initialize, start, stop, or control a Kingbase server.
Usage:
sys_ctl start [-D DATADIR] [-l FILENAME] [-W] [-t SECS] [-s]
[-o OPTIONS] [-p PATH] [-c]
sys_ctl stop [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s]
sys_ctl restart [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s]
[-o OPTIONS] [-c]
sys_ctl reload [-D DATADIR] [-s]
sys_ctl status [-D DATADIR]
sys_ctl promote [-D DATADIR] [-W] [-t SECS] [-s]
sys_ctl logrotate [-D DATADIR] [-s]
sys_ctl kill SIGNALNAME PID
Common options:
-D, --kingbase-data=DATADIR location of the database storage area
-s, --silent only print errors, no informational messages
-t, --timeout=SECS seconds to wait when using -w option
-V, --version output version information, then exit
-w, --wait wait until operation completes (default)
-W, --no-wait do not wait until operation completes
-?, --help show this help, then exit
If the -D option is omitted, the environment variable KINGBASE_DATA is used.
Options for start or restart:
-c, --core-files allow kingbase to produce core files
-l, --log=FILENAME write (or append) server log to FILENAME
-o, --options=OPTIONS command line options to pass to kingbase
(Kingbase server executable) or initdb
-p PATH-TO-KINGBASE normally not necessary
Options for stop or restart:
-m, --mode=MODE MODE can be "smart", "fast", or "immediate"
Shutdown modes are:
smart quit after all clients have disconnected
fast quit directly, with proper shutdown (default)
immediate quit without complete shutdown; will lead to recovery on restart
Allowed signal names for kill:
ABRT HUP INT KILL QUIT TERM USR1 USR2
Report bugs to <kingbase-bugs@kingbase.com.cn>.
2.2 启动数据库服务
2.2.1 启动数据库服务
[kingbase@node1 data]$ sys_ctl start -D /data/kingbase/v8r6_021/data
waiting for server to start....2021-03-01 14:16:55.069 CST [26141] LOG: sepapower extension initialized
2021-03-01 14:16:55.130 CST [26141] LOG: starting KingbaseES V008R006C004B0021 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
2021-03-01 14:16:55.130 CST [26141] LOG: listening on IPv4 address "0.0.0.0", port 54321
2021-03-01 14:16:55.130 CST [26141] LOG: listening on IPv6 address "::", port 54321
2021-03-01 14:16:55.290 CST [26141] LOG: listening on Unix socket "/tmp/.s.KINGBASE.54321"
2021-03-01 14:16:55.457 CST [26141] LOG: redirecting log output to logging collector process
2021-03-01 14:16:55.457 CST [26141] HINT: Future log output will appear in directory "sys_log".
done
server started
2.2.2 查看数据库服务进程
[kingbase@node1 data]$ ps -ef |grep kingbase
/opt/Kingbase/ES/V8R6_021/Server/bin/kingbase -D /data/kingbase/v8r6_021/data
kingbase 26142 26141 0 14:16 ? 00:00:00 kingbase: logger
kingbase 26144 26141 0 14:16 ? 00:00:00 kingbase: checkpointer
kingbase 26145 26141 0 14:16 ? 00:00:00 kingbase: background writer
kingbase 26146 26141 0 14:16 ? 00:00:00 kingbase: walwriter
kingbase 26147 26141 0 14:16 ? 00:00:00 kingbase: autovacuum launcher
kingbase 26148 26141 0 14:16 ? 00:00:00 kingbase: stats collector
kingbase 26149 26141 0 14:16 ? 00:00:00 kingbase: ksh writer
kingbase 26150 26141 0 14:16 ? 00:00:00 kingbase: ksh collector
kingbase 26151 26141 0 14:16 ? 00:00:00 kingbase: kwr collector
kingbase 26152 26141 0 14:16 ? 00:00:00 kingbase: logical replication launcher
2.2.3 查看数据库服务端口状态
[kingbase@node1 data]$ netstat -an |grep :54321
tcp 0 0 0.0.0.0:54321 0.0.0.0:* LISTEN
tcp6 0 0 :::54321 :::* LISTEN
===从数据库服务进程状态及端口状态可知,数据库服务启动成功!===
三、连接数据库服务访问
3.1 数据库连接工具(ksql)帮助信息
[kingbase@node1 data]$ ksql --help
ksql is the Kingbase interactive terminal.
Usage:
ksql [OPTION]... [DBNAME [USERNAME]]
General options:
-c, --command=COMMAND run only single command (SQL or internal) and exit
-d, --dbname=DBNAME database name to connect to (default: "kingbase")
-f, --file=FILENAME execute commands from file, then exit
-l, --list list available databases, then exit
-v, --set=, --variable=NAME=VALUE
set ksql variable NAME to VALUE
(e.g., -v ON_ERROR_STOP=1)
-V, --version output version information, then exit
-X, --no-ksqlrc do not read startup file (~/.ksqlrc)
-1 ("one"), --single-transaction
execute as a single transaction (if non-interactive)
-?, --help[=options] show this help, then exit
--help=commands list backslash commands, then exit
--help=variables list special variables, then exit
Input and output options:
-a, --echo-all echo all input from script
-b, --echo-errors echo failed commands
-e, --echo-queries echo commands sent to server
-E, --echo-hidden display queries that internal commands generate
-L, --log-file=FILENAME send session log to file
-n, --no-readline disable enhanced command line editing (readline)
-o, --output=FILENAME send query results to file (or |pipe)
-q, --quiet run quietly (no messages, only query output)
-s, --single-step single-step mode (confirm each query)
-S, --single-line single-line mode (end of line terminates SQL command)
Output format options:
-A, --no-align unaligned table output mode
--csv CSV (Comma-Separated Values) table output mode
-F, --field-separator=STRING
field separator for unaligned output (default: "|")
-H, --html HTML table output mode
-P, --pset=VAR[=ARG] set printing option VAR to ARG (see \pset command)
-R, --record-separator=STRING
record separator for unaligned output (default: newline)
-t, --tuples-only print rows only
-T, --table-attr=TEXT set HTML table tag attributes (e.g., width, border)
-x, --expanded turn on expanded table output
-z, --field-separator-zero
set field separator for unaligned output to zero byte
-0, --record-separator-zero
set record separator for unaligned output to zero byte
Connection options:
-h, --host=HOSTNAME database server host or socket directory (default: "local socket")
-p, --port=PORT database server port (default: "54321")
-U, --username=USERNAME database user name (default: "kingbase")
-w, --no-password never prompt for password
-W, --password force password prompt (should happen automatically)
For more information, type "\?" (for internal commands) or "\help" (for SQL
commands) from within ksql, or consult the ksql section in the Kingbase
documentation.
Report bugs to <kingbase-bugs@kingbase.com.cn>.
3.2 连接数据库
[kingbase@node1 data]$ ksql -U system test
ksql (V8.0)
Type "help" for help.
test=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------+----------+-------------+-------------+-------------------
security | system | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 |
template0 | system | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/system +
| | | | | system=CTc/system
template1 | system | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/system +
| | | | | system=CTc/system
test | system | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 |
(4 rows)
3.3 创建测试数据
test=# create database prod;
CREATE DATABASE
test=# \c prod
You are now connected to database "prod" as user "system".
prod=# create table t1 (id int ,name varchar(10));
CREATE TABLE
prod=# insert into t1 values (10,'tom'),(20,'jerry');
INSERT 0 2
prod=# \d t1
Table "public.t1"
Column | Type | Collation | Nullable | Default
--------+----------------------------+-----------+----------+---------
id | integer | | |
name | character varying(10 char) | | |
prod=# select * from t1;
id | name
----+-------
10 | tom
20 | jerry
(2 rows)
四、总结
KingbaseES数据库服务启动比较简单,对于Linux系统可以通过sys_ctl工具启动数据库服务;对于Windows环境可以通过Windows服务启动,也可以通过Command界面通过sys_ctl启动。
参考文档:
《[安装与升级]基于Linux系统的数据库软件安装指南(单机版)》
KingbaseES 如何开启并进入数据库的更多相关文章
- wdcp 开启某个Mysql数据库远程访问
wdcp 开启某个Mysql数据库远程访问 登录wdcp后台-Mysql管理-phpmyadmin 输入Mysql的root密码登录进入 示例代码: update mysql.user set hos ...
- 开启本地MySql数据库远程连接
解决MySQL不允许从远程访问的方法 开启 MySQL 的远程登陆帐号有两大步: 1.确定服务器上的防火墙没有阻止 3306 端口. MySQL 默认的端口是 3306 ,需要确定防火墙没有阻止 33 ...
- Oracle记录-开启与关闭数据库
1.配置tnsnames.ora/listener.ora #cd /usr/oracle/oracle/product/11.2.0/db_1/network/admin ---切换到安装目录 #v ...
- 手动开启/关闭Oracle数据库
@echo off@echo 启动/关闭数据库set /p flag=您是否要启动数据库?(是按Y启动,否按N关闭) goto answer%flag% goto end :answery echo ...
- 开启、关闭数据库mysql
1.命令行 net start mysql net start mysql 2.点控制面板→管理→服务 招到mysql 3.找到安装目录下的bin目录
- 图文教程 | 开启远程访问mysql数据库权限
!!!考虑到安全性,不建议使用 所以将指定用户的host改为:% 即可 执行:(以root用户为例) use mysql; update user set host = "%" ...
- KingbaseES启动数据库失败后如何分析
关键字: KingbaseES.sys_ctl.启动日志 一.KingbaseES数据库服务启动 1.1 数据库启动机制 1) 数据库通过sys_ctl工具手工启动数据库服务kingbase. 2) ...
- 记录一次bug解决过程:resultType和手动开启事务
一.总结 二.BUG描述:MyBatis中resultType使用 MyBatis中的resultType类似于入参:parameterType.先看IDCM项目中的实际使用案例代码,如下: // L ...
- 基于Qt5.5.0的sql数据库、SDK_tts文本语音朗读的CET四六级单词背诵系统软件的编写V1.0
作者:小波 QQ:463431476 请关注我的博客园:http://www.cnblogs.com/xiaobo-Linux/ 我的第二款软件:CET四六级单词背诵软件.基于QT5.5.0.sql数 ...
随机推荐
- wcf .net webService和 .net webApi的联系与差异
首先,我们需要清楚它们的概念,然后才能走好下一步. wcf是对于ASMX,.Net Remoting,Enterprise Service,WSE,MSMQ等技术的整合,它是一种重量级消息交互框架,广 ...
- js烧脑面试题大赏
本文精选了20多道具有一定迷惑性的js题,主要考察的是类型判断.作用域.this指向.原型.事件循环等知识点,每道题都配有笔者详细傻瓜式的解析,偏向于初学者,大佬请随意. 第1题 let a = 1 ...
- 【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法
很多开发者在接入华为帐号服务时,经常会出现907135701的报错.根据官网文档说明,错误码907135701表示: 这个错误码在安卓和鸿蒙上都会出现,导致该报错的原因有很多,开发者可以按照下面几点进 ...
- Java ArrayList和LinkedList
目录 集合的概念 集合体系结构 常用list集合 list集合的特点 ArrayList LinkedList 创建对象 常用方法 遍历 ArrayList和LinkedList的区别 集合的概念 ...
- C语言-数据结构-结构体
一.结构体的定义 数组(Array)是一组具有相同类型的数据的集合.但在实际的编程过程中,我们往往还需要一组类型不同的数据,例如对于学生信息登记表,姓名为字符串,学号为整数,年龄为整数,所在的学习小组 ...
- 栈(Stack)和队列
栈(Stack)和队列 栈是一个后进先出的线性表,它要求只在表尾进行删除和插入操作. 所谓的栈,其实就是一个特殊的线性表.表尾称为栈顶(Top),相应的表头称为栈底(Bottom). 栈的插入(Pus ...
- Map集合概述和Map常用子类
概述java.util.Map接口 Map<K,V> 有两个泛型 类型参数:K - 此映射所维护的键的类型V - 映射值的类型 特点:1.Map集合是双列集合,一个元素包含两个值,一个是k ...
- MISC 2022/4/21 刷题记录-千字文
1.千字文 得到名为png的无类型文件,010 Editor查看,png,改后缀,得到二维码 QR扫描,得到一句话"这里只有二维码" 思路不对,binwalk一下,发现有错误信息 ...
- 使用Win自带的远程工具连接Linux
网上教程一大堆,我这边只简单记录一下,主要是黑屏问题,和剪贴板问题.Win连接Linux,一般都是使用的xrdp, 如果是使用的旧版本的Ubuntu,建议先装一下xfce桌面,gnome桌面一般连不起 ...
- Unity3D学习笔记9——加载纹理
目录 1. 概述 2. 详论 2.1. Resources方式 2.2. API方式 2.3. Web方式 1. 概述 理论上,Unity中加载纹理并没有什么难度,只需要将图片放置在Assets文件夹 ...