openEuler22(欧拉)上安装openGuass单节点数据库步骤

一、系统初始化及参数配置

$ python3 --version  # openEuler:支持>=Python 3.6.X且<=Python 3.10.X
    Python 3.9.9
$  rpm -qa |grep libaio    # 建议版本:0.3.109-13
libaio-0.3.113-9.oe2203sp3.x86_64   
$  rpm -qa |grep readline  # 建议版本:7.0-13
readline-8.1-3.oe2203sp3.x86_64 
$ nmcli general hostname lowair-openGaussDB   # 修改机器名
$ systemctl stop firewalld.service # 停止服务
$ systemctl disable firewalld.service  # 禁止自启动
$ sed  -i 's/enforcing/disabled/' /etc/selinux/config   # 关闭SELINUX配置
# 关闭RemoveIPC
$ vi /etc/systemd/logind.conf 
RemoveIPC=no     # 去年前面的注释
$ echo "RemoveIPC=no" >> /usr/lib/systemd/system/systemd-logind.service
$ systemctl daemon-reload
$ systemctl restart systemd-logind
# 检查是否生效
$ loginctl show-session | grep RemoveIPC
RemoveIPC=no
$ systemctl show systemd-logind | grep RemoveIPC
RemoveIPC=no
# 配置root登录
$ vi /etc/ssh/sshd_config
#Banner XXXX   # 修改Banner配置,去掉连接到系统时,系统提示的欢迎信息
PermitRootLogin yes    # 允许root登录
# 查找GSSAPIAuthentication 赋值为no
# 查找UseDNS,赋值为 no(该项默认不启用的,要把前面的#删除掉
$ systemctl restart sshd
$ vi /etc/sysctl.conf
# 在文件后面追加下面两句
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
# 使修改的参数生效
$ sysctl -p
$ swapoff -a  # 为提高性能,关闭交换内存
# 修改网卡mtu长度
$ echo "MTU=8192" >> /etc/sysconfig/network-scripts/ifcfg-`ip -o link show | awk -F': ' '{print $2}' | grep '^ens'`
$ echo "* soft nofile 1000000" >>/etc/security/limits.conf
$ echo "* hard nofile 1000000" >>/etc/security/limits.conf
$ echo "* soft nproc unlimited" >> /etc/security/limits.d/90-nproc.conf
# 解决Abnormal问题:The THP service status RealValue 'enabled' ExpectedValue 'disabled'. 
$ vi /etc/rc.d/rc.local
# 添加以下内容
if test -f /sys/kernel/mm/transparent_hugepage/enabled; 
then
  echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; 
  then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
