技术交流QQ群:①185473046   ②190706903   ③203744115   网站地图
登录

下次自动登录
现在的位置: 首页openGauss>正文
openEuler 22.03 LTS SP1安装部署openGauss-5.0.0
2023年05月25日 openGauss 暂无评论 ⁄ 被围观 3,258次+

openGauss是由华为开源的一款关系型数据库,基于PostgreSQL数据库开发。

操作系统:openEuler 22.03 LTS SP1

官方网站:https://opengauss.org/zh/

下载地址:https://opengauss.org/zh/download/

注意:需要登录才能下载,要选择好操作系统和数据库对应的版本,这里我们选择openEuler 22.03对应的openGauss_5.0.0 企业版openGauss-5.0.0-openEuler-64bit-all.tar

操作系统安装:

openEuler 22.03 LTS SP1安装配置图解教程

https://www.osyunwei.com/archives/13673.html

准备篇

1、关闭SELINUX

vi /etc/selinux/config

#SELINUX=enforcing #注释掉

#SELINUXTYPE=targeted #注释掉

SELINUX=disabled #增加

:wq! #保存退出

setenforce 0 #使配置立即生效

2、开启防火墙5432端口

系统默认使用的是firewall作为防火墙,这里改为iptables防火墙。

2.1、关闭firewall:

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

systemctl mask firewalld

systemctl stop firewalld

yum remove firewalld

2.2、安装iptables防火墙

yum install iptables-services #安装

vi /etc/sysconfig/iptables #编辑防火墙配置文件

# sample configuration for iptables service

# you can edit this manually or use system-config-firewall

# please do not ask us to add additional ports/services to this default configuration

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

:wq! #保存退出

systemctl restart iptables.service #最后重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

/usr/libexec/iptables/iptables.init restart #重启防火墙

3、设置时区同步时间

rm -rf /etc/localtime #先删除默认的时区设置

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #替换上海/北京作为默认

yum install -y ntp #安装ntp

ntpdate time1.aliyun.com #执行时间同步

hwclock --systohc #系统时钟和硬件时钟同步

4、修改主机名称

这里设置主机名为:opengauss-master

hostnamectl set-hostname opengauss-master

vi /etc/hostname #编辑配置文件

opengauss-master #修改localhost.localdomain为opengauss-master

:wq! #保存退出

vi /etc/hosts #编辑配置文件

127.0.0.1 opengauss-master localhost #修改localhost.localdomain为opengauss-master

192.168.21.203 opengauss-master

:wq! #保存退出

5、设置操作系统字符集编码

LANG=en_US.UTF-8

echo "LANG=en_US.UTF-8" >> /etc/profile

source /etc/profile

echo $LANG

6、安装依赖包

yum install bzip2 tar telnet python python3

yum install libaio-devel flex bison ncurses-devel glibc-devel patch readline-devel redhat-*

7、操作系统参数设置

7.1

cat>> /etc/sysctl.conf <<EOF

net.ipv4.tcp_max_tw_buckets=10000

net.ipv4.tcp_tw_reuse=1

net.ipv4.tcp_keepalive_time=30

net.ipv4.tcp_keepalive_intvl=30

net.ipv4.tcp_retries2=12

net.core.wmem_max=21299200

net.core.rmem_max=21299200

net.core.wmem_default=21299200

net.core.rmem_default=21299200

kernel.sem=250 6400000 1000 25600

net.ipv4.tcp_rmem=8192 250000 16777216

net.ipv4.tcp_wmem=8192 250000 16777216

vm.min_free_kbytes=172988

net.core.netdev_max_backlog=65535

net.ipv4.tcp_max_syn_backlog=65535

net.core.somaxconn=65535

kernel.shmall=1152921504606846720

kernel.shmmax=18446744073709551615

net.ipv4.tcp_retries1=5

net.ipv4.tcp_syn_retries=5

EOF

7.2

vi /etc/security/limits.conf #在最后一行添加以下代码

* soft nproc unlimited

* hard nproc unlimited

* soft nofile 1000000

* hard nofile 1000000

:wq! #保存退出

sysctl -p #使参数设置立即生效

ulimit -a

ulimit -n 1000000

7.3

