实践练习二(必选):手动部署 OceanBase 集群

该文详细记录了在CentOS7系统上安装OceanBase数据库的过程,包括系统版本信息检查、下载所需软件包、创建用户、调整主机环境设置、禁用防火墙、安装软件、启动Observer、设置集群和用户权限,以及通过OBProxy进行连接验证和数据插入操作。
摘要由CSDN通过智能技术生成

1,系统版本信息

[root@cts07 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

2,OB软件下载
https://open.oceanbase.com/softwareCenter/community

[root@cts07 software]# ll
total 104636
-rw-r--r--. 1 root root  1337808 Feb  1 02:55 libobclient-2.2.1-2.el7.x86_64.rpm
-rw-r--r--. 1 root root 10970208 Feb  1 02:55 obclient-2.2.1-4.el7.x86_64.rpm
-rw-r--r--. 1 root root 35180084 Feb  1 02:56 ob-deploy-1.6.2-10.el7.x86_64.rpm
-rw-r--r--. 1 root root  9907040 Feb  1 02:56 obproxy-ce-3.2.3.5-2.el7.x86_64.rpm
-rw-r--r--. 1 root root 49582608 Feb  1 02:51 oceanbase-ce-3.1.4-102000012022120715.el7.x86_64.rpm
-rw-r--r--. 1 root root   158404 Feb  1 02:50 oceanbase-ce-libs-3.1.4-102000012022120715.el7.x86_64.rpm

3,创建admin用户

[root@cts07 software]# useradd admin
[root@cts07 software]# echo 'admin:XXXXXXX' | chpasswd

4,主机环境设置

[root@cts07 software]# cat /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
[root@cts07 software]# cat /etc/security/limits.conf | grep -v "^#"
* soft nofile 655360
* hard nofile 655360
* soft nproc 655360
* hard nproc 655360
* soft core unlimited
* hard core unlimited
* soft stack unlimited
* hard stack unlimited
[root@cts07 software]# 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@cts07 software]# systemctl stop firewalld
[root@cts07 software]# systemctl status firewalld
[root@cts07 software]# cat /etc/selinux/config | grep -v "^#"
SELINUX=disabled
SELINUXTYPE=targeted

5.软件安装

[root@cts07 software]# rpm -ivh oceanbase-ce-*
Preparing...                          ################################# [100%]
Updating / installing...
   1:oceanbase-ce-libs-3.1.4-102000012################################# [ 50%]
   2:oceanbase-ce-3.1.4-10200001202212################################# [100%]
[root@cts07 software]# rpm -ivh obclient-2.2.1-4.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:obclient-2.2.1-4.el7             ################################# [100%]

6.启动OBSERVER

[root@cts07 software]# mkdir -p /data/obdemo/{sstable,etc3} /redo/obdemo/{clog,ilog,slog,etc2}
[root@cts07 software]# chown -R admin.admin /data/ /redo/
[admin@cts07 oceanbase]$ bin/observer -i lo -p 2881 -P 2882 -z zone1 -d ~/oceanbase/store/obdemo -r '127.0.0.1:2882:2881' -c 20230201 -n obdemo -o "memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=4,net_thread_count=4,datafile_size=10G,stack_size=1536K" -d /home/admin/oceanbase/store/obdemo
bin/observer -i lo -p 2881 -P 2882 -z zone1 -d /home/admin/oceanbase/store/obdemo -r 127.0.0.1:2882:2881 -c 20230201 -n obdemo -o memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=4,net_thread_count=4,datafile_size=10G,stack_size=1536K -d /home/admin/oceanbase/store/obdemo
devname: lo
mysql port: 2881
rpc port: 2882
zone: zone1
data_dir: /home/admin/oceanbase/store/obdemo
rs list: 127.0.0.1:2882:2881
cluster id: 20230201
appname: obdemo
optstr: memory_limit=8G,cache_wash_threshold=1G,__min_full_resource_pool_memory=268435456,system_memory=3G,memory_chunk_cache_size=128M,cpu_count=4,net_thread_count=4,datafile_size=10G,stack_size=1536K
data_dir: /home/admin/oceanbase/store/obdemo

集群自举(初始化)

[root@cts07 ~]# obclient -h 192.168.1.246 -P 2881 -uroot -p -c -A
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 3221225472
Server version: 5.7.25 OceanBase 3.1.0 (r-) (Built May 30 2021 11:21:29)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '192.168.1.246:2882';
Query OK, 0 rows affected (0.016 sec)

Query OK, 0 rows affected (1 min 53.356 sec)

查看当前所有数据库,设置集群管理员密码及OBPROXY 用户

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
+--------------------+
7 rows in set (0.053 sec)

MySQL [(none)]> alter user root identified by 'XXXXXXX';
Query OK, 0 rows affected (0.113 sec)

MySQL [(none)]>
MySQL [(none)]> grant select on oceanbase.* to proxyro identified by 'XXXXXXX';
Query OK, 0 rows affected (0.327 sec)

启动obproxy,设置 obproxy 与 observer 间的通信密码

[admin@cts07 ~]$ cd ~/obproxy-3.1.0/ && bin/obproxy -r "192.168.1.246:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c obdemo
bin/obproxy -r 192.168.1.246:2881 -p 2883 -o enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false -c obdemo
rs list: 192.168.1.246:2881
listen port: 2883
optstr: enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false
cluster_name: obdemo
[admin@cts07 obproxy-3.1.0]$ obclient -h 192.168.1.246 -u root@proxysys -P 2883 -p
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]>
ySQL [(none)]> show proxyconfig like '%sys_password%';
+-----------------------+-------+--------------------------------+-------------+---------------+
| name                  | value | info                           | need_reboot | visible_level |
+-----------------------+-------+--------------------------------+-------------+---------------+
| observer_sys_password |       | password for observer sys user | false       | SYS           |
| obproxy_sys_password  |       | password for obproxy sys user  | false       | SYS           |
+-----------------------+-------+--------------------------------+-------------+---------------+
2 rows in set (0.002 sec)

