3-8 创建 XML 配置文件,用于数据库安装
[root@opengauss openGauss]#
vi clusterconfig.xml
将以下内容添加进 clusterconfig.xml 文件中。输入"i"切换到编辑模式,复
制内容粘贴到文档中,然后按下 ESC 键退出编辑模式,然后输入":wq"退出并
进行保存。
下面的文档中黄色标出的地方,需要根据 centos 安装时的主机名和 ip 地址进
行设置。
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss 整体信息 -->
<CLUSTER>
<PARAM name="clusterName" value="dbCluster" />
<PARAM name="nodeNames" value="
opengauss
" />
<PARAM name="backIp1s" value="
192.168.1.7
"/>
<PARAM name="gaussdbAppPath" value="/opt/gaussdb/app" />
<PARAM name="gaussdbLogPath" value="/var/log/gaussdb" />
<PARAM name="gaussdbToolPath" value="/opt/huawei/wisequery"
/>
<PARAM name="corePath" value="/opt/opengauss/corefile"/>
<PARAM name="clusterType" value="single-inst"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- node1 上的节点部署信息 -->
<DEVICE sn="1000001">
<PARAM name="name" value="
opengauss
"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将 backIP1 和 sshIP1 配置
成同一个 IP -->
<PARAM name="backIp1" value="
192.168.1.7
"/>
<PARAM name="sshIp1" value="
192.168.1.7
"/>
<!--dbnode-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="26000"/>
<PARAM name="dataNode1" value="
/gaussdb/data/opengauss
"/>
</DEVICE>
</DEVICELIST>
</ROOT>
3-8 使用putty将安装包解压至存放目录
使用 openGauss-2.1.0-CentOS-64bit-all.tar.gz,已经提前下载
使用 winSCP 连接服务器,上传该安装包
这里主机名是安装 centos 时的。用户名为 root,密码是 openGauss,设置后,
点击登录
登录后,在左边选择自己电脑中存放安装包的位置 ,右边就是服务器中,要上传安装包的位置
找到你下载openGauss-2.1.0-CentOS-64bit-all.tar.gz的路径
在右侧虚拟机目录找到 /opt/software/openGauss/,这是之前3-7创的
在左侧的压缩包中点击右键,在出现的菜单中选择上传
上传成功
3-9 将下载好的安装包解压至存放目录
先解压 openGauss-2.1.0-CentOS-64bit-all.tar.gz 包。注意命令是在openGauss目录下输入的
[root@opengauss openGauss]#
tar -zxvf openGauss-2.1.0-CentOS-64bit-all.tar.gz
openGauss-2.1.0-CentOS-64bit-om.tar.gz
openGauss-2.1.0-CentOS-64bit.tar.bz2
openGauss-2.1.0-CentOS-64bit-om.sha256
openGauss-2.1.0-CentOS-64bit.sha256
upgrade_sql.tar.gz
upgrade_sql.sha256
再解压 openGauss-2.1.0-CentOS-64bit-om.tar.gz
[root@opengauss openGauss]#
tar -zxvf openGauss-2.1.0-CentOS-64bit-om.tar.gz
./lib/
./lib/pyasn1/
./lib/pyasn1/codec/
./lib/pyasn1/codec/cer/
。。。。。。。。。。。。
解压后如下,用 ls 命令查看如下:
[root@opengauss openGauss]#
ls
clusterconfig.xml openGauss-2.1.0-CentOS-
64bit-om.tar.gz simpleInstall
lib openGauss-2.1.0-CentOS-
64bit.sha256 upgrade_sql.sha256
openGauss-2.1.0-CentOS-64bit-all.tar.gz openGauss-2.1.0-CentOS-
64bit.tar.bz2 upgrade_sql.tar.gz
openGauss-2.1.0-CentOS-64bit-om.sha256 script
version.cfg
安装包解压后,会在/opt/software/openGauss 路径下自动生成 script 子目
录,并且在 script 目录下生成 gs_preinstall 等各种 OM 工具脚本。
这些是我们后续安装需要使用的。
更改权限。
[root@opengauss openGauss]#
chmod 755 -R /opt/software
3-10 执行初始化脚本
[root@opengauss openGauss]# cd script
[root@opengauss script]#
python gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml
没有错误跳过即可
[GAUSS-50217] : Failed to decompress version.cfg.The cmd is cd
/opt/software/openGauss/script/../ && tar -xpf `head -1 version.
cfg`*.tar.bz2 ./version.cfg. The output is tar (child): lbzip2:
Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now.
出现错误,因为少解压软件,安装。。
[root@opengauss script]#
yum install bzip2
报错,无法安装
Downloading packages:
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^
SyntaxError: invalid syntax
从网上查找解决方案
[root@opengauss script]# vi /usr/libexec/urlgrabber-ext-down
将第一行"#!/usr/bin/python" 改为 "
#!/usr/bin/python2.7
"即可。
修改后,重新安装
[root@opengauss script]#
yum install bzip2
这次安装成功!
继续执行初始化脚本
[root@opengauss script]#
python gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml
Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
Setting pssh path
Successfully set core path.
Are you sure you want to create the user[omm] and create trust for it
(yes/no)?
yes
Please enter password for cluster user.
Password:这里输入密码为 openGauss@123,但是输入的时候是看不到的
Please enter password for cluster user again.
Password: 这里输入密码为 openGauss@123,但是输入的时候是看不到的
Successfully created [omm] user on all nodes.
Preparing SSH service.
Successfully prepared SSH service.
Checking OS software.
Successfully check os software.
Checking OS version.
Successfully checked OS version.
Creating cluster's path.
Successfully created cluster's path.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Warning: Installation environment contains some warning messages.
Please get more details by "/opt/software/openGauss/script/gs_checkos
-i A -h opengauss --detail".
Set and check OS parameter completed.
Preparing CRON service.
Successfully prepared CRON service.
Setting user environmental variables.
Successfully set user environmental variables.
Setting the dynamic link library.
Successfully set the dynamic link library.
Setting Core file
Successfully set core path.
Setting pssh path
Successfully set pssh path.
Setting Cgroup.
Successfully set Cgroup.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.
初始化安装成功!
3-11 初始化数据库
用 init 6 重启下虚拟机(主要是为了释放一些内存资源)。
[root@opengauss script]#
init 6
等虚拟机重启后,再重新打开 putty 连接
输入用户名 root,密码 openGauss
先更新下权限。
[root@opengauss ~]# chmod 755 -R /opt/software
使用 omm 用户进行数据库初始化。
[root@opengauss ~]# su - omm
Last login: Sun Mar 27 01:07:53 CST 2022 on pts/0
[omm@opengauss ~]$ cd /opt/software/openGauss/script
[omm@opengauss script]$ gs_install -X /opt/software/openGauss/clusterconfig.xml --gsinit-
parameter="--encoding=UTF8" --dn-guc="max_process_memory=4GB" --dn-guc="shared_buffers=128MB" --dn-guc="bulk_write_ring_size=128MB" --dn-guc="cstore_
buffers=16MB"
Parsing the configuration file.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Successfully created the backup directory.
begin deploy..
Installing the cluster.
begin prepare Install Cluster..
Checking the installation environment on all nodes.
begin install Cluster..
Installing applications on all nodes.
Successfully installed APP.
begin init Instance..
encrypt cipher and rand files for database.
Please enter password for database: 这里输入密码为 openGauss@123,但
输入时看不到
Please repeat for database: 这里输入密码为 openGauss@123,但是输入的
时候是看不到的
begin to create CA cert files
The sslcert will be generated in /opt/gaussdb/app/share/sslcert/om
Cluster installation is completed.
Configuring.
Deleting instances from all nodes.
Successfully deleted instances from all nodes.
Checking node configuration on all nodes.
Initializing instances on all nodes.
Updating instance configuration on all nodes.
Check consistence of memCheck and coresCheck on database nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
Successfully started cluster.
Successfully installed application.
end deploy..
安装成功!
3-12 测试!!
终于到这一步了,终于等到你~~~~
使用普通用户登录
[omm@opengauss script]$ su - omm
Password: 这里输入密码为 openGauss@123
Last login: Sun Mar 27 01:20:15 CST 2022 on pts/0
[omm@opengauss ~]$ gs_om -t start
Starting cluster.
=========================================
[SUCCESS] opengauss:
[2022-03-27 01:26:42.531][6742][][gs_ctl]: gs_ctl started,datadir is
/gaussdb/data/opengauss
[2022-03-27 01:26:42.537][6742][][gs_ctl]: another server might be
running; Please use the restart command
=========================================
Successfully started.
[omm@opengauss ~]$ gsql -d postgres -p 26000 -r
gsql ((openGauss 2.1.0 build 590b0f8e) compiled at 2021-09-30
14:29:04 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring
high-security)
Type "help" for help.
openGauss=#
成功!!!
千辛万苦
三、使用SQL语句测试
sql语句参考链接:openGauss数据库基本操作(超详细)_hlsongsong的博客-CSDN博客
1.创建数据库用户
create user joe password "Huawei_123";
2.创建数据库,并指定所有者owner
create database joe_db owner joe;
3. 切换到joe_db数据库
openGauss=# \c joe_db
4. 切换到joe用户
joe_db=# \c - joe
Password for user joe: Huawei_123
5. 为用户joe创建一个模式joe1
create schema 模式名 authorization 用户名;
create schema joe1 authorization joe;
joe_db=> create schema joe1 authorization joe;
6. 创建表
CREATE TABLE teacher (
tno VARCHAR(20) NOT NULL PRIMARY KEY,
name VARCHAR(15) NOT NULL,
gender CHAR(3),
email VARCHAR(50) NOT NULL,
address VARCHAR(100) NOT NULL
);
7.报错
普通用户创建数据库时报错:ERROR: permission denied to create database
登陆超级用户omm进入数据库,进行授权
GRANT ALL PRIVILEGES TO 新用户;
\q 退出数据库
su - omm omm登录
gs_om -t start
gsql -d postgres -p 26000 -r
GRANT ALL PRIVILEGES TO joe;
继续刚才的,切换数据库joe_db,用户joe,继续创建表,不用再创模式了
参考原文链接:opengauss(postgresql)创建用户等基本命令_opengauss创建用户_vv_a的博客-CSDN博客
8.往teacher表插入数据记录
INSERT INTO teacher VALUES ('21003','花花','男','123@qq.com','上海天龙人');
9.插入成功,查看表中数据
select * from teacher;
总结
恭喜你走到最后,it的勇士!这些都是我以学校老师提供的资料为主体,参考网上资料摸索出来的,当初折磨了两三个星期,最后发现可以直接从实验室拷贝一份老师已经安装好的(但是账号是老师设置的,网卡和ip还要自己设置)。过程是曲折的,关于Linux操作系统、openGauss数据库才刚刚开始学习,很多东西都是先学先卖,还有很多的要学,若在安装过程遇到任何问题,请尽情百度,或者为什么不问问“万能的”GPT呢?第一次写博客,希望这篇文章给你带来帮助。