新聞中心
??想了解更多關(guān)于開源的內(nèi)容,請?jiān)L問:??

?? 開源基礎(chǔ)軟件社區(qū)??
??https://ost.??
安裝Guass數(shù)據(jù)庫
修改python環(huán)境:
[root@ecs-6d3f ~]# python -V --2.6.8
[root@ecs-6d3f ~]# cd /usr/bin
[root@ecs-6d3f bin]# mv python python.bak
[root@ecs-6d3f bin]# ln -s python3 /usr/bin/python
python -V --3.7.4
關(guān)閉防火墻:
systemctl stop firewalld.service
systemctl disable firewalld.service
# 關(guān)閉之后查看狀態(tài),應(yīng)為inactive
systemctl status firewalld
修改/etc/selinux/config文件中的“SELINUX”值為“disabled”。
[root@ecs-6d3f ~]# vim /etc/selinux/config
SELINUX=disabled
在/etc/profile文件中添加環(huán)境變量。
vim /etc/profile
# 設(shè)置 HISTSIZE=0
HISTSIZE=0
# 下面四行加到文件最后
export LANG=en_US.UTF‐8
export packagePath=/opt/software/openGauss
export LD_LIBRARY_PATH=$packagePath/lib:$LD_LIBRARY_PATH
export PATH=/opt/software/openGauss/bin:$PATH
# wq保存退出后執(zhí)行下面的命令
source /etc/profile
將交換內(nèi)存關(guān)閉。
# 關(guān)閉交換內(nèi)存
swapoff -a
調(diào)整系統(tǒng)參數(shù)值。
# 執(zhí)行如下命令打開performance.sh文件
vi /etc/profile.d/performance.sh
# 用#注釋sysctl -w vm.min_free_kbytes=112640 &> /dev/null
#sysctl -w vm.min_free_kbytes=112640 &> /dev/null
安裝軟件依賴包。
yum install
libaio-devel
flex
bison
ncurses-devel
glibc-devel
patch
readline-devel
libnsl
# 用yum命令安裝這些包
準(zhǔn)備安裝包和數(shù)據(jù)庫管理用戶。
# 創(chuàng)建安裝目錄
mkdir -p /opt/software/openGauss
# 進(jìn)入安裝目錄
cd /opt/software/openGauss
# 將數(shù)據(jù)庫安裝包下載到該目錄
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.0/x86_openEuler/openGauss-3.1.0-openEuler-64bit.tar.bz2
# 將安裝包解壓
tar -jxf openGauss-3.1.0-openEuler-64bit.tar.bz2
# 更改權(quán)限
chmod 755 -R /opt/software
# 創(chuàng)建用戶組
groupadd dbgroup
# 創(chuàng)建用戶omm
useradd -g dbgroup omm
# 設(shè)置密碼
passwd omm
新密碼:rootScz123
# 更改權(quán)限
chown 755 -R /opt/software
# 更換文件擁有者為omm
chown -R omm /opt/software/openGauss
# 執(zhí)行下面的命令
cat /etc/sysctl.conf
sysctl -w kernel.sem="250 85000 250 330"
安裝:
# 切換用戶omm
su - omm
# 進(jìn)入安裝目錄
cd /opt/software/openGauss/simpleInstall
# 執(zhí)行下面命令安裝 (-w后面為密碼,可以自己設(shè)置)
sh install.sh -w rootScz123
安裝執(zhí)行完成后,使用ps和gs_ctl查看進(jìn)程是否正常。
ps ux | grep gaussdb
gs_ctl query -D /opt/software/openGauss/data/single_node
執(zhí)行ps命令,顯示類似如下信息:
執(zhí)行g(shù)s_ctl命令,顯示類似如下信息:
啟動(dòng)數(shù)據(jù)庫:
# 啟動(dòng)/停止/重啟數(shù)據(jù)庫服務(wù)
gs_ctl start|stop/restart -D /opt/software/openGauss/data/single_node
連接數(shù)據(jù)庫。
# 連接命令,默認(rèn)為omm用戶
gsql -d postgres -p 5432
常用命令:
\l --查看所有數(shù)據(jù)庫
\c --進(jìn)入某個(gè)數(shù)據(jù)庫
\dt --查看數(shù)據(jù)庫里面的表
\q --退出Gauss
Navicat或Data Studio遠(yuǎn)程連接管理數(shù)據(jù)庫
首先,在服務(wù)器安全組上開放5432端口:
切換omm用戶:
# 進(jìn)入數(shù)據(jù)庫節(jié)點(diǎn)目錄內(nèi)
cd /opt/software/openGauss/data/single_node
在pg_hba.conf中添加放行ip。
vim pg_hba.conf
host all all 本機(jī)ip/32 md5
host all all 0.0.0.0/0 md5
本機(jī)ip在Windows上命令提示符上用 ipconfig 命令得到。
修改postgresql.conf文件。
vim postgresql.conf
將listen_address的值改為*。
刪除此行的注釋,并將原本的password_encryption_type = 2?更換為password_encryption_type = 0(使用md5加密)。
完成文件修改后,執(zhí)行下列命令重啟數(shù)據(jù)庫服務(wù)。
gs_ctl stop -D /opt/software/openGauss/data/single_node
gs_ctl start -D /opt/software/openGauss/data/single_node
創(chuàng)建遠(yuǎn)程連接角色。
# omm用戶連接數(shù)據(jù)庫
gsql -d postgres -p 5432
# 創(chuàng)建用戶并設(shè)置password (scz為用戶名 ""內(nèi)為password,可以更改)
create user scz with password "rootScz123";
# 授予新建用戶權(quán)限
GRANT ALL PRIVILEGES TO scz;
# 創(chuàng)建一個(gè)數(shù)據(jù)庫所有者為scz用戶
create database db1 owner scz;
連接
Data Studio
下載地址:
??立即下載 (myhuaweicloud.com)??
navicat(與上面相同填寫ip,端口等)。
django連接Gauss數(shù)據(jù)庫
注:Django應(yīng)在3.x版本,4.x版本不支持
1.安裝psycopg2和sqlparse庫。
pip install psycopg2
??2.修改settings.py??
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '', # 數(shù)據(jù)庫名
'USER': '', # 用戶名
'PASSWORD': '', # 密碼
'HOST': '', # 服務(wù)器ip
'PORT': 5432 # openGauss數(shù)據(jù)口的端口
}
}??想了解更多關(guān)于開源的內(nèi)容,請?jiān)L問:??
?? 開源基礎(chǔ)軟件社區(qū)??
??https://ost.??
網(wǎng)頁名稱:梅科爾HOS-openGauss數(shù)據(jù)庫安裝使用(openEuler服務(wù)器)
分享URL:http://www.5511xx.com/article/dhjiidc.html


咨詢
建站咨詢
