Centos7安装thingsboard

Centos7 安装 thingsboard

安装必要工具

# Install wget
sudo yum install -y wget
# Add latest EPEL release for CentOS 7
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

安装 Java 11(OpenJDK)

sudo yum install -y java-11-openjdk-devel
# 选择jdk11
sudo alternatives --config java

安装 thingsboard 服务

cd ~/download/thingsboard
wget https://github.com/thingsboard/thingsboard/releases/download/v3.4.1/thingsboard-3.4.1.rpm
sudo rpm -Uvh thingsboard-3.4.1.rpm

配置数据库(PostgreSQL方式)

支持三种方式:PostgreSQL, PostgreSQL+Cassandra, PostgreSQL + TimescaleDB

#安装postgresql-12
# Update your system
sudo yum update -y
# Install the repository RPM (for CentOS 7):
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install packages
sudo yum install -y epel-release yum-utils
sudo yum-config-manager --enable pgdg12
sudo yum install -y postgresql12-server postgresql12
# Initialize your PostgreSQL DB
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl start postgresql-12

# Set password "postgres"
sudo su - postgres
postgres=# \password
Enter new password for user "postgres": 
Enter it again: 
postgres=# \q
-bash-4.2$ "Ctrl+D"

# 对postgres用户使用MD5认证,允许远程访问
sudo vi /var/lib/pgsql/12/data/postgresql.conf
listen_addresses = '*'

sudo vi /var/lib/pgsql/12/data/pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             0.0.0.0/0               md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

sudo systemctl restart postgresql-12
# 创建thingsboard数据库,密码为“postgres”
psql -U postgres -d postgres -h 127.0.0.1 -W
CREATE DATABASE thingsboard;

# 配置thingsboard,内容添加
sudo vi /etc/thingsboard/conf/thingsboard.conf
# DB Configuration
export DATABASE_ENTITIES_TYPE=sql
export DATABASE_TS_TYPE=sql
export SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect
export SPRING_DRIVER_CLASS_NAME=org.postgresql.Driver
export SPRING_DATASOURCE_URL=jdbc:postgresql://192.168.2.101:5432/thingsboard
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=postgres
export SPRING_DATASOURCE_MAXIMUM_POOL_SIZE=5
# Specify partitioning size for timestamp key-value storage. Allowed values: DAYS, MONTHS, YEARS, INDEFINITE.
export SQL_POSTGRES_TS_KV_PARTITIONING=MONTHS

配置消息队列(Kafka方式)

# 安装zookeeper
sudo mkdir -p /data/zookeeper/data
sudo mkdir -p /data/zookeeper/logs
sudo touch /data/zookeeper/data/myid
sudo su -
echo 1 > /data/zookeeper/data/myid
exit
cd /opt/install/zookeeper-3.4.6/conf/
cp zoo_sample.cfg zoo.cfg

vi zoo.cfg
...
dataDir=/data/zookeeper/data
dataLogDir=/data/zookeeper/logs
clientPort=2181
maxClientCnxns=60
autopurge.snapRetainCount=3
autopurge.purgeInterval=1
# Information exchange port
server.1=192.168.2.101:2187:2187

sudo vi /etc/systemd/system/zookeeper.service
[Unit]
Description=zookeeper.service
After=network.target
ConditionPathExists=/opt/install/zookeeper-3.4.6/conf/zoo.cfg
[Service]
Type=forking
User=root
Group=root
ExecStart=/opt/install/zookeeper-3.4.6/bin/zkServer.sh start
ExecStop=/opt/install/zookeeper-3.4.6/bin/zkServer.sh stop
TimeoutStartSec=0
TimeoutStopSec=0
[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload

# 安装kafka
wget https://archive.apache.org/dist/kafka/2.1.1/kafka_2.11-2.1.1.tgz
tar -zxf kafka_2.11-2.1.1.tgz
mv kafka_2.11-2.1.1 /opt/install/

vi /opt/install/kafka_2.11-2.1.1/config/server.properties
listeners=PLAINTEXT://192.168.2.101:9092
zookeeper.connect=192.168.2.101:2181

sudo vi /etc/systemd/system/kafka.service
[Unit]
Description=kafka.service
After=network.target zookeeper.service
ConditionPathExists=/opt/install/kafka_2.11-2.1.1/config/server.properties
[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/install/kafka_2.11-2.1.1/bin/kafka-server-start.sh /opt/install/kafka_2.11-2.1.1/config/server.properties
ExecStop=/opt/install/kafka_2.11-2.1.1/bin/kafka-server-stop.sh
TimeoutStartSec=0
TimeoutStopSec=0
[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload

# 配置thingsboard,内容添加
sudo vi /etc/thingsboard/conf/thingsboard.conf
# Kafka Configuration
export TB_QUEUE_TYPE=kafka
export TB_KAFKA_SERVERS=192.168.2.101:9092

安装thingsboard系统服务并加载demo数据

sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo

启停thingsboard及其依赖服务

sudo systemctl start zookeeper
sudo systemctl start kafka
sudo systemctl start postgresql-12
sudo systemctl start thingsboard

sudo systemctl stop thingsboard
sudo systemctl stop postgresql-12
sudo systemctl stop kafka
sudo systemctl stop zookeeper

登录

URL:http://192.168.2.101:8080/
# 默认凭证
系统管理员: sysadmin@thingsboard.org / sysadmin
租户管理员: tenant@thingsboard.org / tenant
客户: customer@thingsboard.org / customer
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值