华为国产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 Python-3.6.8.tgz //解压
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/libpython3.6m.so.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 db1.opengauss.com #Gauss OM IP Hosts Mapping
—————————————————————
3、关闭防火墙
systemctl status firewalld
systemctl stop firewalld.service
4、关闭SELinux
vi /etc/selinux/config
—————————————————————
SELINUX=disabled
—————————————————————
5、修改字符集参数
vi ~/.bash_profile
—————————————————————
export LANG=en_US.UTF-8
—————————————————————
source ~/.bash_profile
6、关闭SWAP
vi /etc/fstab ## 注释掉swap分区挂载
swapoff -a ## 关闭swap
7、配置内核参数
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.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10
net.sctp.association_max_retrans = 10
net.sctp.hb_interval = 30000
net.ipv4.tcp_retries2 = 12
vm.overcommit_memory = 0
net.sctp.sndbuf_policy = 0
net.sctp.rcvbuf_policy = 0
net.sctp.sctp_mem = 94500000 915000000 927000000
net.sctp.sctp_rmem = 8192 250000 16777216
net.sctp.sctp_wmem = 8192 250000 16777216
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
vm.min_free_kbytes = 102400 ## 内存*5%
net.core.somaxconn = 65535
net.ipv4.tcp_syncookies = 1
net.sctp.addip_enable = 0
net.core. netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 60
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
vm.extfrag_threshold = 500
vm.overcommit_ratio = 90
----------------------------------------
8、redhat 6.4&6.5需要打开sctp的checksums,否则可能引起创建表或数据库失败
echo 0 > /sys/module/sctp/parameters/no_checksums
二、预安装openGauss软件
1、配置clusterconfig.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整体信息 -->
<CLUSTER>
<PARAM name="clusterName" value="dbCluster" />
<PARAM name="nodeNames" value="gaussdb.sugon.com" />
<PARAM name="backIp1s" value="192.168.15.155"/>
<PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
<PARAM name="gaussdbLogPath" value="/var/log/omm" />
<PARAM name="tmpMppdbPath" value="/opt/huawei/tmp" />
<PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
<PARAM name="corePath" value="/opt/huawei/corefile" />
<PARAM name="clusterType" value="single-inst"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- node1上的节点部署信息 -->
<DEVICE sn="1000001">
<PARAM name="name" value="gaussdb.sugon.com"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.15.155"/>
<PARAM name="sshIp1" value="192.168.15.155"/>
<!--dbnode-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="26000"/>
<PARAM name="dataNode1" value="/opt/huawei/install/data/db1"/>
</DEVICE>
</DEVICELIST>
</ROOT>
2、初始化环境
openGauss-1.0.0-CentOS-64bit.tar.gz 安装包地址
#mkdir /gauss
#chgrp dbgrp -R /gauss
#chmod 775 -R /gauss
#mkdir -p /soft/openGauss
#chmod 775 -R /soft
#mv clusterconfig.xml /soft/openGauss
#mv openGauss-1.0.0-CentOS-64bit.tar.gz /soft/openGauss
#cd /soft/openGauss
#tar -zxvf openGauss-1.0.0-CentOS-64bit.tar.gz
#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/clusterconfig.xml //预安装
```
## 三、部署安装openGauss软件
### 1、执行安装脚本
```
chmod -R 775 /soft/
chown omm:dbgrp /soft -R
su - omm
cd /soft/openGauss/script
./gs_install -X /soft/openGauss/clusterconfig.xml ## 密码复杂度要求:大写+小写+数字+特殊字符(任选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. 创建数据库gaussdb
```
CREATE DATABASE gaussadb ENCODING 'UTF-8' template = template0;
```
### 6. 创建表test
```
create table t_sys(id int primary key,name varchar(40),pass varchar(20));
```