Oceanbase-03.安装OCP

03.安装OCP

安装Doker

下载对应的安装包,直接rpm安装,使用Redhat 7.6 yum安装总是报错,随后直接rpm安装了。

安装docker

[root@dbdriver soft]# rpm -ivh container-selinux-2.119.1-.c57a6f9.el7.noarch.rpm
[root@dbdriver soft]# rpm -ivh containerd.io-1.2.6-3.3.el7.x86_64.rpm
[root@dbdriver soft]# rpm -ivh docker-ce-cli-19.03.9-3.el7.x86_64.rpm
[root@dbdriver soft]# rpm -ivh docker-ce-19.03.9-3.el7.x86_64.rpm

启动doker

[root@dbdriver ocp-ce-3.1.1-bp1]# docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@dbdriver ocp-ce-3.1.1-bp1]# systemctl start docker
[root@dbdriver ocp-ce-3.1.1-bp1]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@dbdriver ocp-ce-3.1.1-bp1]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

还有几个docker命令,记录一下:
 docker stats ocp
 docker exec -it ocp bash
 docker rm ocp
 docker start ocp  
 docker stop ocp  

报错信息

如果使用yum install 会有报错container-selinux,虽然已经手工安装还是报错,干脆用rpm直接装了
Error: Package: containerd.io-1.2.6-3.3.el7.x86_64 (/containerd.io-1.2.6-3.3.el7.x86_64)
           Requires: container-selinux >= 2:2.74
Error: Package: 3:docker-ce-19.03.9-3.el7.x86_64 (/docker-ce-19.03.9-3.el7.x86_64)
           Requires: container-selinux >= 2:2.74

创建MetaDB和MonitorDB

[admin@dbdriver ~]$  obclient -h10.51.xx.65 -P2883 -uroot@sys#obtest -p -A

MySQL [(none)]> CREATE RESOURCE UNIT ocp_unit_config MAX_CPU 2, MAX_MEMORY '1G', MAX_IOPS 10000,MAX_DISK_SIZE '10G', MAX_SESSION_NUM 1000, MIN_CPU=2, MIN_MEMORY='1G',MIN_IOPS=1000;
MySQL [(none)]> CREATE RESOURCE POOL ocp_pool UNIT='ocp_unit_config',UNIT_NUM=1,ZONE_LIST=('zone1','zone2','zone3');
MySQL [(none)]> CREATE TENANT IF NOT EXISTS ocp_meta charset='utf8mb4',replica_num=3, zone_list=('zone1','zone2','zone3'), primary_zone='RANDOM',comment 'mysql ocp_meta', resource_pool_list=('ocp_pool') set ob_tcp_invited_nodes='%',ob_compatibility_mode='mysql';
MySQL [(none)]> CREATE RESOURCE POOL ocp_monitory_pool UNIT='ocp_unit_config',UNIT_NUM=1,ZONE_LIST=('zone1','zone2','zone3');
MySQL [(none)]> CREATE TENANT IF NOT EXISTS ocp_monitor charset='utf8mb4',replica_num=3, zone_list=('zone1','zone2','zone3'), primary_zone='RANDOM',comment 'mysql ocp_meta', resource_pool_list=('ocp_monitory_pool') set ob_tcp_invited_nodes='%',ob_compatibility_mode='mysql';

安装OCP

解压OCP 包

[admin@dbdriver soft]$ tar -xzvf ocp-3.1.1-ce-bp1.tar.gz
ocp-ce-3.1.1-bp1/
ocp-ce-3.1.1-bp1/ocp_installer.sh
ocp-ce-3.1.1-bp1/ocp.tar.gz

生成配置文件

admin@dbdriver ocp-ce-3.1.1-bp1]$ ls
ocp_installer.sh  ocp.tar.gz
[admin@dbdriver ocp-ce-3.1.1-bp1]$ ls -l
total 1815792
-rwx--x--x. 1 admin admin      11643 Mar 11 15:25 ocp_installer.sh
-rw-------. 1 admin admin 1859357696 Mar 18 15:24 ocp.tar.gz
[admin@dbdriver ocp-ce-3.1.1-bp1]$ ./ocp_installer.sh genconf -c ocp.yaml
write example config to ocp.yaml
done. Please edit ocp.yaml for later use
[admin@dbdriver ocp-ce-3.1.1-bp1]$ ls -l
total 1815796
-rwx--x--x. 1 admin admin      11643 Mar 11 15:25 ocp_installer.sh
-rw-------. 1 admin admin 1859357696 Mar 18 15:24 ocp.tar.gz
-rw-rw-r--. 1 admin admin       1218 May 21 11:36 ocp.yaml

编辑配置文件:

[admin@dbdriver ocp-ce-3.1.1-bp1]$ vi ocp.yaml
# The ip address to deploy ocp, config multiple ip with an array (IP1 IP2 IP3)
# The ip address should not be 127.0.0.1 or localhost
# If the server has both public ip and private ip, private ip is ok
OCP_IP_ARRAY=(10.51.xx.65)

SSH_USER=root    # if not root, make sure remote user can use sudo without password    admin   ALL=(ALL)   NOPASSWD:ALL
SSH_PORT=22
SSH_AUTH=password     # can be password or pubkey
SSH_PASSWORD='Root1234'     # password for passowrd auth, when use pubkey auth, is passphrase
SSH_KEY_FILE='/root/.ssh/id_rsa'   # pubkey auth

# it's highly recommended to use separate tenant for metadb and monitordb
# metadb host address, should not be 127.0.0.1 or localhost
OCP_METADB_HOST=10.51.xx.66
OCP_METADB_PORT=2881
OCP_METADB_USER=root@ocp_meta
OCP_METADB_PASSWORD=''   # password may contains special char, make sure correctly quote
OCP_METADB_DBNAME=ocp
OCP_MONITORDB_USER=root@ocp_monitor
OCP_MONITORDB_PASSWORD=''    # password may contains special char, make sure correctly quote
OCP_MONITORDB_DBNAME=ocp_monitor
OCP_WEB_PORT=8080

