Oracle Sharding Oracle 12.2 is introduced a new version of the feature, also called data piece for online transaction processing (OLTP). Oracle Sharding table based partitioning technique, is a data layer in the horizontal partition data stored in the database to a different technology. Sharding can be implemented in different databases, each database server located on a different partition table stored in different partitions, each shard is called a database, which form a logical database shard referred sharded database (SDB). this table also known sharded table, each shard hold different data sets in the database table (partition according sharding key), but they have the same column (columns).
Oracle Sharding advantages:
Oracle Sharding technology provides linear scaling and failure isolation advantages:
Linear expansion: Because each shard is a separate database, Shard by adding new nodes to the linear scalability. Automatically rebalance data.
Failure isolation: As the Shard is a shared-nothing technology, each shard using a separate hardware, so a shard node fails, it will only affect the data stored in this shard, without affecting the other shard.
Geographically distributed data: can be selected depending on the geographic location, the data is stored in a different shard.
Rolling upgrade: Select Upgrade at different times different shard. For example, at the same time upgrade only one or a part shard, only the data stored in these upgrades shard is affected, the other shard is not affected, can continue to provide services.
Cloud deployment: Shard ideal for deployment in the cloud.
12c new features -Oracle Sharding Profile
Oracle 12c realese2 installation tutorial
Oracle Download
Stand-alone node
1 |
10.244.4.30 1521 SID=orcl |
shard cluster information
1 |
master: |
single vision
1. Create the oracle user and the oinstall user groups
Oracle create users and user groups oinstall
1 |
sudo groupadd oinstall |
Create the oracle installation directory
1 |
[oracle] mkdir -p ~/u01/app |
Before you create must use df -h
to view the next disk partition, select the appropriate installation directory, the best remaining disk space is larger than 20G, under development machine / directory only 50G space, does not recommend the oracle installation directory in the / directory.
2. Set swap partition
free -m
Check swap partition case
The method of setting swap partition (512M)
1 |
sudo dd if=/dev/zero of=/swapfile1 bs=1024k count=512 |
3.vnc Configuration
By vnc can use the graphical interface to install oracle, greatly improving the success rate of installation
1 |
sudo yum install tigervnc-server -y |
server open vnc: vncserver :1
server stop vnc:vncserver -kill :1
Vnc client Download
client connection methods:IP:开启的端口号
TIPS:
1, if vnc shell window does not appear, check the server is installed xterm
2, if a more graphical interface, install the gnome
4. Installation oracle 12c dependencies
1 |
sudo yum install -y binutils* |
5.开始安装
通过vnc连接server,在安装目录下执行 ./runInstaller
安装过程具体每一步操作参考: 大专栏 Oracle_12c_Sharding集群安装教程ntq.net/2017/04/18/install-db12c-ol73/#%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E8%AE%BE%E7%BD%AE" target="_blank" rel="noopener noreferrer">Oracle Linux 7.3 下安装 Oracle Database 12c R2
Oracle环境变量
1 |
export ORACLE_BASE=/home/oracle/u01/app |
Listener开启和关闭方法
1 |
lsnrctl start |
TIPS: 如果遇到sqlplus command not found
lsnrctl command not found
,检查下环境变量是否失效
创建Oracle实例的方法: 执行 $ORACLE_HOME/bin/dbca
Sharding集群版
1.节点需要安装的服务
Master节点: Oracle RDMS,GSM
Slave节点: Oracle RDMS
Oracle安装Singleinstance database installation
版本,安装好之后仅仅在Master节点创建实例(非non-cdb
)
slave节点可采用响应文件进行静默安装 ./runInstaller -silent -responseFile /home/oracle/db.rsp
安装详细过程过程参考
2.配置hosts和防火墙
配置SDB与各个shard节点的host
1 |
100.88.11.91 OceanBase088011091.gtjsqa OceanBase088011091 |
关闭防火墙,开发机上默认是关闭的,最好检查一下
1 |
sudo service iptables status |
3.Shard配置流程
环境变量
Oracle
1
2
3
4export ORACLE_BASE=/home/oracle/u01/app
export ORACLE_HOME=/home/oracle/u01/app/product/12.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=catadbGSM
1
2
3export ORACLE_BASE=/home/oracle/u01/app
export ORACLE_HOME=/home/oracle/u01/app/product/12.2.0/gsmhome_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
在master服务器(catalog 数据库/shard director),连接到Sharding catalog数据库, 解锁 GSMCATUSER 用户,shard director 通过GSMCATUSER 用户连接到shard catalog database
1
SQL> alter user gsmcatuser identified by oracle account unlock;
在 catalog数据库,创建管理用户mygds,用户mygds用于存储Sharding管理信息,GDSCTL接口通过用户mygds连接到catalog数据库
1
2
3
4SQL> create user mygds identified by oracle;
SQL> grant connect, create session, gsmadmin_role to mygds;
SQL> grant inherit privileges on user SYS to GSMADMIN_INTERNAL;
SQL> exec DBMS_SCHEDULER.SET_AGENT_REGISTRATION_PASS('oracle');
在gsm1服务器(catalog 数据库/shard director),创建shard catalog,在shard catalog中配置remote scheduler agent
1
2
3$ gdsctl
GDSCTL> create shardcatalog -database OceanBase088011091:1521:catadb -chunks 12 -user mygds/oracle -sdb shdb -region region1, region2 -agent_port 8080 -agent_password oracle
Catalog is created创建和启动shard director
1
2
3
4
5
6
7
8GDSCTL> add gsm -gsm sharddirector3 -listener 1522 -pwd oracle -catalog OceanBase088011091:1521:catadb -region region1
GSM successfully added
GDSCTL>start gsm -gsm sharddirector3
GSM is started successfully
GDSCTL> add credential -credential cre_reg1 -osaccount oracle -ospassword oracle
The operation completed successfully去shard节点上进行注册
1
2
3
4
5$ schagent -start
Scheduler agent started using port 21620
$ schagent -status
$ echo oracle | schagent -registerdatabase 100.88.11.91 8080
$ lsnrctl stop
**一定要关闭shard节点上的监听器**
deploy shard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16$ gdsctl
GDSCTL> set gsm -gsm sharddirector3
GDSCTL> connect mygds/oracle
Catalog connection is established
GDSCTL> add shardgroup -shardgroup primary_shardgroup -deploy_as primary -region region1
The operation completed successfully
GDSCTL> add invitednode OceanBase088011096
GDSCTL> create shard -shardgroup primary_shardgroup -destination OceanBase088011096 -credential cre_reg1 -sys_password oracle
The operation completed successfully
DB Unique Name: sh1
GDSCTL> deploy
查看shard配置 `config shard`
查看invitednode `config vncr`
删除shard配置 `remove shard -shard sh1`
删除invitednode `remove invitednode oceanbase004085`
看到如下信息,说明shard集群已经搭建成功
1
2
3
4
5
6
GDSCTL>config shard
Catalog connection is established
Name Shard Group Status State Region Availability
---- ----------- ------ ----- ------ ------------
sh1 primary_shardgroup Ok Deployed region1 ONLINE
sh2 primary_shardgroup Ok Deployed region1 ONLINE
3.注意事项
下面是我安装过程中碰到的坑
- 安装Oracle过程中会检查安装条件,ignore即可
- slave节点安装好Oracle后,关闭Listener,否则deploy过程中会报错
- add shard过程中,如果遇到
destination not found
错误,检查节点上Hosts文件配置,确保各个节点上可以ping通 - deploy过程中十分缓慢(10分钟至20分钟),成功或者错误都会返回信息
如果还碰到困难参考下面帖子: