2023年12月8日发(作者:芒驰)
华为国产openGauss数据库安装详细教程
安装openGauss步骤
一、检查硬件配置
#cat /proc/cpuinfo |grep processor
#cat /etc/redhat-release
#free -m
## 如果内存小于32GB,会因为内存不足导致数据库无法启动,此时需要修改shared_buffers和max_connections调整openGauss
所需的内存
1、安装jdk8、python3,系统默认是python2,需要升级到3.6 先下载 python3.6.8
#yum install -y lksctp*
#yum install -y java-1.8.0-openjdk* psmisc bzip2 python3 python3-devel
#yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core
#rpm -qa java-1.8.0-openjdk psmisc bzip2 libaio-devel flex bison ncurses-devel glibc-de
#checksctp
#yum install gcc zlib* openssl* -y
#tar -zxvf //解压
#cd Python-3.6.8
#./configure --prefix=/usr/python3.6.11 --enable-optimizations --enable-shared
#make
#make install
#ln -s /usr/python3.6.11/bin/python3.6 /usr/bin/python3
#ln -s /usr/python3.6.11/bin/pip3 /usr/bin/pip3
#ln -s /usr/python3.6.11/lib/.1.0 /usr/lib64/
#export LD_LIBRARY_PATH=/usr/python3.6.11/lib:$LD_LIBRARY_PATH
#python3 -V ///查看python版本是否升级成功
2、设置主机IP 主机名 (主机名在后续配置文件使用到)
#vi /etc/hosts
--------------------
192.168.0.11 #Gauss OM IP Hosts Mapping
--------------------
3、关闭防火墙
#systemctl status firewalld
#systemctl stop e
4、关闭SELinux #vi /etc/selinux/config --------------------------- SELINUX=disabled --------------------------- 5、修改字符集参数 #vi ~/.bash_profile --------------------------- export LANG=en_-8 --------------------------- #source ~/.bash_profile 6、关闭SWAP
#vi /etc/fstab ## 注释掉swap分区挂载 swapoff -a ## 关闭swap
7、配置内核参数
# vi /etc/
---------------------------
_max_tw_buckets = 10000
_tw_reuse = 1
_tw_recycle = 1
_keepalive_time = 30
_keepalive_probes = 9
_keepalive_intvl = 30
_retries1 = 5
_syn_retries = 5
_synack_retries = 5
_max_retrans = 10
_init_retransmits = 10
ation_max_retrans = 10
_interval = 30000
_retries2 = 12
mmit_memory = 0
_policy = 0
_policy = 0
_mem = 94500000 915000000 927000000
_rmem = 8192 250000 16777216
_wmem = 8192 250000 16777216
_rmem = 8192 250000 16777216
_wmem = 8192 250000 16777216
_max = 21299200
_max = 21299200
_default = 21299200
_default = 21299200
_local_port_range = 26000 65535
= 250 6400000 1000 25600
_free_kbytes = 102400 ## 内存*5%
onn = 65535
_syncookies = 1
_enable = 0
. netdev_max_backlog = 65535
_max_syn_backlog = 65535
_fin_timeout = 60
= 11529215
= 18446744
_sack = 1
_timestamps = 1
g_threshold = 500
mmit_ratio = 90
----------------------------------------
8、redhat 6.4&6.5需要打开sctp的checksums,否则可能引起创建表或数据库失败
#echo 0 > /sys/module/sctp/parameters/no_checksums
二、预安装openGauss软件
1、配置文件
2、初始化环境
#mkdir /gauss
#chgrp dbgrp -R /gauss
#chmod 775 -R /gauss
#mkdir -p /soft/openGauss
#chmod 775 -R /soft
#mv /soft/openGauss
#mv /soft/openGauss
#cd /soft/openGauss
#tar -zxvf
#export LD_LIBRARY_PATH=/soft/openGauss/script/gspylib/clib:/usr/python3.6.8/lib:
$LD_LIBRARY_PATH
#cd /soft/openGauss/script
#./gs_preinstall -U omm -G dbgrp -X /soft/openGauss/ //预安装
四、部署安装openGauss软件
1、执行安装脚本
#chmod -R 775 /soft/
#chown omm:dbgrp /soft -R
#su - omm
#cd /soft/openGauss/script
#./gs_install -X /soft/openGauss/ ## 密码复杂度要求:大写+小写+数字+特殊字符(任选3类,至少8位)
五、数据库操作
1. 启停数据库
#gs_ctl start -D /opt/huawei/install/data/db1/
#gs_ctl stop -D /opt/huawei/install/data/db1/
2. 切换omm系统用户,登录数据库
1)#gs_guc set -N all -I all -h "host all jack 192.168.137.1/32 sha256"
2)#gsql -d postgres -p 26000
3)修改oom用户密码 :
ALTER ROLE omm IDENTIFIED BY '@Dean1912' REPLACE '@Dean19910707';
3. 创建用户并赋予用户管理权限
1)创建用户jack 并设置密码为jack@123
create user jack identified by 'jack@123';
2)默认用户没有创建数据库表权限需要修改其权限
ALTER ROLE gaussadmin SYSADMIN;
4. 先安装gsql远程登录工具()
#gsql -d postgres -h 192.168.15.155 -U jack -p 26000 -W jack@123
#gsql -d postgres -h 192.168.15.155 -U gaussadmin -p 26000 -W Gauss@123
5. 创建数据库gaussdbCREATE DATABASE gaussadb ENCODING 'UTF-8' template = template0; 6. 创建表testcreate table t_sys(id int primary key,name varchar(40),pass varchar(20));
2023年12月8日发(作者:芒驰)
华为国产openGauss数据库安装详细教程
安装openGauss步骤
一、检查硬件配置
#cat /proc/cpuinfo |grep processor
#cat /etc/redhat-release
#free -m
## 如果内存小于32GB,会因为内存不足导致数据库无法启动,此时需要修改shared_buffers和max_connections调整openGauss
所需的内存
1、安装jdk8、python3,系统默认是python2,需要升级到3.6 先下载 python3.6.8
#yum install -y lksctp*
#yum install -y java-1.8.0-openjdk* psmisc bzip2 python3 python3-devel
#yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core
#rpm -qa java-1.8.0-openjdk psmisc bzip2 libaio-devel flex bison ncurses-devel glibc-de
#checksctp
#yum install gcc zlib* openssl* -y
#tar -zxvf //解压
#cd Python-3.6.8
#./configure --prefix=/usr/python3.6.11 --enable-optimizations --enable-shared
#make
#make install
#ln -s /usr/python3.6.11/bin/python3.6 /usr/bin/python3
#ln -s /usr/python3.6.11/bin/pip3 /usr/bin/pip3
#ln -s /usr/python3.6.11/lib/.1.0 /usr/lib64/
#export LD_LIBRARY_PATH=/usr/python3.6.11/lib:$LD_LIBRARY_PATH
#python3 -V ///查看python版本是否升级成功
2、设置主机IP 主机名 (主机名在后续配置文件使用到)
#vi /etc/hosts
--------------------
192.168.0.11 #Gauss OM IP Hosts Mapping
--------------------
3、关闭防火墙
#systemctl status firewalld
#systemctl stop e
4、关闭SELinux #vi /etc/selinux/config --------------------------- SELINUX=disabled --------------------------- 5、修改字符集参数 #vi ~/.bash_profile --------------------------- export LANG=en_-8 --------------------------- #source ~/.bash_profile 6、关闭SWAP
#vi /etc/fstab ## 注释掉swap分区挂载 swapoff -a ## 关闭swap
7、配置内核参数
# vi /etc/
---------------------------
_max_tw_buckets = 10000
_tw_reuse = 1
_tw_recycle = 1
_keepalive_time = 30
_keepalive_probes = 9
_keepalive_intvl = 30
_retries1 = 5
_syn_retries = 5
_synack_retries = 5
_max_retrans = 10
_init_retransmits = 10
ation_max_retrans = 10
_interval = 30000
_retries2 = 12
mmit_memory = 0
_policy = 0
_policy = 0
_mem = 94500000 915000000 927000000
_rmem = 8192 250000 16777216
_wmem = 8192 250000 16777216
_rmem = 8192 250000 16777216
_wmem = 8192 250000 16777216
_max = 21299200
_max = 21299200
_default = 21299200
_default = 21299200
_local_port_range = 26000 65535
= 250 6400000 1000 25600
_free_kbytes = 102400 ## 内存*5%
onn = 65535
_syncookies = 1
_enable = 0
. netdev_max_backlog = 65535
_max_syn_backlog = 65535
_fin_timeout = 60
= 11529215
= 18446744
_sack = 1
_timestamps = 1
g_threshold = 500
mmit_ratio = 90
----------------------------------------
8、redhat 6.4&6.5需要打开sctp的checksums,否则可能引起创建表或数据库失败
#echo 0 > /sys/module/sctp/parameters/no_checksums
二、预安装openGauss软件
1、配置文件
2、初始化环境
#mkdir /gauss
#chgrp dbgrp -R /gauss
#chmod 775 -R /gauss
#mkdir -p /soft/openGauss
#chmod 775 -R /soft
#mv /soft/openGauss
#mv /soft/openGauss
#cd /soft/openGauss
#tar -zxvf
#export LD_LIBRARY_PATH=/soft/openGauss/script/gspylib/clib:/usr/python3.6.8/lib:
$LD_LIBRARY_PATH
#cd /soft/openGauss/script
#./gs_preinstall -U omm -G dbgrp -X /soft/openGauss/ //预安装
四、部署安装openGauss软件
1、执行安装脚本
#chmod -R 775 /soft/
#chown omm:dbgrp /soft -R
#su - omm
#cd /soft/openGauss/script
#./gs_install -X /soft/openGauss/ ## 密码复杂度要求:大写+小写+数字+特殊字符(任选3类,至少8位)
五、数据库操作
1. 启停数据库
#gs_ctl start -D /opt/huawei/install/data/db1/
#gs_ctl stop -D /opt/huawei/install/data/db1/
2. 切换omm系统用户,登录数据库
1)#gs_guc set -N all -I all -h "host all jack 192.168.137.1/32 sha256"
2)#gsql -d postgres -p 26000
3)修改oom用户密码 :
ALTER ROLE omm IDENTIFIED BY '@Dean1912' REPLACE '@Dean19910707';
3. 创建用户并赋予用户管理权限
1)创建用户jack 并设置密码为jack@123
create user jack identified by 'jack@123';
2)默认用户没有创建数据库表权限需要修改其权限
ALTER ROLE gaussadmin SYSADMIN;
4. 先安装gsql远程登录工具()
#gsql -d postgres -h 192.168.15.155 -U jack -p 26000 -W jack@123
#gsql -d postgres -h 192.168.15.155 -U gaussadmin -p 26000 -W Gauss@123
5. 创建数据库gaussdbCREATE DATABASE gaussadb ENCODING 'UTF-8' template = template0; 6. 创建表testcreate table t_sys(id int primary key,name varchar(40),pass varchar(20));