一、系统环境优化
安装依赖
yum -y install libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel python3 expect bzip2 libnsl ncurses-devel
注意事项:libnsl 包在BCLinux8.2、openEuler x86 系统中需要安装。Centos7 环境和 BC-Linux7.6、BC-Linux7.8环境中不用安装
关闭selinux
# 修改配置文件:
vim /etc/selinux/config
# 永久关闭SELINUX
SELINUX=disabled
# 临时关闭selinux
setenforce 0
内核优化
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.ipv4.tcp_retries2 = 12
vm.overcommit_memory = 0
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
net.core.somaxconn = 65535
net.ipv4.tcp_syncookies = 1
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 60
kernel.shmall = 6291456 #根据实际情况进行计算
kernel.shmmax = 25769803776 #根据实际情况进行计算
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
vm.extfrag_threshold = 500
vm.overcommit_ratio = 90
vm.swappiness = 0
# 配置生效
sysctl -p
注意:kernel.shmall和kernel.shmmax需根据主机操作系统的内存配置进行自定义调整,一般shmmax建议设置为主机物理内存的60%,shmall >= shmmax/4096。例如主机100G内存,shmmax=4G60%102410241024= 25769803776,shmall= 25769803776/4096= 6291456。
配置资源限制
vim /etc/security/limits.conf
* soft nofile 655360
* hard nofile 655360
* soft nproc 655360
* hard nproc 655360
* soft memlock unlimited
* hard memlock unlimited
* soft core unlimited
* hard core unlimited
* soft stack unlimited
* hard stack unlimited
安装python
# 检查python3
# 下载地址:https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
# 检查 python3 版本,如果为 Python 3.6.9 则满足要求,如果不满足则需进行编译安装
# python3 --version
[root@192]$python3 --version
Python 3.6.8
[root@192]$wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
# 从下载安装包
[root@192]$tar -zxf Python-3.6.9.tgz
[root@192]$cd Python-3.6.9
[root@192]$./configure --prefix=/opt/python/Python-3.6.9 --enable-shared --enable-optimizations --with-ssl
[root@192]$make -j 12 && make install
[root@192]$ln -sf /opt/python/Python-3.6.9/bin/python3 /usr/bin/python3
[root@192]$ln -sf /opt/python/Python-3.6.9/bin/python3.6-config /usr/bin/python3-config
[root@192]$cp /opt/python/Python-3.6.9/lib/libpython3.6m.so.1.0 /usr/lib64
[root@192]$chmod -R 755 /usr/lib64/libpython3.6m.so.1.0
[root@192]$ln -sf /usr/lib64/libpython3.6m.so.1.0 /usr/lib64/libpython3.6m.so
[root@192]$cat >> /etc/profile <<-EOF
export PYTHON_HOME=/opt/python/Python-3.6.9
export PATH=$PYTHON_HOME/bin:$PATH
EOF
# 环境变量生效
source /etc/profile
[root@192]$python3 --version
Python 3.6.9
二、安装数据库
创建用户组
[root@192]$groupadd -g 1101 dbgrp
[root@192]$useradd -g dbgrp -u 1101 -m omm
[root@192]$echo 'User@123'|passwd --stdin omm
创建安装包目录
[root@192]$mkdir -p /opt/panweidb/soft
上传安装包
上传安装包到 /opt/panweidb/soft
目录下
授权
[root@192]$chown -R omm:dbgrp /opt/panweidb
[root@192]$chmod -R 755 /opt/panweidb
登录OMM
使用omm用户登录到openGauss包安装的主机,解压openGauss压缩包到安装目录(假定安装目录为/opt/panweidb/soft,请用实际值替换)。
su - omm
解压
[root@192]$ cd /opt/panweidb/soft
[root@192]$ tar -xf PanWeiDB_1.0.0_beta_CentOS7_x86.tar.gz
[omm@192 soft]$ tar -xf PanWeiDB_1.0.0_beta_CentOS7_x86.tar.gz
[omm@192 soft]$ ls
PanWeiDB_1.0.0_beta_CentOS7_x86.tar.gz PanWeiDB-1.0.0-CentOS-64bit-Libpq.tar.gz PanWeiDB-1.0.0-CentOS-64bit.sha256 upgrade_sql.sha256
PanWeiDB-1.0.0-CentOS-64bit-cm-symbol.tar.gz PanWeiDB-1.0.0-CENTOS-64bit-Odbc.tar.gz PanWeiDB-1.0.0-CentOS-64bit-symbol.tar.gz upgrade_sql.tar.gz
PanWeiDB-1.0.0-CentOS-64bit-cm.tar.gz PanWeiDB-1.0.0-CentOS-64bit-om.sha256 PanWeiDB-1.0.0-CentOS-64bit.tar.bz2
PanWeiDB-1.0.0-CENTOS-64bit-Jdbc.tar.gz PanWeiDB-1.0.0-CentOS-64bit-om.tar.gz PanWeiDB-1.0.0-CentOS-64bit-tools.tar.gz
[omm@192 soft]$ tar -xf PanWeiDB-1.0.0-CentOS-64bit.tar.bz2
执行安装脚本
[omm@192 soft]$ cd /opt/panweidb/soft/simpleInstall
[omm@192 simpleInstall]$ sh install.sh -w "op@Passw123" && source ~/.bashrc
上述命令中,-w是指初始化数据库密码(gs_initdb指定),安全需要必须设置。
检查是否安装成功
[omm@192 simpleInstall]$ ps ux | grep gaussdb
omm 66235 1.2 16.4 2907884 633428 ? Ssl 06:32 0:01 /opt/panweidb/soft/bin/gaussdb -D /opt/panweidb/soft/data/single_node
omm 66359 0.0 0.0 110480 904 pts/1 S+ 06:34 0:00 grep --color=auto gaussdb
[omm@192 simpleInstall]$ gs_ctl query -D /opt/panweidb/soft/data/single_node
[2023-10-07 06:35:00.490][66360][][gs_ctl]: gs_ctl query ,datadir is /opt/panweidb/soft/data/single_node
HA state:
local_role : Normal
static_connections : 0
db_state : Normal
detail_information : Normal
Senders info:
No information
Receiver info:
No information
创建和使用数据库
[omm@192 simpleInstall]$ gsql -d postgres
gsql ((PanWeiDB(openGauss) 1.0.0 build 9a7e96bc) compiled at 2022-10-15 20:54:36 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
# 创建用户USER
PanWeiDB=# CREATE USER test IDENTIFIED BY 'test@Passw123';
CREATE ROLE
# 授权用户test为系统管理员
PanWeiDB=# grant all privileges to test;
ALTER ROLE
# 使用如下命令创建一个新的表空间test_tbs,并将表空间escspdb_tbs授权给用户test
PanWeiDB=# CREATE TABLESPACE test_tbs OWNER test RELATIVE LOCATION 'tablespace/test_tbs';
CREATE TABLESPACE
# 使用如下命令创建一个新的数据库testdb,放在使用test_tbs表空间中。
PanWeiDB=# CREATE DATABASE testdb WITH TABLESPACE = test_tbs;
CREATE DATABASE
# 使用以下命令为数据库设置默认的模式搜索路径。
PanWeiDB=# ALTER DATABASE testdb SET search_path TO pa_catalog,public;
ALTER DATABASE
# 使用如下命令修改数据库表空间
#ALTER DATABASE testdb SET TABLESPACE testza_tbs;
# 退出数据库
PanWeiDB=# \q
[omm@192 simpleInstall]$
# 测试数据库连接
[omm@192 simpleInstall]$ gsql -d testdb -U test -W 'test@Passw123' -r
gsql ((PanWeiDB(openGauss) 1.0.0 build 9a7e96bc) compiled at 2022-10-15 20:54:36 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
testdb=>
开启远程链接
[omm@192 bin]$ vi /opt/panweidb/soft/data/single_node/postgresql.conf
password_encryption_type = 1
listen_addresses = '*'
[omm@192 bin]$ vi /opt/panweidb/soft/data/single_node/pg_hba.conf
host all all 0.0.0.0/0 sha256
注意:不同客户端加密方式不一样
重启客户端
[omm@192 bin]$ cd /opt/panweidb/soft/bin/
# gs_ctl start、gs_ctl stop
[omm@192 bin]$ gs_ctl restart -D /opt/panweidb/soft/data/single_node/
关闭防火墙
# 以root执行
[root@192 ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@192 ~]# systemctl stop firewalld.service
标签:单机版,磐维,Centos,PanWeiDB,soft,omm,192,net,root
From: https://www.cnblogs.com/fades/p/17746718.html