客户端安装练习
GBase 安装与客户端连接练习
一、数据库安装前的准备(以x86_64架构下的Linux为例)
1、创建gbasedbt组(使用root用户执行)
groupadd gbasedbt
创建gbasedbt用户并修改口令
useradd -g gbasedbt -d /home/gbasedbt -m gbasedbt
passwd gbasedbt (不设置密码会导致dbaccess进入数据库时提示密码错误)
2. linux网络环境设置
1、设置主机名与网络
配置/etc/hosts,仅主机名hostname与IP地址对应匹配
vim /etc/hosts 中添加上主机名称和IP对应关系
192.168.12.67 localhost.localdomain
2、关闭selinux
临时关闭selinux,省却对数据库软件安装的影响
/etc/selinux/config中的SELINUX=disabled
3、关闭或者配置防火墙
注:不同的系统,关闭方式不一样
如:RHEL6中service iptables stop
RHEL7中systemctl stop firewalld
二、GBase 8s SERVER安装
1、上传安装介质(使用root用户解压)
上传安装包到服务器并在单独的目录中解压。解压后产生安装文件(可使用x-shell类远程连接工具)
su - root //使用root用户解压
cd /opt //若上传安装包到/opt目录下
tar -xvf GBase8sV8.7_2.0.0.2.RHEL5_x86_64.tar
以下是解压后的文件(共7个):
bundle.properties CSDK ICONNECT ids_install
JDBC README.html SERVER
2、安装GBase 8s SERVER步骤--字符界面安装:(进入刚刚解压的目录下,使用root用户安装)
[root@localhost opt]# ./ids_install (注: . 后面没有空格,在opt目录下)
Preparing to install...
.........
If you want to change something on a previous step, type 'back'.
You may cancel this installation at any time by typing 'quit'.
PRESS <ENTER> TO CONTINUE: //回车
.........
2. RESTRICTIONS. Software is confidential and copyrighted. Title to Software
PRESS <ENTER> TO CONTINUE: //回车
LIMITATION OF LIABILITY. To the extent not prohibited by law, in no event
.........
PRESS <ENTER> TO CONTINUE: //回车
.........
7. CHINESE GOVERNMENT RESTRICTED. If Software is being acquired by
PRESS <ENTER> TO CONTINUE: //回车
.........
10. INTEGRATION. This Agreement is the entire agreement between you and
.........
PRESS <ENTER> TO CONTINUE: //回车
.........
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): Y
.........
Choose location for software installation
Default Install Folder: /opt/GBASE/gbase8s //默认安装路径
ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
: /opt/gbase8s //输入安装目录(该目录请提前建立好)
INSTALL FOLDER IS: /home/gbasedbt/gbase
IS THIS CORRECT? (Y/N): Y //确认安装目录,如正确,输入Y,反之N
.........
Minimum disk space required: 75 MB (without a server instance)
->1- Typical installation
2- Custom installation
3- Extract the product files (-DLEGACY option)
4- Create a RPM package for redistribution
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:: //回车,选择典型安装
.........
Create a server instance?
->1- Yes - create an instance
2- No - do not create an instance
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:: 1 //选择1,创建实例
==============================================================
Database Administrative Password
---------------------------------
Type 'back' to go to the previous step or 'quit' to cancel the installation.
==============================================================
Configuration - Number of Users
-------------------------------
Select the number of expected database users.
->1- 1 - 100
2- 101 - 500
3- 501 - 1000
4- 1000+
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:: //回车
InstallAnywhere is now ready to install GBase 8s Software Bundle onto your
system at the following location:
/opt/gbase8s
PRESS <ENTER> TO INSTALL: //回车
============================================================
Installing...
-------------
[==================|==================|==================]
[------------------|------------------|------------------|------------------]
===============================================================================
Server Initialization
---------------------
The server will now be initialized. Initialization might take quite a while,
depending on the performance of your computer.
PRESS <ENTER> TO CONTINUE: //回车(初始化实例, 需要等一段时间)
============================================================ Using the new instance
----------------------
A database server instance was created. If you chose to initialize the
instance, it is ready to use.
You can open a command prompt to an initialized instance by running one of the
following commands at /opt/gbase8s, where ol_gbasedbt1210 is the path or
filename of the instance.
Windows:
ol_gbasedbt1210.cmd
UNIX csh:
source ol_gbasedbt1210.csh
UNIX ksh or bourne:
./ol_gbasedbt1210.ksh
If initialization fails, check the online.log file for messages. The instance's
root chunk must be owned by the correct user and group, and it must have
readable and writable (rw) permission bits set only for owner and group.
PRESS <ENTER> TO CONTINUE: //回车
===========================================================
Installation Complete
---------------------
Congratulations! GBase 8s Software Bundle installation is complete.
Product install status:
GBase 8s: Successful
GBase 8s Connect: Successful
For more information about using GBase 8s products, see the GBase 8s
Information Center at http://www.gbase.cn.
PRESS <ENTER> TO EXIT THE INSTALLER: //回车
[root@localhost rh]#
执行完以上步骤,数据库安装完成。
3、安装成功后,三个重要配置文件
参数配置文件 onconfig.gbaseserver
连接信息文件 sqlhosts.gbaseserver
配置环境变量 profile.gbaseserver
3.1配置环境变量
复制环境变量,并使用gbasedbt用户,使得环境变量生效。
su - gbasedbt
cd /opt/gbase8s
cat ol_gbasedbt1210.ksh >> /home/gbasedbt/.bash_profile
su - gbasedbt
. .bash_profile
备注:
自动初始化的数据库服务名称GBASEDBTSERVER是ol_gbasedbt1210
数据库服务名(端口号)是在/etc/services中注册的ol_gbasedbt1210对应端口号
cat /etc/services | grep ol_gbasedbt1210
ol_gbasedbt1210 14958/tcp
3.2参数配置文件
onconfig配置参数文件名称在安装目录的etc目录下,在此文件中可设置8s的各种配置参数。
使用下面命令显示文件名:
echo $GBASEDBTDIR/etc/$ONCONFIG
/opt/gbase8s/etc/ onconfig.ol_gbasedbt1210
3.3连接信息文件
sqlhosts配置文件名称可设置连接的IP和端口号,在安装目录的etc目录下。
/opt/gbase8s/etc/sqlhosts.ol_gbasedbt1210
如果是默认安装实例,则sqlhost配置文件为
ol_gbasedbt1210 onsoctcp localhost.localdomainol_gbasedbt1210
dr_gbasedbt1210 drsoctcp localhost.localdomain dr_gbasedbt1210
lo_gbasedbt1210 onsoctcp 127.0.0.1 lo_gbasedbt1210
建议修改为本机IP和端口号(保留一行即可),以便访问速度更快,例如:
vi $GBASEDBTDIR/etc/sqlhosts.$GBASEDBTSERVER
ol_gbasedbt1210 onsoctcp 192.168.12.67 9088
基本管理练习
服务启停和模式转换命令练习:(在做模式转换时,要注意当前实例模式的状态)
A、通过onstat -l查看逻辑日志/物理日志。
B、启动实例(oninit -v),并查看实例状态(onstat -)
C、将实例切换成单用户模式(onmode -j),查看实例状态(onstat -)
D、切换实例状态到在线状态(onmode -m),查看实例状态(onstat -)
E、关闭实例(onmode -ky),查看实例状态(onstat -)
dbaccess连接数据库(Linux命令行方式连接服务器)
1、尝试下面3种连接方法,每种方法连接到实例后,请执行建库建表和查询语句来熟悉dbaccess工具。
第一种方法—菜单选择式环境:dbaccess
连接进入后执行:
建库: testdb
依次选择 Database -->> Create -->> testdb -->> Exit -->> Create-new-database-->>Exit
建表:t(no int,name varchar(20),birth date)
插入一条数据
Insert into t values (1,’zhangsan’,today);
查看数据:
select * from t;
退出
第二种方法—命令行编辑器环境:dbaccess - -
连接进入后执行:
create database testdb2 in datadbs1 with log;
database testdb2;
Create table t (no int,name varchar(20),birth date);
insert into t values(1,'zhangsan','12/1/2017');
insert into t values(2,'lisi','12/2/2017');
insert into t values(3,'wangwu','12/3/2017');
select * from t;
close database;
退出
第三种方法—指定实例的命令行编辑器环境:dbaccess sysmaster@ol_gbasedbt1210 -
(sysmaster 是系统数据库,ol_gbasedbt1210是实例名)
连接进入后执行:
查询当前实例名
SELECT DBSERVERNAME FROM sysmaster:sysdual;
查看当前所有数据库
select name from sysmaster:sysdatabases;
查看数据库test中的第一张表
select first 1 dbsname,tabname from sysmaster:systabnames where dbsname='testdb2';
查看test库中表t的第2条记录(略过结果集第一条记录后的1条记录)
database testdb2;
select skip 1 first 1 * from t;
退出dbaccess,可使用命令dbschema -d testdb2 -t t 查询test库中t表的表结构
企业管理器连接数据库(windows)
企业管理器为windows端的客户端,是一款绿色软件,只要解压缩即可直接使用。
双击GBaseDataStudio.exe 软件,启动企业管理器,然后点“新建连接向导”图标,选择“GBase8s”,进入“通用JDBC连接设置”窗口,见下图:
JDBC URI先不用管,会根据下面内容自动设置,其他栏位设置方法如下:
主机:填写服务器ip地址。
查询命令:ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:B1:2C:A0
inet addr:192.168.12.67 Bcast:192.168.12.255 Mask:255.255.255.0
端口号:
查询方式:填写用GBASEDBTSERVER环境变量对应的端口
查询/etc/services 文件 在命令行模式下搜索 :/ol_gbasedbt1210 找到对应的端口号
ol_gbasedbt1210 14958/tcp
服务器:
[gbasedbt@localhost etc]$ echo $GBASEDBTSERVER
ol_gbasedbt1210
数据库/模式
写一个具体的数据库名称或者写sysmaster系统库名称
用户名/密码:
写数据库的用户名和密码,例如管理员 gbasedbt
都填好之后,单击“测试连接”测试通过则连接成功,单击“下一步”保存即可。
异常情况:
如果配置都正确,但是企业管理器长时间连接不上服务器,需查看windows防火墙是否关闭。
再检查linux服务器上的防火墙是否关闭
使用ping命令,看windows能否ping通linux服务器的IP
再检查8s服务是正常启动状态,使用 onstat – 命令
评论
热门帖子
- 12025-12-01浏览数:181724
- 22023-05-09浏览数:23894
- 42023-09-25浏览数:17076
- 52020-05-11浏览数:16212