GaussDB 100单机安装 For 手工建库
墨天轮原文链接:https://www.modb.pro/db/23180?ywm
一、安装环境准备
1、部署架构规划
GaussDB 100单机部署的总体架构如上图,DM、CM、ETCD在单机部署中是非必要组件,因此本次不部署,DN节点规划如下:
注:数据目录需要>=20GB,如果要减小,需要修改install.py和create_database.sample.sql。
2、操作系统配置
root远程登录权限修改
sed -i ‘s/#PermitRootLogin yes/PermitRootLogin yes/g’ /etc/ssh/sshd_config
sed -i ‘s/#PasswordAuthentication yes/ PasswordAuthentication yes/g’ /etc/ssh/sshd_config
–修改完重庆sshd服务
/bin/systemctl restart sshd.service
关闭防火墙和SELinux(官方建议是添加信任,此处直接关闭避免后续连接有问题)
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
配置corefile
echo ‘ulimit -c unlimited’>>/etc/profile
echo ‘kernel.core_pattern =/opt/gdb/corefile/core-%e-%p-%t’>>/etc/sysctl.conf
–使配置生效
source /etc/profile
ulimit -c
sysctl -p
.
检查ntp和lsof(此单机环境不需要ntp,可略过)
rpm -qa|grep ntp --NTP 4.2.6或以上版本
若没有,使用yum安装ntp
yum install ntp
which lsof
–若没有,使用yum安装lsof
yum install lsof
创建数据库安装用户组和用户
groupadd dbgrp
useradd -g dbgrp -d /home/omm -m -s /bin/bash omm
-g <所属组
-d <登入目录
-m <自动建立用户的登入目录
-s <指定用户登入后所使用的shell
–设置密码
passwd omm
配置数据目录
–查看可用磁盘
[root@gaussdb ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 8G 0 disk
├─sda1 8:1 0 200M 0 part /boot
└─sda2 8:2 0 7.8G 0 part
├─rhel-root 253:0 0 6.8G 0 lvm /
└─rhel-swap 253:1 0 1G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
sdc 8:32 0 1G 0 disk
sr0 11:0 1 1024M 0 rom
–创建PV
[root@gaussdb ~]# pvcreate /dev/sdb
Physical volume “/dev/sdb” successfully created.
–创建GV
[root@gaussdb ~]# vgcreate datavg /dev/sdb
Volume group “datavg” successfully created
–创建LV
[root@gaussdb ~]# lvcreate -L 20G -n datalv datavg
Logical volume “datalv” created.
-L <size 逻辑卷大小
-n <name 逻辑卷的名字
–格式化LV
[root@gaussdb ~]# mkfs.ext4 /dev/datavg/datalv
–创建挂载点目录
[root@gaussdb ~]# mkdir /gsdata
.
.
–挂载LV
[root@gaussdb ~]# mount /dev/datavg/datalv /gsdata
–删除目录中的lost+found文件,防止安装软件时报错
[root@gaussdb ~]# find /gdb -name lost+found | xargs rm -rf
注:lost+found 是一个特殊目录,用途是用来存放文件系统错误导致文件丢失后找回数据的。
–将文件挂载信息写入fstab文件
cat /etc/fstab
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / ext4 defaults 1 1
UUID=a3e33662-9f1b-4a0a-a8c2-7f7681c5d6c9 /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/datavg/datalv /gsdata ext4 defaults,noatime,nobarrier 0 0
--注意添加noatime,nobarrier选项,提升性能
noatime,nobarrier <禁止记录最近一次访问时间戳
--重新挂载文件系统
[root@gaussdb ~]# mount -o remount /gsdata
-o <options 指定加载文件系统时选项
---以防万一重启os
shutdown -r now
二、安装数据库软件
解压安装包(本次使用的是一个大包,包含多个安装包,因此解压了多次)
chown omm:dbgrp GaussDB_100_1.0.1-REDHAT7.5-X86.tar.gz
su - omm
cd /opt/software/gaussdb/
tar -zxvf GaussDB_100_1.0.1-REDHAT7.5-X86.tar.gz
tar -zxvf GaussDB_100_1.0.1-CLUSTER-REDHAT7.5-64bit.tar.gz
tar -zxvf GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
cd GaussDB_100_1.0.1-DATABASE-REDHAT-64bit
使用root用户安装(添加-O参数不建库,手工建库方便定制化)
python install.py -U omm:dbgrp -R /gdb/gaussdb/app -D /gsdata -O
.
三、手工建库
## 1、 配置参数文件 虽然安装软件是没有建库,但是相关的目录已经创建好,不需要手工创建
.
--到 /gsdata/data/cfg目录修改zengine.ini
TEMP_BUFFER_SIZE = 1G
DATA_BUFFER_SIZE = 2G
SHARED_POOL_SIZE = 1G
LOG_BUFFER_SIZE = 64M
DBWR_PROCESSES = 8
LOG_BUFFER_COUNT = 8
SESSIONS = 800 --跟进需要设置,最大值为8000
INSTANCE_NAME = gyl --修改实例名
LSNR_ADDR = 127.0.0.1,192.168.80.128 --添加本机地址到监听端口
LSNR_PORT = 1888 --监听端口
ENABLE_SYSDBA_LOGIN = TRUE
.
2、启动数据库到nomount阶段
source .bashrc
[omm@gaussdb cfg]$ cd $GSDB_HOME/bin
[omm@gaussdb bin]$ python zctl.py -t start -m nomount -D /gdb/gaussdb/data
Successfully started instance.
.
3、创建数据库
[omm@gaussdb bin]$ zsql / as sysdba
Warning: SSL connection to server without CA certificate is insecure. Continue anyway? (y/n):y
connected.
SQL> @/home/omm/create_db.sql
SQL> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Succeed.
SQL>
SQL> select instance_name,status from dv_instance;
INSTANCE_NAME STATUS
-------------------- --------------------
gyl OPEN
1 rows fetched.
.
.
SQL> select name,status from dv_database;
NAME STATUS
-------------------------------- --------------------
GYL OPEN
1 rows fetched.
.
create_db.sql内容如下
create database gyl character set utf8
CONTROLFILE('/gdb/gaussdb/data/cntl1', '/gdb/gaussdb/data/cntl2', '/gdb/gaussdb/data/cntl3')
LOGFILE('/gdb/gaussdb/data/log1' size 128M, --这里将日志组数和大小进行了修改
'/gdb/gaussdb/data/log2' size 128M,
'/gdb/gaussdb/data/log3' size 128M)
system tablespace DATAFILE '/gdb/gaussdb/data/system' size 1G
undo tablespace DATAFILE '/gdb/gaussdb/data/undo' size 1G
default tablespace DATAFILE '/gdb/gaussdb/data/user1' size 1G autoextend on next 32M,
'/gdb/gaussdb/data/user2' size 1G autoextend on next 32M,
'/gdb/gaussdb/data/user3' size 1G autoextend on next 32M,
'/gdb/gaussdb/data/user4' size 1G autoextend on next 32M,
'/gdb/gaussdb/data/user5' size 1G autoextend on next 32M
temporary tablespace TEMPFILE '/gdb/gaussdb/data/temp1_01' size 160M autoextend on next 32M,
'/gdb/gaussdb/data/temp1_02' size 160M autoextend on next 32M nologging
tablespace TEMPFILE '/gdb/gaussdb/data/temp2_01' size 160M autoextend on next 32M,
'/gdb/gaussdb/data/temp2_02' size 160M autoextend on next 32M
nologging undo tablespace TEMPFILE '/gdb/gaussdb/data/temp2_undo' size 1G
++ sysaux tablespace DATAFILE '/gdb/gaussdb/data/sysaux' size 160M autoextend on next 32M ARCHIVELOG; ----sysaux 默认是没有的。不需要建立。++
.
至此,安装结束!
**4、附录**
## 1、测试监听连接
.
[omm@gaussdb bin]$ zsql sys/Changeme_123@127.0.0.1:1888
.
.
Warning: SSL connection to server without CA certificate is insecure. Continue anyway? (y/n):y
.
.
connected.
.
.
SQL> select instance_name,status from dv_instance;
.
.
INSTANCE_NAME STATUS
.
.
-------------------- --------------------
.
.
gyl OPEN
.
.
1 rows fetched.
.
2、主进程状态问题修正
--此时主进程显示的状态还是nomount
[omm@gaussdb ~]$ ps -ef | grep zen
omm 2452 1 5 13:21 pts/0 00:00:21 /gdb/gaussdb/app/bin/zengine nomount -D /gdb/gaussdb/data
.
.
--下面做一次启停修复状态
[omm@gaussdb bin]$ python zctl.py -t stop -m immediate
Successfully stopped instance.
[omm@gaussdb bin]$ python zctl.py -t start
Successfully started instance.
[omm@gaussdb bin]$
.
.
[omm@gaussdb bin]$ ps -ef | grep zen
omm 2612 1 2 13:34 pts/0 00:00:00 /gdb/gaussdb/app/bin/zengine open -D /gdb/gaussdb/data
omm 2646 2221 0 13:34 pts/0 00:00:00 grep --color=auto zen
[omm@gaussdb bin]$
.
.
[omm@gaussdb bin]$ zsql sys/Changeme_123@127.0.0.1:1888
Warning: SSL connection to server without CA certificate is insecure. Continue anyway? (y/n):y
connected.
SQL> select instance_name,status from dv_instance;
INSTANCE_NAME STATUS
-------------------- --------------------
gyl OPEN
1 rows fetched.
.
Gaussdb single卸载
[root@gaudb bin]# python uninstall.py -U user -F
Checking uninstall parameters...
Can not get user home, command: su - user -c "echo ~"
[root@gaudb bin]#
[root@gaudb bin]# python uninstall.py -U omm -F
Checking uninstall parameters...
Checking username in parameters...
Getting install path...
Checking uninstall.py position...
Getting user environment variables file path...
Checking whether install path in the user environment variables...
Getting data directory...
Begin check data dir...
Stopping zenith instance...
Successfully stopped zenith instance.
Cleaning data path...
Cleaning user environment variables...
Cleaning install path...
Zengine was successfully removed from your computer, for more message please see /home/omm/z engineuninstall.log.
Common options:
-F clean the database storage area
-D location of the database cluster storage area,it will be available after -F
-g run uninstall script without root privilege, but you must have permission of uninstallation folder
-P if sysdba login is disabled by configuration, specify this option the end
--help show this help, then exit
-F:清理数据存储目录
-D 软件安装目录
-g 非root用户卸载
-p 在sysdba会话登陆的情况下使用