安装openGauss极简版单节点

举报
小麦苗DB宝 发表于 2022/01/07 14:38:36 2022/01/07
【摘要】 参考:https://opengauss.org/zh/docs/2.1.0/docs/Quickstart/Quickstart.html 单节点安装参考:https://opengauss.org/zh/docs/2.1.0/docs/installation/极简版安装.htmldocker rm -f lhropengausssimpledocker run -d --name lh...

参考:https://opengauss.org/zh/docs/2.1.0/docs/Quickstart/Quickstart.html

单节点安装

参考:https://opengauss.org/zh/docs/2.1.0/docs/installation/极简版安装.html


docker rm -f lhropengausssimple
docker run -d --name lhropengausssimple -h lhropengausssimple \
  -p 35432-35439:5432-5439 -p 35632-35639:5632-5639 \
  -v /sys/fs/cgroup:/sys/fs/cgroup \
  --privileged=true lhrbest/lhrcentos76:8.5 \
  /usr/sbin/init
  
docker exec -it lhropengausssimple bash
cd /soft



#close selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

#close firewalld
systemctl stop firewalld && systemctl disable firewalld

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

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


sysctl -w kernel.sem="250 85000 250 330" 


-- 创建用户和组
groupadd dbgrp
useradd -g dbgrp -d /home/omm -m -s /bin/bash omm
echo "lhr" | passwd --stdin omm

## 创建相关目录
mkdir /opengauss
chgrp dbgrp -R /opengauss
chmod 775 -R /opengauss



## 解压数据库安装包,85Mb
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.1.0/x86/openGauss-2.1.0-CentOS-64bit.tar.bz2
tar -jxf openGauss-2.1.0-CentOS-64bit.tar.bz2 -C /opengauss
chown -R omm:dbgrp  /opengauss

-- 单节点安装
su - omm
cd /opengauss/simpleInstall
sh install.sh  -w lhr@123XXT


-- 启动停止
gs_ctl start|stop|restart -D $GAUSSHOME/data/single_node -Z single_node
 

gs_ctl status -D $GAUSSHOME/data/single_node

-- 连接,-r表示可以使用上下左右键
gsql -d postgres -r


# 环境变量,会自动写入 /home/omm/.bashrc
export GAUSSHOME=/opengauss
export PATH=$GAUSSHOME/bin:$PATH
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH
export GS_CLUSTER_NAME=dbCluster
ulimit -n 1000000


# 环境变量
echo "export PGDATA=$GAUSSHOME/data/single_node" >>  /home/omm/.bashrc
source /home/omm/.bashrc


-- 配置远程访问
create database omm;
alter system set password_policy=0;
alter system set password_encryption_type=1;
alter system set listen_addresses = '*';

echo "host  all  all  0.0.0.0/0  sha256" >> /opengauss/data/single_node/pg_hba.conf




-- 重启
gs_ctl restart



-- 新建用户
-- 初始化数据库的用户,是不能通过IP远程连接的,所以需要创建另外一个用户才能远程连接


# 创建用户(初始化数据库的用户不能进行远程连接,需要重新创建用户)
create user lhr with password 'lhr' sysadmin ;
grant all PRIVILEGES to lhr; 

-- 验证远程登录数据库
gsql -dpostgres -h172.17.0.6 -Ulhr -r -W'lhr'

-- 远程连接
gsql -d postgres -U lhr  -W'lhr' -h 192.168.66.35 -p35432 -r

psql -d postgres -U lhr  -h 192.168.66.35 -p35432


-- 解锁用户
alter user lhr account unlock;

安装过程:

[omm@lhropengausssimple bin]$ /opengauss/bin/gaussdb -V                             
gaussdb (openGauss 2.1.0 build 590b0f8e) compiled at 2021-09-30 14:29:04 commit 0 last mr  
[omm@lhropengausssimple bin]$ 
[omm@lhropengausssimple bin]$ cd /opengauss/simpleInstall
[omm@lhropengausssimple simpleInstall]$ sh install.sh  -w lhr@123XXT
[step 1]: check parameter
[step 2]: check install env and os setting
[step 3]: change_gausshome_owner
[step 4]: set environment variables

[step 6]: init datanode
The files belonging to this database system will be owned by user "omm".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

