#1、使用exp命令将yasuser01用户下所有数据导出至export. yasuser01.data文件中[yashan@tango-DB01 ~]$ exp yasuser01/YashanDB01 FILE=export.yasuser01.dat OWNER=yasuser01YashanDB Export Personal Edition Release 23.1.1.100 x86_64 0e623bdexport terminated successfully[yashan@tango-DB01 ~]$ lltotal 1892-rw-r----- 1 yashan yashan 1936736 Nov 23 19:54 export.yasuser01.dat#2、使用imp命令将导出数据导入到yasuser02中[yashan@tango-DB01 ~]$ imp yasuser02/YashanDB02 FILE=export.yasuser01.dat FROMUSER=yasuser01 TOUSER=yasuser02YashanDB Import Personal Edition Release 23.1.1.100 x86_64 0e623bdimport terminated successfully##查看表数据情况SQL> SELECT table_name FROM USER_TABLES;TABLE_NAME---------------------------------------------------------------- TB011 row fetched.SQL> select count(1) from tb01;COUNT(1) ---------------------99991 row fetched.
- FROMUSER模式用于导入指定用户下的对象及数据 , 包括用户下所有元数据、表数据以及用户权限等
- TOUSER命令用于更换导入的用户,将导入对象的OWNER更换成TOUSER指定的用户
1)使用命令开启election
[yashan@tango-DB01 ~]$ yasboot election enable on -c yashandbresult: Succeed查看仲裁选举的参数配置[yashan@tango-DB01 ~]$ yasboot election config show -c yashandbProtection Mode: MAXIMUM PROTECTIONMembers:[1-1:1] - Primary database[1-2:2] - Physical standby databaseTransport Lag: 0 secondsApply Lag:0 secondsApply Rate:11.85 MByte/sProperties:FailoverThreshold= 9FailoverAutoReinstate= falseZeroDataLossMode= trueAutomatic Failover: Enabled in Zero Data Loss Mode默认是最大保护模式,表示redo log同步到备节点后,事务才提交 。- FailoverThreshold:备机心跳超时时间,到达该时间后,yasom将执行failover切换流程
- FailoverAutoReinstate:是否启用自动脑裂修复,启用后如果备机发送脑裂处于Need REPAIR状态,yasom将尝试自动修复
- ZeroDataLossMode:是否启用零丢失模式 , 启用后主备设置为最大保护模式,当主库宕机后备机会自动failover;当备库异常时主库降级为最大可用模式,并禁止自动failover , 直到备库恢复同步 。
$ yasboot election enable off -c yashandb$ yasboot election config set -k FailoverThreshold -v 2 -c yashandb$ yasboot election enable on -c yashandb$ yasboot election config show -c yashandb2)检查主备集群的状态[yashan@tango-DB01 ~]$ yasboot cluster status -c yashandb -d hostid| node_type | nodeid | pid| instance_status | database_status | database_role | listen_address| data_path---------------------------------------------------------------------------------------------------------------------------------------------------------- host0001 | db| 1-1:1| 16119 | open| normal| primary| 192.168.112.121:1688 | /usr/local/yashandb/yasdb_data/db-1-1 ----------+-----------+--------+-------+-----------------+-----------------+---------------+----------------------+--------------------------------------- host0002 | db| 1-2:2| 15363 | open| normal| standby| 192.168.112.122:1688 | /usr/local/yashandb/yasdb_data/db-1-2 ----------+-----------+--------+-------+-----------------+-----------------+---------------+----------------------+---------------------------------------3)模拟主节点故障,kill主节点进程[yashan@tango-DB01 ~]$ ps -fu $USERUIDPIDPPIDC STIME TTYTIME CMDyashan187410 11:14 ?00:00:10 /usr/local/yashandb/yasdb_home/yashandb/23.1.1.100/bin/yasom -c yashandb -l 192.168.112.121:1675 -dyashan195210 11:16 ?00:01:17 /usr/local/yashandb/yasdb_home/yashandb/23.1.1.100/bin/yasagent -c yashandb -l 192.168.112.121:1676 -dyashan9509117 16:23 ?00:01:47 /usr/local/yashandb/yasdb_home/yashandb/23.1.1.100/bin/yasdb open -D /usr/local/yashandb/yasdb_data/db-1-1 [yashan@tango-DB01 ~]$ kill -9 95091查看yasom.log日志,能看到failover切换信息2023-11-25 16:47:38 DEBUG[yasom] replication.go:188 process replication event: failover2023-11-25 16:47:38 INFO[yasom] task.go:24 call yasagent api success: NodeAPI.ExecSQL, get result: {"connection":"DISCONNECTED","status":"NORMAL","time_since_last_msg":"2"}2023-11-25 16:47:38 ERROR[yasom] task.go:21 call yasagent api failed: NodeAPI.ExecSQL, err: YAS-00402 failed to connect socket, errno 111, error message "Connection refused"2023-11-25 16:47:38 INFO[yasom] task.go:24 call yasagent api success: NodeAPI.ExecSQL, get result: {"database_role":"STANDBY","status":"NORMAL","switchover_status":"NOT ALLOWED"}2023-11-25 16:47:38 INFO[yasom] replication.go:231 execute failover sql command on node 1-2:2, next reset id is 12023-11-25 16:47:40 INFO[yasom] task.go:24 call yasagent api success: NodeAPI.ExecSQL, get result: {}2023-11-25 16:47:40 INFO[yasom] replication.go:246 failover succeeds
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 集中式数据库与分布式数据库的战场与战争
- 解读向量数据库
- Python内置数据库:轻量级SQLite
- Oracle数据库存在不可用索引性能问题
- 每个程序员都必须了解的十种数据库
- 深度优化数据库性能:Linux 内核参数调整解析
- 14个开源免费数据库监控工具,MySQL、Oracle、Postgres或MSSQL
- 初识向量数据库与pgvector实践
- 直面数据库的“崖山海战”:YashanDB另辟蹊径站上新高地
- 国内首个向量数据库标准发布
