diff --git a/media/lxs-picture/1-1-4-01.png b/media/lxs-picture/1-1-4-01.png new file mode 100644 index 0000000000000000000000000000000000000000..4e3d55c78c31d36e3381a82f3b027aa489ab1665 Binary files /dev/null and b/media/lxs-picture/1-1-4-01.png differ diff --git a/media/lxs-picture/2-3-01.png b/media/lxs-picture/2-3-01.png new file mode 100644 index 0000000000000000000000000000000000000000..a0c252a05509b54514867983fbe4f72e7bbde0fa Binary files /dev/null and b/media/lxs-picture/2-3-01.png differ diff --git a/media/lxs-picture/3-2-01.png b/media/lxs-picture/3-2-01.png new file mode 100644 index 0000000000000000000000000000000000000000..902fa4a8f5a823ef599ec4650c0b7dd5dbadc351 Binary files /dev/null and b/media/lxs-picture/3-2-01.png differ diff --git a/media/lxs-picture/3-3-01.png b/media/lxs-picture/3-3-01.png new file mode 100644 index 0000000000000000000000000000000000000000..992ae338e891e1a34798f14e67db60b0ab6551c9 Binary files /dev/null and b/media/lxs-picture/3-3-01.png differ diff --git a/media/lxs-picture/3-5-01.png b/media/lxs-picture/3-5-01.png new file mode 100644 index 0000000000000000000000000000000000000000..90f46e2ea170a3b3b36c6c2fb738b175c2a4c6bf Binary files /dev/null and b/media/lxs-picture/3-5-01.png differ diff --git a/media/lxs-picture/3-5-02.png b/media/lxs-picture/3-5-02.png new file mode 100644 index 0000000000000000000000000000000000000000..bf742ad6c5561a85f57d3b1bb54d1091c76389a8 Binary files /dev/null and b/media/lxs-picture/3-5-02.png differ diff --git a/media/lxs-picture/3-5-03.png b/media/lxs-picture/3-5-03.png new file mode 100644 index 0000000000000000000000000000000000000000..7441f68e7bca138e23565e13a7bda6bc06506a86 Binary files /dev/null and b/media/lxs-picture/3-5-03.png differ diff --git a/media/lxs-picture/3-5-04.png b/media/lxs-picture/3-5-04.png new file mode 100644 index 0000000000000000000000000000000000000000..5f499662d0b3c9a4edadca89126770c9062a1651 Binary files /dev/null and b/media/lxs-picture/3-5-04.png differ diff --git a/media/lxs-picture/4-2-01.png b/media/lxs-picture/4-2-01.png new file mode 100644 index 0000000000000000000000000000000000000000..340edc74e655ccf36eb435e449c15fb23c4bc483 Binary files /dev/null and b/media/lxs-picture/4-2-01.png differ diff --git a/media/lxs-picture/4-2-02.png b/media/lxs-picture/4-2-02.png new file mode 100644 index 0000000000000000000000000000000000000000..4997e3e45c2bd53fe73929d5d8124d21dd9e2b8b Binary files /dev/null and b/media/lxs-picture/4-2-02.png differ diff --git a/media/lxs-picture/4-2-03.png b/media/lxs-picture/4-2-03.png new file mode 100644 index 0000000000000000000000000000000000000000..83a2036bbe951be32b5d0baf973dbd549751889b Binary files /dev/null and b/media/lxs-picture/4-2-03.png differ diff --git a/media/lxs-picture/4-3-01.png b/media/lxs-picture/4-3-01.png new file mode 100644 index 0000000000000000000000000000000000000000..0d947a69540839ce624836153f84dd899a004191 Binary files /dev/null and b/media/lxs-picture/4-3-01.png differ diff --git a/media/lxs-picture/4-3-02.png b/media/lxs-picture/4-3-02.png new file mode 100644 index 0000000000000000000000000000000000000000..820499c2d9bed10be609ef279b89bd0021e32f3e Binary files /dev/null and b/media/lxs-picture/4-3-02.png differ diff --git a/media/lxs-picture/4-3-03.png b/media/lxs-picture/4-3-03.png new file mode 100644 index 0000000000000000000000000000000000000000..7361d605f5b755a4faf4d5ec0b09985c7c2462f6 Binary files /dev/null and b/media/lxs-picture/4-3-03.png differ diff --git a/media/lxs-picture/4-3-04.png b/media/lxs-picture/4-3-04.png new file mode 100644 index 0000000000000000000000000000000000000000..008ba8587eb4aa15ccbb3d8e49fa35a65b6bc946 Binary files /dev/null and b/media/lxs-picture/4-3-04.png differ diff --git a/media/lxs-picture/4-3-05.png b/media/lxs-picture/4-3-05.png new file mode 100644 index 0000000000000000000000000000000000000000..4996b5d8a1c1aab43dd78eee26c8a3720d99fdce Binary files /dev/null and b/media/lxs-picture/4-3-05.png differ diff --git a/media/lxs-picture/4-3-06.png b/media/lxs-picture/4-3-06.png new file mode 100644 index 0000000000000000000000000000000000000000..0784b32f5bb07221292a57404468d287b6196702 Binary files /dev/null and b/media/lxs-picture/4-3-06.png differ diff --git a/media/lxs-picture/4-3-07.png b/media/lxs-picture/4-3-07.png new file mode 100644 index 0000000000000000000000000000000000000000..0784b32f5bb07221292a57404468d287b6196702 Binary files /dev/null and b/media/lxs-picture/4-3-07.png differ diff --git a/media/lxs-picture/4-3-08.png b/media/lxs-picture/4-3-08.png new file mode 100644 index 0000000000000000000000000000000000000000..588c34c07658f6ff736035014e9ff6ff8728490f Binary files /dev/null and b/media/lxs-picture/4-3-08.png differ diff --git a/media/lxs-picture/4-3-09.png b/media/lxs-picture/4-3-09.png new file mode 100644 index 0000000000000000000000000000000000000000..bc222cad9c8b93c5431a50583b447638045e0c29 Binary files /dev/null and b/media/lxs-picture/4-3-09.png differ diff --git a/media/lxs-picture/4-3-10.png b/media/lxs-picture/4-3-10.png new file mode 100644 index 0000000000000000000000000000000000000000..45afee7b2b6e66fdbde7ca7e07d6b98fc36f4fde Binary files /dev/null and b/media/lxs-picture/4-3-10.png differ diff --git a/media/lxs-picture/4-3-11.png b/media/lxs-picture/4-3-11.png new file mode 100644 index 0000000000000000000000000000000000000000..48ba72fadf37cc1d487d46e38ae451b31d15b577 Binary files /dev/null and b/media/lxs-picture/4-3-11.png differ diff --git a/media/lxs-picture/4-3-12.png b/media/lxs-picture/4-3-12.png new file mode 100644 index 0000000000000000000000000000000000000000..90f46e2ea170a3b3b36c6c2fb738b175c2a4c6bf Binary files /dev/null and b/media/lxs-picture/4-3-12.png differ diff --git a/media/lxs-picture/4-3-13.png b/media/lxs-picture/4-3-13.png new file mode 100644 index 0000000000000000000000000000000000000000..1443029a9aacc8373cf36a3c4a9f8a9ed8b76c68 Binary files /dev/null and b/media/lxs-picture/4-3-13.png differ diff --git a/media/lxs-picture/4-3-14.png b/media/lxs-picture/4-3-14.png new file mode 100644 index 0000000000000000000000000000000000000000..c8234beb4a8146a991c1cb4ed5b2560d74ea0445 Binary files /dev/null and b/media/lxs-picture/4-3-14.png differ diff --git a/media/lxs-picture/5-1-01.png b/media/lxs-picture/5-1-01.png new file mode 100644 index 0000000000000000000000000000000000000000..03d5723e8cb3e9cbc0fef94e74a3d3b888ec331f Binary files /dev/null and b/media/lxs-picture/5-1-01.png differ diff --git a/media/lxs-picture/5-1-02.png b/media/lxs-picture/5-1-02.png new file mode 100644 index 0000000000000000000000000000000000000000..a66b6c18013d0d41a4362a99cf70203eab7128fb Binary files /dev/null and b/media/lxs-picture/5-1-02.png differ diff --git a/media/lxs-picture/5-2-01.png b/media/lxs-picture/5-2-01.png new file mode 100644 index 0000000000000000000000000000000000000000..949a4f14325f165d65ec07f178e982aa94c655f3 Binary files /dev/null and b/media/lxs-picture/5-2-01.png differ diff --git a/media/lxs-picture/5-2-02.png b/media/lxs-picture/5-2-02.png new file mode 100644 index 0000000000000000000000000000000000000000..13027eb6605baa3f5ed8fab16f7cfb401a01b673 Binary files /dev/null and b/media/lxs-picture/5-2-02.png differ diff --git a/media/lxs-picture/5-2-03.png b/media/lxs-picture/5-2-03.png new file mode 100644 index 0000000000000000000000000000000000000000..12fff083eb09b7195d8ca57e0922ad981ac503b9 Binary files /dev/null and b/media/lxs-picture/5-2-03.png differ diff --git a/media/lxs-picture/5-2-04.png b/media/lxs-picture/5-2-04.png new file mode 100644 index 0000000000000000000000000000000000000000..5e387cd47283a72ff4998203a0340d1133d99b54 Binary files /dev/null and b/media/lxs-picture/5-2-04.png differ diff --git a/media/lxs-picture/5-3-01.png b/media/lxs-picture/5-3-01.png new file mode 100644 index 0000000000000000000000000000000000000000..61be6558de4102a4c0a259b20945812a11684c3f Binary files /dev/null and b/media/lxs-picture/5-3-01.png differ diff --git a/media/lxs-picture/5-3-02.png b/media/lxs-picture/5-3-02.png new file mode 100644 index 0000000000000000000000000000000000000000..ff875c9ee54cc90a0c5000995c4db45f208cd6b8 Binary files /dev/null and b/media/lxs-picture/5-3-02.png differ diff --git a/media/lxs-picture/5-3-03.png b/media/lxs-picture/5-3-03.png new file mode 100644 index 0000000000000000000000000000000000000000..1b32e40be7b63099fbaeb57d67caa2cf8902ab9f Binary files /dev/null and b/media/lxs-picture/5-3-03.png differ diff --git a/media/lxs-picture/zw b/media/lxs-picture/zw new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\256\211\350\243\205\351\203\250\347\275\262 \346\211\213\345\212\250\351\203\250\347\275\262CentOS7.9\347\216\257\345\242\203\344\270\213\347\232\204 OceanBase \345\215\225\345\211\257\346\234\254\351\233\206\347\276\244.md" "b/\345\256\211\350\243\205\351\203\250\347\275\262 \346\211\213\345\212\250\351\203\250\347\275\262CentOS7.9\347\216\257\345\242\203\344\270\213\347\232\204 OceanBase \345\215\225\345\211\257\346\234\254\351\233\206\347\276\244.md" new file mode 100644 index 0000000000000000000000000000000000000000..9c1f8bc63406366819971dd05b20f4065d76347a --- /dev/null +++ "b/\345\256\211\350\243\205\351\203\250\347\275\262 \346\211\213\345\212\250\351\203\250\347\275\262CentOS7.9\347\216\257\345\242\203\344\270\213\347\232\204 OceanBase \345\215\225\345\211\257\346\234\254\351\233\206\347\276\244.md" @@ -0,0 +1,413 @@ +## 一、前期准备 +### 1.准备: +#### ⑴硬件条件: + 4核CPU,32G内存,500G硬盘容量,网卡型号:lo +#### ⑵软件信息: + IP地址:127.0.0.1。软件版本:CentOS Linux release 7.9.2009 (Core) +#### ⑶准备服务器: +| 角色 | 机器 | 备注 | +| --- | --- | --- | +| observer | 127.0.0.1 | zone1, 监听2881和2883端口 | +| obproxy | 127.0.0.1 | 监听2883和2884端口 | + +#### ⑷ 硬盘信息: + +![1-1-4-01.png](media/lxs-picture/1-1-4-01.png) + +### 2.安装相关应用工具软件 + + yum -y install tree + + yum install epel-release -y + + yum install -y net-tools lrzsz tree htop dstat sysvinit-tools + + yum -y install sysvinit-tools + + yum install -y net-tools + +### 3.下载OceanBase 软件: + + 从OB官网社区版下载如下五个软件: + +①libobclient-2.0.0-2.el7.x86_64.rpm + +②obclient-2.0.0-2.el7.x86_64.rpm + +③obproxy-3.2.0-1.el7.x86_64.rpm + +④oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm + +⑤oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm + +### 4.服务器内核参数初始化 + +[root@localhost etc]# 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 + + +[root@localhost etc]# sysctl -p生效。 + +### 5.会话设置: + +[root@localhost security]# vim limits.conf +* 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@localhost security]# ulimit -a + + ulimit -a检查,退出重新登录会话生效。 + +### 6.关闭防火墙和SELinux设置: +#### ⑴查看防火墙状态 + systemctl stop firewalld +#### ⑵关闭 SELinux + +修改 SELinux 配置文件中的 SELINUX 选项。 + + vim /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 + +## 二、安装 +### 1.用户设置: +#### ⑴增加用户: + useradd admin + passwd admin +#### ⑵授予admin用户sudo权限: + [angel@localhost /]#cat /etc/sudoers + rootALL=(ALL) ALL + admin ALL=(ALL) ALL +#### ⑶目录权限: + chown -R admin.admin /data /redo +#### ⑷时钟同步: + yum -y install chrony +### 2.创建工作目录: + mkdir -p /home/admin/oceanbase/store/{sstable,etc3,clog,ilog,slog,etc2} + + [admin@XTZJ-20211224SR ~]$ tree ~/oceanbase/ + +/home/admin/oceanbase/ + +├── bin +├── etc +├── etc2 +├── etc3 +├── lib +├── log +├── run +└── store + ├── clog + ├── sort_dir + ├── ilog + ├── slog + └── sstable + +### 3.安装软件: + rpm -ivh *.rpm + +![2-3-01.png](media/lxs-picture/2-3-01.png) + +### 4.查看安装: + rpm -ql libobclient-2.0.0-2.el7.x86_64.rpm + + rpm -ql obclient-2.0.0-2.el7.x86_64.rpm + + rpm -ql obproxy-3.2.0-1.el7.x86_64.rpm + + rpm -ql oceanbase-ce-3.1.2-10000392021123010.el7 + + rpm -ql oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm + +### 5.环境变量设置: + + $ echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/oceanbase/lib' >> ~/.bash_profile + + $ source ~/.bash_profile echo $LD_LIBRARY_PATH + +## 三、启动OB进程: +### 1.启动: +cd /home/admin/oceanbase && bin/observer -i lo -p 2881 -P 2882 -z zone1 -d /home/admin/oceanbase/store -r '127.0.0.1:2882:2881' -c 20220221 -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=16,net_thread_count=4,datafile_size=50G,stack_size=1536K" + +### 2.查看进程: +**ps -ef|grep observer** + +![3-2-01.png](media/lxs-picture/3-2-01.png) + +### 3.查看监听: + **netstat –ntlp** + +![3-3-01.png](media/lxs-picture/3-3-01.png) + +**OB启动成功!** +### 4.集群: + **obclient -h 127.0.0.1 -P 2881 -uroot -c -A** + **set session ob_query_timeout=1000000000; alter system bootstrap ZONE 'zone1' SERVER '127.0.0.1:2882';** + +### 5.集群成功后重新登录: + **obclient -h 127.0.0.1 -P 2881 -uroot@sys -c -A** + + **alter user root identified by '123'; #更改用户名和密码。后退出。** + + **show databases;** + +![3-5-01.png](media/lxs-picture/3-5-01.png) + +**#多了一个oceanbase数据库,说明初始化成功了。** +**然后更改密码,退出后带密码登录。** + +**登录OB数据库,查看表:** + +![3-5-02.png](media/lxs-picture/3-5-02.png) + + **show processlist;** + +![3-5-03.png](media/lxs-picture/3-5-03.png) + +select gmt_create,gmt_modified,tenant_id,tenant_name,replica_num,zone_list,primary_zone,info,locality,default_tablegroup_id,drop_tenant_time,status from __all_tenant; + + + **select * from __all_tenant;** + **use test;** + +**#建表也可以,但是不要在SYS实例里面导入大量的数据,或者做功能性或性能测试。** +**如果做测试可以做业务实例。** + + **show tables;** + + **MySQL [oceanbase]> select * from gv$tenant;#只有一个实例是SYS实例。** + +**退出OB:** + +![3-5-04.png](media/lxs-picture/3-5-04.png) + +## 四、启动 OBPROXY 进程 +### 1.启动: +cd ~/obproxy-3.2.0 && bin/obproxy -r "127.0.0.1:2881" -p 2883 -o "enable_strict_kernel_release=false,enable_cluster_checkout=false,enable_metadb_used=false" -c obdemo + +启动-c 指定的集群名obdemo和OBserver的集群名保持一致才能启动 + +### 2.检查 OBPROXY监听进程正常 +进程 obproxy 默认会监听2个端口:2883 和 2884 。 + + ps -ef|grep obproxy + +![4-2-01.png](media/lxs-picture/4-2-01.png) + + netstat -ntlp |grep obproxy + +![4-2-02.png](media/lxs-picture/4-2-02.png) + + obclient -h 127.0.0.1 -u root@proxysys -P 2883 -p123 + +![4-2-03.png](media/lxs-picture/4-2-03.png) + +### 3.修改 OBPROXY 管理密码 + MySQL [(none)]> show proxyconfig like '%sys_password%'; + +![4-3-01.png](media/lxs-picture/4-3-01.png) + + alter proxyconfig set observer_sys_password = '123'; #修改obproxy and observer通信的密码。 + + alter proxyconfig set obproxy_sys_password = '123'; #修改obproxy 管理员的密码。 + +![4-3-02.png](media/lxs-picture/4-3-02.png) + +密文显示如下: + +![4-3-03.png](media/lxs-picture/4-3-03.png) + + +退出obproxy,再一次带密码登录 + + obclient -h 127.0.0.1 -u root@proxysys -P 2883 -p123 + +![4-3-04.png](media/lxs-picture/4-3-04.png) + + show processlist; + +![4-3-05.png](media/lxs-picture/4-3-05.png) + + show databases; + +![4-3-06.png](media/lxs-picture/4-3-06.png) + +测试obproxy连OB集群: + +![4-3-07.png](media/lxs-picture/4-3-07.png) + + obclient -h 127.0.0.1 -u root@sys#obdemo -P 2883 -p123 -c -A oceanbase + +![4-3-08.png](media/lxs-picture/4-3-08.png) + +漏了一步,需要到OB上去建用户。 + + obclient -h 127.0.0.1 -u root@sys -P 2881 -p123 -c -A oceanbase + +![4-3-09.png](media/lxs-picture/4-3-09.png) + +proxyro的用户需要在oceanbase集群里创建,并同时设置密码。 + + grant select on oceanbase.* to proxyro identified by '123'; + +![4-3-10.png](media/lxs-picture/4-3-10.png) + + obclient -h 127.0.0.1 -u root@sys#obdemo -P 2883 -p123 -c -A oceanbase + +![4-3-11.png](media/lxs-picture/4-3-11.png) + +obproxy连接到了 ob集群。 + + show databases; + +![4-3-12.png](media/lxs-picture/4-3-12.png) + + show processlist; + +![4-3-13.png](media/lxs-picture/4-3-13.png) + + show full processlist; + +![4-3-14.png](media/lxs-picture/4-3-14.png) + +这表明obproxy起作用了。 + +## 五、创建业务租户、数据库和表: +### 1.创建资源规格和资源池: + + create resource unit lxs_unit1 max_cpu=1, max_memory='1g', max_iops=1000, max_disk_size='10g', max_session_num=10000, min_cpu=1, min_memory='1g', min_iops=1000; + + select * from __all_unit_config; + +![5-1-01.png](media/lxs-picture/5-1-01.png) + + create resource pool lxs_pool1 unit='lxs_unit1', unit_num=1, zone_list=('zone1'); + + select resource_pool_id, name from __all_resource_pool; + +![5-1-02.png](media/lxs-picture/5-1-02.png) + + tenant_id=-1,表示没有关联到用户。 + +### 2.创建业务租户: + create tenant lxs_tenant1 resource_pool_list=('lxs_pool1'); + + select * from __all_tenant; + + select gmt_create,gmt_modified,tenant_id,tenant_name,replica_num,zone_list,primary_zone,info,locality,default_tablegroup_id,drop_tenant_time,status from __all_tenant; + +![5-2-01.png](media/lxs-picture/5-2-01.png) + +查看资源情况: + +![5-2-02.png](media/lxs-picture/5-2-02.png) + +**重新登录数据库,连接新建业务租户:lxs_tenant1** + + exit + + 退出sys,登录lxs_tenant1 + +![5-2-03.png](media/lxs-picture/5-2-03.png) + + show databases; + +![5-2-04.png](media/lxs-picture/5-2-04.png) + +### 3.创建数据库 +执行命令:create database lxs_db; + +![5-3-01.png](media/lxs-picture/5-3-01.png) + +创建数据表:lxs_student03 + +执行命令:use lxs_db + + create table lxs_student03(id int, name varchar(20)); + + insert into lxs_student03(id, name) value(1, 'angel'); + + insert into lxs_student03(id, name) value(2, 'alice'); + +![5-3-02.png](media/lxs-picture/5-3-02.png) + +![5-3-03.png](media/lxs-picture/5-3-03.png) + +# 总结:遇到的坑。 +1.启动时,CPU数量设置至少需要16个,否则在租户中可能无法打开数据库。 + +2.根目录设置尽可能大一点,我开始设置50G,无法启动,后来扩容了。 + +3.查询IP时,要用hostname –i查询,再结合ifconfig确认网卡型号。 + +4.启动的命令行需要用英文半角标点符号。 + +5.如果启动过程中有任何问题,立即与老师和同学联系,请求帮助! +