安装前提:
安装gaussdb 100的文件存储空间必须大于20G,否则安装完成后(该版本不会因为空间不足导致安装报错)无法新建表空间和在表空间里新建用户导致无法用DataStudio工具连接gaussdb
安装前建议使用 df -h 查看磁盘空间
1.内核参数优化(可忽略)
[[email protected] ~]# /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 = /tmp/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
[[email protected] ~]# sysctl -p
[[email protected] ~]# vi /etc/profile ulimit -c unlimited
[[email protected] ~]# source /etc/profile
2.禁用防火墙以及SElinux(已经操作过的可跳过)
[[email protected] ~]# systemctl disable firewalld Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[[email protected] ~]# sed -i -e 's,enforcing,disabled,' /etc/selinux/config
完成后,重启服务器
3 安装软件包
安装依赖包
[[email protected] ~]# yum install -y zlib readline python python-devel perl-ExtUtils-Embed readline-devel zlib-devel lsof expect mlocate openssl-devel sqlite-devel bzip2-devel libffi libffi-devel gcc gcc-c++ ntp ntp-date
检查依赖包
[[email protected] ~]# 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"
如果均已安装,会输出"OK.OK.OK"
4 创建用户
[[email protected] ~]# groupadd dbgrp [[email protected] ~]# useradd -g dbgrp -d /home/omm -m -s /bin/bash omm [[email protected] ~]# echo redhat|passwd --stdin omm
5 创建软件目录
[[email protected] ~]# mkdir -p /opt/software/gaussdb [[email protected] ~]# cd /opt/software/gaussdb/
上传安装包到/opt/software/gaussdb
[[email protected] gaussdb]# tar -xzf /tmp/GaussDB_100_1.0.0-DATABASE-REDHAT-64bit.tar.gz
6 安装GaussDB 100
[[email protected] gaussdb]# cd GaussDB_100_1.0.0-DATABASE-REDHAT-64bit
[[email protected] GaussDB_100_1.0.0-DATABASE-REDHAT-64bit]# python install.py -U omm:dbgrp -R /opt/gaussdb/app -D /opt/gaussdb/data -C LSNR_ADDR=127.0.0.1,192.168.2.6 -C LSNR_PORT=1888
192.168.2.6 为虚拟机地址
安装完成后数据库默认是启动状态(重启虚拟机后需要手动启动guassdb数据库)
安装失败时
出现重装报错:Database has been installed already.
REPL_PORT=1889 -C "LOG_ARCHIVE_DEST_2=SERVICE=192.168.56.21:1889 SYNC" -C CHECKPOINT_TIMEOUT=3 -C SESSIONS=1500 -C REPL_WAIT_TIMEOUT=30000
Checking runner.
Checking parameters.
End check parameters.
Checking user.
End check user.
Checking old install.
Error: Database has been installed already.
Please refer to install log "/home/omm/zengineinstall.log" for more detailed information.
解决办法:检查日志/home/omm/zengineinstall.log
找到相关配置文件
[2020-03-09 22:37:31] Using user profile : /home/omm/.bashrc
[2020-03-09 22:37:31] Error: Database has been installed already.
修改配置文件
[[email protected] etc]# vi /home/omm/.bashrc
删除环境变量中Gaussdb参数:
export GSDB_HOME="/opt/gaussdb/app"
export PATH="/opt/gaussdb/app/bin":$PATH
export LD_LIBRARY_PATH="/opt/gaussdb/app/lib":"/opt/gaussdb/app/add-ons":$LD_LIBRARY_PATH
export GSDB_DATA="/opt/gaussdb/data"
删除以上参数后重新安装
当出现错误:
Error: Run package GaussDB_100_1.0.0-RUN-REDHAT-64bit.tar.gz is inconsistent with os system centos.
解决办法:在install.py文件中将
if self.run_pkg_name.find(distname.upper().replace("OS", "")) == -1;
改成
if self.run_pkg_name.find(distname.upper().replace("OS", "")) == -2;
7 数据库的启动与关闭
启动数据库(每次启动虚拟机都需要启动数据库)
[[email protected] ~]# su - omm [[email protected] ~]$ cd /opt/gaussdb/app/bin [[email protected] bin]$ python zctl.py -t start Zengine instance has already started.
关闭数据库
[[email protected] bin]$ python zctl.py -t stop Successfully stopped instance.
8 设置用户白名单
[[email protected] bin]$ vi /opt/gaussdb/data/cfg/zhba.conf
添加IP白名单(没有白名单的IP地址无法通过客户端连接gaussdb数据库)
保存后进入数据库
[[email protected] bin]$ zsql SYS/[email protected]:1888
SQL> ALTER SYSTEM RELOAD HBA CONFIG;
查看白名单
SQL> ALTER * FROM SYS.DV_HBA;
9 创建表空间以及用户
默认用户无法通过客户端进入数据库
必须新建表空间 在表空间创建用户
SQL> create tablespace spacewalk datafile '/opt/gaussdb/data/data/spw01' size 1G maxsize unlimited;
SQL> create user spwuser identified by ABCabc123 default tablespace spacewakl;
SQL> grant dba to spwuser;
10 使用Data Studio工具连接(用户:spwuser;密码:ABCabc123)