#读取

/sbin/blockdev --getra /dev/nvme0n1

#修改

/sbin/blockdev --setra 16384 /dev/nvme0n1

#添加到开机启动

echo '/sbin/blockdev --setra 16384 /dev/nvme0n1' >> /etc/rc.local

#添加执行权限

chmod +x /etc/rc.local

#查看

more /etc/rc.local

7.4关闭THP服务

echo never > /sys/kernel/mm/transparent_hugepage/defrag

echo never > /sys/kernel/mm/transparent_hugepage/enabled

echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.d/rc.local

echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.d/rc.local

chmod +x /etc/rc.d/rc.local

/usr/bin/sh /etc/rc.d/rc.local

安装篇

1、上传安装包到目录/data/soft/openGauss下面

openGauss-5.0.0-openEuler-64bit-all.tar.gz

2、安装数据库

2.1解压数据库安装包

cd /data/soft/openGauss

tar -zxvf openGauss-5.0.0-openEuler-64bit-all.tar.gz #解压

tar -zxvf openGauss-5.0.0-openEuler-64bit-om.tar.gz #继续解压

2.2创建数据库用户和用户组

groupadd dbgrp

useradd -g dbgrp omm

echo 'omm@a1b2c3' | passwd --stdin omm

#添加omm到whell组

gpasswd -a omm wheel

2.3创建数据库安装目录并设置权限

mkdir -p /data/server/openGauss

chmod 775 /data/server/openGauss -R

chown omm:dbgrp /data/server/openGauss -R

2.4创建安装配置文件(单节点安装)

vi /data/soft/openGauss/cluster_config.xml

<?xml version="1.0" encoding="UTF-8"?>

<ROOT>

<!-- openGauss整体信息 -->

<CLUSTER>

<!-- 数据库名称 -->

<PARAM name="clusterName" value="dbCluster" />

<!-- 数据库节点名称(hostname) -->

<PARAM name="nodeNames" value="opengauss-master" />

<!-- 数据库安装目录-->

<PARAM name="gaussdbAppPath" value="/data/server/openGauss/app" />

<!-- 日志目录-->

<PARAM name="gaussdbLogPath" value="/data/server/openGauss/log/omm" />

<!-- 临时文件目录-->

<PARAM name="tmpMppdbPath" value="/data/server/openGauss/tmp" />

<!-- 数据库工具目录-->

<PARAM name="gaussdbToolPath" value="/data/server/openGauss/om" />

<!-- 数据库core文件目录-->

<PARAM name="corePath" value="/data/server/openGauss/corefile" />

<!-- 节点IP,与数据库节点名称列表一一对应 -->

<PARAM name="backIp1s" value="192.168.21.203"/>

</CLUSTER>

<!-- 每台服务器上的节点部署信息 -->

<DEVICELIST>

<!-- 节点1上的部署信息 -->

<DEVICE sn="opengauss-master">

<!-- 节点1的主机名称 -->

<PARAM name="name" value="opengauss-master"/>

<!-- 节点1所在的AZ及AZ优先级 -->

<PARAM name="azName" value="AZ1"/>

<PARAM name="azPriority" value="1"/>

<!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->

<PARAM name="backIp1" value="192.168.21.203"/>

<PARAM name="sshIp1" value="192.168.21.203"/>

<!--dbnode-->

<PARAM name="dataNum" value="1"/>

<PARAM name="dataPortBase" value="5432"/>

<PARAM name="dataNode1" value="/data/server/openGauss/data/dn"/>

<PARAM name="dataNode1_syncNum" value="0"/>

</DEVICE>

</DEVICELIST>

</ROOT>

:wq! #保存退出

#参数说明:把后面的值改为主机名opengauss-master

nodeNames value=opengauss-master

sn=opengauss-master

#节点IP,与数据库节点名称列表对应

backIp1 value=192.168.21.203

sshIp1 value=192.168.21.203

节点IP,与数据库节点名称列表对应

#数据库端口

dataPortBase value=5432

2.5执行预安装脚本

为了保证openGauss正确安装,需要对主机环境进行初始化

cd /data/soft/openGauss/script/

./gs_preinstall -U omm -G dbgrp -X /data/soft/openGauss/cluster_config.xml

