【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(上篇)
环境准备
- VMware 17.0.2
- openEuler-22.03-LTS-SP2
- openGauss-5.0.0
- MobaXterm 22.1
- 服务器名称:node0,IP地址:192.168.192.129
- 查看、设置主机名
## 查看主机名
[root@192 ~]# hostname
192.168.192.129
## 设置主机名
[root@192 ~]# hostnamectl set-hostname node0
[root@192 ~]#
## 重启
[root@192 ~]# reboot
## 重启后
[root@node0 ~]# hostname
node0
获取openGauss安装包
openGauss是一款开源关系型数据库管理系统,采用木兰宽松许可证v2发行。openGauss内核深度融合华为在数据库领域多年的经验,结合企业级场景需求,持续构建竞争力特性。
安装依赖包
[root@node0 ~]# yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
OS 4.5 MB/s | 3.4 MB 00:00
everything 2.1 MB/s | 17 MB 00:07
EPOL 9.9 MB/s | 4.5 MB 00:00
debuginfo 4.6 MB/s | 4.0 MB 00:00
source 1.9 MB/s | 1.8 MB 00:00
update 2.1 MB/s | 1.8 MB 00:00
update-source 66 kB/s | 22 kB 00:00
Package pcre-8.45-5.oe2203sp2.x86_64 is already installed.
Package zlib-1.2.11-22.oe2203sp2.x86_64 is already installed.
Package zlib-devel-1.2.11-22.oe2203sp2.x86_64 is already installed.
Package openssl-1:1.1.1m-20.oe2203sp2.x86_64 is already installed.
Package openssl-devel-1:1.1.1m-20.oe2203sp2.x86_64 is already installed.
Dependencies resolved.
===============================================================================================================......
Installed:
gcc-c++-10.3.1-37.oe2203sp2.x86_64 libstdc++-devel-10.3.1-37.oe2203sp2.x86_64 pcre-devel-8.45-5.oe2203sp2.x86_64
Complete!
修改操作系统配置
关闭操作系统防火墙
目前仅支持在防火墙关闭的状态下进行安装。
# 查看防火墙状态
[root@node0 ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-07-20 21:38:54 CST; 6min ago
Docs: man:firewalld(1)
Main PID: 932 (firewalld)
Tasks: 2 (limit: 21384)
Memory: 34.1M
CGroup: /system.slice/firewalld.service
└─ 932 /usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid
7月 20 21:38:53 node0 systemd[1]: Starting firewalld - dynamic firewall daemon...
7月 20 21:38:54 node0 systemd[1]: Started firewalld - dynamic firewall daemon.
[root@node0 ~]#
# 关闭防火墙并禁止开机重启
[root@node0 ~]# systemctl stop firewalld.service
[root@node0 ~]#
[root@node0 ~]# systemctl disable firewalld.service
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
[root@node0 ~]#
# 查看防火墙状态
[root@node0 ~]# systemctl status firewalld
○ firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
7月 20 21:38:53 node0 systemd[1]: Starting firewalld - dynamic firewall daemon...
7月 20 21:38:54 node0 systemd[1]: Started firewalld - dynamic firewall daemon.
7月 20 21:46:24 node0 systemd[1]: Stopping firewalld - dynamic firewall daemon...
7月 20 21:46:25 node0 systemd[1]: firewalld.service: Deactivated successfully.
7月 20 21:46:25 node0 systemd[1]: Stopped firewalld - dynamic firewall daemon
关闭SELINUX
修改/etc/selinux/config文件中的“SELINUX”值为“disabled”
- 使用vi打开config文件
vi /etc/selinux/config
- 修改“SELINUX”的值“disabled”,执行:wq保存并退出修改
- 重新启动操作系统
[root@192 openEuler]# reboot
设置操作系统字符集
# 设置字符集
[root@node0 ~]# cat>> /etc/profile<<EOF
>export
> EOF
[root@node0 ~]#
# 使参数生效
[root@node0 ~]# source /etc/profile
Welcome to 5.10.0-153.12.0.92.oe2203sp2.x86_64
System information as of time: 2023年 07月 20日 星期四 21:51:32 CST
System load: 0.00
Processes: 158
Memory used: 6.1%
Swap used: 0%
Usage On: 4%
IP address: 192.168.192.129
Users online: 1
# 检查字符集
[root@node0 ~]# env |grep -i lang
LANG=en_US.UTF-8
设置时区和时间
# 安装ntp服务
[root@node0 ~]# yum install -y ntp
Last metadata expiration check: 0:11:18 ago on Thu 20 Jul 2023 09:43:18 PM CST.
Dependencies resolved.
......
Installed:
ntp-4.2.8p15-11.oe2203sp2.x86_64 ntp-help-4.2.8p15-11.oe2203sp2.noarch ntpstat-0.6-4.oe2203sp2.noarch
Complete!
# 开机启动ntp服务
[root@node0 ~]# systemctl enable ntpd
Created symlink /etc/systemd/system/multi-user.target.wants/ntpd.service → /usr/lib/systemd/system/ntpd.service.
# 启动ntp服务
[root@node0 ~]# systemctl start ntpd
# 设置时区Asia/Shanghai
[root@node0 ~]# timedatectl set-timezone Asia/Shanghai
# 检查时区
[root@node0 ~]# timedatectl |grep -i zone
Time zone: Asia/Shanghai (CST, +0800)
# 启用ntp服务
[root@node0 ~]# timedatectl set-ntp yes
# 编辑定时任务列表
[root@node0 ~]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
# 查看时间及时区
[root@node0 ~]# timedatectl status
Local time: Thu 2023-07-20 22:00:27 CST
Universal time: Thu 2023-07-20 14:00:27 UTC
RTC time: Thu 2023-07-20 14:00:27
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
修改硬件时钟
# 将当前系统时间写入硬件时钟
[root@node0 ~]# hwclock --systohc
[root@node0 ~]#
# 查看硬件时钟
[root@node0 ~]# hwclock
2023-07-20 22:02:58.916124+08:00
关闭swap交换内存
关闭swap交换内存是为了保障数据库的访问性能,避免把数据库的缓冲区内存淘汰到磁盘上。 如果服务器内存比较小,内存过载时,可打开swap交换内存保障正常运行。
[root@node0 ~]# swapoff -a
设置网卡MTU值
# 设置网卡MTU,MTU值推荐8192
[root@node0 ~]# ifconfig ens33 mtu 8192
# 查看网卡MTU
[root@node0 ~]# ifconfig -a |grep -i mtu
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 8192
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
关闭RemoveIPC
- 修改logind.conf文件
# 使用vi打开logind.conf文件
[root@node0 ~]# vi /etc/systemd/logind.conf
# 修改“RemoveIPC”值为“no”
修改systemd-logind.service文件
# 使用vi打开systemd-logind.service文件
[root@node0 ~]# vi /usr/lib/systemd/system/systemd-logind.service
# 修改“RemoveIPC”值为“no”
# 文件中没有配置参数,追加到文件的末尾即可
- 重新加载配置参数
[root@node0 ~]# systemctl daemon-reload
[root@node0 ~]# systemctl restart systemd-logind
- 检查修改是否生效
[root@node0 ~]# loginctl show-session | grep RemoveIPC
RemoveIPC=no
[root@node0 ~]# systemctl show systemd-logind | grep RemoveIPC
RemoveIPC=no
关闭HISTORY记录
为避免指令历史记录安全隐患,需关闭各主机的history指令。
- 修改根目录下/etc/profile文件
[root@node0 ~]# vi /etc/profile
- 设置HISTSIZE值为0
系统中HISTSIZE默认值为1000,将其修改为0。
保存/etc/profile。 :wq
- 设置/etc/profile生效
[root@node0 ~]# source /etc/profile
Welcome to 5.10.0-153.12.0.92.oe2203sp2.x86_64
System information as of time: Thu Jul 20 10:23:28 PM CST 2023
System load: 0.00
Processes: 158
Memory used: 6.0%
Swap used: 0.0%
Usage On: 4%
IP address: 192.168.192.129
Users online: 1
设置root用户远程登录
在openGauss安装时需要root帐户远程登录访问权限
数据库需要root互信时才开启远程连接。在各主机操作完成并且验证完毕后请及时注销root用户,避免误操作。修改PermitRootLogin配置,允许用户远程登录
- 打开sshd_config文件
[root@node0 ~]# vi /etc/ssh/sshd_config
- 修改权限配置
# 方式1:注释掉“PermitRootLogin no”
#PermitRootLogin no
# 方式2:将“PermitRootLogin”改为“yes”
PermitRootLogin=yes
- 执行:wq保存并退出编辑页面
修改Banner配置,去掉连接到系统时,系统提示的欢迎信息。欢迎信息会干扰安装时远程操作的返回结果,影响安装正常执行。
- 编辑sshd_config文件
vi /etc/ssh/sshd_config
- 修改Banner配置,注释掉“Banner”所在的行
- 执行:wq保存并退出编辑页面
使设置生效
[root@node0 ~]# systemctl restart sshd.service
以root用户身份重新登录
[root@node0 ~]# ssh 192.168.192.129
The authenticity of host '192.168.192.129 (192.168.192.129)' can't be established.
ED25519 key fingerprint is SHA256:YIx66zD1ELsXkT4D82ZpOk7Pbity1evlwbtM9kc3wcI.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.192.129' (ED25519) to the list of known hosts.
root@192.168.192.129's password:
Authorized users only. All activities may be monitored and reported.
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Thu Jul 20 21:39:19 2023 from 192.168.192.1
Welcome to 5.10.0-153.12.0.92.oe2203sp2.x86_64
System information as of time: Thu Jul 20 10:34:04 PM CST 2023
System load: 0.00
Processes: 165
Memory used: 6.3%
Swap used: 0.0%
Usage On: 4%
IP address: 192.168.192.129
Users online: 2
文章转载自公众号:openGauss