|
首先创建数据库用户kingbase,并且创建数据库数据目录和安装目录及数据库安装包上传目录,如下所示。
[root@localhost ~]# useradd kingbase
[root@localhost ~]# su -l kingbase
[kingbase@localhost ~]$ ls
data soft tools
上传数据库安装包ISO映像,以root用户加载数据库安装映像。只能以root用户安装,不能以kingbase用户加载映像,kingbase用户属于普通用户加载不了。如下所示
[root@localhost tools]# mount KingbaseES_V009R003C011B0003_Lin64_install.iso /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
现在切换为数据库用户kingbase,进入数据库安装包的上传目录tools进行安装,如下所示。
[root@localhost tools]# su -l kingbase
[kingbase@localhost ~]$ ls
data soft tools
[kingbase@localhost ~]$ cd tools/
[kingbase@localhost tools]$ ls
KingbaseES_V009R003C011B0003_Lin64_install.iso license_mysql.dat
[kingbase@localhost tools]$ cd /mnt
[kingbase@localhost mnt]$ ls
setup setup.sh
现在开始安装了,如果是在生产环境中,在安装之前,大家要提前根据自己的CPU、内存、硬盘的特性,单独做好有关操作系统内核参数、防火墙等方面的配置。这方面的内容,金仓社区的不少大佬的文章都有详细介绍,大家也可以参考金仓社区DBA实践一书。在安装之前由于忘记执行export LANG=zh_CN.UTF-8设置语言类别,导致安装界面全是英文输出。
[kingbase@localhost mnt]$ ./setup.sh -i console
Now launch installer...
Preparing to install
Extracting the JRE from the installer archive...
Unpacking the JRE...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
........
Launching installer...
===============================================================================
KingbaseES V9 (created with InstallAnywhere)
-------------------------------------------------------------------------------
Preparing CONSOLE Mode Installation...
===============================================================================
Please Wait
-----------
===============================================================================
Welcome
-------
This installer will guide you through the installation of KingbaseES V9.
It is strongly recommended that you quit all programs before continuing with
this installation. You may cancel this installation by typing 'quit'.
KingbaseES Version: V9
Kingbase Type:BMJ-NO
Installer Version: V009R003C011
Install DATE:202508071124
Kingbase Inc.
http://www.kingbase.com.cn
PRESS TO CONTINUE:
===============================================================================
Please Wait
-----------
===============================================================================
License Agreement
-----------------
Installation and Use of KingbaseES V9 Requires Acceptance of the Following
License Agreement:
China Electronics Technology Kingbase (Beijing) Technologies Inc.
"SOFTWARE END-USER LICENSE AGREEMENT"
IMPORTANT-READ CAREFULLY: This End-User License Agreement ("EULA") is a legal
agreement between you (either an individual or a single entity) and China
Electronics Technology Kingbase (Beijing) Technologies Inc.(abbreviated as
Kingbase in the context). The "software product" includes computer software,
and may include associated media, printed materials, and online
documentation(Software product). This "software product" includes any upgrade
and supplemental materials to the original "software product" provided by
Kingbase. Any software product that are provided with the "software product",
which are accompanied by their own license agreements or terms of use are
governed by this EULA. You agree to be bound by the terms of this EULA by
installing, copying, downloading, accessing or otherwise using the "software
product". If you do not agree to the terms of this EULA, you may not install,
copy or use the "software product".
SOFTWARE PRODUCT LICENSE
The "software product" is protected by copyright laws, international copyright
treaty and other intellectual property laws and treaties.
The "software product" is licensed to use, not sold.
PRESS TO CONTINUE:
1. GRANT OF LICENSE. As long as you follow this EULA, Kingbase grants you the
following non-exclusive, non-transitive rights:
APPLICATION SOFTWARE. You can use the software in locations as agreed in the
related contract. The usage is restricted by the quantity of the purchased and
the type of the license (as agreed in the contract). If the license type has
no special specification, you can only install, use, access, display, run or
use other methods to interact(run) with one copy of this "software product"
(or any previous versions on the same operating system) on a single computer,
workstation, handheld computer, smart phone or other electronic device
("computer").
RESERVATION OF RIGHTS. Except for the specific statements in this EULA,
Kingbase reserves all rights not expressly granted to you. Kingbase reserves
the right to interpret the content of the agreement.
2. LIMITATIONS AND OTHER RIGHT
LIMITATION ON TRANSFER. Under any condition, without the written permission of
Kingbase, you may not transfer this license and any usage permission under
this license.
PRESS TO CONTINUE:
NOT FOR RESALE SOFTWARE. If this "software product" is identified as "Not For
Resale", it may not be sold or otherwise transferred for value, or used for
any purpose other than demonstration, test or evaluation, no matter what else
is stated in this EULA.
LIMITATIONS ON REVERSE ENGINEERING, DECOMPILATION, AND DISASSEMBLY. You may
not reverse engineer, decompile, or disassemble the "software product", except
and only to the extent that such activity is expressly permitted by applicable
law not with standing this limitation.
TRADEMARKS. This EULA does not grant you any rights in connection with any
trademarks or service marks of Kingbase.
NO RENTAL. You may not rent, lease or lend the "software product" to others.
EXPORT LIMITATION. You admit that the "software product" is governed by the
export laws of People's Republic of China. You agree to obey all the
international and domestic laws applicable to this "software product",
including "Foreign Trade Law of the People's Republic of China", and other
restrictions and regulations issued by the Chinese government related to
software exportation.
PRESS TO CONTINUE:
PRODUCT SUPPORT. Kingbase provides you the support service related to the
software product ("support service"), but the specific content of the support
service is limited by related contract. Kingbase reserves the right to charge
the support service. The usage of support service is restricted by the
policies and plans in the user's manual, online document and/or other Kingbase
provided materials. Any supplemental software code provided to you should be
treated as a part of the "software product", and has to comply the terms and
conditions in this EULA. As for the technical information you provided to
Kingbase as a part of the support service, Kingbase may commercialize it,
including product support and development. Kingbase will not mention you
individually when using this technical information.
TERMINATION. Without prejudice to other rights, Kingbase may terminate this
EULA if you fail to comply with the terms and conditions of this EULA. In such
event, you must destroy all copies of the "software product" and all of its
component parts.
3. UPGRADES. If the "software product" is labeled as an upgrade, you must be
properly licensed to use a product identified by Kingbase as being eligible
for the upgrade in order to use the "software product". Kingbase reserves the
right to charge the upgrade version or upgrade. "software product" labeled as
PRESS TO CONTINUE:
an upgrade replaces and/or supplements the Eligible Product which you are
qualified to use. You may use the resulting upgraded product only in
accordance with the terms of this EULA. If the "software product" is an
upgrade of a component of a package of software programs that you licensed as
a single product, the "software product" may be used and transferred only as
part of that single product package and may not be separated for use on more
than one computer.
4. INTELLECTUAL PROPERTY. The ownership, copyright and other intellectual
property of the "software product" (including but not limited to the picture,
photo, animation, video, recordings, music, text and supplemental programs
contained in the "software product"), enclosed printed materials and any
copies of the "software product", is owner by Kingbase and its suppliers. The
ownership and intellectual property accessed by this "software product"
belongs to the owner of the contents, and may be protected by copyright laws,
and other intellectual property laws and treaties. This EULA does not grant
you the right to use these contents. If this "software product" include
documents only provided electronically, you can print one copy of the
electronic documents. You may not remove the copyright declaration from the
software, and ensures that the copyright declaration is copied for the replica
(whole or part) of the "software product". You agree to stop any forms of
illegal copying this software and the documents. You cannot copy the enclosed
PRESS TO CONTINUE:
printed materials in this "software product".
5. MULTIMEDIA SOFTWARE. You may obtain the "software product" through multiple
medias. No matter the type and size of the media you receive, you can only use
the media which is applicable to your single computer. You cannot run a
different media on another computer. Except for the part as in "permanent
transfer" of the "software product (as stated above), you cannot transfer the
other medias to another user via rent, lease or lend.
6. BACKUP COPY. After installing a copy of the "software product" according to
the EULA, you may keep the original media by which Kingbase provided you the
"software product" solely for backup or archival purpose. If original media is
needed to use the "software product", you may make one back-up copy solely for
your backup or archival purposes. Except as expressly provided in this EULA,
you may not otherwise make copies of the software, including the printed
materials accompanying the software. Authorized copy should be kept in secured
environments.
7. CONFIDENTIALITY. "Confidential information" includes program(including the
methods and concepts used in the program) and any information that Kingbase
identifies as exclusive or confidential. Unless expressly granted by this
EULA, you may not expose or provide the confidential information by other
PRESS TO CONTINUE:
methods to a third party and any employees to whom you do not grant the usage
in their business. You should take any reasonable, necessary measures to
ensure that the program or any component of the software is not exposed or
provided by other methods to a third party.
If you acquired the Kingbase product in People's Republic of China, the
following limited warranty applies to you.
1. LIMITED WARRANTY.
As long as you have valid license, Kingbase warrants that: (1) The "software
product" will perform substantially in accordance with the accompanying
materials for a period of ninety (90) days after the date of receipt. (2) The
provided support will perform substantially in accordance with the
accompanying materials, and Kingbase engineers will try their best to solve
any problems permitted by commercial range. If the product is not compliant to
the warranty, Kingbase will fix, replace the product or refund you for the
product, and you have to return the "software product" to Kingbase along with
the invoice held by you. If the malfunction of the product is due to accident,
abuse or misuse, then the warranty is not effective. The replaced product has
the residual of the original warranty period, or thirty days, whichever is
longer. To the maximum extent permitted by applicable law, except for the
above warranty, all expressed or implied warranties, conditions and other
PRESS TO CONTINUE:
terms are denied by Kingbase. All implicit warranties which cannot be excluded
are limited to 90 days or the minimum period allowed by the appropriate laws,
whichever is longer.
2. LIMITATION OF LIABILITY
To the maximum extent permitted by applicable law, except for the above
warranty, Kingbase and its suppliers shall not be liable for any damages
whatsoever (including without limitation, damages for loss of business
profits, business interruption, loss of business information or other
pecuniary loss) arising out of the use or inability to use the "software
product", even if Kingbase and its suppliers have been advised of the
possibility of such damages. In any case Kingbase and any of its suppliers'
entire liability under any provision of this EULA shall be limited to the
amount actually paid by you for the "software product" or RMB 10.00 Yuan,
which ever is higher. However, if you have signed support agreement with
Kingbase, all Kingbase's liability of the support service will be defined by
that agreement.
GOVERNING LAWS
This EULA is governed by the laws of the People's Republic of China (including
but not restricted to "Copyright Law of the People's Republic of China",
"Regulations for the Protection of Computer Software of the People's Republic
PRESS TO CONTINUE:
of China", "Trademark Law of the People's Republic of China", "Patent Law of
the People's Republic of China", "Anti-Unfair Competition Law of the People's
Republic of China", etc.). In respect of any dispute or claim which may arise
by this EULA or the violation of the EULA, you consent to the jurisdiction of
the federal and provincial courts sitting in the location of Kingbase. If
Kingbase's intellectual property is violated, the above terms do not restrict
Kingbase to apply remedial measures from the legitimate court with governing
rights.
China Electronics Technology Kingbase (Beijing) Technologies Inc.
Add: 2 layer, E block, Information Industrial Park, Rongda Road 7, Chaoyang
District, Beijing, 100102 China
Tel: 86-10-5885 1118
Http: //www.kingbase.com.cn
National Hotline: 400-601-1188
Support E-mail: support@kingbase.com.cn
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): y
===============================================================================
Choose Install Set
------------------
Please choose the Install Set to be installed by this installer.
->1- Full
2- Client
3- Custom
ENTER THE NUMBER FOR THE INSTALL SET, OR PRESS TO ACCEPT THE DEFAULT
: 1
默认为全部安装,我们也可以选择定制。
======================================================================
Please Wait
-----------
=============================================================================
Choose License File
-------------------
Use the Trial license if no license is selected.
Please replace the offical license before expiration.
File Path : /home/kingbase/tools/license_mysql.dat(这里要录入授权文件绝对路径)
License序列号 --- 启用 --- 22456E40-D15E-11EF-8CB3-000C29CBE49F
生产日期 --- 启用 --- 2025-01-13
产品名称 --- 启用 --- KingbaseES
细分版本模板名 --- 启用 --- SALES-企业版
产品版本号 --- 启用 --- V009R003C
浮动基准日期 ------ 启用
有效期间 --- 启用 --- 90
用户名称 --- 启用 --- MySQL试用授权
项目名称 --- 启用 --- MySQL试用授权
CPU检查 --- 启用 --- 0
容器名称 --- 禁用 --- 0
MAC地址 --- 启用 --- 00:00:00:00:00:00
最大连接数 --- 启用 --- 0
分区 --- 启用 --- 0
物理同步 --- 启用 --- 0
读写分离模块 --- 启用 --- 0
恢复到指定时间点 --- 启用 --- 0
集群对网络故障的容错 --- 启用 --- 0
快速加载 --- 启用 --- 0
日志压缩 --- 启用 --- 0
全文检索 --- 启用 --- 0
性能优化包(性能诊断) --- 启用 --- 0
性能优化包(性能调优) --- 启用 --- 0
保密通讯协议 --- 启用 --- 0
审计 --- 启用 --- 0
三权分立 --- 启用 --- 0
透明加密 --- 启用 --- 0
强制访问控制 --- 启用 --- 0
列加密 --- 启用 --- 0
密码复杂度 --- 启用 --- 0
用户锁定 --- 启用 --- 0
集群管理软件 --- 启用 --- 0
集群配置工具 --- 启用 --- 0
集群高级管理包 --- 启用 --- 0
并行查询 --- 启用 --- 0
并行备份还原 --- 启用 --- 0
异构数据源 --- 启用 --- 0
日志解析 --- 启用 --- 0
GIS --- 启用 --- 0
日志解析为SQL --- 启用 --- 0
操作系统类型 --- 启用 --- 0
数据守护集群 --- 启用 --- 0
多活共享存储集群 --- 启用 --- 0
从上面的输出信息看,虽然是试用版本,但支持的功能却不少。
===============================================================================
Choose Install Folder
---------------------
Please choose a destination folder for this installation.
Where would you like to install?
Default Install Folder: /opt/Kingbase/ES/V9
ENTER AN ABSOLUTE PATH, OR PRESS TO ACCEPT THE DEFAULT
: /home/kingbase/soft(这是我定义的数据库安装目录)
INSTALL FOLDER IS: /home/kingbase/soft
IS THIS CORRECT? (Y/N): y
===============================================================================
Pre-Installation Summary
------------------------
Please Review the Following Before Continuing:
Product Name:
KingbaseES V9
Install Folder:
/home/kingbase/soft
Product Features:
SERVER,
INTERFACE,
DEPLOY,
KSTUDIO,
KDTS
Install Disk Space Information
Require Disk space : 5112 MB Free Disk Space : 20258 MB
PRESS TO CONTINUE:
===============================================================================
Ready To Install
----------------
InstallAnywhere is now ready to install KingbaseES V9 onto your system at the
following location:
/home/kingbase/soft
PRESS TO INSTALL:
===============================================================================
Installing...
-------------
[==================|==================|==================|==================]
[------------------|------------------|------------------|------------------]
======================================================================
Choose a Folder for data directory
----------------------------------
Please choose a folder. The folder must be empty.
Data folder (Default: /home/kingbase/soft/data): /home/kingbase/data(这是我定义的数据库数据目录)
Port
----
Please enter database service listened port, default 54321.
Port (Default: 54321):
===============================================================================
User
----
Please enter database administrator user name.
User (Default: system):
===============================================================================
Enter Password
--------------
Please Enter the Password: Please Enter the Password:****
===============================================================================
Enter Password again
--------------------
Please Enter the Password Again: Please Enter the Password Again:****
===============================================================================
Server Encoding
---------------
Please enter server character set encoding.
1- default
->2- UTF8
3- GBK
4- GB2312
5- GB18030
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS TO ACCEPT THE DEFAULT:
===============================================================================
Locale
------
Please enter the Database Locale.
1- C
->2- zh_CN.UTF-8
3- en_US.UTF-8
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS TO ACCEPT THE DEFAULT:
===============================================================================
Database Mode
-------------
Please enter database mode.
->1- MySQL
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS TO ACCEPT THE DEFAULT:
===============================================================================
Case Sensitivity
----------------
Please enter the case sensitivity.
1- YES
->2- NO
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS TO ACCEPT THE DEFAULT:
===============================================================================
Block Size
----------
Please enter block size used in storing data.
->1- 8k
2- 16k
3- 32k
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS TO ACCEPT THE DEFAULT:
===============================================================================
Authentication Method
---------------------
Please enter the authentication method.
->1- scram-sha-256
2- scram-sm3
3- sm4
4- sm3
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS TO ACCEPT THE DEFAULT:
===============================================================================
Custom
------
Please enter database custom parameters.
Custom :
===============================================================================
Tips
----
The database will be initialized, which may take some time. Please be patient.
PRESS TO CONTINUE:
===============================================================================
Installation Complete
---------------------
Congratulations. KingbaseES V9 has been successfully installed to:
/home/kingbase/soft
If you want to register KingbaseES V9 as OS service, please run
/home/kingbase/soft/install/script/root.sh(这条命令用root执行一下)
PRESS TO EXIT THE INSTALLER:
Complete.
[kingbase@localhost ~]$ ksql
Licesen Type: SALES-企业版.
Type "help" for help.
kingbase=# \d
List of relations
Schema | Name | Type | Owner
--------+-------------------------+------+----------
public | sys_stat_statements | view | kingbase
public | sys_stat_statements_all | view | kingbase
(2 rows)
kingbase=# select version();
version
-------------------------
KingbaseES V009R003C011
(1 row)
kingbase=# show database_mode;
database_mode
---------------
mysql
(1 row)
test=# SELECT setting FROM pg_settings WHERE name = 'server_version';
setting
---------
12.1
(1 row)
从上面的语句输出后,kingbase使用的是PG内核12.1版本。
测试用户变量,如下所示。
test=# set @val=1;
SET
test=# select @val;
@val
------
1
(1 row)
test=# create table t(id int,name char(20));
test=# insert into t values(1,'mosk'),(2,'mike');
INSERT 0 2
test=# insert into t values(3,'john'),(4,'bob');
INSERT 0 2
test=# insert into t values(5,'lisa'),(6,'mary');
INSERT 0 2
test=# select * from t;
id | name
----+------
1 | mosk
2 | mike
3 | john
4 | bob
5 | lisa
6 | mary
(6 rows)
UPDATE语句中的LIMIT子句,如下所示,确实只更新了两条。
test=# update t set name='reddey' limit 2;
UPDATE 2
test=# select * from t;
id | name
----+--------
3 | john
4 | bob
5 | lisa
6 | mary
1 | reddey
2 | reddey
(6 rows)
试一下多表更新功能,先把测试表和数据搞起来,如下所示。
test=# create table t1(id int,name char(10));
CREATE TABLE
test=# create table t2(id int,name char(10));
CREATE TABLE
test=# insert into t1 values( 1,'1'),(2,'2');
INSERT 0 2
test=# insert into t2 values(1,'one'),(2,'two');
INSERT 0 2
test=# table t1;
id | name
----+------
1 | 1
2 | 2
(2 rows)
test=# table t2;
id | name
----+------
1 | one
2 | two
(2 rows)
test=# update t1,t2 set t1.name=t2.name where t1.id=t2.id;
UPDATE 2
test=# table t1;
id | name
----+------
1 | one
2 | two
(2 rows)
test=# table t2;
id | name
----+------
1 | one
2 | two
(2 rows)
REPLACE INTO语句的测试,做这种测试时我在表中添加了主键,如下所示。
test=# table t2;
id | name
----+------
1 | one
2 | two
(2 rows)
test=# alter table t2 add primary key(id);
ALTER TABLE
test=# replace into t2 values(2,'2');
INSERT 0 2
test=# table t2;
id | name
----+------
1 | one
2 | 2
(2 rows)
注:金仓数据库安装后,由于对数据库配置文件和客户认证文件已经做不少的优化处理,广大开发人员可以使用类似Navicat Premium工具进行连接开发,不用担心由于配置文件和客户认证文件的配置不当导致无法连接。听说Navicat Premium工具已经支持了电科金仓,亲自测试果然如此。
在生产环境中如果真要部署kingbase mysql兼容版,大家要根据自己的CPU、内存、IO、网络的实际情况,对数据库安装后的配置文件参数和动态参数信息做出适合自己的调整。由于kingbase是使用的PG内核开发的,不仅仅要学习mysql数据库,大家还是要下功夫学习一下PG数据库,以便更好地使用kingbase mysql兼容版发挥更好的性能。
不过,我有个疑问,金仓的mysql兼容版兼容是哪个mysql版本,各位网友如果知道,能否告知一下。
合作电话:010-64087828
社区邮箱:greatsql@greatdb.com