MySQL [(none)]> alter proxyconfig set obproxy_sys_password = 'XXXXXXX' ;
Query OK, 0 rows affected (0.014 sec)

MySQL [(none)]> alter proxyconfig set observer_sys_password = 'XXXXXXX' ;
Query OK, 0 rows affected (0.016 sec)

MySQL [(none)]> show proxyconfig like '%sys_password%';
+-----------------------+------------------------------------------+--------------------------------+-------------+---------------+
| name                  | value                                    | info                           | need_reboot | visible_level |
+-----------------------+------------------------------------------+--------------------------------+-------------+---------------+
| observer_sys_password | cf2e875d70c402e4aaf32ceb64b1fa6f7396af59 | password for observer sys user | false       | SYS           |
| obproxy_sys_password  | 951cd25c26a0cd87f314fafdfcc5fea9e0a4c19a | password for obproxy sys user  | false       | SYS           |
+-----------------------+------------------------------------------+--------------------------------+-------------+---------------+
2 rows in set (0.001 sec)

通过proxy使用密码登录验证,

[admin@cts07 obproxy-3.1.0]$ obclient -h 192.168.1.246 -u root@proxysys -P 2883 -p
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.25

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> quit
Bye
[admin@cts07 obproxy-3.1.0]$ obclient -h 192.168.1.246 -P 2883 -uroot@sys#obdemo -proot123 -c -A oceanbase
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.25

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

创建业务规格及资源池

MySQL [oceanbase]> alter resource unit sys_unit_config min_cpu=5;
Query OK, 0 rows affected (0.026 sec)

min_memory=‘1G’, max_iops=10000, min_iops=1000, max_session_num=10' at line 1
MySQL [oceanbase]>  alter system __min_full_resource_pool_memory=1073741824;
Query OK, 0 rows affected (0.150 sec)

MySQL [oceanbase]> CREATE resource unit S4C1G max_cpu=4, min_cpu=4, max_memory='1G', min_memory='1G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='1024G';
Query OK, 0 rows affected (0.063 sec)

MySQL [oceanbase]> CREATE resource pool pool1 unit = 'S4C1G', unit_num = 1;
Query OK, 0 rows affected (0.055 sec)

创建业务表并插入数据

[admin@cts07 obproxy-3.1.0]$ obclient -h 192.168.1.246 -P 2883 -uroot@obmysql#obdemo -p -c -A oceanbase
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.25

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> create database frm_test;
Query OK, 1 row affected (0.443 sec)

MySQL [(none)]> use frm_test;
Database changed
MySQL [frm_test]> create table user(id bigint not null auto_increment primary key,name varchar(50),sex varchar(1),age int);
Query OK, 0 rows affected (0.500 sec)

MySQL [frm_test]> show tables;
+--------------------+
| Tables_in_frm_test |
+--------------------+
| user               |
+--------------------+
1 row in set (0.011 sec)

MySQL [frm_test]>  insert into user values(1,'张三','男',11);
Query OK, 1 row affected (0.174 sec)

MySQL [frm_test]> select * from user;
+----+--------+------+------+
| id | name   | sex  | age  |
+----+--------+------+------+
|  1 | 张三   | 男   |   11 |
+----+--------+------+------+
1 row in set (0.005 sec)

MySQL [frm_test]>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值