详细过程参考:https://www.xmmup.com/zaiopeneuler-22-03caozuoxitongshangshiyongyumanzhuangopengaussdanjihuanjing.html
小麦苗使用yum安装openGauss示例
代码语言:javascript复制-- 直接使用小麦苗定制镜像
docker rm -f lhropeneuler22
docker run -itd --name lhropeneuler22 -h lhropeneuler22
-p 225:22 -p 7654:7654
--privileged=true
-v /sys/fs/cgroup:/sys/fs/cgroup
lhrbest/openeuler22:1.0
init
docker exec -it lhropeneuler22 bash
[root@lhropeneuler22 /]# cat /etc/os-release
NAME="openEuler"
VERSION="22.03 LTS"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 LTS"
ANSI_COLOR="0;31"
yum install -y opengauss
systemctl status opengauss
systemctl restart opengauss
systemctl status opengauss
su - opengauss
-- gs_initdb /var/lib/opengauss/data/ --nodename=lhropeneuler22
gs_ctl start
gs_ctl status
gs_ctl query
代码语言:javascript复制[root@lhropeneuler22 /]# systemctl status opengauss
○ opengauss.service - Start openGauss server
Loaded: loaded (/usr/lib/systemd/system/opengauss.service; enabled; vendor preset: disabled)
Active: inactive (dead)
[root@lhropeneuler22 /]#
[root@lhropeneuler22 /]# systemctl restart opengauss
[root@lhropeneuler22 /]# systemctl status opengauss
● opengauss.service - Start openGauss server
Loaded: loaded (/usr/lib/systemd/system/opengauss.service; enabled; vendor preset: disabled)
Active: active (exited) since Tue 2022-04-12 16:45:14 CST; 1s ago
Process: 3362 ExecStart=/usr/local/opengauss/script/autostart.sh (code=exited, status=0/SUCCESS)
Main PID: 3362 (code=exited, status=0/SUCCESS)
Apr 12 16:45:14 lhropeneuler22 systemd[1]: Started Start openGauss server.
Apr 12 16:45:14 lhropeneuler22 su[3363]: (to opengauss) root on none
Apr 12 16:45:14 lhropeneuler22 su[3363]: pam_unix(su-l:session): session opened for user opengauss(uid=1000) by (uid=0)
Apr 12 16:45:15 lhropeneuler22 su[3363]: pam_unix(su-l:session): session closed for user opengauss
Apr 12 16:45:15 lhropeneuler22 autostart.sh[3362]: Start openGauss database success.
[root@lhropeneuler22 /]#
[root@lhropeneuler22 /]# su - opengauss
Last login: Tue Apr 12 16:45:14 CST 2022
Welcome to 3.10.0-1127.10.1.el7.x86_64
System information as of time: Tue Apr 12 16:45:26 CST 2022
System load: 0.48
Processes: 34
Memory used: 3.6%
Swap used: 0%
Usage On: 68%
IP address: 172.17.0.3
Users online: 0
To run a command as administrator(user "root"),use "sudo <command>".
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$ gs_ctl status
[2022-04-12 16:45:35.496][3484][][gs_ctl]: gs_ctl status,datadir is /var/lib/opengauss/data
gs_ctl: server is running (PID: 3133)
/usr/local/opengauss/bin/gaussdb "-D" "/var/lib/opengauss/data"
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$ gs_ctl query
[2022-04-12 16:45:43.686][3491][][gs_ctl]: gs_ctl query ,datadir is /var/lib/opengauss/data
HA state:
local_role : Normal
static_connections : 0
db_state : Normal
detail_information : Normal
Senders info:
No information
Receiver info:
No information
[opengauss@lhropeneuler22 ~]$ more /var/lib/opengauss/.bash_profile
export GAUSSHOME=/usr/local/opengauss/
export LD_LIBRARY_PATH=/usr/local/opengauss/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/opengauss/bin:$PATH
export PGDATA=/var/lib/opengauss/data
export PORT=7654
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$ gsql -d postgres -r
gsql ((GaussDB Kernel V500R002C00 build ) compiled at 2022-03-30 05:12:20 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=# l
ERROR: Please use "ALTER ROLE user_name PASSWORD 'password';" to set the password of user opengauss before other operation!
openGauss=#
openGauss=# ALTER ROLE opengauss PASSWORD 'lhr@xxt123';
ALTER ROLE
openGauss=#
openGauss=# alter system set password_policy=0;
ALTER SYSTEM SET
openGauss=# alter system set password_encryption_type=1;
ALTER SYSTEM SET
openGauss=# ALTER ROLE opengauss IDENTIFIED BY 'lhr' REPLACE 'lhr@xxt123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
ALTER ROLE
openGauss=# exit
openGauss-# q
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$ cat >> /var/lib/opengauss/data/postgresql.conf <<"EOF"
> listen_addresses = '*'
> EOF
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$ echo "host all all 0.0.0.0/0 sha256" >> /var/lib/opengauss/data/pg_hba.conf
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$ gs_ctl restart
[2022-04-12 16:47:25.231][3508][][gs_ctl]: gs_ctl restarted ,datadir is /var/lib/opengauss/data
waiting for server to shut down... done
server stopped
[2022-04-12 16:47:32.254][3508][][gs_ctl]: waiting for server to start...
.0 LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env.
0 LOG: [Alarm Module]Host Name: lhropeneuler22
0 LOG: [Alarm Module]Host IP: 172.17.0.3
0 LOG: [Alarm Module]Get ENV GS_CLUSTER_NAME failed!
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
2022-04-12 16:47:32.341 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: when starting as multi_standby mode, we couldn't support data replicaton.
2022-04-12 16:47:32.341 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env.
2022-04-12 16:47:32.341 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: [Alarm Module]Host Name: lhropeneuler22
2022-04-12 16:47:32.341 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: [Alarm Module]Host IP: 172.17.0.3
2022-04-12 16:47:32.341 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: [Alarm Module]Get ENV GS_CLUSTER_NAME failed!
2022-04-12 16:47:32.341 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 55
2022-04-12 16:47:32.556 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: loaded library "security_plugin"
2022-04-12 16:47:32.557 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-04-12 16:47:32.594 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] WARNING: No explicit IP is configured for listen_addresses GUC.
2022-04-12 16:47:32.594 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.
2022-04-12 16:47:32.595 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: reserved memory for backend threads is: 220 MB
2022-04-12 16:47:32.595 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: reserved memory for WAL buffers is: 128 MB
2022-04-12 16:47:32.595 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: Set max backend reserve memory is: 348 MB, max dynamic memory is: 11873 MB
2022-04-12 16:47:32.595 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: shared memory 50 Mbytes, memory context 12221 Mbytes, max process memory 12288 Mbytes
2022-04-12 16:47:32.622 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [CACHE] LOG: set data cache size(12582912)
2022-04-12 16:47:32.623 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [CACHE] LOG: set metadata cache size(4194304)
2022-04-12 16:47:32.666 [unknown] [unknown] localhost 140364734101056 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
2022-04-12 16:47:32.708 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: gaussdb: fsync file "/var/lib/opengauss/data/gaussdb.state.temp" success
2022-04-12 16:47:32.708 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: create gaussdb state file success: db state(STARTING_STATE), server mode(Normal)
2022-04-12 16:47:32.732 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: max_safe_fds = 980, usable_fds = 1000, already_open = 10
The core dump path is an invalid directory
2022-04-12 16:47:32.738 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: the configure file /usr/local/opengauss/etc/gscgroup_opengauss.cfg doesn't exist or the size of configure file has changed. Please create it by root user!
2022-04-12 16:47:32.739 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [BACKEND] LOG: Failed to parse cgroup config file.
2022-04-12 16:47:32.745 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [EXECUTOR] WARNING: Failed to obtain environment value $GAUSSLOG!
2022-04-12 16:47:32.745 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [EXECUTOR] DETAIL: N/A
2022-04-12 16:47:32.745 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [EXECUTOR] CAUSE: Incorrect environment value.
2022-04-12 16:47:32.745 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [EXECUTOR] ACTION: Please refer to backend log for more details.
2022-04-12 16:47:32.746 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [EXECUTOR] WARNING: Failed to obtain environment value $GAUSSLOG!
2022-04-12 16:47:32.746 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [EXECUTOR] DETAIL: N/A
2022-04-12 16:47:32.746 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [EXECUTOR] CAUSE: Incorrect environment value.
2022-04-12 16:47:32.746 [unknown] [unknown] localhost 140364734101056 0[0:0#0] 0 [EXECUTOR] ACTION: Please refer to backend log for more details.
[2022-04-12 16:47:33.265][3508][][gs_ctl]: done
[2022-04-12 16:47:33.265][3508][][gs_ctl]: server started (/var/lib/opengauss/data)
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$ gsql -d postgres -r
gsql ((GaussDB Kernel V500R002C00 build ) compiled at 2022-03-30 05:12:20 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=#
openGauss=# create user lhr with password 'lhr' sysadmin ;
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
openGauss=#
openGauss=# grant all PRIVILEGES to lhr;
ALTER ROLE
openGauss=# q
[opengauss@lhropeneuler22 ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.3 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:ac:11:00:03 txqueuelen 0 (Ethernet)
RX packets 5739 bytes 38912047 (37.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5384 bytes 332270 (324.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 481 bytes 155467 (151.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 481 bytes 155467 (151.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$ gsql -dpostgres -h172.17.0.3 -Ulhr -r -W'lhr'
gsql ((GaussDB Kernel V500R002C00 build ) compiled at 2022-03-30 05:12:20 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
----------- ----------- ---------- ------------- ------------- -------------------------
postgres | opengauss | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | opengauss | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/opengauss
| | | | | opengauss=CTc/opengauss
template1 | opengauss | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/opengauss
| | | | | opengauss=CTc/opengauss
(3 rows)
openGauss=> q
[opengauss@lhropeneuler22 ~]$
[opengauss@lhropeneuler22 ~]$ gsql -d postgres -U lhr -W'lhr' -h 192.168.66.35 -p7654 -r
gsql ((GaussDB Kernel V500R002C00 build ) compiled at 2022-03-30 05:12:20 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=> q
参考
https://www.xmmup.com/tag/opengauss
在Docker中快速体验openGauss数据库
在Docker中快速体验openGauss主备环境数据库
安装openGauss极简版单节点和一主一备节点环境
https://mp.weixin.qq.com/s/sh6GIhTV2V2aaxuZQDoozg