标签:sysctl ace std 特殊 http moved 用户 locate systemctl
当前GaussDB T支持一主多备部署和一主多备多级联备部署。其中备机和级联备机的个数之和最多支持9个。本文为一主一备环境。GaussDB T中的Primary角色是主备关系中的主节点,即业务的直接处理节点。它负责与备机通信,向备机同步日志。Standby角色是主备关系中的备节点,为只读状态。它主要用于接收主机日志,对主机业务日志进行回放 ,在主机出现异常或者异常退出的情况下可切换成主机保证业务正常进行。
若无特殊说明,以下操作在主备节点分别执行。
[root@hwd07 ~]# yum install -y zlib readline gcc python python-devel perl-ExtUtils-Embed readline-devel zlib-devel lsof expect mlocate
编辑/etc/sysctl.conf,加入以下内容:
[root@hwd07 ~]# vi /etc/sysctl.conf
kernel.sem = 50100 128256000 50100 2560
net.core.netdev_max_backlog = 1000
net.ipv4.tcp_max_syn_backlog = 2048
kernel.core_pattern = /tmp/core.%p.%e
kernel.core_uses_pid = 1
kernel.shmmni = 4096
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
fs.file-max = 6815744
[root@hwd07 ~]# sysctl -p
编辑/etc/profile,加入以下内容:
[root@hwd07 ~]# vi /etc/profile
ulimit -c unlimited
[root@hwd07 ~]# source /etc/profile
[root@hwd07 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@hwd07 ~]# sed -i -e ‘s,enforcing,disabled,‘ /etc/selinux/config
[root@hwd07 ~]# groupadd dbgrp
[root@hwd07 ~]# useradd -g dbgrp -d /home/omm -m -s /bin/bash omm
[root@hwd07 ~]# echo redhat|passwd --stdin omm
Changing password for user omm.
passwd: all authentication tokens updated successfully.
[root@hwd07 ~]# mkdir -p /opt/software/gaussdb
[root@hwd07 ~]# cd /opt/software/gaussdb/
[root@hwd07 gaussdb]# tar -xzf /tmp/GaussDB_T_1.0.2-DATABASE-REDHAT-64bit.tar.gz
以上操作完成后,重启服务器。
在主节点执行下面的命令,安装并创建数据库:
[root@hwd07 gaussdb]# cd GaussDB_T_1.0.2-DATABASE-REDHAT-64bit/
[root@hwd07 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]# python install.py -U omm:dbgrp -R /opt/gaussdb/app -D /opt/gaussdb/data -C LSNR_ADDR=127.0.0.1,192.168.120.28 -C LSNR_PORT=1888 -C REPL_PORT=1889 -C "ARCHIVE_DEST_2=SERVICE=192.168.120.29:1889 SYNC" -C SESSIONS=1500
Checking runner.
Checking parameters.
End check parameters.
Checking user.
End check user.
Checking old install.
End check old install.
Checking kernel parameters.
Checking directory.
Checking integrality of run file...
Decompressing run file.
Setting user env.
Checking data dir and config file
Initialize db instance.
Creating database.
[2020-03-13 09:23:43] Instance start log output:starting instance(nomount)
instance started
.
[2020-03-13 09:23:43] start instance successfully, pid = 8981
[2020-03-13 09:23:43] create zenith database ...
[2020-03-13 09:36:29] Execute sql file /opt/gaussdb/app/admin/scripts/create_database.sample.sql output:
connected.
SQL>
Succeed.
SQL>
[2020-03-13 09:36:29] Creating database succeed.
[2020-03-13 09:36:29] Changing file permission due to security audit.
[2020-03-13 09:36:29] Successfully install zenith instance.
[2020-03-13 09:36:29] Install successfully, for more detail information see /home/omm/zengineinstall.log.
参数说明,如下图:
安装时可以使用默认zengine.ini的优化配置,也可以通过-C修改参数替换初始配置,其中用户关注的通用参数如下图所示:
主备机配置时需要关注参数如下图:
在备机上执行下面的命令,只安装、不建库、不启动。
[root@hwd08 gaussdb]# cd GaussDB_T_1.0.2-DATABASE-REDHAT-64bit/
[root@hwd08 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]# python install.py -U omm:dbgrp -R /opt/gaussdb/app -D /opt/gaussdb/data -C LSNR_ADDR=127.0.0.1,192.168.120.29 -C LSNR_PORT=1888 -C REPL_PORT=1889 -C "ARCHIVE_DEST_2=SERVICE=192.168.120.28:1889 SYNC" -O
Checking runner.
Checking parameters.
End check parameters.
Checking user.
End check user.
Checking old install.
End check old install.
Checking kernel parameters.
Checking directory.
Checking integrality of run file...
Decompressing run file.
Setting user env.
Checking data dir and config file
Initialize db instance.
Changing file permission due to security audit.
Install successfully, for more detail information see /home/omm/zengineinstall.log.
安装完成后,以omm用户执行下面的命令,重建备机数据库:
[root@hwd08 GaussDB_T_1.0.2-DATABASE-REDHAT-64bit]# su - omm
Last login: Fri Mar 13 09:40:07 CST 2020
[omm@hwd08 ~]$ cd /opt/gaussdb/app/bin/
[omm@hwd08 bin]$ python zctl.py -t build
Check if incremental build is available ...
Begin to shutdown database ...
Done
Begin to clear data and log ...
Done
Begin to startup instance nomount ...
Done
Is incremental build: False
Begin to build database ...
Done
Successfully build database
在主节点执行即可,备节点会自动同步的。
SQL> ALTER USER SYS IDENTIFIED BY abcABC12 REPLACE Changeme_123;
在主备节点分别执行下面的命令,验证是否创建成功:
主备切换包含正常切换(switchover)和故障切换(failover)。
在备节点上查询状态,是否允许切换:
SQL> SELECT DATABASE_ROLE, DATABASE_CONDITION, SWITCHOVER_STATUS FROM DV_DATABASE;
如果查询结果是备机,而且状态是normal,则可以在该节点上执行switchover。
在备机上执行switchover操作:
SQL> ALTER DATABASE SWITCHOVER;
主备节点上验证是否切换成功:
failover适用于主机发生故障,而且短时间内无法及时恢复。在有级联备的情况下,如果主机和所有备机均已发生故障,则可以在级联备上执行failover升主。
现在将hwd08的数据库关闭,模拟主节点故障,然后在hwd07上执行failover操作。
关闭hwd08上的主数据库:
hwd07上的数据库状态如下:
状态为disconnected,表示可以直接failover,如下:
现在hwd07已经成为主节点了。模拟hwd08主机恢复,重建备库。
[omm@hwd08 bin]$ python zctl.py -t build -D /opt/gaussdb/data
Check if incremental build is available ...
Begin to shutdown database ...
Done
Begin to clear data and log ...
Done
Begin to startup instance nomount ...
Done
Is incremental build: False
Begin to build database ...
Done
Successfully build database
标签:sysctl ace std 特殊 http moved 用户 locate systemctl
原文地址:https://blog.51cto.com/candon123/2477967