wsl2安装openEuler

目前windows 11 提供官方的openEuler子系统下载:

1

我这里选择安装了24.03版本 之后再搜索界面搜索openEuler即可打开对应的命令行。 (注意:如果电脑之前没有配置WSL2,需要首先配置wsl2) 2

安装opengauss

之后开始opengauss的安装

下载opengauss

首先在官网下载对应版本的opengauss opengauss

3

我这里选择了x86架构的企业版server

下载后移动到wsl2 openEuler home文件夹里

安装

[openEuler@xyy ~]$ cd
[openEuler@xyy ~]$ mkdir -p ~/opengauss && cd ~/opengauss
[openEuler@xyy opengauss]$ mv /mnt/path/to/openGauss-All-7.0.0-RC1-openEuler24.03-x86_64.tar.gz ./
[openEuler@xyy opengauss]$ ls
openGauss-All-7.0.0-RC1-openEuler24.03-x86_64.tar.gz

之后解压安装文件:

[openEuler@xyy opengauss]$ tar -xjf openGauss-3.1.1-openEuler-64bit.tar.bz2
tar (child): openGauss-3.1.1-openEuler-64bit.tar.bz2: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
[openEuler@xyy opengauss]$ tar -xvzf openGauss-All-7.0.0-RC1-openEuler24.03-x86_64.tar.gz
openGauss-CM-7.0.0-RC1-openEuler24.03-x86_64.tar.gz
openGauss-OM-7.0.0-RC1-openEuler24.03-x86_64.tar.gz
openGauss-Server-7.0.0-RC1-openEuler24.03-x86_64.tar.bz2
openGauss-CM-7.0.0-RC1-openEuler24.03-x86_64.sha256
openGauss-OM-7.0.0-RC1-openEuler24.03-x86_64.sha256
openGauss-Server-7.0.0-RC1-openEuler24.03-x86_64.sha256
upgrade_sql.tar.gz
upgrade_sql.sha256
[openEuler@xyy opengauss]$ ls
openGauss-All-7.0.0-RC1-openEuler24.03-x86_64.tar.gz  openGauss-Server-7.0.0-RC1-openEuler24.03-x86_64.sha256
openGauss-CM-7.0.0-RC1-openEuler24.03-x86_64.sha256   openGauss-Server-7.0.0-RC1-openEuler24.03-x86_64.tar.bz2
openGauss-CM-7.0.0-RC1-openEuler24.03-x86_64.tar.gz   upgrade_sql.sha256
openGauss-OM-7.0.0-RC1-openEuler24.03-x86_64.sha256   upgrade_sql.tar.gz
openGauss-OM-7.0.0-RC1-openEuler24.03-x86_64.tar.gz
[openEuler@xyy opengauss]$ tar -xvjf openGauss-Server-7.0.0-RC1-openEuler24.03-x86_64.tar.bz2
[openEuler@xyy opengauss]$ tar -xvzf openGauss-CM-7.0.0-RC1-openEuler24.03-x86_64.tar.gz
tar -xvzf openGauss-OM-7.0.0-RC1-openEuler24.03-x86_64.tar.gz

依次解压得到的三个tar文件得到以下内容:

[openEuler@xyy opengauss]$ ls
bin                                                   openGauss-Server-7.0.0-RC1-openEuler24.03-x86_64.sha256
etc                                                   openGauss-Server-7.0.0-RC1-openEuler24.03-x86_64.tar.bz2
include                                               script
jre                                                   share
lib                                                   simpleInstall
openGauss-All-7.0.0-RC1-openEuler24.03-x86_64.tar.gz  tool
openGauss-CM-7.0.0-RC1-openEuler24.03-x86_64.sha256   upgrade_sql.sha256
openGauss-CM-7.0.0-RC1-openEuler24.03-x86_64.tar.gz   upgrade_sql.tar.gz
openGauss-OM-7.0.0-RC1-openEuler24.03-x86_64.sha256   version.cfg
openGauss-OM-7.0.0-RC1-openEuler24.03-x86_64.tar.gz

