欣欣闹天下

古有洛离感青天,乾坤泣血憾无言。时光无情终逝去,唯留玲珑血玉兰。

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

oceanbase 社区版安装

一、环境准备

节点类别 主机名 IP
OBSERVER observer1 192.168.3.41
OBSERVER observer2 192.168.3.42
OBSERVER observer3 192.168.3.43
ocp ocpserver 192.168.3.47
中控机 obcontrol 192.168.3.48

二、名词解析

中控机:存储Oceanbase数据库安装包和集群配置信息的机器

目标机器:安装OceanBase数据库的机器

OBD:Oceanbase Deployer,Oceanbase 开源软件的安装部署工具,简称OBD

OBProxy:Oceanbase Database Proxy, OceanBase高性能反向代理服务器,简称OBProxy

OCP: OceanBase cloud Platform OceanBase运维管理工具,简称OCP

三、主机安装步骤

3.1 配置hosts文件和磁盘的规划

echo "192.168.3.41 observer1"> /etc/hosts
echo "192.168.3.42 observer2">> /etc/hosts
echo "192.168.3.43 observer3">> /etc/hosts
echo "192.168.3.47 ocpserver">> /etc/hosts
echo "192.168.3.48 obcontrol">> /etc/hosts
cat /etc/hosts

pvcreate /dev/sdb /dev/sdc
vgcreate redovg /dev/sdb
vgcreate datavg /dev/sdc
lvcreate -n datalv -L 200000M datavg
lvcreate -n adminlv -L 100000M datavg
lvcreate -n redolv -L 100000M redovg

mkfs.xfs /dev/datavg/datalv
mkfs.xfs /dev/datavg/adminlv
mkfs.xfs /dev/redovg/redolv

cat >> /etc/fstab << EOF
/dev/datavg/datalv /data xfs defaults 0 0
/dev/datavg/adminlv /home/admin xfs defaults 0 0
/dev/redovg/redolv /redo xfs defaults 0 0
EOF
cat /etc/fstab

3.2 创建目录和admin用户

mkdir -p /data/soft
mkdir /redo
mkdir /home/admin
mount /data
mount /home/admin
mount /redo
rm -fr /var/spool/mail/admin
userdel -r admin
groupadd -g 66000 admin
useradd -u 66000 -g admin -m -d /home/admin -s /bin/bash admin
cp /etc/skel/.bash* /home/admin/
echo "admin" | passwd --stdin admin

chown -R admin:admin /data
chown -R admin:admin /redo
chown -R admin:admin /home/admin


3.3 配置 sudoers文件和 字符集

cat >> /etc/sudoers << EOF
Admin ALL=(ALL) NOPASSWD: ALL
EOF

测试:
su - admin
sudo -su root
exit
exit;

echo "export LANG=en_US.UTF8" >> ~/.bash_profile
cat ~/.bash_profile

echo "export LANG=en_US.UTF8" >> /home/admin/.bash_profile
systemctl set-default multi-user.target

3.4 配置yum

mkdir /media/cdrom
mount /dev/cdrom /media/cdrom

cd /etc/yum.repos.d
mkdir bk
mv -f *.repo bk/


vi /etc/yum.repos.d/oracle.repo
[Server]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
baseurl=file:///media/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

yum install -y expect mariadb mariadb-devel python-devel openssl-devel gcc gcc-gfortran gcc-c++ python-setuptools bc et-tools mtr chrony bind-utils libaio tree

3.5 配置limits.conf和sysctl.conf


cat >> /etc/security/limits.conf << EOF
* soft nofile 655360
* hard nofile 655360
* soft nproc 655360
* hard nproc 655360
* hard core unlimited
* soft core unlimited
* hard stack 10240
* soft stack 10240
* hard cpu unlimited
* soft cpu unlimited
EOF

cat >> /etc/sysctl.conf << EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
vm.swappiness=1
vm.max_map_count=655360
kernel.pid_max=819200
#vm.nr_hugepages = 0
kernel.core_pattern=/data/1/core-%e-%p-%t
vm.min_free_kbytes=204800
net.core.somaxconn=32768
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=10000 65535
net.ipv4.ip_forward=1
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.default.accept_source_route=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_tw_reuse=1
net.ipv4.tcp_slow_start_after_idle=0
EOF

sysctl -p

3.6 配置时间服务

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock

echo "SELINUX=disabled" > /etc/selinux/config
echo "#SELINUXTYPE=targeted " >> /etc/selinux/config
cat /etc/selinux/config
setenforce 0

systemctl stop firewalld.service
systemctl disable firewalld.service

cat >> /home/admin/.vimrc << EOF
map <F10>:set paste<CR>
map <F11>:set nopaste<CR>
EOF

cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never

cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

cat >> /etc/rc.d/rc.local << EOF
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
EOF

chmod +x /etc/rc.d/rc.local
/etc/rc.d/rc.local

# vim set_deadline.sh
for DISK in `ls /sys/block | grep "sd\?"` ; do echo deadline > /sys/block/$DISK/queue/scheduler ; done

yum -y install chrony

192.168.3.48:
/etc/chrony.conf

cp /etc/chrony.conf /etc/chrony.conf.bak
cat >> /etc/chrony.conf << EOF
server 127.127.1.0
allow 192.168.3.0/24
local stratum 10
EOF
systemctl start chronyd
systemctl enable chronyd