根据提示输入yes继续

2.6根据上一步的提示信息,继续检查系统环境

/data/soft/openGauss/script/gs_checkos -i A -h opengauss-master --detail

#查看结果,Abnormal numbers:0说明环境没问题,如果Abnormal numbers:不为0,请根据提示信息进行修改后再次检查,直到Abnormal numbers:0才能进行下一步操作

Total numbers:13. Abnormal numbers:0. Warning numbers:2.

2.7安装数据库

#设置目录权限

chown omm.dbgrp /data/soft/openGauss -R

su - omm #切换到omm用户

cd /data/soft/openGauss/script/

gs_install -X /data/soft/openGauss/cluster_config.xml

Please enter password for database:

根据提示设置数据库密码,最少包含8个字符:A1b2c3@#

不能和用户名、当前密码(ALTER)、或当前密码反序相同。

至少包含大写字母(A-Z)、小写字母(a-z)、数字、非字母数字字符(限定为~!@#$%^&*()-_=+|[{}];:,<.>/?)四类字符中的三类字符。

2.8启动数据库

gs_ctl start -D /data/server/openGauss/data/dn

#查看数据库状态

gs_om -t status

gs_om -t status --detail

gs_om -t status --all

gs_checkperf

#查看进程

ps -ef | grep gaussdb | egrep -v "grep"

#查看实例状态

gs_om -t status --detail

#进入控制台

gsql -d postgres -p 5432

select version(); #查看版本

SHOW server_version;

SELECT * FROM pg_settings WHERE NAME='server_version';

\q #退出控制台

3、设置数据库

3.1设置数据库配置文件

cd /data/server/openGauss/data/dn

cp postgresql.conf postgresql.conf-bak

cp pg_hba.conf pg_hba.conf-bak

vi /data/server/openGauss/data/dn/postgresql.conf

ssl = off

listen_addresses = 'localhost,192.168.21.203' #192.168.21.203需要替换为openGauss所在节点实际IP。

password_encryption_type = 1 #修改为1,同时支持sha256 + md5加密,支持用pgsql客户端连接工具

#Password storage type, 0 is md5 for PG, 1 is sha256 + md5, 2 is sha256 onl

:wq! 保存退出

vi /data/server/openGauss/data/dn/pg_hba.conf

# TYPE DATABASE USER ADDRESS METHOD

# IPv4 local connections:

host all all 192.168.21.0/24 md5

:wq! 保存退出

#允许从指定网段192.168.21.0/24的ip地址访问数据库,加密方式为md5,支持用pgsql客户端连接工具

#也可以设置从指定ip以指定账号访问指定的数据库,如host testdb admin 192.168.21.100 md5

gs_om -t restart #重启数据库

3.2创建用户、数据库、schema

gsql -d postgres -p 5432 #进入控制台

create user admin with password "A1b2c3@#"; #创建用户admin并设置密码为A1b2c3@#

create database testdb owner admin; #创建数据库testdb并设置所有者为admin

GRANT ALL PRIVILEGES TO admin; #设置权限

create schema testdb authorization admin; #设置schema权限

\c testdb admin; #以admin账号登录testdb数据库

create table test(id int,name varchar(200));

insert into test values (1,'myname');

select * from test;

\q #退出控制台

3.3使用工具进行连接操作

#Windows 需要提前安装好jdk-11.0.17_windows-x64_bin并配置好环境变量

工具下载Data Studio_5.0.0

https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/tools/DataStudio_win_64.zip

3.3打开Data Studio_5.0.0

配置好连接信息

DBeaver

gs_om -t stop #关闭

gs_om -t start #启动

至此,openEuler 22.03 LTS SP1安装部署openGauss-5.0.0完成。

     

  系统运维技术交流QQ群:①185473046 系统运维技术交流□Ⅰ ②190706903 系统运维技术交流™Ⅱ ③203744115 系统运维技术交流™Ⅲ

给我留言

您必须 [ 登录 ] 才能发表留言!



Copyright© 2011-2024 系统运维 All rights reserved
版权声明:本站所有文章均为作者原创内容,如需转载,请注明出处及原文链接
陕ICP备11001040号-3