安装gauss数据库之前先查看自己的操作系统有没有rdtscp指令集,之前安装的时候我的电脑没有这个指令集搞了好久
查看指令集命令
cat /proc/cpuinfo | grep flags
安装python
CentOS7 默认已经安装了 Python2.7
[root@openGauss opt]# python2
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> quit()
因为 openGauss 依赖 Python3 环境,故需要安装 Python3.6,直接敲命令 python3 进入 python 交互式环境,默认安装Python3.6.8。
[root@openGauss yum.repos.d]# yum install python3.6*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package python3-pip.noarch 0:9.0.3-7.el7_7 will be installed
--> Processing Dependency: python(abi) = 3.6 for package: python3-pip-9.0.3-7.el7_7.noarch
--> Processing Dependency: /usr/bin/python3 for package: python3-pip-9.0.3-7.el7_7.noarch
---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed
---> Package python3-wheel.noarch 0:0.31.1-5.el7_7 will be installed
--> Running transaction check
---> Package python3.x86_64 0:3.6.8-13.el7 will be installed
--> Processing Dependency: python3-libs(x86-64) = 3.6.8-13.el7 for package: python3-3.6.8-13.el7.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.8-13.el7.x86_64
--> Running transaction check
---> Package python3-libs.x86_64 0:3.6.8-13.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================
Installing:
python3-pip noarch 9.0.3-7.el7_7 updates 1.8 M
python3-setuptools noarch 39.2.0-10.el7 base 629 k
python3-wheel noarch 0.31.1-5.el7_7 base 63 k
Installing for dependencies:
python3 x86_64 3.6.8-13.el7 base 69 k
python3-libs x86_64 3.6.8-13.el7 base 7.0 M
Transaction Summary
===================================================================================================================================
Install 3 Packages (+2 Dependent packages)
Total download size: 9.5 M
Installed size: 48 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/python3-3.6.8-13.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for python3-3.6.8-13.el7.x86_64.rpm is not installed
(1/5): python3-3.6.8-13.el7.x86_64.rpm | 69 kB 00:00:00
(2/5): python3-wheel-0.31.1-5.el7_7.noarch.rpm | 63 kB 00:00:00
(3/5): python3-setuptools-39.2.0-10.el7.noarch.rpm | 629 kB 00:00:01
Public key for python3-pip-9.0.3-7.el7_7.noarch.rpm is not installed==- ] 897 kB/s | 3.4 MB 00:00:06 ETA
(4/5): python3-pip-9.0.3-7.el7_7.noarch.rpm | 1.8 MB 00:00:02
(5/5): python3-libs-3.6.8-13.el7.x86_64.rpm | 7.0 MB 00:00:04
-----------------------------------------------------------------------------------------------------------------------------------
Total 1.9 MB/s | 9.5 MB 00:00:05
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python3-setuptools-39.2.0-10.el7.noarch 1/5
Installing : python3-libs-3.6.8-13.el7.x86_64 2/5
Installing : python3-3.6.8-13.el7.x86_64 3/5
Installing : python3-pip-9.0.3-7.el7_7.noarch 4/5
Installing : python3-wheel-0.31.1-5.el7_7.noarch 5/5
Verifying : python3-pip-9.0.3-7.el7_7.noarch 1/5
Verifying : python3-3.6.8-13.el7.x86_64 2/5
Verifying : python3-wheel-0.31.1-5.el7_7.noarch 3/5
Verifying : python3-setuptools-39.2.0-10.el7.noarch 4/5
Verifying : python3-libs-3.6.8-13.el7.x86_64 5/5
Installed:
python3-pip.noarch 0:9.0.3-7.el7_7 python3-setuptools.noarch 0:39.2.0-10.el7 python3-wheel.noarch 0:0.31.1-5.el7_7
Dependency Installed:
python3.x86_64 0:3.6.8-13.el7 python3-libs.x86_64 0:3.6.8-13.el7
Complete!
[root@openGauss opt]# python3
Python 3.6.8 (default, Apr 2 2020, 13:34:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
安装依赖
yum install -y bzip2 libaio-devel flex bison ncurses-devel glibc-devel patch
sudo vi /etc/sysctl.conf
net.ipv4.tcp_max_tw_buckets= 10000
net.ipv4.tcp_tw_reuse= 1
net.ipv4.tcp_tw_recycle= 1
net.ipv4.tcp_keepalive_time= 30
net.ipv4.tcp_keepalive_probes= 9
net.ipv4.tcp_keepalive_intvl= 30
net.ipv4.tcp_retries1= 5
net.ipv4.tcp_syn_retries= 5
net.ipv4.tcp_synack_retries= 5
net.ipv4.tcp_retries2= 12
vm.overcommit_memory= 0
net.ipv4.tcp_rmem= 8192 250000 16777216
net.ipv4.tcp_wmem= 8192 250000 16777216
net.core.wmem_max= 21299200
net.core.rmem_max= 21299200
net.core.wmem_default= 21299200
net.core.rmem_default= 21299200
net.ipv4.ip_local_port_range= 26000-65535
kernel.sem= 250 6400000 1000 25600
net.core.somaxconn= 65535
net.ipv4.tcp_syncookies= 1
net.core.netdev_max_backlog= 65535
net.ipv4.tcp_max_syn_backlog= 65535
net.ipv4.tcp_fin_timeout= 60
kernel.shmall= 1.15292E+18
kernel.shmmax= 1.84467E+19
net.ipv4.tcp_sack= 1
net.ipv4.tcp_timestamps= 1
vm.extfrag_threshold= 500
vm.overcommit_ratio= 90
MTU= 8192
修改系统资源限制
vi /etc/security/limits.conf
----------------------------
* soft stack 3072
* hard stack 3072
* soft nofile 1000000 ## gs_preinstall脚本自动设置,可以不手动设置
* hard nofile 1000000 ## gs_preinstall脚本自动设置,可以不手动设置
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.0.1/x86/openGauss-2.0.1-CentOS-64bit.tar.bz2
解压安装包
tar -jxvf openGauss-2.0.1-CentOS-64bit.tar.bz2
或者
curl -# -O https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.0.1/x86/openGauss-2.0.1-CentOS-64bit-all.tar.gz
解压
tar -zxvf openGauss-2.0.1-CentOS-64bit-all.tar.gz
设置OpenGauss环境变量
export GAUSSHOME=/home/user/openGauss
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GAUSSHOME/lib
export PATH=$PATH:$GAUSSHOME/bin
数据库初始化
gs_initdb -w agree@123 -D /home/user/gaussdb/data --nodename='sgnode'
或者直接安装
cd /home/user/openGauss/simpleInstall
sh install.sh -w agree@123 -p 5432
说明: - -w:初始化数据库密码(gs_initdb指定),安全需要必须设置。 - -p:指定的openGauss端口号, 如不指定,默认为5432。 - -h|–help 打印使用说明。 - 安装后,数据库的名称为sgnode。 - 安装后,数据库目录安装路径/opt/software/openGauss/data/single_node,其中/opt/software/openGauss为解压包路径,data/single_node为新创建的数据库节点目录。
远程连接设置
想要用navicat连接吗?
将数据库的认证改为MD5就能连接了
cd /home/user/openGauss/data/single_node
vi pg_hba.conf
允许所有网段连接 在IPv4 local connections下行添加
host all all 0.0.0.0/0 md5
vi postgresql.conf
将前面#去掉,改为*
listen_addresses = '*'
允许navicat连接设置,password_encryption_type改为0
password_encryption_type=0
重载和重启
启停数据库
gs_ctl -D /home/user/openGauss/data/single_node start
gs_ctl -D /home/user/openGauss/data/single_node stop
gs_ctl -D /home/user/openGauss/data/single_node reload
gs_ctl -D /home/user/openGauss/data/single_node restart
以postgres用户登录数据库
gsql -d postgres -p 5432
创建用户
CREATE USER agree IDENTIFIED BY 'Agree123';
查看密码是否MD5保存了,否则无法使用navicat连接
select rolname,rolpassword from pg_authid;
#修改密码
alter user agree with encrypted password 'Agree1234';
用户授予数据库管理员权限,默认用户没有创建数据库表权限需要修改其权限
ALTER ROLE gaussadmin SYSADMIN;
创建数据库gaussdb
CREATE DATABASE soa ENCODING 'UTF-8';
创建表test
create table t_sys(id int primary key,name varchar(40),pass varchar(20));
参考: