1. 环境准备
konga 是Kong的图形化管理工具,使用NodeJs编写。
由于机房内部无法连接,从Konga源码构建比较麻烦,这里我使用 Konga的Docker镜像
2. 安装
2.1 安装docker
tar -xvf docker-18.09.6.tgz
将解压出来的文件全部拷贝到/usr/local/bin
cd docker
cp * /usr/bin/
启动Dockerd 进程
dockerd &
可以修改一下Docker的默认存放镜像和容器的存放目录
修改Docker工作目录:
# 查看一下当前Docker的工作目录
[root@sybj-int-25 ~]# docker info | grep 'Docker Root'
Docker Root Dir: /var/lib/docker
mv /var/lib/docker /opt/ylbzj/
ln -s /opt/ylbzj/docker /var/lib/docker
2.2 启动Konga容器
将下载下来的包导入Docker
docker load -i kong-docker-image.tar
查看导进来的容器
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pantsel/konga 0.14.7 bb9636231c3d 5 months ago 398MB
konga 默认使用本地json文件存储数据,生成环境需要换成mysql或者其他数据库,这里咱们使用Mysql,在mysql数据库新建一个名为konga的数据库实例,然后开始初始化数据库,建立Mysql表结构。
[root@sybj-int-25 ~]# docker run --rm pantsel/konga:0.14.7 -c prepare -a mysql -u mysql://username:password@10.0.3.29:3306/konga
debug: Preparing database...
Using MySQL DB Adapter.
Creating database `konga` if not exists.
(node:6) [DEP0096] DeprecationWarning: timers.unenroll() is deprecated. Please use clearTimeout instead.
(node:6) [DEP0095] DeprecationWarning: timers.enroll() is deprecated. Please use setTimeout instead.
debug: Hook:api_health_checks:process() called
debug: Hook:health_checks:process() called
debug: Hook:start-scheduled-snapshots:process() called
debug: Hook:upstream_health_checks:process() called
debug: Hook:user_events_hook:process() called
debug: Seeding User...
debug: User seed planted
debug: Seeding Kongnode...
debug: Kongnode seed planted
debug: Seeding Emailtransport...
debug: Emailtransport seed planted
debug: Database migrations completed!
如果你的数据库密码有URL特殊字符。需要进行url encode。
以上步骤已经初始化好了Mysql数据库表结构。
启动konga容器
docker run -d -p 1337:1337 -e "TOKEN_SECRET=123qwe" -e "DB_ADAPTER=mysql" -e "DB_URI=mysql://username:password@yourIP:3306/konga" -e "NODE_ENV=production" --name konga pantsel/konga:0.14.7
启动Dockerd 进程的时候,自动启动容器
docker container update --restart=always konga
开机启动Dockerd
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
安装完成。
3. 设置开机启动
3.1 cassandra 开机启动
编写cassandra.service
vim /usr/lib/systemd/system/cassandra.service
Description=Cassandra Server Service
After=network.service
[Service]
Type=simple
Environment=JAVA_HOME=/usr/local/jdk1.8.0_231
PIDFile=/opt/ylbzj/apache-cassandra-3.11.6/bin/cassandra.pid
User=cassandra
Group=cassandra
ExecStart=/opt/ylbzj/apache-cassandra-3.11.6/bin/cassandra -p /opt/ylbzj/apache-cassandra-3.11.6/bin/cassandra.pid
ExecStop=/bin/kill -s QUIT $MAINPID
[Install]
WantedBy=multi-user.target
设置开机启动
systemctl daemon-reload
systemctl enable cassandra