之后到simpleinstall目录下:

[openEuler@xyy opengauss]$ cd simpleInstall
ls
finance.sql  install.sh  README.md  school.sql
[openEuler@xyy simpleInstall]$ vim README.md

可根据README.md中指导进行安装。 注意安装以下两个包:

[openEuler@xyy simpleInstall]$ sudo dnf install net-tools
[openEuler@xyy simpleInstall]$ sudo dnf install libaio

执行以下命令即可安装成功:

[openEuler@xyy simpleInstall]$ sh install.sh -w password

配置路径

注意配置安装的路径:

[openEuler@xyy simpleInstall]$ export GAUSSHOME=/home/openEuler/opengauss/
[openEuler@xyy simpleInstall]$ export PATH=$GAUSSHOME/bin:$PATH
[openEuler@xyy simpleInstall]$ source ~/.bashrc   # 或者 source ~/.zshrc

测试

可以使用以下命令进行测试:

[openEuler@xyy simpleInstall]$ ps -ef | grep gaussdb
openEul+     951      75  1 17:21 ?        00:00:01 /home/openEuler/opengauss/bin/gaussdb -D /home/openEuler/opengauss/data/single_node
openEul+    1005      76  0 17:22 pts/0    00:00:00 grep --color=auto gaussdb
[openEuler@xyy simpleInstall]$ gs_ctl status -D $GAUSSHOME/data/single_node
[2025-04-08 17:23:13.156][1011][][gs_ctl]: gs_ctl status,datadir is /home/openEuler/opengauss/data/single_node
gs_ctl: server is running (PID: 951)
/home/openEuler/opengauss/bin/gaussdb "-D" "/home/openEuler/opengauss/data/single_node"
[openEuler@xyy simpleInstall]$ gsql -d postgres -p 5432 -U openEuler -r
gsql ((openGauss 7.0.0-RC1 build cff7b04d) compiled at 2025-03-28 10:40:19 commit 0 last mr  release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# help
You are using gsql, the command-line interface to gaussdb.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with gsql commands
       \g or terminate with semicolon to execute query
       \q to quit
openGauss=# \l
                                   List of databases
   Name    |   Owner   | Encoding |   Collate   |    Ctype    |    Access privileges
-----------+-----------+----------+-------------+-------------+-------------------------
 finance   | openEuler | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres  | openEuler | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 school    | openEuler | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | openEuler | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/openEuler           +
           |           |          |             |             | openEuler=CTc/openEuler
 template1 | openEuler | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/openEuler           +
           |           |          |             |             | openEuler=CTc/openEuler
(5 rows)

openGauss=# \c school
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "school" as user "openEuler".
school=# \dt
                                 List of relations
 Schema |       Name        | Type  |   Owner   |             Storage
--------+-------------------+-------+-----------+----------------------------------
 public | class             | table | openEuler | {orientation=row,compression=no}
 public | course            | table | openEuler | {orientation=row,compression=no}
 public | school_department | table | openEuler | {orientation=row,compression=no}
 public | student           | table | openEuler | {orientation=row,compression=no}
 public | teacher           | table | openEuler | {orientation=row,compression=no}
(5 rows)

school=# SELECT * FROM student;
 std_id | std_name | std_sex |      std_birth      |       std_in        |     std_address
--------+----------+---------+---------------------+---------------------+----------------------
      1 | 张一     | 男      | 1993-01-01 00:00:00 | 2011-09-01 00:00:00 | 江苏省南京市雨花台区
      2 | 张二     | 男      | 1993-01-02 00:00:00 | 2011-09-01 00:00:00 | 江苏省南京市雨花台区
      3 | 张三     | 男      | 1993-01-03 00:00:00 | 2011-09-01 00:00:00 | 江苏省南京市雨花台区
      4 | 张四     | 男      | 1993-01-04 00:00:00 | 2011-09-01 00:00:00 | 江苏省南京市雨花台区