1、创建用户
useradd admin
Passwd admin
2、修改内核参数
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=350065535 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=40968738016777216 net.ipv4.tcp_wmem=40966553616777216 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
[root@localhost ~]# sysctl -p 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 sysctl: setting key "net.ipv4.ip_local_port_range": Invalid argument net.ipv4.ip_local_port_range = 350065535 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 sysctl: setting key "net.ipv4.tcp_rmem": Invalid argument net.ipv4.tcp_rmem = 40968738016777216 net.ipv4.tcp_wmem = 40966553616777216 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 |
3、修改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 ~]# ulimit -a core file size (blocks, -c) unlimited data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 64052 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 655360 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) unlimited cpu time (seconds, -t) unlimited max user processes (-u) 655360 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited |
4、关闭防火墙
[root@localhost ~]# systemctl stop firewalld [root@localhost ~]# systemctl disable firewalld [root@localhost ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: inactive (dead) since Fri 2024-03-08 03:59:32 CST; 13s ago Docs: man:firewalld(1) Process: 911 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS) Main PID: 911 (code=exited, status=0/SUCCESS)
Jan 18 23:40:56 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon... Jan 18 23:40:58 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon. Mar 08 03:59:13 localhost.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon... Mar 08 03:59:32 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon. [root@localhost ~]# |
5、关闭selinux
[root@localhost ~]# cat /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 # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted |
6、配置时钟,这里是单机部署因此去掉这一步
7、查看时区
[root@localhost ~]# timedatectl Local time: Fri 2024-03-08 04:04:46 CST Universal time: Thu 2024-03-07 20:04:46 UTC RTC time: Thu 2024-03-07 20:04:46 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: no NTP synchronized: no RTC in local TZ: no DST active: n/a |
8、安装obd软件
[root@localhost tmp]# rpm -ivh ob-deploy-1.1.2-1.el7.x86_64.rpm warning: ob-deploy-1.1.2-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY Preparing... ################################# [100%] Updating / installing... 1:ob-deploy-1.1.2-1.el7 ################################# [100%] Installation of obd finished successfully Please source /etc/profile.d/obd.sh to enable it [root@localhost tmp]# |
9、将软件包加入离线仓库
[admin@localhost ~]$ obd mirror clone /tmp/opt/*.rpm name: libobclient version: 2.2.3 release:1.el7 arch: x86_64 md5: 841949aa594173e1751dfbe9730b2787410e6f01 add /tmp/opt/libobclient-2.2.3-1.el7.x86_64.rpm to local mirror name: obagent version: 1.2.1 release:2.el7 arch: x86_64 md5: e3e3d854f42873ff09c899e4e16cadea13da521d add /tmp/opt/obagent-1.2.1-2.el7.x86_64.rpm to local mirror name: obclient version: 2.2.3 release:1.el7 arch: x86_64 md5: a983aa8564d4c47a7afce933e9659c7fc60c4d29 add /tmp/opt/obclient-2.2.3-1.el7.x86_64.rpm to local mirror name: ob-deploy version: 1.1.2 release:1.el7 arch: x86_64 md5: 75e2f1921ae7760e4bc80777b4cb3b9b2b4e9c96 add /tmp/opt/ob-deploy-1.1.2-1.el7.x86_64.rpm to local mirror name: obproxy version: 3.1.0 release:1.el7 arch: x86_64 md5: 0b17cf0459a3b53c5a2febb6572894d183154c64 add /tmp/opt/obproxy-3.1.0-1.el7.x86_64.rpm to local mirror name: oceanbase-ce version: 3.1.0 release:1.el7 arch: x86_64 md5: 56f57e9843e719d830ec03c206d914f4b3adc82b add /tmp/opt/oceanbase-ce-3.1.0-1.el7.x86_64.rpm to local mirror name: oceanbase-ce-libs version: 3.1.0 release:1.el7 arch: x86_64 md5: b70d3839280f145a86af26811bbfcdfaeb645509 add /tmp/opt/oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm to local mirror
[root@localhost tmp]# obd mirror list local +-------------------------------------------------------------------------------------------+ | local Package List | +-------------------+---------+---------+--------+------------------------------------------+ | name | version | release | arch | md5 | +-------------------+---------+---------+--------+------------------------------------------+ | libobclient | 2.2.3 | 1.el7 | x86_64 | 841949aa594173e1751dfbe9730b2787410e6f01 | | obagent | 1.2.1 | 2.el7 | x86_64 | e3e3d854f42873ff09c899e4e16cadea13da521d | | obclient | 2.2.3 | 1.el7 | x86_64 | a983aa8564d4c47a7afce933e9659c7fc60c4d29 | | ob-deploy | 1.1.2 | 1.el7 | x86_64 | 75e2f1921ae7760e4bc80777b4cb3b9b2b4e9c96 | | obproxy | 3.1.0 | 1.el7 | x86_64 | 0b17cf0459a3b53c5a2febb6572894d183154c64 | | oceanbase-ce | 3.1.0 | 1.el7 | x86_64 | 56f57e9843e719d830ec03c206d914f4b3adc82b | | oceanbase-ce-libs | 3.1.0 | 1.el7 | x86_64 | b70d3839280f145a86af26811bbfcdfaeb645509 | +-------------------+---------+---------+--------+------------------------------------------+ [root@localhost tmp]# |
10、机器信息
机器类型 |
虚拟机 |
IP |
172.22.XX.XX |
网卡名 |
ens192 |
OS |
Red Hat Enterprise Linux Server release 7.5 (Maipo) |
CPU |
8C |
内存 |
16G |
磁盘 |
/dev/mapper/rhel-u01 100GB |
|
|
角色 |
机器 |
OBD |
ob |
OBCLIENT |
ob |
OBSERVER |
ob |
OBPROXY |
ob |
11、创建目录
[root@localhost security]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 38G 4.8G 33G 13% / devtmpfs 7.9G 0 7.9G 0% /dev tmpfs 7.9G 0 7.9G 0% /dev/shm tmpfs 7.9G 83M 7.8G 2% /run tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup /dev/sda1 25G 157M 25G 1% /boot /dev/mapper/rhel-home 28G 37M 28G 1% /home /dev/mapper/rhel-u01 94G 33M 94G 1% /u01 tmpfs 1.6G 52K 1.6G 1% /run/user/1000 /dev/sr0 4.4G 4.4G 0 100% /run/media/zhenglinsong/RHEL-7.5 Server.x86_64 tmpfs 1.6G 0 1.6G 0% /run/user/0 [root@localhost security]# mkdir -p /u01/data /u01/redo /u01/observer [root@localhost security]# chown -R admin:admin /u01/data/ /u01/redo/ /u01/observer |
12、编辑OBD配置文件
[admin@localhost ~]$ obd cluster deploy obtest -c /u01/single1.yaml Update OceanBase-community-stable-el7 x [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml
Update OceanBase-development-kit-el7 x [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml
[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml Package oceanbase-ce-3.1.0 is available. install oceanbase-ce-3.1.0 for local ok +-----------------------------------------------------------------------------+ | Packages | +--------------+---------+---------+------------------------------------------+ | Repository | Version | Release | Md5 | +--------------+---------+---------+------------------------------------------+ | oceanbase-ce | 3.1.0 | 1.el7 | 56f57e9843e719d830ec03c206d914f4b3adc82b | +--------------+---------+---------+------------------------------------------+ Repository integrity check ok Parameter check ok Open ssh connection ok Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository install ok Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check !! [WARN] 127.0.0.1 oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b require: libmariadb.so.3
Try to get lib-repository Update OceanBase-community-stable-el7 x [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml
Update OceanBase-development-kit-el7 x [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml
[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml Package oceanbase-ce-libs-3.1.0 is available. install oceanbase-ce-libs-3.1.0 for local ok Use oceanbase-ce-libs-3.1.0-b70d3839280f145a86af26811bbfcdfaeb645509 for oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b Remote oceanbase-ce-libs-3.1.0-b70d3839280f145a86af26811bbfcdfaeb645509 repository install ok Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check ok Cluster status check ok Initializes observer work home ok obtest deployed |
在配置OBTEST配置文件中,一直报错信息如下:
[admin@localhost u01]$ obd cluster deploy obtest -c single.yaml [ERROR] Parsing error: while parsing a block mapping in "/home/admin/.obd/cluster/obtest/config.yaml", line 7, column 5 expected <block end>, but found '<block mapping start>' in "/home/admin/.obd/cluster/obtest/config.yaml", line 9, column 6 [ERROR] Components not detected. Please check the syntax of your configuration file. |
该错误是由于配置文件有问题,我吧注释去掉之后就可以。
oceanbase-ce: servers: # Please don't use hostname, only IP can be supported - 172.22.150.x global: home_path: /u01/observer data_dir: /u01/data redo_dir: /u01/redo devname: ens192 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 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: 10G # Size of the data file. datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G log_disk_size: 14G # The size of disk space used by the clog files. cpu_count: 8 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: xxx |
部署单机集群obd cluster deploy obtest -c single1.yaml
|
报错,这个的原因是配置文件中,少加了
user: username: admin password: admin |
再次部署集群
[admin@ob ~]$ obd cluster deploy obtest -c /u01/single1.yaml Update OceanBase-community-stable-el7 x [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml
Update OceanBase-development-kit-el7 x [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml
[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml oceanbase-ce-3.1.0 already installed. +-----------------------------------------------------------------------------+ | Packages | +--------------+---------+---------+------------------------------------------+ | Repository | Version | Release | Md5 | +--------------+---------+---------+------------------------------------------+ | oceanbase-ce | 3.1.0 | 1.el7 | 56f57e9843e719d830ec03c206d914f4b3adc82b | +--------------+---------+---------+------------------------------------------+ Repository integrity check ok Parameter check ok Open ssh connection ok Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository install ok Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check ok Cluster status check ok Initializes observer work home ok obtest deployed |
部署成功。下一步初始化打开集群
[admin@ob u01]$ obd cluster deploy obtest -c single1.yaml Update OceanBase-community-stable-el7 x [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml
Update OceanBase-development-kit-el7 x [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml
[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml [ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/admin/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml oceanbase-ce-3.1.0 already installed. +-----------------------------------------------------------------------------+ | Packages | +--------------+---------+---------+------------------------------------------+ | Repository | Version | Release | Md5 | +--------------+---------+---------+------------------------------------------+ | oceanbase-ce | 3.1.0 | 1.el7 | 56f57e9843e719d830ec03c206d914f4b3adc82b | +--------------+---------+---------+------------------------------------------+ Repository integrity check ok Parameter check ok Open ssh connection ok Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository install ok Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check ok Cluster status check ok Initializes observer work home ok obtest deployed [admin@ob u01]$ obd cluster start obtest Get local repositories and plugins ok Open ssh connection ok Cluster param config check ok Check before start observer ok [WARN] (172.22.150.7) clog and data use the same disk (/u01) Start observer ok observer program health check ok Connect to observer ok Initialize cluster Cluster bootstrap ok Wait for observer init ok +------------------------------------------------+ | observer | +--------------+---------+------+-------+--------+ | ip | version | port | zone | status | +--------------+---------+------+-------+--------+ | 172.22.150.7 | 3.1.0 | 2881 | zone1 | active | +--------------+---------+------+-------+--------+ obtest running [admin@ob u01]$ obd cluster display obtest Get local repositories and plugins ok Open ssh connection ok Cluster status check ok Connect to observer ok Wait for observer init ok +------------------------------------------------+ | observer | +--------------+---------+------+-------+--------+ | ip | version | port | zone | status | +--------------+---------+------+-------+--------+ | 172.22.150.7 | 3.1.0 | 2881 | zone1 | active | +--------------+---------+------+-------+--------+ |
中途启动过程中,遇到这个错误:
[admin@ob ~]$ obd cluster start obtest Get local repositories and plugins ok Open ssh connection ok Cluster param config check ok Check before start observer ok [WARN] (172.22.150.7) clog and data use the same disk (/u01) Start observer ok observer program health check ok Connect to observer x [ERROR] Failed to connect oceanbase-ce |
解决办法:加大内存,修改如下2个参数解决
memory_limit: 10G system_memory: 5G |
|
手工部署obclient和obproxy使用sudo
为账户 admin 设置 sudo 权限。 执行以下命令,打开 /etc/sudoers 文件,在 /etc/sudoers 文件添加以下内容: [root@test001 ~]# vim /etc/sudoers # 添加如下内容: ## Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL admin ALL=(ALL) NOPASSWD: ALL
[admin@ob opt]$ sudo rpm -ivh libobclient-2.2.3-1.el7.x86_64.rpm obclient-2.2.3-1.el7.x86_64.rpm [sudo] password for admin: warning: libobclient-2.2.3-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY Preparing... ################################# [100%] Updating / installing... 1:obclient-2.2.3-1.el7 ################################# [ 50%] 2:libobclient-2.2.3-1.el7 ################################# [100%] [admin@ob opt]$ sudo rpm -ivh obproxy-3.1.0-1.el7.x86_64.rpm warning: obproxy-3.1.0-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY Preparing... ################################# [100%] Updating / installing... 1:obproxy-3.1.0-1.el7 ################################# [100%] |
启动obproxy
cd /home/admin/obproxy-3.1.0 &&./bin/obproxy -p 2883 -r "172.22.150.7:2881" -o observer_sys_password=7c4a8d09ca3762af61e59520943dc26494f8941b,obproxy_sys_password=7c4a8d09ca3762af61e59520943dc26494f8941b,enable_cluster_checkout=false -n test -c obtest
|
切记这里需要设置:observer_sys_password和obproxy_sys_password否则会报如下错误:
Lost connection to MySQL server at 'reading authorization packet', system error: 11 |
尝试通过proxy 2883登录sys租户,报错如下:
[admin@ob obproxy-3.1.0]$ obclient -h 172.22.150.7 -uroot@sys -P2883 -p -c -A Enter password: ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 11 [admin@ob obproxy-3.1.0]$ obclient -h 172.22.150.7 -uroot@sys -P2881 -p -c -A Enter password: Welcome to the OceanBase. Commands end with ; or \g. |
解决办法:使用2881端口登录到SYS租户,这里创建的密码和启动proxy的密码保持一致一个是加密sha-1(https://www.iamwawa.cn/jiami.html)加密的一个是明文,都是123456.
[admin@ob obproxy-3.1.0]$ obclient -h 172.22.150.7 -uroot@sys -P2881 -p -c -A Enter password: Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221488595 Server version: OceanBase 3.1.0 (r-) (Built May 30 2021 11:21:29)
Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [(none)]> obclient [(none)]> obclient [(none)]> CREATE USER proxyro IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.164 sec)
obclient [(none)]> GRANT SELECT ON *.* TO proxyro; Query OK, 0 rows affected (0.084 sec)
obclient [(none)]> exit |
使用2883 proxy代理登录sys 租户
[admin@ob obproxy-3.1.0]$ obclient -h 172.22.150.7 -uroot@sys -P2883 -p -c -A Enter password: Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 4 Server version: OceanBase 3.1.0 (r-) (Built May 30 2021 11:21:29)
Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. |
13、创建资源规格、资源池、租户和数据库
obclient [oceanbase]> CREATE RESOURCE UNIT unit1 max_cpu=1,min_cpu=1,max_memory='1G',min_memory='1G', max_iops=1000,min_iops=1000,max_session_num=100,max_disk_size='10G'; Query OK, 0 rows affected (0.294 sec)
obclient [oceanbase]> create resource pool pool1 unit='unit1',unit_num=1; Query OK, 0 rows affected (0.038 sec)
obclient [oceanbase]> create tenant test resource_pool_list=('pool1') set ob_tcp_invited_nodes='%'; Query OK, 0 rows affected (3.925 sec) |
14、连接业务租户、创建业务数据库和插入数据
[admin@ob ~]$ obclient -h172.22.150.7 -u root@test -P2881 -p -A -c -Doceanbase Enter password: Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221487643 Server version: OceanBase 3.1.0 (r-) (Built May 30 2021 11:21:29)
Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient [oceanbase]> alter user root identified by 'Zls19830907)'; Query OK, 0 rows affected (0.098 sec) obclient [oceanbase]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | test | +--------------------+ 4 rows in set (0.055 sec)
obclient [oceanbase]> create database trade; Query OK, 1 row affected (0.070 sec) obclient [oceanbase]> use trade; Database changed obclient [trade]> create table emp(id int,ename varchar(20)); Query OK, 0 rows affected (0.384 sec)
obclient [trade]> insert into emp values(1,'wuhan'),(2,'hubei'),(3,'zls'); Query OK, 3 rows affected (0.141 sec) Records: 3 Duplicates: 0 Warnings: 0
[admin@ob ~]$ obclient -h172.22.150.7 -u root@test -P2883 -p -A -c -Doceanbase Enter password: Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 24 Server version: OceanBase 3.1.0 (r-) (Built May 30 2021 11:21:29)
Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [oceanbase]> obclient [oceanbase]> obclient [oceanbase]> obclient [oceanbase]> use trade; Database changed obclient [trade]> select * from emp; +------+-------+ | id | ename | +------+-------+ | 1 | wuhan | | 2 | hubei | | 3 | zls | +------+-------+ 3 rows in set (0.015 sec)
obclient [trade]> select * from emp; +------+-------+ | id | ename | +------+-------+ | 1 | wuhan | | 2 | hubei | | 3 | zls | +------+-------+ 3 rows in set (0.011 sec)
obclient [trade]> |
另外,OBSERVER默认日志级别INFO 打印日志太多不便于分析问题,可以修改为ERROR即可。需要在sys租户下面修改,其他租户没有修改权限。
obclient [oceanbase]> alter system set syslog_level='ERROR'; Query OK, 0 rows affected (0.141 sec)
obclient [oceanbase]> SHOW PARAMETERS LIKE '%syslog_level%'; +-------+----------+--------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level | +-------+----------+--------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone1 | observer | 172.22.150.7 | 2882 | syslog_level | NULL | ERROR | specifies the current level of logging. There are DEBUG, TRACE, INFO, WARN, USER_ERR, ERROR, six different log levels. | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | +-------+----------+--------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ 1 row in set (0.013 sec) |