)# docker安装opengauss最新版
目前最新版为5.0.0
docker命令直接安装:
# GS_PASSWORD 设置密码
docker run --name opengauss --privileged=true -d -e GS_PASSWORD=Enmo@123 -v ./opengauss:/var/lib/opengauss opengauss:2.0.0
docker-compose 安装
version: '3'
services:
opengauss1:
image: enmotech/opengauss:latest
container_name: opengauss
ports:
- "5433:5432"
volumes:
- ./opengauss:/var/lib/opengauss
environment:
- GS_PASSWORD=Enmo@123
restart: always
privileged: true
networks:
dnmp_default:
个人注意
我的数据库端口为 5432,默认用户为 omm
勇哥的数据库端口为7654 默认用户为 opengauss
使用opengauss系统
连接数据库
- 进入容器
docker exec -it opengauss sh
- 连接上数据库
这里官方的文档是写的8000
端口,实际上应该需要使用5432
的端口
# 先要切换到omm用户
su - omm
# 执行链接
gsql -d postgres -p 5432
显示如下信息表示成功
gsql ((openGauss x.x.x build 50dc16a6) compiled at 2020-11-24 20:03:57 commit 1093 last mr 1793 debug)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=#
备份数据库
gs_dump -p 7654 ningbo_police -f /var/sql/ningbo_police.sql;
还原数据
我这里是从A容器的opengauss备份的数据库语句还原到B数据库语句
由于A容器是新创的角色来操作,所有B容器也同样需要创建这样一个角色
su - opengauss
gsql -d postgres -p 5432
gsql -d ningbo_police -U root -p 7654
# 断开所有的连接
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE datname='ningbo_police' AND pid<>pg_backend_pid();
drop database ningbo_police;
CREATE DATABASE ningbo_police OWNER root;
gsql -d ningbo_police -p 7654 -U root -f /var/www/sql/ningbo_police.sql
CREATE USER root WITH PASSWORD "Xt123456789";
GRANT ALL PRIVILEGES TO root;
CREATE DATABASE ningbo_police OWNER root;
ERROR: role “root” cannot be dropped because some objects depend on it
DROP OWNED BY root;
drop role root;
drop database ningbo_police;
删除角色
DROP OWNED BY root;
drop role root
drop database ningbo_police
questions
the user is not omm, who to find the use?
u can use the command
cat /etc/passwd
The command will show u the use acount list
u can use “grep keyword ” to filter , like this
cat /etc/passwd | grep gauss
whice port is listening by opengauss
ps aux|grep guass
this command can find the guass’s pid
next , use next command to find out whice port is listened by guass
netstat -anp|grep pid
notice Please use “ALTER ROLE user_name PASSWORD ‘password’;” to set the password of user opengauss before other operation!
The error message suggest that your should frist set password for the ‘opengauss’ user before trying to create another user
ALTER ROLE opengauss PASSWORD 'u password ';
设置远程连接
cd /var/lib/opengauss/data
vim pg_hba.conf
find
host all all 127.0.0.1/32 trust
change to next
host all all 0.0.0.0/0 md5
vim postgresql.conf
find listen_addresses = ‘127.0.0.1’
change to
listen_addresses = '*'
vim postgresql.conf
find password_encryption_type
password_encryption_type = 0
restart opengauss
su - opengauss
gs_ctl restart
myself program
# link database
gsql -d postgres -p 7654
# set password of user opengauss
ALTER ROLE opengauss PASSWORD 'aEhC3TP%gLrm';
# create user
CREATE USER root WITH PASSWORD "Xt123456789";
GRANT ALL PRIVILEGES TO root;
CREATE DATABASE ningbo_police OWNER root;
# restore database
gsql -d ningbo_police -p 7654 -U root -f /var/www/sql/ningbo_police.sql
# maybe your need drop database before restore data
gsql -d postgres -p 7654
DROP DATABASE ningbo_police;
openEuler system
rechang user
vi /etc/pam.d/su
find the line
auth required pam_wheel.so use_uid
comment this line
install redis
cd /opt
wget http://download.redis.io/releases/redis-6.2.2.tar.gz
tar -zxvf redis-6.2.2.tar.gz
cd redis-6.2.2
make && make install
cp /opt/redis-6.2.2/redis.conf /usr/local/bin/
vim /usr/local/bin/redis.conf
将bind 127.0.0.1注释掉,这样Redis服务就可以接受来自任何IP的连接。
修改protected-mode为no,这样Redis服务可以接受外部连接。
修改requirepass为一个密码,这样可以提高Redis服务的安全性。
start redis
/opt/redis-6.2.2/redis-server /usr/local/bin/redis.conf &
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/181696.html