在openEuler 22.03操作系统上使用yum安装openGauss单机环境
Tags: openEuleropenGaussyum单机安装部署
简介
EulerOS是华为自主研发的服务器操作系统,能够满足客户从传统IT基础设施到云计算服务的需求。EulerOS对ARM64架构提供全栈支持,打造完善的从芯片到应用的一体化生态系统。
openEuler 也就是华为服务器操作系统 EulerOS,开源后命名为 openEuler。openEuler 面向企业级通用服务器架构平台,基于 Linux 稳定系统内核,支持鲲鹏处理器和容器虚拟化技术,特性包括系统高可靠、高安全以及高保障。openEuler 拥有三级智能调度,可以将多进程并发时延缩短 60%,而且还可以智能自动有规划,可将 Web 服务器性能提升 137%。
2022年3月,openEuler 22.03 LTS版本ISO安装包仓库及LTS官方软件仓库均上线openGauss2.1.0版本安装包,提供RPM一键安装openGauss的能力,提高用户易用性。
在openEuler系统上安装openGauss
openGauss软件包使用,提供用户易用性
openEuler 22.03 LTS版本中涉及的openGauss安装包及其依赖仓库如下:
https://gitee.com/src-openeuler/opengauss-server
https://gitee.com/src-openeuler/opengauss-dcf
方式一:安装操作系统时勾选数据库
在使用openEuler 22.03 LTS ISO镜像安装操作系统时候,安装引导界面的选择软件包里面勾选上openGauss Server,在安装完成操作系统后,便会默认安装上openGauss数据库并启动单机数据库进程。
方式二:安装完操作系统后使用yum一键安装
如果在安装操作系统时候没有选择openGauss软件包,还可以在安装完系统后,通过命令一键安装上openGauss的单机数据库实例:
1 | yum install opengauss -y |
使用说明:
openGauss数据库进程的管理用户为opengauss,切换到该用户下可以进行数据库的常用操作。
1 | su - opengauss |
登录数据库中执行sql语句:
1 | gsql -d postgres -r |
查询数据库实例状态:
1 | gs_ctl query |
停止数据库实例进程:
1 | gs_ctl stop |
启动数据库实例进程:
1 | gs_ctl start |
openGauss RPM软件包使用概述
概述为使用非openEuler 22.03 LTS ISO软件包的用户,需要配置openEuler 22.03 LTS官方源。
Step.1
针对不同硬件平台(aarch64/x86_64)在本地添加openEuler 22.03 LTS everything 软件仓库,openGauss软件包所处位置为:
https://repo.openeuler.org/openEuler-22.03-LTS/everything/
配置完成后,执行
1 | dnf update |
在本地更新远端仓库。
Step.2
安装openGauss软件包及其对应依赖包。
1 | dnf install opengauss -y |
安装完成后:
openGauss的安装路径在 /usr/local/opengauss
首先来看openGauss环境变量,启动openGauss和连入服务需要的环境变量被放置在 /var/lib/opengauss/.bash_profile
1 2 3 4 5 | 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的安装路径,DATA PATH,依赖库路径等等。
另外,openGauss轻量化构建选项opengauss_config_file_mini,被放在/usr/local/opengauss/share/postgresql/
默认启动的配置文件在 /usr/local/opengauss/share/postgresql/postgresql.conf.sample,可以按需修改或重新指定。
Systemd相关文件存放在 /usr/local/opengauss/script/
Step.3
在openGauss软件包安装成功后,会为其创建opengauss用户用来运行openGauss服务。接下来就可以使用:
1 | systemctl start opengauss |
启动openGauss单节点环境。
Notes:
安装前需要确定系统中没有opengauss同名用户存在,以免产生安装冲突;
当前只支持openGauss单节点环境安装,更多配置参考openGauss社区官方文档;
如需修改openGauss配置文件或systemd启动脚本,参考
1 | /usr/local/opengauss/script/opengauss.service/usr/local/opengauss/script/autostart.sh |
进行添加适配;
- 新添配置或目录需要给予opengauss用户相应权限。
小麦苗使用yum安装openGauss示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | -- 直接使用小麦苗定制镜像 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 [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 su - opengauss gsql -d postgres -r ALTER ROLE opengauss PASSWORD 'lhr@xxt123'; alter system set password_policy=0; alter system set password_encryption_type=1; -- 修改初始化用户的密码(若需要),openGauss 加强安全,如果需要修改初始化数据库用户的密码,需要用REPLACE哦! ALTER ROLE opengauss IDENTIFIED BY 'lhr' REPLACE 'lhr@xxt123'; -- 配置远程登录 cat >> /var/lib/opengauss/data/postgresql.conf <<"EOF" listen_addresses = '*' EOF echo "host all all 0.0.0.0/0 sha256" >> /var/lib/opengauss/data/pg_hba.conf -- 重启 gs_ctl restart -- 新建用户 -- 初始化数据库的用户,是不能通过IP远程连接的,所以需要创建另外一个用户才能远程连接 # 创建用户(初始化数据库的用户不能进行远程连接,需要重新创建用户) gsql -d postgres -r create user lhr with password 'lhr' sysadmin ; grant all PRIVILEGES to lhr; -- 验证远程登录数据库 gsql -dpostgres -h172.17.0.3 -Ulhr -r -W'lhr' -- 远程连接 gsql -d postgres -U lhr -W'lhr' -h 192.168.66.35 -p7654 -r psql -d postgres -U lhr -h 192.168.66.35 -p7654 -- 解锁用户 alter user lhr account unlock; |
运行过程:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | [root@docker35 ~]# 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 e29f895c1a88f4fc3df6fe4079994c5a9382db632bd22fe5d6ef08286923d4b5 [root@docker35 ~]# [root@docker35 ~]# docker exec -it lhropeneuler22 bash Welcome to 3.10.0-1127.10.1.el7.x86_64 System information as of time: Tue Apr 12 16:40:48 CST 2022 System load: 1.45 Processes: 15 Memory used: 3.3% Swap used: 0% Usage On: 68% IP address: 172.17.0.3 Users online: 0 [root@lhropeneuler22 /]# [root@lhropeneuler22 /]# [root@lhropeneuler22 /]# [root@lhropeneuler22 /]# systemctl status sshd ● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2022-04-12 16:40:50 CST; 11s ago Docs: man:sshd(8) man:sshd_config(5) Main PID: 603 (sshd) Tasks: 1 (limit: 514309) Memory: 896.0K CGroup: /docker/e29f895c1a88f4fc3df6fe4079994c5a9382db632bd22fe5d6ef08286923d4b5/system.slice/sshd.service └─603 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups" Apr 12 16:40:50 lhropeneuler22 systemd[1]: Starting OpenSSH server daemon... Apr 12 16:40:50 lhropeneuler22 sshd[603]: WARNING: 'UsePAM no' is not supported in openEuler and may cause several problems. Apr 12 16:40:50 lhropeneuler22 sshd[603]: Server listening on 0.0.0.0 port 22. Apr 12 16:40:50 lhropeneuler22 sshd[603]: Server listening on :: port 22. Apr 12 16:40:50 lhropeneuler22 systemd[1]: Started OpenSSH server daemon. [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" [root@lhropeneuler22 /]# [root@lhropeneuler22 /]# yum install -y opengauss Last metadata expiration check: 0:40:00 ago on Tue Apr 12 16:03:14 2022. Dependencies resolved. ======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================== Package Architecture Version Repository Size ======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================== Installing: opengauss x86_64 2.1.0-5.oe2203 OS 14 M Installing dependencies: DCF x86_64 1.0.0-2.oe2203 OS 286 k boost x86_64 1.78.0-11.oe2203 OS 12 k boost-atomic x86_64 1.78.0-11.oe2203 OS 17 k boost-chrono x86_64 1.78.0-11.oe2203 OS 24 k boost-container x86_64 1.78.0-11.oe2203 OS 42 k boost-context x86_64 1.78.0-11.oe2203 OS 14 k boost-contract x86_64 1.78.0-11.oe2203 OS 43 k boost-coroutine x86_64 1.78.0-11.oe2203 OS 19 k boost-date-time x86_64 1.78.0-11.oe2203 OS 14 k boost-devel x86_64 1.78.0-11.oe2203 OS 16 M boost-fiber x86_64 1.78.0-11.oe2203 OS 37 k boost-filesystem x86_64 1.78.0-11.oe2203 OS 63 k boost-graph x86_64 1.78.0-11.oe2203 OS 144 k boost-iostreams x86_64 1.78.0-11.oe2203 OS 37 k boost-json x86_64 1.78.0-11.oe2203 OS 102 k boost-locale x86_64 1.78.0-11.oe2203 OS 226 k boost-log x86_64 1.78.0-11.oe2203 OS 466 k boost-math x86_64 1.78.0-11.oe2203 OS 282 k boost-nowide x86_64 1.78.0-11.oe2203 OS 18 k boost-program-options x86_64 1.78.0-11.oe2203 OS 124 k boost-python3 x86_64 1.78.0-11.oe2203 OS 97 k boost-random x86_64 1.78.0-11.oe2203 OS 23 k boost-regex x86_64 1.78.0-11.oe2203 OS 106 k boost-serialization x86_64 1.78.0-11.oe2203 OS 114 k boost-stacktrace x86_64 1.78.0-11.oe2203 OS 24 k boost-system x86_64 1.78.0-11.oe2203 OS 13 k boost-test x86_64 1.78.0-11.oe2203 OS 227 k boost-thread x86_64 1.78.0-11.oe2203 OS 51 k boost-timer x86_64 1.78.0-11.oe2203 OS 22 k boost-type_erasure x86_64 1.78.0-11.oe2203 OS 28 k boost-wave x86_64 1.78.0-11.oe2203 OS 208 k cjson x86_64 1.7.15-1.oe2203 OS 29 k libboundscheck x86_64 v1.1.11-6.oe2203 OS 46 k libcgroup x86_64 0.42.2-1.oe2203 OS 97 k libcgroup-devel x86_64 0.42.2-1.oe2203 OS 33 k libedit-devel x86_64 3.1-28.oe2203 OS 14 k libquadmath x86_64 10.3.1-10.oe2203 OS 155 k libquadmath-devel x86_64 10.3.1-10.oe2203 OS 22 k protobuf x86_64 3.14.0-1.oe2203 OS 976 k protobuf-compiler x86_64 3.14.0-1.oe2203 OS 871 k protobuf-devel x86_64 3.14.0-1.oe2203 OS 2.5 M snappy x86_64 1.1.9-1.oe2203 OS 28 k snappy-devel x86_64 1.1.9-1.oe2203 OS 22 k Transaction Summary ======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================== Install 44 Packages Total download size: 37 M Installed size: 288 M Downloading Packages: (1/44): boost-1.78.0-11.oe2203.x86_64.rpm 64 kB/s | 12 kB 00:00 (2/44): boost-atomic-1.78.0-11.oe2203.x86_64.rpm 77 kB/s | 17 kB 00:00 (3/44): boost-chrono-1.78.0-11.oe2203.x86_64.rpm 274 kB/s | 24 kB 00:00 (4/44): boost-container-1.78.0-11.oe2203.x86_64.rpm 329 kB/s | 42 kB 00:00 (5/44): boost-context-1.78.0-11.oe2203.x86_64.rpm 157 kB/s | 14 kB 00:00 (6/44): boost-contract-1.78.0-11.oe2203.x86_64.rpm 563 kB/s | 43 kB 00:00 (7/44): DCF-1.0.0-2.oe2203.x86_64.rpm 551 kB/s | 286 kB 00:00 (8/44): boost-date-time-1.78.0-11.oe2203.x86_64.rpm 109 kB/s | 14 kB 00:00 (9/44): boost-coroutine-1.78.0-11.oe2203.x86_64.rpm 89 kB/s | 19 kB 00:00 (10/44): boost-fiber-1.78.0-11.oe2203.x86_64.rpm 460 kB/s | 37 kB 00:00 (11/44): boost-filesystem-1.78.0-11.oe2203.x86_64.rpm 466 kB/s | 63 kB 00:00 (12/44): boost-graph-1.78.0-11.oe2203.x86_64.rpm 1.0 MB/s | 144 kB 00:00 (13/44): boost-iostreams-1.78.0-11.oe2203.x86_64.rpm 450 kB/s | 37 kB 00:00 (14/44): boost-json-1.78.0-11.oe2203.x86_64.rpm 1.2 MB/s | 102 kB 00:00 (15/44): boost-log-1.78.0-11.oe2203.x86_64.rpm 2.4 MB/s | 466 kB 00:00 (16/44): boost-locale-1.78.0-11.oe2203.x86_64.rpm 850 kB/s | 226 kB 00:00 (17/44): boost-math-1.78.0-11.oe2203.x86_64.rpm 2.9 MB/s | 282 kB 00:00 (18/44): boost-nowide-1.78.0-11.oe2203.x86_64.rpm 193 kB/s | 18 kB 00:00 (19/44): boost-program-options-1.78.0-11.oe2203.x86_64.rpm 1.4 MB/s | 124 kB 00:00 (20/44): boost-python3-1.78.0-11.oe2203.x86_64.rpm 516 kB/s | 97 kB 00:00 (21/44): boost-random-1.78.0-11.oe2203.x86_64.rpm 139 kB/s | 23 kB 00:00 (22/44): boost-serialization-1.78.0-11.oe2203.x86_64.rpm 968 kB/s | 114 kB 00:00 (23/44): boost-regex-1.78.0-11.oe2203.x86_64.rpm 575 kB/s | 106 kB 00:00 (24/44): boost-stacktrace-1.78.0-11.oe2203.x86_64.rpm 309 kB/s | 24 kB 00:00 (25/44): boost-system-1.78.0-11.oe2203.x86_64.rpm 150 kB/s | 13 kB 00:00 (26/44): boost-test-1.78.0-11.oe2203.x86_64.rpm 2.4 MB/s | 227 kB 00:00 (27/44): boost-thread-1.78.0-11.oe2203.x86_64.rpm 594 kB/s | 51 kB 00:00 (28/44): boost-timer-1.78.0-11.oe2203.x86_64.rpm 244 kB/s | 22 kB 00:00 (29/44): boost-type_erasure-1.78.0-11.oe2203.x86_64.rpm 295 kB/s | 28 kB 00:00 (30/44): boost-wave-1.78.0-11.oe2203.x86_64.rpm 2.3 MB/s | 208 kB 00:00 (31/44): cjson-1.7.15-1.oe2203.x86_64.rpm 349 kB/s | 29 kB 00:00 (32/44): libboundscheck-v1.1.11-6.oe2203.x86_64.rpm 599 kB/s | 46 kB 00:00 (33/44): libcgroup-devel-0.42.2-1.oe2203.x86_64.rpm 368 kB/s | 33 kB 00:00 (34/44): libcgroup-0.42.2-1.oe2203.x86_64.rpm 585 kB/s | 97 kB 00:00 (35/44): libedit-devel-3.1-28.oe2203.x86_64.rpm 176 kB/s | 14 kB 00:00 (36/44): libquadmath-devel-10.3.1-10.oe2203.x86_64.rpm 257 kB/s | 22 kB 00:00 (37/44): libquadmath-10.3.1-10.oe2203.x86_64.rpm 662 kB/s | 155 kB 00:00 (38/44): protobuf-3.14.0-1.oe2203.x86_64.rpm 444 kB/s | 976 kB 00:02 (39/44): protobuf-compiler-3.14.0-1.oe2203.x86_64.rpm 406 kB/s | 871 kB 00:02 (40/44): protobuf-devel-3.14.0-1.oe2203.x86_64.rpm 551 kB/s | 2.5 MB 00:04 (41/44): snappy-1.1.9-1.oe2203.x86_64.rpm 174 kB/s | 28 kB 00:00 (42/44): snappy-devel-1.1.9-1.oe2203.x86_64.rpm 247 kB/s | 22 kB 00:00 (43/44): opengauss-2.1.0-5.oe2203.x86_64.rpm 920 kB/s | 14 MB 00:15 (44/44): boost-devel-1.78.0-11.oe2203.x86_64.rpm 815 kB/s | 16 MB 00:19 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 1.8 MB/s | 37 MB 00:20 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : boost-chrono-1.78.0-11.oe2203.x86_64 1/44 Installing : boost-thread-1.78.0-11.oe2203.x86_64 2/44 Installing : boost-regex-1.78.0-11.oe2203.x86_64 3/44 Installing : boost-context-1.78.0-11.oe2203.x86_64 4/44 Installing : boost-atomic-1.78.0-11.oe2203.x86_64 5/44 Installing : boost-filesystem-1.78.0-11.oe2203.x86_64 6/44 Installing : protobuf-3.14.0-1.oe2203.x86_64 7/44 Running scriptlet: libcgroup-0.42.2-1.oe2203.x86_64 8/44 Installing : libcgroup-0.42.2-1.oe2203.x86_64 8/44 Running scriptlet: libcgroup-0.42.2-1.oe2203.x86_64 8/44 Installing : libboundscheck-v1.1.11-6.oe2203.x86_64 &n |