在虚拟机 Docker 中安装 solo, 宿主机不能访问

本贴最后更新于 1960 天前,其中的信息可能已经时移世异

问题描述:

1. window10 安装了虚拟机,系统 CentOS7, 配置了固定 ip, 宿主机和虚拟机互联测试没问题

宿主机:
ping 192.168.100.101

正在 Ping 192.168.100.101 具有 32 字节的数据:
来自 192.168.100.101 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.100.101 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.100.101 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.100.101 的回复: 字节=32 时间<1ms TTL=64

192.168.100.101 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms


虚拟机:
[root@bogon ~]# ping 192.168.100.1
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.353 ms
64 bytes from 192.168.100.1: icmp_seq=2 ttl=64 time=0.392 ms
64 bytes from 192.168.100.1: icmp_seq=3 ttl=64 time=0.396 ms
64 bytes from 192.168.100.1: icmp_seq=4 ttl=64 time=0.241 ms
64 bytes from 192.168.100.1: icmp_seq=5 ttl=64 time=0.247 ms
64 bytes from 192.168.100.1: icmp_seq=6 ttl=64 time=0.242 ms
64 bytes from 192.168.100.1: icmp_seq=7 ttl=64 time=0.450 ms
64 bytes from 192.168.100.1: icmp_seq=8 ttl=64 time=0.310 ms
64 bytes from 192.168.100.1: icmp_seq=9 ttl=64 time=0.328 ms
64 bytes from 192.168.100.1: icmp_seq=10 ttl=64 time=0.275 ms
64 bytes from 192.168.100.1: icmp_seq=11 ttl=64 time=0.252 ms

2. 虚拟机安装了最新版本 docker-ce

yum install docker-ce

3. docker 中安装了 mysql5.7, 宿主机使用 Xshell 连接正常, 账号密码: root:123456

docker pull mysql:5.7
docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456  -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

4. 在 docker 中拉取了 solo 镜像

docker pull b3log/solo

5. 运行镜像

docker run --detach --name solo --network=host \
    --env RUNTIME_DB="MYSQL" \
    --env JDBC_USERNAME="root" \
    --env JDBC_PASSWORD="123456" \
    --env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" \
    --env JDBC_URL="jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC" \
    b3log/solo --listen_port=8080 --server_scheme=http --server_host=192.168.100.101 --server_port=8080

6. mysql 中自动创建了表

图片.png

7. 查看 solo 日志正常 docker logs solo