# 保存退出,赋予rc.local文件执行权限
$ chmod +x /etc/rc.d/rc.local
$ init 6
# 重启系统,检查THP是否被禁用
$ cat /sys/kernel/mm/transparent_hugepage/enabled
$ cat /sys/kernel/mm/transparent_hugepage/defrag
# 安装tar命令(先从openEuler-22.03-LTS-SP3-x86_64-dvd.iso文件的Packages目录下提取tar-1.34-5.oe2203sp3.x86_64.rpm、net-tools-2.10-3.oe2203sp3.x86_64.rpm,并上传至服务器)
$ rpm -Uvh ~/*.rpm
image.png

说明:如果使用SecureCRT连接服务器,老版本的可能会登录失败,并提示:No compatible key exchange method. The server supports these methods: curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,kex-strict-s-v00@openssh.com ,这时要安装新版软件,以保证至少其支持上面其中一项,如:curve25519-sha256。

image-20241024165511835.png

二、安装数据库

参考官网文档: 点击访问参考文档

访问网址:https://opengauss.org/zh/download/ 下载 openGauss-All-6.0.0-openEuler22.03-x86_64.tar.gz 并上传至服务器

$ mkdir /home/software && chmod -R 755  /home/software
$ tar zxvf openGauss-All-6.0.0-openEuler22.03-x86_64.tar.gz -C /home/software/
$ cd /home/software/
$ tar -zxvf  openGauss-OM-6.0.0-openEuler22.03-x86_64.tar.gz
$ vi cluster_config.xml  # 输入以下内容
<ROOT>
    <CLUSTER>
        <PARAM name="clusterName" value="Cluster_template" />
        <PARAM name="nodeNames" value="myDB-Server" />
        <PARAM name="gaussdbAppPath" value="/home/openGauss/install/app" />
        <PARAM name="gaussdbLogPath" value="/home/openGauss/install/log" />
        <PARAM name="tmpMppdbPath" value="/home/openGauss/install/tmp" />
        <PARAM name="gaussdbToolPath" value="/home/openGauss/install/tool" />
        <PARAM name="corePath" value="/home/openGauss/install/corefile" />
        <PARAM name="backIp1s" value="192.168.XX.XX" />
        </CLUSTER>

    <DEVICELIST>
        <DEVICE sn="node1_hostname">
            <PARAM name="name" value="myDB-Server" />
            <PARAM name="azName" value="AZ1" />
            <PARAM name="azPriority" value="1" />
            <PARAM name="backIp1" value="192.168.XX.XX" />
            <PARAM name="sshIp1" value="192.168.XX.XX" />
            <PARAM name="dataNum" value="1" />
            <PARAM name="dataPortBase" value="15000" />
            <PARAM name="dataNode1" value="/home/openGauss/install/data/dn1" />
            <PARAM name="dataNode1_syncNum" value="0" />
        </DEVICE>

        </DEVICELIST>
</ROOT>
# 说明:将上面的“myDB-Server”换为你自己的hostname,还要指定自己机器的ip
$ cd script/
# 预安装
$ ./gs_preinstall -U omm -G dbgrp -X /home/software/cluster_config.xml  
Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
Setting host ip env
Successfully set host ip env.
Are you sure you want to create the user[omm] (yes/no)? yes  # 此处输入yes
Please enter password for cluster user.
Password:                                   # 输入密码
Please enter password for cluster user again.
Password: 
Generate cluster user password files successfully.
Successfully created [omm] user on all nodes.
Preparing SSH service.
Successfully prepared SSH service.
Checking OS software.
Successfully check OS software.
Checking OS version.
Successfully checked OS version.
Checking cpu instructions.
Warning: This cluster is missing the rdtscp or avx instruction.
Successfully checked cpu instructions.
Creating cluster's path.
Successfully created cluster's path.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Warning: Installation environment contains some warning messages.
Please get more details by "/home/software/script/gs_checkos -i A -h lowair-openGaussDB -X /home/software/cluster_config.xml --detail".
Set and check OS parameter completed.
Preparing CRON service.
Successfully prepared CRON service.
Setting user environmental variables.
Successfully set user environmental variables.
Setting the dynamic link library.
Successfully set the dynamic link library.
Setting Core file
Successfully set core path.
Setting pssh path
Successfully set pssh path.
Setting Cgroup.
Successfully set Cgroup.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.
# 以上预安装成功。另外,如果此处出错的话,可以输入”/home/software/script/gs_checkos -i A -h lowair-openGaussDB -X /home/software/cluster_config.xml --detail“ 命令查看问题所在,再相应处理。
# 正式安装
# su - omm   && cd /home/software/script/
$ ./gs_install -X /home/software/cluster_config.xml --gsinit-parameter="--locale=en_US.utf8"
Parsing the configuration file.
Successfully checked gs_uninstall on every node.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Successfully created the backup directory.
begin deploy..
Installing the cluster.
begin prepare Install Cluster..
Checking the installation environment on all nodes.
begin install Cluster..
Installing applications on all nodes.
Successfully installed APP.
begin init Instance..
encrypt cipher and rand files for database.
Please enter password for database:                 # 此处输入密码
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /home/openGauss/install/app/share/sslcert/om
NO cm_server instance, no need to create CA for CM.
Non-dss_ssl_enable, no need to create CA for DSS
Cluster installation is completed.
Configuring.
Deleting instances from all nodes.
Successfully deleted instances from all nodes.
Checking node configuration on all nodes.
Initializing instances on all nodes.
Updating instance configuration on all nodes.
Check consistence of memCheck and coresCheck on database nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
The cluster status is Normal.
Successfully started cluster.
Successfully installed application.
end deploy..

三、验证安装

# 以omm用户登录
$ gs_om -t status  # “cluster_state ”显示“Normal”表示数据库可正常使用
-----------------------------------------------------------------------
cluster_name    : Cluster_template
cluster_state   : Normal       
redistributing  : No
-----------------------------------------------------------------------
# 数据库安装完成后,默认生成名称为postgres的数据库。第一次连接数据库时可以连接到此数据库
$ gsql -d postgres -p 15000
gsql ((openGauss 6.0.0 build aee4abd5) compiled at 2024-09-29 19:14:27 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

# 创建数据库mydb
openGauss=#  CREATE DATABASE mydb WITH ENCODING 'utf8' template = template0;                                  CREATE DATABASE

# 查看数据库
openGauss=# SELECT datname FROM pg_database WHERE datistemplate = false;
 datname  
----------
 mydb
 postgres
(2 rows)

# 数据库重启命令
$ gs_om -t restart 

四、配置客户端工具连接

$ cd /home/openGauss/install/data/dn1
# 更改口令加密方式(默认sha256)为password_encryption_type = 1 (sha256 + md5两种加密方式)
$ echo "password_encryption_type = 1" >>  postgresql.conf 
# 修改远程登录机器范围与加密方式
$ echo "host   all   all  0.0.0.0/0    md5" >> /pg_hba.conf
$ su omm
$ gsql -d postgres -p 15000
openGauss=#  select pg_reload_conf(); # 重新加载配置文件而无需重启 PostgreSQL 服务
 pg_reload_conf 
----------------
 t
(1 row)po
# 新建用户
openGauss=# CREATE USER szatc WITH PASSWORD 'xxxxxx';
NOTICE:  The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE

说明:第三方工具连接openGuass时,选择PostgreSQL类型数据库即可,因为前者是基于后者二开的


image.png
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,053评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,527评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,779评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,685评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,699评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,609评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,989评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,654评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,890评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,634评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,716评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,394评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,976评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,950评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,191评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,849评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,458评论 2 342

推荐阅读更多精彩内容