GaussDB T单机部署
【摘要】 近期GaussDB很火,作为一名DBA,本身对国产数据库有无限憧憬与向往,所以就先走一步,体验一下。 GaussDB安装过程中使用Python脚本实现,此处仅简要记录安装步骤。部署环境说明: Centos7.5 mini安装 CPU:1C MEM:2G磁盘:100G1.系统初始 1>关闭防火墙[root@Gauss1 ~]# systemctl status f...
近期GaussDB很火,作为一名DBA,本身对国产数据库有无限憧憬与向往,所以就先走一步,体验一下。
GaussDB安装过程中使用Python脚本实现,此处仅简要记录安装步骤。
部署环境说明:
Centos7.5 mini安装
CPU:1C MEM:2G磁盘:100G
1.系统初始
1>关闭防火墙
[root@Gauss1 ~]# systemctl status firewalld.service
[root@Gauss1 ~]# systemctl stop firewalld.service
[root@Gauss1 ~]# systemctl disable firewalld.service
[root@G0 ~]# firewall-cmd --state
not running
[root@G0 ~]#
2>调整内核参数
/etc/sysctl.conf追加如下内容:
kernel.sem = 50100 128256000 50100 2560
net.core.netdev_max_backlog = 1000
net.ipv4.tcp_max_syn_backlog = 2048
kernel.core_pattern = /corefile/core.%p.%e
kernel.core_uses_pid = 1
kernel.shmmni = 4096
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
fs.file-max = 6815744
增加完成后执行sysctl -p更新
3>配置本地YUM源,安装依赖包
echo "/dev/sr0 mnt/iso iso9660 defaults,loop 0 0" >> etc/fstab
mkdir -p mnt/iso
rm -rf /etc/yum.repos.d/*
cat >> etc/yum.repos.d/ios.repo <<EOF
[ios]
name=ios
baseurl=file:///mnt/iso
enabled=1
gpgcheck=0
EOF
mount -a
yum repolist
配置完成后,检查依赖包。安装未安装的依赖包
[root@G0 ~]# unset uninstall_rpm;for i in zlib readline gcc python python-devel perl-ExtUtils-Embed readline-devel zlib-devel lsof;do rpm -q $i &>/dev/null || uninstall_rpm="$uninstall_rpm $i";done ;[[ -z "$uninstall_rpm" ]] && echo -e "\nuninstall_rpm:\n\tOK.OK.OK" || echo -e "\nuninstall_rpm:\n\t$uninstall_rpm"
uninstall_rpm:
gcc python-devel perl-ExtUtils-Embed readline-devel zlib-devel
[root@G0 ~]# yum -y install gcc python-devel perl-ExtUtils-Embed readline-devel zlib-devel
安装完成后,再次执行脚本,如果均已按安装,会输出“ OK.OK.OK”
4>管理用户创建
[root@G0 ~]# groupadd -g 1000 dbgrp
[root@G0 ~]# useradd -u 1100 -g dbgrp -d home/omm -m -s bin/bash omm
[root@G0 ~]# passwd omm
5>目录规划
[root@G0 ~]# mkdir -p opt/software/gaussdb --软件包存放目录
[root@G0 ~]# mkdir -p opt/gaussdb/data --数据目录
[root@G0 ~]# mkdir -p opt/gaussdb/log --日志目录
[root@G0 ~]# mkdir -p opt/gaussdb/gaussdb --软件家目录
[root@G0 ~]# chown omm:dbgrp /opt -R
6>突破上传解压
[omm@G0 ~]$ cd opt/software/gaussdb/
[omm@G0 gaussdb]$ rz GaussDB_100_1.0.0-DATABASE-REDHAT-64bit.tar.gz
[omm@G0 gaussdb]$ ls
GaussDB_100_1.0.0-DATABASE-REDHAT-64bit.tar.gz
[omm@G0 gaussdb]$ tar -xzf GaussDB_100_1.0.0-DATABASE-REDHAT-64bit.tar.gz
[omm@G0 gaussdb]$ ls
GaussDB_100_1.0.0-DATABASE-REDHAT-64bit GaussDB_100_1.0.0-DATABASE-REDHAT-64bit.tar.gz
2.安装展开
1>执行安装命令
[root@G0 ~]# cd /opt/software/gaussdb/GaussDB_100_1.0.0-DATABASE-REDHAT-64bit
[root@G0 GaussDB_100_1.0.0-DATABASE-REDHAT-64bit]# ls
funclib.py GaussDB_100_1.0.0-RUN-REDHAT-64bit.tar.gz sshexkey.py
GaussDB_100_1.0.0-RUN-REDHAT-64bit.sha256 install.py upgrade.py
[root@G0 GaussDB_100_1.0.0-DATABASE-REDHAT-64bit]# python install.py -U omm:dbgrp -R /opt/gaussdb/gaussdb100 -D /opt/gaussdb/data -C LSNR_ADDR=127.0.0.1,192.168.0.11 -C LSNR_PORT=1888 -C DATA_BUFFER_SIZE=500m -C SHARED_POOL_SIZE=150M -C TEMP_BUFFER_SIZE=150M
Error: Run package GaussDB_100_1.0.0-RUN-REDHAT-64bit.tar.gz is inconsistent with os system centos.
Please refer to install log "/home/omm/zengineinstall.log" for more detailed information.
[root@G0 GaussDB_100_1.0.0-DATABASE-REDHAT-64bit]#
报错是因为操作系统模型检查未通过,可通过编辑install.py规避(注释掉L572,573安装脚本中的校验)
571 # check os version of package is mattched with current os version
572 #if self.run_pkg_name.find(distname.upper().replace("OS", "")) == -1: --注释掉
573 # logExit("Run package %s.tar.gz is inconsistent with os system %s." % (self.run_pkg_name, distname)) --注释掉
574
重新执行
[root@G0 GaussDB_100_1.0.0-DATABASE-REDHAT-64bit]# python install.py -U omm:dbgrp -R /opt/gaussdb/gaussdb100 -D /opt/gaussdb/data -C LSNR_ADDR=127.0.0.1,192.168.0.11 -C LSNR_PORT=1888 -C DATA_BUFFER_SIZE=500m -C SHARED_POOL_SIZE=150M -C TEMP_BUFFER_SIZE=150M
Checking runner.
Checking parameters.
End check parameters.
Checking user.
End check user.
Checking old install.
End check old install.
Checking kernel parameters.
Checking directory.
Checking integrality of run file...
Decompressing run file.
Setting user env.
Checking data dir and config file
Initialize db instance.
Creating database.
Creating database succeed.
Changing file permission due to security audit.
Install successfully, for more detail information see /home/omm/zengineinstall.log.
[root@G0 GaussDB_100_1.0.0-DATABASE-REDHAT-64bit]#
成功完成安装后,数据库预设是启动的。
[omm@G0 ~]$ ps -ef | grep zengine
omm 26232 1 7 18:49 ? 00:00:14 /opt/gaussdb/gaussdb100/bin/zengine nomount -D /opt/gaussdb/data
omm 26312 25605 0 18:52 pts/3 00:00:00 grep --color=auto zengine
[omm@G0 ~]$
2>首次登陆数据库,修改默认密码
[omm@G0 ~]$ zsql SYS/Changeme_123@127.0.0.1:1888 -q
connected.
SQL> alter user sys identified by 123456 replace Changeme_123;
GS-00657, Password is too simple, password should contain at least three of the following character types:
A. at least one lowercase letter
B. at least one uppercase letter
C. at least one digit
D. at least one special character: `~!@#$%^&*()-_=+\|[{}]:'",<.>/? and space --密码复杂度要求
SQL> alter user sys identified by "aA123!@#" replace Changeme_123;
Succeed.
SQL>
3.测试使用:
1>创建用户表空间
SQL> create tablespace kevin datafile '/opt/gaussdb/data/kevin' size 100M autoextend on;
SQL> create user kevin identified by "kevinA1!" default tablespace kevin temporary tablespace temp;
SQL> grant connect,resource to kevin;
2>创建表并测试性能
SQL> create table kevin.test as select * from dv_tablespaces;
SQL> select count(*) from kevin.test;
COUNT(*)
--------------------
7
1 rows fetched.
SQL> set timing on
SQL> insert into kevin.test select * from kevin.test;
... --重复执行多次
SQL> insert into kevin.test select * from kevin.test;
3670016 rows affected.
Elapsed: 18.545 sec
SQL> insert into kevin.test select * from kevin.test;
7340032 rows affected.
Elapsed: 55.795 sec
SQL>
如上,插入734w数据仅耗时55s,这个速度令人惊奇,非常厉害。
4.补充
下次开机后不会自动启动,需要手动启。
[omm@G0 ~]$ cd /opt/gaussdb/gaussdb100/bin/
[omm@G0 bin]$ python zctl.py -t start
Successfully started instance.
[omm@G0 bin]
本文转自“墨天轮”社区GaussDB频道
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)