OceanBase 社区版本安装
作者:Friend
热衷技术分享、编写技术文档
原创作品
oceanbase 数据库
原创内容未经授权不得随意使用、转载请联系小编并注明来源,谢谢!
1、安装准备
#1、手动关闭透明大页
对于 Red Hat 操作系统,需要运行以下命令,手动关闭透明大页:
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
对于 CentOS 操作系统,需要运行以下命令,手动关闭透明大页:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
#2、关闭防火墙
查看防火墙状态
systemctl status firewalld
如果输出结果非 inactive, 可以通过如下命令进行关闭
systemctl disable firewalld
systemctl stop firewalld
#3、关闭SELinux
修改配置文件,将SELINUX的配置修改为disabled
vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
配置文件修改后只会重启后生效,还需要使用下面命令立即生效。
setenforce 0
#4、设置内核参数
vim /etc/sysctl.conf
net.core.somaxconn = 2048
net.core.netdev_max_backlog = 10000
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.ip_local_port_range = 3500 65535
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_slow_start_after_idle=0
vm.swappiness = 0
vm.min_free_kbytes = 2097152
vm.max_map_count=655360
fs.aio-max-nr=1048576
#生效:
sysctl -p
#5、修改句柄数
vim /etc/security/limits.conf
添加如下内容后保存
root soft nofile 655350
root hard nofile 655350
* soft nofile 655350
* hard nofile 655350
* soft stack 20480
* hard stack 20480
* soft nproc 655360
* hard nproc 655360
* soft core unlimited
* hard core unlimited
#修改完成后重新连接查看,以生效
#查看
ulimit -a
#7、在线安装OB4.1或离线下载包
bash -c "$(curl -s https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/oceanbase-all-in-one/installer.sh)"
tar -xzf oceanbase-all-in-one-4.1.0.0-100120230523143820.el7.x86_64.tar.gz && cd oceanbase-all-in-one/bin &&./install.sh
#8、生效环境变量
source ~/.oceanbase-all-in-one/bin/env.sh
#9、验证安装是否成功
[root@localhost ~]# which obd
/root/.oceanbase-all-in-one/obd/usr/bin/obd
[root@localhost ~]# which obclient
/root/.oceanbase-all-in-one/obclient/u01/obclient/bin/obclient
2、利用OBD自动安装(单机)
#直接obd demo
#连接数据库
obclient -h127.0.0.1 -uroot@sys -P2881
#修改用户密码
alter user root@'%' identified by '123456';
3、指定配置文档安装(单机)
#1、查看默认配置文件
/root/oceanbase-all-in-one/conf
[root@localhost conf]# cat mini-local-example.yaml
oceanbase-ce:
servers:
# Please don't use hostname, only IP can be supported
- 127.0.0.1
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /root/observer
# The directory for data storage. The default value is $home_path/store.
# data_dir: /data
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
# redo_dir: /redo
# Please set devname as the network adaptor's name whose ip is in the setting of severs.
# if set severs as "127.0.0.1", please set devname as "lo"
# if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
devname: lo
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
zone: zone1
cluster_id: 1
# please set memory limit to a suitable value which is matching resource.
memory_limit: 6G # The maximum running memory for an observer
system_memory: 1G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
datafile_size: 20G # Size of the data file.
log_disk_size: 15G # The size of disk space used by the clog files.
cpu_count: 16
production_mode: false
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
# root_password: # root user password, can be empty
#2、指定配置文件安装数据库
obd cluster deploy obcluster -c mini-local-example.yaml
#3、启动数据库
obd cluster start obcluser
#4、查看集群状态
[root@localhost conf]# obd cluster list
+------------------------------------------------------------+
| Cluster List |
+-----------+------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+-----------+------------------------------+-----------------+
| obcluster | /root/.obd/cluster/obcluster | running |
+-----------+------------------------------+-----------------+
Trace ID: da3c2aee-0468-11ee-85f5-02000aba3d82
#5、连接数据库
obclient -h127.0.0.1 -P2881 -uroot@sys -p'123456' -Doceanbase -A
obclient [oceanbase]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| LBACSYS |
| mysql |
| oceanbase |
| ORAAUDITOR |
| SYS |
| test |
+--------------------+
7 rows in set (0.006 sec)
4、创建租户
#1、创建unit
obclient -h127.0.0.1 -P2881 -uroot@sys -p'123456' -Doceanbase -A
CREATE RESOURCE UNIT ut_4c8g MAX_CPU 4, MIN_CPU 4, MEMORY_SIZE '8G', MAX_IOPS 1024, MIN_IOPS 1024, IOPS_WEIGHT 0, LOG_DISK_SIZE '5G';
obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS\G;
*************************** 1. row ***************************
UNIT_CONFIG_ID: 1
NAME: sys_unit_config
CREATE_TIME: 2023-06-06 20:51:04.337290
MODIFY_TIME: 2023-06-06 20:51:04.337290
MAX_CPU: 1
MIN_CPU: 1
MEMORY_SIZE: 2147483648
LOG_DISK_SIZE: 2147483648
MAX_IOPS: 10000
MIN_IOPS: 10000
IOPS_WEIGHT: 1
*************************** 2. row ***************************
UNIT_CONFIG_ID: 1006
NAME: ut_4c8g
CREATE_TIME: 2023-06-07 09:29:11.447438
MODIFY_TIME: 2023-06-07 09:29:11.447438
MAX_CPU: 4
MIN_CPU: 4
MEMORY_SIZE: 8589934592
LOG_DISK_SIZE: 5368709120
MAX_IOPS: 1024
MIN_IOPS: 1024
IOPS_WEIGHT: 0
2 rows in set (0.001 sec)
#2、创建资源池
CREATE RESOURCE POOL pool1 UNIT='ut_4c8g',UNIT_NUM=1,ZONE_LIST=('zone1');
obclient [oceanbase]> select * from DBA_OB_RESOURCE_POOLS\G;
*************************** 1. row ***************************
RESOURCE_POOL_ID: 1
NAME: sys_pool
TENANT_ID: 1
CREATE_TIME: 2023-06-06 20:51:04.340379
MODIFY_TIME: 2023-06-06 20:51:04.346218
UNIT_COUNT: 1
UNIT_CONFIG_ID: 1
ZONE_LIST: zone1
REPLICA_TYPE: FULL
*************************** 2. row ***************************
RESOURCE_POOL_ID: 1004
NAME: pool1
TENANT_ID: NULL
CREATE_TIME: 2023-06-06 22:04:49.869788
MODIFY_TIME: 2023-06-06 22:04:49.869788
UNIT_COUNT: 1
UNIT_CONFIG_ID: 1004
ZONE_LIST: zone1
REPLICA_TYPE: FULL
2 rows in set (0.002 sec)
#3、创建租户
#查看服务器资源
obclient [oceanbase]> SELECT * FROM oceanbase.GV$OB_SERVERS;
+-----------+----------+-------+----------+--------------+------------------+--------------+------------------+--------------+--------------+-------------------+-------------------+-----------------+--------------------+------------------+-------------------------+--------------+-------------------------+-----------------------+
| SVR_IP | SVR_PORT | ZONE | SQL_PORT | CPU_CAPACITY | CPU_CAPACITY_MAX | CPU_ASSIGNED | CPU_ASSIGNED_MAX | MEM_CAPACITY | MEM_ASSIGNED | LOG_DISK_CAPACITY | LOG_DISK_ASSIGNED | LOG_DISK_IN_USE | DATA_DISK_CAPACITY | DATA_DISK_IN_USE | DATA_DISK_HEALTH_STATUS | MEMORY_LIMIT | DATA_DISK_ABNORMAL_TIME | SSL_CERT_EXPIRED_TIME |
+-----------+----------+-------+----------+--------------+------------------+--------------+------------------+--------------+--------------+-------------------+-------------------+-----------------+--------------------+------------------+-------------------------+--------------+-------------------------+-----------------------+
| 127.0.0.1 | 2882 | zone1 | 2881 | 16 | 16 | 1 | 1 | 5368709120 | 2147483648 | 16106127360 | 2147483648 | 134217728 |