其他主机
cp /etc/chrony.conf /etc/chrony.conf.bak
cat >> /etc/chrony.conf << EOF
server 192.168.3.48
allow 192.168.3.0/24
local stratum 10
EOF

systemctl start chronyd
systemctl enable chronyd

timedatectl set-timezone Asia/Shanghai
chronyc -a makestep
chronyc sources -v
date

3.7 配置ssh

cd ssh
chmod u+x ssh
./ssh -user admin -hosts "observer1 observer2 observer3 observer4 observer5 observer6 ocpserver obcontrol " -advanced -exverify -confirm
chmod 600 /home/admin/.ssh/config
su - admin
ssh observer1 date
ssh observer2 date
ssh observer3 date
ssh observer4 date
ssh observer5 date
ssh observer6 date
ssh ocpserver date
ssh obcontrol date

四、 安装oceanbase

4.1 下载ob的软件 和上传软件

4.2 删除阿里云*.repo

cd /data
chown -R admin:admin soft
su - admin

cd /data/soft/
sudo rpm -ivh ob-deploy-1.2.1-9.el7.x86_64.rpm
source /etc/profile.d/obd.sh
rpm -ql `rpm -qa|grep ob-deploy`
obd mirror list

/bin/rm -rf ~/.obd/mirror/remote/*.repo

obd mirror clone /data/soft/*.rpm

obd mirror list local

4.3 配置 dbobce-3zones.yaml

cd /data
vi dbobce-3zones.yaml
:set paste

# Only need to configure when remote login is required
user:
username: admin
password: admin

oceanbase-ce:

servers:

- name: observer1

# Please don't use hostname, only IP can be supported

ip: 192.168.3.41

- name: observer2

ip: 192.168.3.42

- name: observer3

ip: 192.168.3.43

global:

# 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: enp0s3

cluster_id: 2

# please set memory limit to a suitable value which is matching resource.

memory_limit: 8G # The maximum running memory for an observer

system_memory: 3G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.

stack_size: 512K

cpu_count: 16

cache_wash_threshold: 1G

__min_full_resource_pool_memory: 268435456

workers_per_cpu_quota: 10

schema_history_expire_time: 1d

# The value of net_thread_count had better be same as cpu's core number.

net_thread_count: 4

major_freeze_duty_time: Disable

minor_freeze_times: 10

enable_separate_sys_clog: 0

enable_merge_by_turn: FALSE

#datafile_disk_percentage: 3 # The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.

datafile_size: 10G

syslog_level: WARN # System log level. The default value is INFO.

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: 10 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.

# observer cluster name, consistent with obproxy's cluster_name

appname: eduobce

root_password: 123123 # root user password, can be empty

proxyro_password: rootroot # proxyro user pasword, consistent with obproxy's observer_sys_password, can be empty

observer1:

mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.

rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.

# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.

home_path: /home/admin/oceanbase-ce

# 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

zone: zone1

observer2:

mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.

rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.

# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.

home_path: /home/admin/oceanbase-ce

# 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

zone: zone2

observer3:

mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.

rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.

# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.

home_path: /home/admin/oceanbase-ce

# 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

zone: zone3

obproxy:

servers:

- 192.168.3.41
- 192.168.3.42
- 192.168.3.43

# Set dependent components for the component.

# When the associated configurations are not done, OBD will automatically get the these configurations from the dependent components.

depends:

- oceanbase-ce

global:

listen_port: 2883 # External port. The default value is 2883.

prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.

home_path: /home/admin/obproxy

# oceanbase root server list

# format: ip:mysql_port;ip:mysql_port

rs_list: 192.168.3.41:2881;192.168.3.42:2881;192.168.3.43:2881

enable_cluster_checkout: false

# observer cluster name, consistent with oceanbase-ce's appname

cluster_name: eduobce

obproxy_sys_password: rootroot # obproxy sys user password, can be empty

observer_sys_password: rootroot # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty

4.4安装eduobce

su - admin
obd cluster deploy eduobce -c dbobce-3zones.yaml
obd cluster list

obd cluster start eduobce

4.5 安装客户端

sudo rpm -ivh libobclient-2.0.0-2.el7.x86_64.rpm obclient-2.0.0-2.el7.x86_64.rpm

IPS="192.168.3.41 192.168.3.42 192.168.3.43"
for ob in $IPS;do echo $ob; ssh $ob "netstat -ntlp" ; done

4.6 查看集群状态

[admin@obcontrol ~]$ obd cluster display eduobce
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 |
+--------------+---------+------+-------+--------+
| 192.168.3.41 | 3.1.2 | 2881 | zone1 | active |
| 192.168.3.42 | 3.1.2 | 2881 | zone2 | active |
| 192.168.3.43 | 3.1.2 | 2881 | zone3 | active |
+--------------+---------+------+-------+--------+

Connect to obproxy ok
+------------------------------------------------+
| obproxy |
+--------------+------+-----------------+--------+
| ip | port | prometheus_port | status |
+--------------+------+-----------------+--------+
| 192.168.3.41 | 2883 | 2884 | active |
| 192.168.3.42 | 2883 | 2884 | active |
| 192.168.3.43 | 2883 | 2884 | active |
+--------------+------+-----------------+--------+
[admin@obcontrol ~]$

posted on   欣欣闹天下  阅读(175)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
点击右上角即可分享
微信分享提示