OCP_LB_VIP=       # HA OCP VIP
OCP_LB_VPORT=     # HA OCP VPORT

OCP_IMAGE=/oceanbase/soft/ocp-ce-3.1.1-bp1/ocp.tar.gz # absoulute path of ocp image file
OCP_CPU=16
OCP_MEMORY=20G
OCP_LOG_DIR=/oceanbase/ocp_logs

部署OCP

开始部署
[admin@dbdriver ocp-ce-3.1.1-bp1]$ ./ocp_installer.sh install -c ocp.yaml

SUCCESS.
start create backup databases
start create backup1472
loading sql script: backup_metadb_init.sql
loading sql script: restore_metadb_init.sql
end create backup1472
start create backup147x
loading sql script: backup_metadb_init.sql
loading sql script: restore_metadb_init.sql
end create backup147x
start create backup21
loading sql script: backup_metadb_init.sql
loading sql script: restore_metadb_init.sql
end create backup21
start create backup2230
loading sql script: backup_metadb_init.sql
loading sql script: restore_metadb_init.sql
end create backup2230
end create backup databases
init ocp database success on 10.51.xx.65
set ocp site url
Enter password: set ocp web port
Enter password: now need create sub dirs under ocp log dir
82fd0ba338f109671c2814aa1f564977fc17c3f35b0dcbd81bc8fc7dd47b28c6
start ocp image /oceanbase/soft/ocp-ce-3.1.1-bp1/ocp.tar.gz succeess on 10.51.xx.65
waiting for ocp web console ready, max wait time is 3 min
OCP start successful on 10.51.xx.65
done

docker中也有image在running了
[root@dbdriver ~]# docker ps
CONTAINER ID        IMAGE                                                              COMMAND                  CREATED             STATUS              PORTS               NAMES
82fd0ba338f1        reg.docker.alibaba-inc.com/oceanbase/ocp-all-in-one:3.1.1-ce-bp1   "/usr/bin/supervisor…"   14 minutes ago      Up 14 minutes                           ocp

在安装过程中异常的报了几次错误,清理了元数据的数据库接着跑就行了。

报错一:
run sql CREATE INDEX IF NOT EXISTS idx_sql_audit_stat_cluster_tenant_server_db_sqlid_time
  ON ob_hist_sql_audit_stat (`ob_cluster_id`, `cluster_name`, `ob_tenant_id`, `ob_server_id`, `ob_db_id`, `sql_id`, `end_interval_time`) LOCAL; got exception Traceback (most recent call last):
  File "create_metadb.py", line 493, in execute_sql_file
    run_sql_no_result(sql, config)
  File "create_metadb.py", line 62, in run_sql_no_result
    cursor.execute(sql)
  File "/usr/lib64/python2.7/site-packages/mysql/connector/cursor.py", line 569, in execute
    self._handle_result(self._connection.cmd_query(stmt))
  File "/usr/lib64/python2.7/site-packages/mysql/connector/connection.py", line 590, in cmd_query
    result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
  File "/usr/lib64/python2.7/site-packages/mysql/connector/connection.py", line 478, in _handle_result
    raise errors.get_exception(packet)
ProgrammingError: 1146 (42S02): Table 'ocp_monitor.ob_hist_sql_audit_stat' doesn't exist

一开始我是用proxy登录oceanbase,可能有问题,后来改成了直连oceanbase一个server。
即修改这里:
OCP_METADB_HOST=10.51.xx.65  -->  10.51.xx.66
OCP_METADB_PORT=2883          -->  2881

报错二:
  File "create_metadb.py", line 62, in run_sql_no_result
    cursor.execute(sql)
  File "/usr/lib64/python2.7/site-packages/mysql/connector/cursor.py", line 569, in execute
    self._handle_result(self._connection.cmd_query(stmt))
  File "/usr/lib64/python2.7/site-packages/mysql/connector/connection.py", line 590, in cmd_query
    result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
  File "/usr/lib64/python2.7/site-packages/mysql/connector/connection.py", line 478, in _handle_result
    raise errors.get_exception(packet)
IntegrityError: 1062 (23000): Duplicate entry '3000006' for key 'PRIMARY'

这个报错就比较诡异了,我直接清理了数据,重新跑安装就ok了。个人怀疑是安装脚本跑乱套了。

清理方法:

登录ocp_meta租户删除 ocp 数据库
[admin@dbdriver ocp-ce-3.1.1-bp1]$ obclient -h10.51.xx.65 -P2883 -uroot@ocp_meta#obtest -p -A
Enter password:
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 18051
Server version: 5.6.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47: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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| test               |
| ocp                |
+--------------------+
5 rows in set (0.005 sec)

MySQL [(none)]> drop database ocp;
Query OK, 0 rows affected (4.924 sec)

登录ocp_monitor租户删除ocp_monitor数据库
[admin@dbdriver ocp-ce-3.1.1-bp1]$ obclient -h10.51.xx.65 -P2883 -uroot@ocp_monitor#obtest -p -A

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| test               |
| ocp_monitor        |
+--------------------+
5 rows in set (0.002 sec)

MySQL [(none)]> drop database ocp_monitor;
Query OK, 0 rows affected (0.145 sec)

登录OCP

使用账户默认账户密码登录

http://10.51.xx.65:8080/login

admin / root
image
image
image
image
image
image
image
image
image

posted @ 2022-05-21 21:00  lizhao01  阅读(779)  评论(0编辑  收藏  举报