CentOS 8.2上安装Cassandra Web部署
在本文中,您将学习如何在CentOS 8上安装Cassandra Web界面。
什么是Cassandra Web?
Cassandra Web是带有AngularJS和服务器发送的事件的Apache Cassandra的Web界面。Cassandra Web是免费的开放源代码,其源代码可在GitHub上获得。
Cassandra Web是功能有限的非常简单的应用程序,但是它可以通过单个Web界面实现监视整个Apache Cassandra集群的目的。
环境规格:
-
CPU:3.4 GHz(2核)
-
内存:2 GB
-
储存空间:20 GB
-
作业系统:CentOS 8.2
-
主机名: cassandra.liangglab.cn
-
IP地址:192.168.6.65/24
前面我们已经安装 CentOS 8.2上安装Apache Cassandra 3.11.9 所以我们现在不需要安装Cassandra,我们现在直接在这台机器上安装Cassandra Web
第一步:CentOS 8上安装Ruby
我们需要Rubygems软件包管理器才能在CentOS 8上安装Cassandra Web,我们正在使用dnf命令 安装Ruby 安装相关软件包。
[root@cassandra ~]# dnf install -y rubygems ruby-devel
Last metadata expiration check: 1:31:25 ago on Mon 21 Dec 2020 06:10:25 PM CST.
Dependencies resolved.
====================================================================================================================
Package Architecture Version Repository Size
====================================================================================================================
Installing:
ruby-devel x86_64 2.5.5-105.module_el8.1.0+214+9be47fd7 AppStream 126 k
rubygems noarch 2.7.6.2-105.module_el8.1.0+214+9be47fd7 AppStream 308 k
Installing dependencies:
ruby x86_64 2.5.5-105.module_el8.1.0+214+9be47fd7 AppStream 86 k
ruby-irb noarch 2.5.5-105.module_el8.1.0+214+9be47fd7 AppStream 102 k
ruby-libs x86_64 2.5.5-105.module_el8.1.0+214+9be47fd7 AppStream 2.9 M
rubygem-json x86_64 2.1.0-105.module_el8.1.0+214+9be47fd7 AppStream 90 k
rubygem-openssl x86_64 2.1.2-105.module_el8.1.0+214+9be47fd7 AppStream 190 k
rubygem-psych x86_64 3.0.2-105.module_el8.1.0+214+9be47fd7 AppStream 95 k
Installing weak dependencies:
rubygem-bigdecimal x86_64 1.3.4-105.module_el8.1.0+214+9be47fd7 AppStream 97 k
rubygem-did_you_mean noarch 1.2.0-105.module_el8.1.0+214+9be47fd7 AppStream 90 k
rubygem-io-console x86_64 0.4.6-105.module_el8.1.0+214+9be47fd7 AppStream 66 k
rubygem-rdoc noarch 6.0.1-105.module_el8.1.0+214+9be47fd7 AppStream 486 k
Enabling module streams:
ruby 2.5
Transaction Summary
====================================================================================================================
Install 12 Packages
Total download size: 4.6 M
Installed size: 15 M
Downloading Packages:
(1/12): ruby-devel-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64.rpm 6.3 MB/s | 126 kB 00:00
(2/12): ruby-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64.rpm 3.9 MB/s | 86 kB 00:00
(3/12): ruby-irb-2.5.5-105.module_el8.1.0+214+9be47fd7.noarch.rpm 4.4 MB/s | 102 kB 00:00
(4/12): rubygem-bigdecimal-1.3.4-105.module_el8.1.0+214+9be47fd7.x86_64.rpm 5.2 MB/s | 97 kB 00:00
(5/12): rubygem-did_you_mean-1.2.0-105.module_el8.1.0+214+9be47fd7.noarch.rpm 4.2 MB/s | 90 kB 00:00
(6/12): rubygem-io-console-0.4.6-105.module_el8.1.0+214+9be47fd7.x86_64.rpm 14 MB/s | 66 kB 00:00
(7/12): rubygem-json-2.1.0-105.module_el8.1.0+214+9be47fd7.x86_64.rpm 20 MB/s | 90 kB 00:00
(8/12): rubygem-openssl-2.1.2-105.module_el8.1.0+214+9be47fd7.x86_64.rpm 21 MB/s | 190 kB 00:00
(9/12): rubygem-psych-3.0.2-105.module_el8.1.0+214+9be47fd7.x86_64.rpm 10 MB/s | 95 kB 00:00
(10/12): rubygems-2.7.6.2-105.module_el8.1.0+214+9be47fd7.noarch.rpm 20 MB/s | 308 kB 00:00
(11/12): rubygem-rdoc-6.0.1-105.module_el8.1.0+214+9be47fd7.noarch.rpm 19 MB/s | 486 kB 00:00
(12/12): ruby-libs-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64.rpm 38 MB/s | 2.9 MB 00:00
--------------------------------------------------------------------------------------------------------------------
Total 47 MB/s | 4.6 MB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : ruby-libs-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64 1/12
Installing : ruby-irb-2.5.5-105.module_el8.1.0+214+9be47fd7.noarch 2/12
Installing : rubygem-bigdecimal-1.3.4-105.module_el8.1.0+214+9be47fd7.x86_64 3/12
Installing : rubygem-did_you_mean-1.2.0-105.module_el8.1.0+214+9be47fd7.noarch 4/12
Installing : rubygem-io-console-0.4.6-105.module_el8.1.0+214+9be47fd7.x86_64 5/12
Installing : rubygem-json-2.1.0-105.module_el8.1.0+214+9be47fd7.x86_64 6/12
Installing : rubygem-openssl-2.1.2-105.module_el8.1.0+214+9be47fd7.x86_64 7/12
Installing : rubygem-psych-3.0.2-105.module_el8.1.0+214+9be47fd7.x86_64 8/12
Installing : rubygem-rdoc-6.0.1-105.module_el8.1.0+214+9be47fd7.noarch 9/12
Installing : rubygems-2.7.6.2-105.module_el8.1.0+214+9be47fd7.noarch 10/12
Installing : ruby-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64 11/12
Installing : ruby-devel-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64 12/12
Running scriptlet: ruby-devel-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64 12/12
Verifying : ruby-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64 1/12
Verifying : ruby-devel-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64 2/12
Verifying : ruby-irb-2.5.5-105.module_el8.1.0+214+9be47fd7.noarch 3/12
Verifying : ruby-libs-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64 4/12
Verifying : rubygem-bigdecimal-1.3.4-105.module_el8.1.0+214+9be47fd7.x86_64 5/12
Verifying : rubygem-did_you_mean-1.2.0-105.module_el8.1.0+214+9be47fd7.noarch 6/12
Verifying : rubygem-io-console-0.4.6-105.module_el8.1.0+214+9be47fd7.x86_64 7/12
Verifying : rubygem-json-2.1.0-105.module_el8.1.0+214+9be47fd7.x86_64 8/12
Verifying : rubygem-openssl-2.1.2-105.module_el8.1.0+214+9be47fd7.x86_64 9/12
Verifying : rubygem-psych-3.0.2-105.module_el8.1.0+214+9be47fd7.x86_64 10/12
Verifying : rubygem-rdoc-6.0.1-105.module_el8.1.0+214+9be47fd7.noarch 11/12
Verifying : rubygems-2.7.6.2-105.module_el8.1.0+214+9be47fd7.noarch 12/12
Installed products updated.
Installed:
ruby-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64
ruby-devel-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64
ruby-irb-2.5.5-105.module_el8.1.0+214+9be47fd7.noarch
ruby-libs-2.5.5-105.module_el8.1.0+214+9be47fd7.x86_64
rubygem-bigdecimal-1.3.4-105.module_el8.1.0+214+9be47fd7.x86_64
rubygem-did_you_mean-1.2.0-105.module_el8.1.0+214+9be47fd7.noarch
rubygem-io-console-0.4.6-105.module_el8.1.0+214+9be47fd7.x86_64
rubygem-json-2.1.0-105.module_el8.1.0+214+9be47fd7.x86_64
rubygem-openssl-2.1.2-105.module_el8.1.0+214+9be47fd7.x86_64
rubygem-psych-3.0.2-105.module_el8.1.0+214+9be47fd7.x86_64
rubygem-rdoc-6.0.1-105.module_el8.1.0+214+9be47fd7.noarch
rubygems-2.7.6.2-105.module_el8.1.0+214+9be47fd7.noarch
Complete!
[root@cassandra ~]#
第二步:安装Cassandra Web必备软件包
要使用rubygems安装Cassandra Web ,我们需要make和build软件包。我们正在使用单个dnf命令安装所有必需的软件包。
[root@cassandra ~]# dnf install -y make gcc gcc-c++ redhat-rpm-config
Last metadata expiration check: 1:32:13 ago on Mon 21 Dec 2020 06:10:25 PM CST.
Package make-1:4.2.1-10.el8.x86_64 is already installed.
Package gcc-8.3.1-5.el8.0.2.x86_64 is already installed.
Package redhat-rpm-config-122-1.el8.noarch is already installed.
Dependencies resolved.
====================================================================================================================
Package Architecture Version Repository Size
====================================================================================================================
Installing:
gcc-c++ x86_64 8.3.1-5.el8.0.2 AppStream 12 M
Installing dependencies:
libstdc++-devel x86_64 8.3.1-5.el8.0.2 AppStream 2.0 M
Transaction Summary
====================================================================================================================
Install 2 Packages
Total download size: 14 M
Installed size: 42 M
Downloading Packages:
(1/2): libstdc++-devel-8.3.1-5.el8.0.2.x86_64.rpm 27 MB/s | 2.0 MB 00:00
(2/2): gcc-c++-8.3.1-5.el8.0.2.x86_64.rpm 57 MB/s | 12 MB 00:00
--------------------------------------------------------------------------------------------------------------------
Total 66 MB/s | 14 MB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : libstdc++-devel-8.3.1-5.el8.0.2.x86_64 1/2
Installing : gcc-c++-8.3.1-5.el8.0.2.x86_64 2/2
Running scriptlet: gcc-c++-8.3.1-5.el8.0.2.x86_64 2/2
Verifying : gcc-c++-8.3.1-5.el8.0.2.x86_64 1/2
Verifying : libstdc++-devel-8.3.1-5.el8.0.2.x86_64 2/2
Installed products updated.
Installed:
gcc-c++-8.3.1-5.el8.0.2.x86_64 libstdc++-devel-8.3.1-5.el8.0.2.x86_64
Complete!
[root@cassandra ~]#
第三步:安装Cassandra Web界面
我们准备安装Cassandra Web界面。我们正在执行以下gem命令以将其安装在我们的CentOS 8服务器上。
[root@cassandra ~]# gem install cassandra-web
Fetching: lz4-ruby-0.3.3.gem (100%)
Building native extensions. This could take a while...
Successfully installed lz4-ruby-0.3.3
Fetching: rack-1.6.13.gem (100%)
Successfully installed rack-1.6.13
Fetching: rack-protection-1.5.5.gem (100%)
Successfully installed rack-protection-1.5.5
Fetching: tilt-2.0.10.gem (100%)
Successfully installed tilt-2.0.10
Fetching: sinatra-1.4.8.gem (100%)
Successfully installed sinatra-1.4.8
Fetching: rack-parser-0.7.0.gem (100%)
Successfully installed rack-parser-0.7.0
Fetching: rack-cors-0.4.1.gem (100%)
Successfully installed rack-cors-0.4.1
Fetching: eventmachine-1.2.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed eventmachine-1.2.7
Fetching: daemons-1.3.1.gem (100%)
Successfully installed daemons-1.3.1
Fetching: thin-1.8.0.gem (100%)
Building native extensions. This could take a while...
Successfully installed thin-1.8.0
Fetching: ione-1.2.4.gem (100%)
Successfully installed ione-1.2.4
Fetching: cassandra-driver-3.2.5.gem (100%)
Building native extensions. This could take a while...
Successfully installed cassandra-driver-3.2.5
Fetching: cassandra-web-0.5.0.gem (100%)
Successfully installed cassandra-web-0.5.0
13 gems installed
Cassandra Web界面也需要Ruby Bundler gem。因此,我们现在也正在安装它。
[root@cassandra ~]# gem install bundler
Fetching: bundler-2.2.2.gem (100%)
Successfully installed bundler-2.2.2
1 gem installed
第四步:Cassandra Web配置CentOS 8防火墙
Cassandra Web界面默认端口3000/tcp上运行。因此,我们需要在Linux防火墙中允许3000端口流入。
[root@cassandra ~]# firewall-cmd --permanent --add-port=3000/tcp
success
[root@cassandra ~]# firewall-cmd --reload
success
第五步:Cassandra Web创建数据库用户
要访问Apache Cassandra节点,Cassandra Web界面需要一个Admin用户。因此,我们为此创建一个数据库用户,如下所示。
[root@cassandra ~]# cqlsh -u lianglab -p lianglab@123
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.9 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
lianglab@cqlsh>
lianglab@cqlsh> CREATE ROLE cassweb WITH PASSWORD = 'Cassweb@123' AND SUPERUSER = true AND LOGIN = true;
lianglab@cqlsh> exit
[root@cassandra ~]#
第六步:Cassandra Web界面启动
通过使用以下命令语法来启动Cassandra Web界面。如果已在另一个节点上运行Apache Cassandra数据库,则必须根据您的环境从以下命令更改主机地址。
[root@cassandra ~]# cassandra-web --hosts '127.0.0.1' --port '9042' --username 'cassweb' --password 'Cassweb@123'
I, [2020-12-21T19:49:50.969783 #58769] INFO -- : Establishing control connection
I, [2020-12-21T19:49:51.089534 #58769] INFO -- : Refreshing connected host's metadata
I, [2020-12-21T19:49:51.096746 #58769] INFO -- : Completed refreshing connected host's metadata
I, [2020-12-21T19:49:51.098335 #58769] INFO -- : Refreshing peers metadata
I, [2020-12-21T19:49:51.099710 #58769] INFO -- : Completed refreshing peers metadata
I, [2020-12-21T19:49:51.099780 #58769] INFO -- : Refreshing schema
I, [2020-12-21T19:49:51.122821 #58769] INFO -- : Schema refreshed
I, [2020-12-21T19:49:51.122871 #58769] INFO -- : Control connection established
I, [2020-12-21T19:49:51.123174 #58769] INFO -- : Creating session
I, [2020-12-21T19:49:51.214760 #58769] INFO -- : Session created
2020-12-21 19:49:51 +0800 Thin web server (v1.8.0 codename Possessed Pickle)
2020-12-21 19:49:51 +0800 Maximum connections set to 1024
2020-12-21 19:49:51 +0800 Listening on 0.0.0.0:3000, CTRL+C to stop
在客户端的浏览器 打开URL http://192.168.6.65:3000,Cassandra Web界面运行正常。
Cassandra Web不提供任何用户身份验证。但是,我们可以配置HTTP基本身份验证来控制对Cassandra Web界面的访问。
单击system_schema。
CTRL+C to 会停止3000端口监听,需要创建一个Cassandra web服务
第七步:Cassandra Web创建系统服务
为了自动启动Cassandra Web应用程序,我们可以创建一个简单的Systemd服务。
为Cassandra Web创建一个Systemd服务文件。
[root@cassandra ~]# vi /usr/lib/systemd/system/cassweb.service
添加以下代码行。
[Unit]
Description=Cassandra Web
[Service]
Type=simple
ExecStart=cassandra-web --hosts '127.0.0.1' --port '9042' --username 'cassweb' --password 'Cassweb@123'
[Install]
WantedBy=multi-user.target
启动Cassandra Web服务。
[root@cassandra ~]# systemctl enable --now cassweb.service
Created symlink /etc/systemd/system/multi-user.target.wants/cassweb.service → /usr/lib/systemd/system/cassweb.service.
[root@cassandra ~]# netstat -antpl | grep 3000
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 59130/ruby
[root@cassandra ~]#
Cassandra Web服务已启动。
广告时间:
- 关于我 :全国7*24高效代维服务
- 微信:lianglab
- QQ:867266199
- 淘宝店:全国7*24高效代维服务
- 全国高效代维:为中小型企业,提供云计算咨询代维、架构设计、降低成本。
结论:
我们的Cassandra Web界面已经在CentOS 8上安装完成,并且运行良好。