creating directory /opengauss/data/single_node ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
Begin init undo subsystem meta.
[INIT UNDO] Init undo subsystem meta successfully.
creating template1 database in /opengauss/data/single_node/base/1 ... The core dump path is an invalid directory
2021-10-24 09:57:56.002 [unknown] [unknown] localhost 140606630728640 0[0:0#0]  [BACKEND] WARNING:  macAddr is 578/2886795268, sysidentifier is 37923857/327574, randomNum is 1556938646
ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
loading PL/pgSQL server-side language ... ok
creating system views ... ok
creating performance views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
initialize global configure for bucketmap length ... ok
creating information schema ... ok
loading foreign-data wrapper for distfs access ... ok
loading foreign-data wrapper for hdfs access ... ok
loading foreign-data wrapper for log access ... ok
loading hstore extension ... ok
loading foreign-data wrapper for MOT access ... ok
loading security plugin ... ok
update system tables ... ok
creating snapshots catalog ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
freezing database template0 ... ok
freezing database template1 ... ok
freezing database postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run gs_initdb.

Success. You can now start the database server of single node using:

    gaussdb -D /opengauss/data/single_node --single_node
or
    gs_ctl start -D /opengauss/data/single_node -Z single_node -l logfile

[step 7]: start datanode
[2021-10-24 09:59:29.904][842][][gs_ctl]: gs_ctl started,datadir is /opengauss/data/single_node 
[2021-10-24 09:59:30.073][842][][gs_ctl]: waiting for server to start...
.0 LOG:  [Alarm Module]can not read GAUSS_WARNING_TYPE env.

0 LOG:  [Alarm Module]Host Name: lhropengausssimple 

0 LOG:  [Alarm Module]Host IP: 172.17.0.4 

0 LOG:  [Alarm Module]Cluster Name: dbCluster 

0 LOG:  [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 55

0 WARNING:  failed to open feature control file, please check whether it exists: FileName=gaussdb.version, Errno=2, Errmessage=No such file or directory.
0 WARNING:  failed to parse feature control file: gaussdb.version.
0 WARNING:  Failed to load the product control file, so gaussdb cannot distinguish product version.
The core dump path is an invalid directory
2021-10-24 09:59:30.416 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  when starting as multi_standby mode, we couldn't support data replicaton.
gaussdb.state does not exist, and skipt setting since it is optional.2021-10-24 09:59:30.416 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]can not read GAUSS_WARNING_TYPE env.

2021-10-24 09:59:30.416 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Host Name: lhropengausssimple 

2021-10-24 09:59:30.416 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Host IP: 172.17.0.4 

2021-10-24 09:59:30.416 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Cluster Name: dbCluster 

2021-10-24 09:59:30.416 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 55

2021-10-24 09:59:30.452 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  loaded library "security_plugin"
2021-10-24 09:59:30.453 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] WARNING:  could not create any HA TCP/IP sockets
2021-10-24 09:59:30.537 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] WARNING:  No explicit IP is configured for listen_addresses GUC.
2021-10-24 09:59:30.537 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.
2021-10-24 09:59:30.538 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  reserved memory for backend threads is: 220 MB
2021-10-24 09:59:30.538 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  reserved memory for WAL buffers is: 128 MB
2021-10-24 09:59:30.538 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  Set max backend reserve memory is: 348 MB, max dynamic memory is: 11069 MB
2021-10-24 09:59:30.538 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  shared memory 358 Mbytes, memory context 11417 Mbytes, max process memory 12288 Mbytes
2021-10-24 09:59:30.626 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [CACHE] LOG:  set data cache  size(402653184)
2021-10-24 09:59:30.664 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [CACHE] LOG:  set metadata cache  size(134217728)
2021-10-24 09:59:30.738 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [SEGMENT_PAGE] LOG:  Segment-page constants: DF_MAP_SIZE: 8156, DF_MAP_BIT_CNT: 65248, DF_MAP_GROUP_EXTENTS: 4175872, IPBLOCK_SIZE: 8168, EXTENTS_PER_IPBLOCK: 1021, IPBLOCK_GROUP_SIZE: 4090, BMT_HEADER_LEVEL0_TOTAL_PAGES: 8323072, BktMapEntryNumberPerBlock: 2038, BktMapBlockNumber: 25, BktBitMaxMapCnt: 512
2021-10-24 09:59:30.827 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  gaussdb: fsync file "/opengauss/data/single_node/gaussdb.state.temp" success
2021-10-24 09:59:30.827 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  create gaussdb state file success: db state(STARTING_STATE), server mode(Normal)
2021-10-24 09:59:30.857 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  max_safe_fds = 979, usable_fds = 1000, already_open = 11
The core dump path is an invalid directory
2021-10-24 09:59:30.860 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  user configure file is not found, it will be created.
2021-10-24 09:59:30.871 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  the configure file /opengauss/etc/gscgroup_omm.cfg doesn't exist or the size of configure file has changed. Please create it by root user!
2021-10-24 09:59:30.871 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [BACKEND] LOG:  Failed to parse cgroup config file.
2021-10-24 09:59:30.910 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [EXECUTOR] WARNING:  Failed to obtain environment value $GAUSSLOG!
2021-10-24 09:59:30.910 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [EXECUTOR] DETAIL:  N/A
2021-10-24 09:59:30.910 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [EXECUTOR] CAUSE:  Incorrect environment value.
2021-10-24 09:59:30.910 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [EXECUTOR] ACTION:  Please refer to backend log for more details.
2021-10-24 09:59:30.913 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [EXECUTOR] WARNING:  Failed to obtain environment value $GAUSSLOG!
2021-10-24 09:59:30.913 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [EXECUTOR] DETAIL:  N/A
2021-10-24 09:59:30.913 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [EXECUTOR] CAUSE:  Incorrect environment value.
2021-10-24 09:59:30.913 [unknown] [unknown] localhost 140607086257088 0[0:0#0]  0 [EXECUTOR] ACTION:  Please refer to backend log for more details.
.
[2021-10-24 09:59:32.130][842][][gs_ctl]:  done
[2021-10-24 09:59:32.130][842][][gs_ctl]: server started (/opengauss/data/single_node)
import sql file
Would you like to create a demo database (yes/no)? YES
Please type 'yes' or 'no': yes
Load demoDB [school,finance] success.
[complete successfully]: You can start or stop the database server using:
    gs_ctl start|stop|restart -D $GAUSSHOME/data/single_node -Z single_node

[omm@lhropengausssimple simpleInstall]$ gs_ctl status -D $GAUSSHOME/data/single_node
[2021-10-25 16:10:28.173][1117][][gs_ctl]: gs_ctl status,datadir is /opengauss/data/single_node 
gs_ctl: server is running (PID: 706)
/opengauss/bin/gaussdb "-D" "/opengauss/data/single_node"
[omm@lhropengausssimple simpleInstall]$ pwd
/opengauss/simpleInstall
[omm@lhropengausssimple simpleInstall]$ ll
total 64
-rw-r--r-- 1 omm dbgrp 10883 Sep 30 14:39 finance.sql
-rw-r--r-- 1 omm dbgrp 12842 Sep 30 14:39 install.sh
-rw-r--r-- 1 omm dbgrp  4491 Oct 24 09:59 load.log
-rw-r--r-- 1 omm dbgrp  5167 Sep 30 14:39 README.md
-rw-r--r-- 1 omm dbgrp 19926 Sep 30 14:39 school.sql
[omm@lhropengausssimple simpleInstall]$ cd ..
[omm@lhropengausssimple opengauss]$ ll
total 40
drwxr-xr-x 3 omm dbgrp 4096 Sep 30 14:39 bin
drwx------ 3 omm dbgrp 4096 Oct 24 09:57 data
drwxr-xr-x 3 omm dbgrp 4096 Sep 30 14:39 etc
drwxr-xr-x 3 omm dbgrp 4096 Sep 30 14:39 include
drwxr-xr-x 4 omm dbgrp 4096 Sep 30 14:39 jre
drwxr-xr-x 5 omm dbgrp 4096 Sep 30 14:39 lib
drwx------ 2 omm dbgrp 4096 Oct 24 09:59 logs
drwxr-xr-x 5 omm dbgrp 4096 Sep 30 14:39 share
drwxr-xr-x 2 omm dbgrp 4096 Oct 24 09:59 simpleInstall
-rw-r--r-- 1 omm dbgrp   32 Sep 30 14:39 version.cfg
[omm@lhropengausssimple opengauss]$ ps -ef|grep omm
root        414     19  0 09:55 pts/0    00:00:00 su - omm
omm         415    414  0 09:55 pts/0    00:00:00 -bash
omm         845      0  4 09:59 pts/0    00:00:02 /opengauss/bin/gaussdb -D /opengauss/data/single_node
omm         973    415  0 10:00 pts/0    00:00:00 ps -ef
omm         974    415  0 10:00 pts/0    00:00:00 grep --color=auto omm
[omm@lhropengausssimple opengauss]$ cd bin
[omm@lhropengausssimple bin]$ ./gsql 
gsql: FATAL:  database "omm" does not exist
[omm@lhropengausssimple bin]$ ./gsql -d postgres
gsql ((openGauss 2.1.0 build 590b0f8e) compiled at 2021-09-30 14:29:04 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# \l
                              List of databases
   Name    | Owner | Encoding |   Collate   |    Ctype    | Access privileges 
-----------+-------+----------+-------------+-------------+-------------------
 finance   | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 school    | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/omm           +
           |       |          |             |             | omm=CTc/omm
 template1 | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/omm           +
           |       |          |             |             | omm=CTc/omm
(5 rows)

openGauss=# 
                                                                        

                                                                        
C:\Users\lhrxxt>psql -d postgres -U lhr -h 192.168.66.35 -p35432
Password for user lhr:
psql (14.0, server 9.2.4)
Type "help" for help.

postgres=> \du
                                    List of roles
       Role name        |                   Attributes                   | Member of
------------------------+------------------------------------------------+-----------
 gs_role_account_lock   | Cannot login                                   | {}
 gs_role_copy_files     | Cannot login                                   | {}
 gs_role_pldebugger     | Cannot login                                   | {}
 gs_role_replication    | Cannot login                                   | {}
 gs_role_signal_backend | Cannot login                                   | {}
 gs_role_tablespace     | Cannot login                                   | {}
 lhr                    |                                                | {}
 omm                    | Superuser, Create role, Create DB, Replication | {}

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。