[root@bogon ~]# docker logs solo
[INFO ]-[2019-08-11 11:54:09]-[org.b3log.solo.util.Markdowns:138]: [markdown-http] is not available, uses built-in [flexmark] for markdown processing. Please read FAQ section in user guide (https://hacpai.com/article/1492881378588) for more details.
[INFO ]-[2019-08-11 11:54:09]-[org.b3log.solo.SoloServletListener:99]: Solo is booting [ver=3.6.3, servletContainer=jetty/9.4.12.v20180830, os=Linux, isDocker=true, markdownHttpAvailable=false, pid=1, runtimeDatabase=MYSQL, runtimeMode=PRODUCTION, jdbc.username=root, jdbc.URL=jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC]
[INFO ]-[2019-08-11 11:54:09]-[com.zaxxer.hikari.HikariDataSource:110]: HikariPool-1 - Starting...
[INFO ]-[2019-08-11 11:54:10]-[com.zaxxer.hikari.HikariDataSource:123]: HikariPool-1 - Start completed.
[WARN ]-[2019-08-11 11:54:11]-[org.b3log.solo.service.InitService:161]: Solo has not been initialized, please open your browser to init Solo
[root@bogon ~]# 

8. 虚拟机访问页面,报 Latke 配置错误

[root@bogon ~]# docker run --detach --name solo --network=host     --env RUNTIME_DB="MYSQL"     --env JDBC_USERNAME="root"     --env JDBC_PASSWORD="123456"     --env JDBC_DRIVER="com.mysql.cj.jdbc.Driver"     --env JDBC_URL="jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC"     b3log/solo --listen_port=8080 --server_scheme=http --server_host=192.168.100.101 --server_port=8080
bae2dac007612761c2637fab11482f5e73b95cbdf5001862983b9e0baa16b975
[root@bogon ~]# curl 192.168.100.101:8080

<!DOCTYPE html>
<html>
<head>
        <link type="text/css" rel="stylesheet".168.100.101:8080/">on">lication/rss+xml" rel="alternate"/>h.xml">
        href="http://192.168.100.101:8080/scss/start.css?1565493586108" charset="utf-8"/>
        <meta name="robots" content="none"/>
</head>
<body>
<div class="wrap">
    <div class="content-wrap">
        <div class="content">
            <div class="main">
<h2>
    <span>欢迎使用</span>
    <a target="_blank" href="https://solo.b3log.org">
        <span class="error"> Solo</span>
    </a>
</h2>

<div id="github">
    <div class="github__icon startAction">
        <img src="http://192.168.100.101:8080/images/github.png"/>
    </div>
    <br>
    <button class="startAction">登录 GitHub 账号后即可开始使用</button><br>
    <a class="github__link" href="javascript:$('ul').slideToggle()">查看 GitHub 数据使用说明</a>
    <div class="github__text">
        <ul>
            <li>获取用户名、头像等用于初始化</li>
            <li>获取公开仓库信息用于展示</li>
            <li>不会对你的已有数据进行写入</li>
        </ul>
    </div>
    <label class="github__check">
        <input type="checkbox" id="isAgreenCheck" checked>
        <span>
            是否愿意在 GitHub 上收藏该<a href="https://github.com/b3log/solo" target="_blank">项目</a>、关注<a href="https://github.com/88250" target="_blank">开发者</a>并加入 <a href="https://github.com/b3log" target="_blank">B3log 开源组织</a>
        </span>
    </label>
</div>
<script type="text/javascript" src="http://192.168.100.101:8080/js/lib/jquery/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript">
    (function () {
        try {
            $('.startAction').click(function () {
                var isAgreen = $('#isAgreenCheck').prop('checked') ? '0' : '1'
                window.location.href = 'http://192.168.100.101:8080/oauth/github/redirect?referer=http%3A%2F%2F192.168.100.101%3A8080__' + isAgreen
                $('#github').addClass('github--loading')
            })
        } catch (e) {
            document.querySelector('.main').innerHTML = "<h2><a href='https://hacpai.com/tag/Latke' target='_blank'>Latke</a> 配置错误</h2><div style='text-align:center'><br><br><br>请浏览 <a target='_blank' href='https://hacpai.com/article/1474087427032'>Latke 配置剖析</a> 以解决该问题。<br><br><br></div>"
        }
    })()
</script>
            </div>
        </div>
    </div>
    <div class="footerWrapper">
        <div class="footer">
            Powered by <a href="https://b3log.org" target="_blank">B3log 开源</a> • <a href="https://solo.b3log.org" target="_blank">Solo</a> 3.6.3
        </div>
    </div>
</div>
</body>
</html>

<!-- Generated by Latke (https://github.com/b3log/latke) in 1441ms, 2019/08/11 11:20:06 -->[root@bogon ~]#

9. 宿主机无法访问

图片.png

10. 删除容器

[root@bogon ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                               NAMES
bae2dac00761        b3log/solo          "java -cp WEB-INF/li…"   14 minutes ago      Up 14 minutes                                                  solo
5bf4ed8b4489        mysql:5.7           "docker-entrypoint.s…"   2 days ago          Up 17 minutes              0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
01d297524c37        nginx               "nginx -g 'daemon of…"   2 days ago          Exited (0) 9 minutes ago                                       nginx
[root@bogon ~]# docker stop bae2dac00761
bae2dac00761
[root@bogon ~]# docker rm bae2dac00761
bae2dac00761
[root@bogon ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
5bf4ed8b4489        mysql:5.7           "docker-entrypoint.s…"   2 days ago          Up 18 minutes       0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
[root@bogon ~]#

11. 重新使用 H2 启动 solo

docker run --detach --name solo --volume ~/solo_h2/:/opt/solo/h2/ --publish 8080:8080 \
    --env RUNTIME_DB="H2" \
    --env JDBC_USERNAME="root" \
    --env JDBC_PASSWORD="123456" \
    --env JDBC_DRIVER="org.h2.Driver" \
    --env JDBC_URL="jdbc:h2:/opt/solo/h2/db;MODE=MYSQL" \
    b3log/solo --listen_port=8080 --server_scheme=http --server_host=192.168.100.101 --server_port=8080

12. 日志正常, 虚拟机访问报配置错误

[root@bogon ~]# docker logs solo
[INFO ]-[2019-08-11 11:37:29]-[org.b3log.solo.util.Markdowns:138]: [markdown-http] is not available, uses built-in [flexmark] for markdown processing. Please read FAQ section in user guide (https://hacpai.com/article/1492881378588) for more details.
[INFO ]-[2019-08-11 11:37:29]-[org.b3log.solo.SoloServletListener:99]: Solo is booting [ver=3.6.3, servletContainer=jetty/9.4.12.v20180830, os=Linux, isDocker=true, markdownHttpAvailable=false, pid=1, runtimeDatabase=H2, runtimeMode=PRODUCTION, jdbc.username=root, jdbc.URL=jdbc:h2:/opt/solo/h2/db;MODE=MYSQL]
[INFO ]-[2019-08-11 11:37:29]-[com.zaxxer.hikari.HikariDataSource:110]: HikariPool-1 - Starting...
[INFO ]-[2019-08-11 11:37:30]-[com.zaxxer.hikari.HikariDataSource:123]: HikariPool-1 - Start completed.
[WARN ]-[2019-08-11 11:37:30]-[org.b3log.solo.service.InitService:161]: Solo has not been initialized, please open your browser to init Solo
[INFO ]-[2019-08-11 11:47:44]-[org.b3log.solo.service.ExportService:154]: Github repo syncing....


[root@bogon ~]# curl 192.168.100.101:8080

<!DOCTYPE html>
<html>
<head>
        <link type="text/css" rel="stylesheet".168.100.101:8080/">on">lication/rss+xml" rel="alternate"/>h.xml">
        href="http://192.168.100.101:8080/scss/start.css?1565494643257" charset="utf-8"/>
        <meta name="robots" content="none"/>
</head>
<body>
<div class="wrap">
    <div class="content-wrap">
        <div class="content">
            <div class="main">
<h2>
    <span>欢迎使用</span>
    <a target="_blank" href="https://solo.b3log.org">
        <span class="error"> Solo</span>
    </a>
</h2>

<div id="github">
    <div class="github__icon startAction">
        <img src="http://192.168.100.101:8080/images/github.png"/>
    </div>
    <br>
    <button class="startAction">登录 GitHub 账号后即可开始使用</button><br>
    <a class="github__link" href="javascript:$('ul').slideToggle()">查看 GitHub 数据使用说明</a>
    <div class="github__text">
        <ul>
            <li>获取用户名、头像等用于初始化</li>
            <li>获取公开仓库信息用于展示</li>
            <li>不会对你的已有数据进行写入</li>
        </ul>
    </div>
    <label class="github__check">
        <input type="checkbox" id="isAgreenCheck" checked>
        <span>
            是否愿意在 GitHub 上收藏该<a href="https://github.com/b3log/solo" target="_blank">项目</a>、关注<a href="https://github.com/88250" target="_blank">开发者</a>并加入 <a href="https://github.com/b3log" target="_blank">B3log 开源组织</a>
        </span>
    </label>
</div>
<script type="text/javascript" src="http://192.168.100.101:8080/js/lib/jquery/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript">
    (function () {
        try {
            $('.startAction').click(function () {
                var isAgreen = $('#isAgreenCheck').prop('checked') ? '0' : '1'
                window.location.href = 'http://192.168.100.101:8080/oauth/github/redirect?referer=http%3A%2F%2F192.168.100.101%3A8080__' + isAgreen
                $('#github').addClass('github--loading')
            })
        } catch (e) {
            document.querySelector('.main').innerHTML = "<h2><a href='https://hacpai.com/tag/Latke' target='_blank'>Latke</a> 配置错误</h2><div style='text-align:center'><br><br><br>请浏览 <a target='_blank' href='https://hacpai.com/article/1474087427032'>Latke 配置剖析</a> 以解决该问题。<br><br><br></div>"
        }
    })()
</script>
            </div>
        </div>
    </div>
    <div class="footerWrapper">
        <div class="footer">
            Powered by <a href="https://b3log.org" target="_blank">B3log 开源</a> • <a href="https://solo.b3log.org" target="_blank">Solo</a> 3.6.3
        </div>
    </div>
</div>
</body>
</html>

<!-- Generated by Latke (https://github.com/b3log/latke) in 1346ms, 2019/08/11 11:37:48 -->[root@bogon ~]# 

13. 宿主机可以正常访问

图片.png

14. 我没有配置 nginx, nginx 宿主机也是可以正常访问的

图片.png

15. 如果 --server_host=localhost 配置

使用 mysql

日志正常
虚拟机访问 192.168.100.101:8080 报配置错误
虚拟机访问 localhost:8080 报配置错误
宿主机无法访问

[root@bogon ~]# docker run --detach --name solo --network=host \
>     --env RUNTIME_DB="MYSQL" \
>     --env JDBC_USERNAME="root" \
>     --env JDBC_PASSWORD="123456" \
>     --env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" \
>     --env JDBC_URL="jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC" \
>     b3log/solo --listen_port=8080 --server_scheme=http --server_host=localhost --server_port=8080
6e08aef2ca8efb1563bf6731c57c38f444f9fc23c4e214a33add0813f0ae9d88
[root@bogon ~]# docker logs solo
[INFO ]-[2019-08-11 12:03:19]-[org.b3log.solo.util.Markdowns:138]: [markdown-http] is not available, uses built-in [flexmark] for markdown processing. Please read FAQ section in user guide (https://hacpai.com/article/1492881378588) for more details.
[INFO ]-[2019-08-11 12:03:19]-[org.b3log.solo.SoloServletListener:99]: Solo is booting [ver=3.6.3, servletContainer=jetty/9.4.12.v20180830, os=Linux, isDocker=true, markdownHttpAvailable=false, pid=1, runtimeDatabase=MYSQL, runtimeMode=PRODUCTION, jdbc.username=root, jdbc.URL=jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC]
[INFO ]-[2019-08-11 12:03:19]-[com.zaxxer.hikari.HikariDataSource:110]: HikariPool-1 - Starting...
[INFO ]-[2019-08-11 12:03:20]-[com.zaxxer.hikari.HikariDataSource:123]: HikariPool-1 - Start completed.
[WARN ]-[2019-08-11 12:03:20]-[org.b3log.solo.service.InitService:161]: Solo has not been initialized, please open your browser to init Solo
[root@bogon ~]# curl 192.168.100.101:8080

<!DOCTYPE html>
<html>
<head>
        <link type="text/css" rel="stylesheet"alhost:8080/">on">lication/rss+xml" rel="alternate"/>nsearch.xml">
        href="http://localhost:8080/scss/start.css?1565496193888" charset="utf-8"/>
        <meta name="robots" content="none"/>
</head>
<body>
<div class="wrap">
    <div class="content-wrap">
        <div class="content">
            <div class="main">
<h2>
    <span>欢迎使用</span>
    <a target="_blank" href="https://solo.b3log.org">
        <span class="error"> Solo</span>
    </a>
</h2>

<div id="github">
    <div class="github__icon startAction">
        <img src="http://localhost:8080/images/github.png"/>
    </div>
    <br>
    <button class="startAction">登录 GitHub 账号后即可开始使用</button><br>
    <a class="github__link" href="javascript:$('ul').slideToggle()">查看 GitHub 数据使用说明</a>
    <div class="github__text">
        <ul>
            <li>获取用户名、头像等用于初始化</li>
            <li>获取公开仓库信息用于展示</li>
            <li>不会对你的已有数据进行写入</li>
        </ul>
    </div>
    <label class="github__check">
        <input type="checkbox" id="isAgreenCheck" checked>
        <span>
            是否愿意在 GitHub 上收藏该<a href="https://github.com/b3log/solo" target="_blank">项目</a>、关注<a href="https://github.com/88250" target="_blank">开发者</a>并加入 <a href="https://github.com/b3log" target="_blank">B3log 开源组织</a>
        </span>
    </label>
</div>
<script type="text/javascript" src="http://localhost:8080/js/lib/jquery/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript">
    (function () {
        try {
            $('.startAction').click(function () {
                var isAgreen = $('#isAgreenCheck').prop('checked') ? '0' : '1'
                window.location.href = 'http://localhost:8080/oauth/github/redirect?referer=http%3A%2F%2Flocalhost%3A8080__' + isAgreen
                $('#github').addClass('github--loading')
            })
        } catch (e) {
            document.querySelector('.main').innerHTML = "<h2><a href='https://hacpai.com/tag/Latke' target='_blank'>Latke</a> 配置错误</h2><div style='text-align:center'><br><br><br>请浏览 <a target='_blank' href='https://hacpai.com/article/1474087427032'>Latke 配置剖析</a> 以解决该问题。<br><br><br></div>"
        }
    })()
</script>
            </div>
        </div>
    </div>
    <div class="footerWrapper">
        <div class="footer">
            Powered by <a href="https://b3log.org" target="_blank">B3log 开源</a> • <a href="https://solo.b3log.org" target="_blank">Solo</a> 3.6.3
        </div>
    </div>
</div>
</body>
</html>

<!-- Generated by Latke (https://github.com/b3log/latke) in 1227ms, 2019/08/11 12:03:58 -->[root@bogon ~]# 
[root@bogon ~]# curl localhost:8080

<!DOCTYPE html>
<html>
<head>
        <link type="text/css" rel="stylesheet"alhost:8080/">on">lication/rss+xml" rel="alternate"/>nsearch.xml">
        href="http://localhost:8080/scss/start.css?1565496193888" charset="utf-8"/>
        <meta name="robots" content="none"/>
</head>
<body>
<div class="wrap">
    <div class="content-wrap">
        <div class="content">
            <div class="main">
<h2>
    <span>欢迎使用</span>
    <a target="_blank" href="https://solo.b3log.org">
        <span class="error"> Solo</span>
    </a>
</h2>

<div id="github">
    <div class="github__icon startAction">
        <img src="http://localhost:8080/images/github.png"/>
    </div>
    <br>
    <button class="startAction">登录 GitHub 账号后即可开始使用</button><br>
    <a class="github__link" href="javascript:$('ul').slideToggle()">查看 GitHub 数据使用说明</a>
    <div class="github__text">
        <ul>
            <li>获取用户名、头像等用于初始化</li>
            <li>获取公开仓库信息用于展示</li>
            <li>不会对你的已有数据进行写入</li>
        </ul>
    </div>
    <label class="github__check">
        <input type="checkbox" id="isAgreenCheck" checked>
        <span>
            是否愿意在 GitHub 上收藏该<a href="https://github.com/b3log/solo" target="_blank">项目</a>、关注<a href="https://github.com/88250" target="_blank">开发者</a>并加入 <a href="https://github.com/b3log" target="_blank">B3log 开源组织</a>
        </span>
    </label>
</div>
<script type="text/javascript" src="http://localhost:8080/js/lib/jquery/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript">
    (function () {
        try {
            $('.startAction').click(function () {
                var isAgreen = $('#isAgreenCheck').prop('checked') ? '0' : '1'
                window.location.href = 'http://localhost:8080/oauth/github/redirect?referer=http%3A%2F%2Flocalhost%3A8080__' + isAgreen
                $('#github').addClass('github--loading')
            })
        } catch (e) {
            document.querySelector('.main').innerHTML = "<h2><a href='https://hacpai.com/tag/Latke' target='_blank'>Latke</a> 配置错误</h2><div style='text-align:center'><br><br><br>请浏览 <a target='_blank' href='https://hacpai.com/article/1474087427032'>Latke 配置剖析</a> 以解决该问题。<br><br><br></div>"
        }
    })()
</script>
            </div>
        </div>
    </div>
    <div class="footerWrapper">
        <div class="footer">
            Powered by <a href="https://b3log.org" target="_blank">B3log 开源</a> • <a href="https://solo.b3log.org" target="_blank">Solo</a> 3.6.3
        </div>
    </div>
</div>
</body>
</html>

<!-- Generated by Latke (https://github.com/b3log/latke) in 47ms, 2019/08/11 12:06:51 -->[root@bogon ~]#

图片.png

使用 h2
日志正常
虚拟机访问 192.168.100.101:8080 报配置错误
虚拟机访问 localhost:8080 报配置错误
宿主机访问 报配置错误

[root@bogon ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
6e08aef2ca8e        b3log/solo          "java -cp WEB-INF/li…"   6 minutes ago       Up 6 minutes                                            solo
5bf4ed8b4489        mysql:5.7           "docker-entrypoint.s…"   2 days ago          Up 52 minutes       0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
[root@bogon ~]# docker stop 6e08aef2ca8e
6e08aef2ca8e
[root@bogon ~]# docker rm 6e08aef2ca8e
6e08aef2ca8e
[root@bogon ~]# docker run --detach --name solo --volume ~/solo_h2/:/opt/solo/h2/ --publish 8080:8080 \
>     --env RUNTIME_DB="H2" \
>     --env JDBC_USERNAME="root" \
>     --env JDBC_PASSWORD="123456" \
>     --env JDBC_DRIVER="org.h2.Driver" \
>     --env JDBC_URL="jdbc:h2:/opt/solo/h2/db;MODE=MYSQL" \
>     b3log/solo --listen_port=8080 --server_scheme=http --server_host=localhost --server_port=8080
7ac4d0b0debbb85b15a89078d3ec2c3c970782895a45348868ab3fc55dd2e04c
[root@bogon ~]# docker logs solo
[INFO ]-[2019-08-11 12:09:55]-[org.b3log.solo.util.Markdowns:138]: [markdown-http] is not available, uses built-in [flexmark] for markdown processing. Please read FAQ section in user guide (https://hacpai.com/article/1492881378588) for more details.
[INFO ]-[2019-08-11 12:09:55]-[org.b3log.solo.SoloServletListener:99]: Solo is booting [ver=3.6.3, servletContainer=jetty/9.4.12.v20180830, os=Linux, isDocker=true, markdownHttpAvailable=false, pid=1, runtimeDatabase=H2, runtimeMode=PRODUCTION, jdbc.username=root, jdbc.URL=jdbc:h2:/opt/solo/h2/db;MODE=MYSQL]
[INFO ]-[2019-08-11 12:09:55]-[com.zaxxer.hikari.HikariDataSource:110]: HikariPool-1 - Starting...
[INFO ]-[2019-08-11 12:09:56]-[com.zaxxer.hikari.HikariDataSource:123]: HikariPool-1 - Start completed.
[WARN ]-[2019-08-11 12:09:56]-[org.b3log.solo.service.InitService:161]: Solo has not been initialized, please open your browser to init Solo
[root@bogon ~]# curl 192.168.100.101:8080

<!DOCTYPE html>
<html>
<head>
        <link type="text/css" rel="stylesheet"alhost:8080/">on">lication/rss+xml" rel="alternate"/>nsearch.xml">
        href="http://localhost:8080/scss/start.css?1565496590007" charset="utf-8"/>
        <meta name="robots" content="none"/>
</head>
<body>
<div class="wrap">
    <div class="content-wrap">
        <div class="content">
            <div class="main">
<h2>
    <span>欢迎使用</span>
    <a target="_blank" href="https://solo.b3log.org">
        <span class="error"> Solo</span>
    </a>
</h2>

<div id="github">
    <div class="github__icon startAction">
        <img src="http://localhost:8080/images/github.png"/>
    </div>
    <br>
    <button class="startAction">登录 GitHub 账号后即可开始使用</button><br>
    <a class="github__link" href="javascript:$('ul').slideToggle()">查看 GitHub 数据使用说明</a>
    <div class="github__text">
        <ul>
            <li>获取用户名、头像等用于初始化</li>
            <li>获取公开仓库信息用于展示</li>
            <li>不会对你的已有数据进行写入</li>
        </ul>
    </div>
    <label class="github__check">
        <input type="checkbox" id="isAgreenCheck" checked>
        <span>
            是否愿意在 GitHub 上收藏该<a href="https://github.com/b3log/solo" target="_blank">项目</a>、关注<a href="https://github.com/88250" target="_blank">开发者</a>并加入 <a href="https://github.com/b3log" target="_blank">B3log 开源组织</a>
        </span>
    </label>
</div>
<script type="text/javascript" src="http://localhost:8080/js/lib/jquery/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript">
    (function () {
        try {
            $('.startAction').click(function () {
                var isAgreen = $('#isAgreenCheck').prop('checked') ? '0' : '1'
                window.location.href = 'http://localhost:8080/oauth/github/redirect?referer=http%3A%2F%2Flocalhost%3A8080__' + isAgreen
                $('#github').addClass('github--loading')
            })
        } catch (e) {
            document.querySelector('.main').innerHTML = "<h2><a href='https://hacpai.com/tag/Latke' target='_blank'>Latke</a> 配置错误</h2><div style='text-align:center'><br><br><br>请浏览 <a target='_blank' href='https://hacpai.com/article/1474087427032'>Latke 配置剖析</a> 以解决该问题。<br><br><br></div>"
        }
    })()
</script>
            </div>
        </div>
    </div>
    <div class="footerWrapper">
        <div class="footer">
            Powered by <a href="https://b3log.org" target="_blank">B3log 开源</a> • <a href="https://solo.b3log.org" target="_blank">Solo</a> 3.6.3
        </div>
    </div>
</div>
</body>
</html>

<!-- Generated by Latke (https://github.com/b3log/latke) in 1313ms, 2019/08/11 12:10:21 -->[root@bogon ~]# 
[root@bogon ~]# curl localhost:8080

<!DOCTYPE html>
<html>
<head>
        <link type="text/css" rel="stylesheet"alhost:8080/">on">lication/rss+xml" rel="alternate"/>nsearch.xml">
        href="http://localhost:8080/scss/start.css?1565496590007" charset="utf-8"/>
        <meta name="robots" content="none"/>
</head>
<body>
<div class="wrap">
    <div class="content-wrap">
        <div class="content">
            <div class="main">
<h2>
    <span>欢迎使用</span>
    <a target="_blank" href="https://solo.b3log.org">
        <span class="error"> Solo</span>
    </a>
</h2>

<div id="github">
    <div class="github__icon startAction">
        <img src="http://localhost:8080/images/github.png"/>
    </div>
    <br>
    <button class="startAction">登录 GitHub 账号后即可开始使用</button><br>
    <a class="github__link" href="javascript:$('ul').slideToggle()">查看 GitHub 数据使用说明</a>
    <div class="github__text">
        <ul>
            <li>获取用户名、头像等用于初始化</li>
            <li>获取公开仓库信息用于展示</li>
            <li>不会对你的已有数据进行写入</li>
        </ul>
    </div>
    <label class="github__check">
        <input type="checkbox" id="isAgreenCheck" checked>
        <span>
            是否愿意在 GitHub 上收藏该<a href="https://github.com/b3log/solo" target="_blank">项目</a>、关注<a href="https://github.com/88250" target="_blank">开发者</a>并加入 <a href="https://github.com/b3log" target="_blank">B3log 开源组织</a>
        </span>
    </label>
</div>
<script type="text/javascript" src="http://localhost:8080/js/lib/jquery/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript">
    (function () {
        try {
            $('.startAction').click(function () {
                var isAgreen = $('#isAgreenCheck').prop('checked') ? '0' : '1'
                window.location.href = 'http://localhost:8080/oauth/github/redirect?referer=http%3A%2F%2Flocalhost%3A8080__' + isAgreen
                $('#github').addClass('github--loading')
            })
        } catch (e) {
            document.querySelector('.main').innerHTML = "<h2><a href='https://hacpai.com/tag/Latke' target='_blank'>Latke</a> 配置错误</h2><div style='text-align:center'><br><br><br>请浏览 <a target='_blank' href='https://hacpai.com/article/1474087427032'>Latke 配置剖析</a> 以解决该问题。<br><br><br></div>"
        }
    })()
</script>
            </div>
        </div>
    </div>
    <div class="footerWrapper">
        <div class="footer">
            Powered by <a href="https://b3log.org" target="_blank">B3log 开源</a> • <a href="https://solo.b3log.org" target="_blank">Solo</a> 3.6.3
        </div>
    </div>
</div>
</body>
</html>

<!-- Generated by Latke (https://github.com/b3log/latke) in 26ms, 2019/08/11 12:10:34 -->[root@bogon ~]# 

图片.png

所遇问题总结

配置 --server_host=localhost

使用 h2,宿主机访问报配置错误
使用 mysql, 宿主机无法访问

配置 --server_host=192.168.100.101

使用 h2,宿主机访问一切正常
使用 mysql, 宿主机无法访问

请问有没有大佬知道问题出在哪里了呢, 求指点

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...
  • chengzime
    作者

    谢谢大佬耐心解答.

    使用 mysql 配置 --server_host=192.168.100.101 的时候, 宿主机访问 192.168.100.101:8080, 无法访问, 火狐报超时, 查看 solo 日志, 日志中无任何请求信息, 这个试了很多次了依然不行, 使用 h2 是可以正常使用的.

    我刚才在腾讯云服务器使用 mysql 配置的, 一次成功, 已经在正常使用, www.chengzime.com.cn:8888 👌

  • 其他回帖
  • 另外,第 7 步里面输出的日志有 runtimeDatabase=H2,但是你描述的是 MySQL 环境,你是不是把两个环境的输出搞混了?生产环境建议使用 MySQL,比较方便后续运维。

    1 回复
  • 第 8 步输出的 HTML 里,如果配置了 --server_host 的话静态资源的路径不应该是 localhost 的,你再看下参数是否配置正确。

  • chengzime
    作者

    问题已解决, 是因为 8080 端口未对外开放, 被防火墙拦截了

    1. 开放 8080 端口 firewall-cmd --permanent --add-port=8080/tcp
    [root@localhost conf]# firewall-cmd --permanent --add-port=8080/tcp
    success
    
    1. 重新加载开放端口 firewall-cmd --reload
    [root@localhost conf]# firewall-cmd --permanent --add-port=8080/tcp
    success
    
    1. 查询开放端口列表 firewall-cmd --list-ports
    [root@localhost conf]# firewall-cmd --permanent --add-port=8080/tcp
    success
    
    1. 宿主机访问 192.168.100.101:8080 正常.
      image.png

    2. 疑问

    之前也没开放 8080 端口, 但是使用 H2 库配置 solo 时, 宿主机却能正常访问, 使用 Mysql 配置 solo 时, 8080 端口却被防火墙拦截了, 😲 , 知道的小伙伴麻烦帮忙普及一下原因哈

  • 查看全部回帖