广州SEO优化中需要注意哪些饥荒蜘蛛陷阱阱

一、背景描述:
&&&& 我在linux& RED7上安装了mongodb,并没有修改mongodb的配置文件。然后通过另外一台电脑用pymongo连接mongodb时,报错:timeout。
&&&& ping IP 是成功的。 telnet IP 27017 的时候,提示:27017端口连接不上。
二、解决过程:
&&&&& 各种百度,远程连接mongodb失败,网上资料显示原因有两个:
&&&&& 1、mongodb的配置文件中的bind_ip 默认为127.0.0.1,默认只有本机可以连接。& 此时,需要将bind_ip配置为0.0.0.0,表示接受任何IP的连接。
&&&&& 2、防火墙阻止了27017端口。
&&&&& 于是,先修改mongodb配置文件,并重启mongod服务。
&&&&& 各种百度关闭防火墙。
&&&&& -----------但是试了很久很久,仍然telnet时提示:27017端口连接不上。
&&&&& 使用google,发现如下文章:
&&&&& 解决了我的问题。重点是由于在RED7中,关闭防火墙的命令改为:systemctl stop firewalld
&&&&& 这样后,便可以真正关闭防火墙功能。远程连接mongodb成功!
&&&&& 上述连接:/2014/07/centos-70-x64.html 内容如下(需翻 墙才可访问,所以就把原文复制过来了。望原作者莫见怪!):
[研究] CentOS 7.0 x64 的 iptables 與 firewall-cmd 防火牆
[研究] CentOS 7.0 x64 的 iptables 與 firewall-cmd 防火牆
2014-07-25
2014-08-01 修訂
CentOS 7.0 開始,服務的管理使用變成用 systemctl,例如 httpd 的使用可用下面幾種方式
# systemctl status|start|stop|restart|reload httpd
# service httpd status|start|stop|restart|reload
# apachectl configtest| graceful
service httpd 會自動重導指令到 systemctl 命令,問題不大。
但是防火牆就有問題了,因為架網站時本機測試正常,遠端關了防火牆卻仍連不上,所以做了點研究測試。
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# service httpd restart
Redirecting to /bin/systemctl restart
httpd.service
[root@localhost ~]# service httpd status
Redirecting to /bin/systemctl status
httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd. disabled)
Active: active (running) since Fri 2014-07-25 15:54:58 CST; 21s ago
Main PID: 14250 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic:
CGroup: /system.slice/httpd.service
? 14250 /usr/sbin/httpd -DFOREGROUND
? 14251 /usr/sbin/httpd -DFOREGROUND
? 14252 /usr/sbin/httpd -DFOREGROUND
? 14253 /usr/sbin/httpd -DFOREGROUND
? 14254 /usr/sbin/httpd -DFOREGROUND
? 14255 /usr/sbin/httpd -DFOREGROUND
Jul 25 15:54:58 localhost.localdomain systemd[1]: Starting The Apache HTTP Se...
Jul 25 15:54:58 localhost.localdomain httpd[14250]: AH00558: httpd: Could not...
Jul 25 15:54:58 localhost.localdomain systemd[1]: Started The Apache HTTP Ser...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# ps aux | grep httpd
0.2 209484
0:00 /usr/sbin/http
-DFOREGROUND
0.1 211568
0:00 /usr/sbin/http
-DFOREGROUND
0.1 211568
0:00 /usr/sbin/http
-DFOREGROUND
0.1 211568
0:00 /usr/sbin/http
-DFOREGROUND
0.1 211568
0:00 /usr/sbin/http
-DFOREGROUND
0.1 211568
0:00 /usr/sbin/http
-DFOREGROUND
0.0 112640
0:00 grep --color=auto httpd
[root@localhost ~]#
[root@localhost ~]# service iptables stop
Redirecting to /bin/systemctl stop
iptables.service
(下圖) 本機上測試正常
(下圖) 遠端去連失敗
檢查防火牆狀態,是 inactive 的
[root@localhost ~]# service iptables -L
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
[root@localhost ~]# service iptables status
Redirecting to /bin/systemctl status
iptables.service
iptables.service - IPv4 firewall with iptables
Loaded: loaded (/usr/lib/systemd/system/iptables. disabled)
Active: inactive (dead)
Jul 25 15:56:53 localhost.localdomain systemd[1]: Stopped IPv4 firewall with ...
Hint: Some lines were ellipsized, use -l to show in full.
列出防火牆
rules,居然仍有
[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
prot opt source
destination
ctstate RELATED,ESTABLISHED
INPUT_direct
INPUT_ZONES_SOURCE
INPUT_ZONES
reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
prot opt source
destination
ctstate RELATED,ESTABLISHED
FORWARD_direct
FORWARD_IN_ZONES_SOURCE
FORWARD_IN_ZONES
FORWARD_OUT_ZONES_SOURCE
FORWARD_OUT_ZONES
reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
prot opt source
destination
OUTPUT_direct
Chain FORWARD_IN_ZONES (1 references)
prot opt source
destination
FWDI_public
FWDI_public
Chain FORWARD_IN_ZONES_SOURCE (1 references)
prot opt source
destination
Chain FORWARD_OUT_ZONES (1 references)
prot opt source
destination
FWDO_public
FWDO_public
Chain FORWARD_OUT_ZONES_SOURCE (1 references)
prot opt source
destination
Chain FORWARD_direct (1 references)
prot opt source
destination
Chain FWDI_public (2 references)
prot opt source
destination
FWDI_public_log
FWDI_public_deny
FWDI_public_allow
Chain FWDI_public_allow (1 references)
prot opt source
destination
Chain FWDI_public_deny (1 references)
prot opt source
destination
Chain FWDI_public_log (1 references)
prot opt source
destination
Chain FWDO_public (2 references)
prot opt source
destination
FWDO_public_log
FWDO_public_deny
FWDO_public_allow
Chain FWDO_public_allow (1 references)
prot opt source
destination
Chain FWDO_public_deny (1 references)
prot opt source
destination
Chain FWDO_public_log (1 references)
prot opt source
destination
Chain INPUT_ZONES (1 references)
prot opt source
destination
Chain INPUT_ZONES_SOURCE (1 references)
prot opt source
destination
Chain INPUT_direct (1 references)
prot opt source
destination
Chain IN_public (2 references)
prot opt source
destination
IN_public_log
IN_public_deny
IN_public_allow
Chain IN_public_allow (1 references)
prot opt source
destination
tcp dpt:ssh ctstate NEW
Chain IN_public_deny (1 references)
prot opt source
destination
Chain IN_public_log (1 references)
prot opt source
destination
Chain OUTPUT_direct (1 references)
prot opt source
destination
[root@localhost ~]#
經過研究發現,應該要改用 firewall-cmd 命令
要暫時開放 http port,可執行
# firewall-cmd --add-service=http
要永久開放 http port,可執行
# firewall-cmd --permanent --add-service=http
# systemctl restart firewalld
[root@localhost ~]# systemctl stop firewalld
下面確認一下,真的停掉了
[root@localhost ~]# iptables -L
Chain INPUT (policy ACCEPT)
prot opt source
destination
Chain FORWARD (policy ACCEPT)
prot opt source
destination
Chain OUTPUT (policy ACCEPT)
prot opt source
destination
[root@localhost ~]#
(下圖) 再從遠端連上網站看看,成功了
也就是 service iptables stop 無法停掉防火牆了 ( 看下面訊息該有支援,Bug 嗎 ?)
[root@localhost ~]# service iptables
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
設定 httpd 隨作業系統啟動
systemctl enable
其他常用 firewall-cmd 命令
# firewall-cmd --state
# firewall-cmd --list-all
# firewall-cmd --list-interfaces
# firewall-cmd --get-service
# firewall-cmd --query-service service_name
# firewall-cmd --add-port=8080/tcp
[研究] CentOS 7.0 x64 的網站架設與防火牆
http://shaurong.blogspot.tw/2014/07/centos-linux-701406.html
Installing LAMP (Linux, Apache, MariaDB, PHP/PhpMyAdmin) in RHEL/CentOS 7.0
http:///install-lamp-in-centos-7/
点击查看文章内容
三、RED7中通过yum安装mongodb的官方步骤:
四、关于RED 7中关闭防火墙命令的描述如下:
阅读(...) 评论()您还可以使用以下方式登录
当前位置:&>&&>&&>& > 启动Mongo之由于目标计算机积极拒绝,无法连接--mongoDB连接错误解决办法
启动Mongo之由于目标计算机积极拒绝,无法连接--mongoDB连接错误解决办法
首先,先来张图,看看亲们有没有一样的连接问题。我是遇到过两次,觉得有必要记录下来。已备将来查看。&&分析原因:这是启动shell编辑器的时候出现的问题,我分析他可能是服务器连接的问题。解决方法:在mongo安装文件中,创建一个mongo.config文件,内容如下:&&如果每次启动mongo,都从cmd启动,那将是一件很麻烦的事情。使用批处理文件启动会比较方便。首先明白顺序,先启动mongod应用程序。然后运行刚刚建立的config文件。最后运行mongo.exe文件这样可以创建两个个bat文件。分别命名为mongodb.bat何mongodb27017.bat。&&mongodb.bat&&mongodb27017.bat最后。这样问题就被解决了。再这个过程中,首先不要讨厌问题,没有问题的学习是没有起伏的。那样才没有意思。在你分析解决得到结果的过程中,一定是得到了一种从容和韧性。加油!就爱阅读网友整理上传,为您提供最全的知识大全,期待您的分享,转载请注明出处。
欢迎转载:
推荐:    远程连接mongodb时,27017端口连接不上的解决办法_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
远程连接mongodb时,27017端口连接不上的解决办法
上传于|0|0|文档简介
&&远程连接mongodb时遇到连不上问题时的解决方法
你可能喜欢共被编辑 5 次
PHP操作MongoDB的 exception handling没有什么特别的地方,和其他的场景一样,使用try catch来处理。
PHP MongDB client包含了一些exeception的类:
MongoDB\Driver\Exception\AuthenticationException
MongoDB\Driver\Exception\BulkWriteException
MongoDB\Driver\Exception\ConnectionException
MongoDB\Driver\Exception\ConnectionTimeoutException
MongoDB\Driver\Exception\Exception
MongoDB\Driver\Exception\ExecutionTimeoutException
MongoDB\Driver\Exception\InvalidArgumentException
MongoDB\Driver\Exception\LogicException
MongoDB\Driver\Exception\RuntimeException
MongoDB\Driver\Exception\SSLConnectionException
MongoDB\Driver\Exception\UnexpectedValueException
MongoDB\Driver\Exception\WriteException
但是您估计为了简化,只会统一处理MongoDB\Exception\Exception。
正如一楼的朋友所言,可以做一些类来封装此类操作使得事情简洁一些。
Love MongoDB! Have Fun!
PHP操作MongoDB的 exception handling没有什么特别的地方,和其他的场景一样,使用try catch来处理。
PHP MongDB client包含了一些exeception的类:
MongoDB\Driver\Exception\AuthenticationException
MongoDB\Driver\Exception\BulkWriteException
MongoDB\Driver\Exception\ConnectionException
MongoDB\Driver\Exception\ConnectionTimeoutException
MongoDB\Driver\Exception\Exception
MongoDB\Driver\Exception\ExecutionTimeoutException
MongoDB\Driver\Exception\InvalidArgumentException
MongoDB\Driver\Exception\LogicException
MongoDB\Driver\Exception\RuntimeException
MongoDB\Driver\Exception\SSLConnectionException
MongoDB\Driver\Exception\UnexpectedValueException
MongoDB\Driver\Exception\WriteException
但是您估计为了简化,只会统一处理MongoDB\Exception\Exception。
正如一楼的朋友所言,可以做一些类来封装此类操作使得事情简洁一些。
PHP操作MongoDB的 exception handling没有什么特别的地方,和其他的场景一样,使用try catch来处理。
PHP MongDB client包含了一些exeception的类:
MongoDB\Driver\Exception\AuthenticationException
MongoDB\Driver\Exception\BulkWriteException
MongoDB\Driver\Exception\ConnectionException
MongoDB\Driver\Exception\ConnectionTimeoutException
MongoDB\Driver\Exception\Exception
MongoDB\Driver\Exception\ExecutionTimeoutException
MongoDB\Driver\Exception\InvalidArgumentException
MongoDB\Driver\Exception\LogicException
MongoDB\Driver\Exception\RuntimeException
MongoDB\Driver\Exception\SSLConnectionException
MongoDB\Driver\Exception\UnexpectedValueException
MongoDB\Driver\Exception\WriteException
但是您估计为了简化,只会统一处理MongoDBExceptionException。
正如一楼的朋友所言,可以做一些类来封装此类操作使得事情简洁一些。
PHP操作MongoDB的 exception handling没有什么特别的地方,和其他的场景一样,使用try catch来处理。
PHP MongDB client包含了一些exeception的类:
MongoDB\Exception\BadMethodCallException
MongoDB\Exception\InvalidArgumentException
MongoDB\Exception\UnexpectedValueException
MongoDB\Exception\UnsupportedException
MongoDB\GridFS\Exception\CorruptFileException
MongoDB\GridFS\Exception\FileNotFoundException
MongoDB\Exception\Exception
MongoDB\Exception\RuntimeException
但是您估计为了简化,只会统一处理MongoDBExceptionException。
正如一楼的朋友所言,可以做一些类来封装此类操作使得事情简洁一些。
PHP操作MongoDB的 exception handling没有什么特别的地方,和其他的场景一样,使用try catch来处理。
正如一楼的朋友所言,可以做一些类来封装此类操作使得事情简洁一些。
我要该,理由是:
扫扫下载 App问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
明明db.auth返回1,可是mongo -u admin -p就是失败,为啥呢?
andyliwr@andyliwrPC:~/文档/xiaodiFTP/nodejs/xiaodiTodoList$ mongo
MongoDB shell version: 2.6.10
connecting to: test
& use admin
switched to db admin
& db.auth("admin", "123456")
& db.auth("admin", "1234535")
Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 }
andyliwr@andyliwrPC:~/文档/xiaodiFTP/nodejs/xiaodiTodoList$ mongo -u admin -p
MongoDB shell version: 2.6.10
Enter password:
connecting to: test
T22:41:33.520+0800 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1287
exception: login failed
来源: MongoDB 技术问答
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
你的用户是在admin这个数据库中的,而默认连接的数据库是test,自然认证会失败,你应该在使用mongo连接时指定数据库为admin,这样才能进行正确的认证:
mongo -u admin -p admin
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
mongo localhost/admin -u admin -p
mongo -u admin -p --authenticationDatabase admin
都是为了指定使用admin这个库中的用户来认证。有困难找,或者看一下--help。我机器上的是3.2,可能会和你的2.6有些出入。
$ mongo --help
MongoDB shell version: 3.2.6
usage: mongo [options] [db address] [file names (ending in .js)]
db address can be:
foo database on local machine
192.169.0.5/foo
foo database on 192.168.0.5 machine
192.169.0.5:9999/foo
foo database on 192.168.0.5 machine on port 9999
run the shell after executing files
don't connect to mongod on startup - no
'db address' arg expected
will not run the ".mongorc.js" file on
be less chatty
--port arg
port to connect to
--host arg
server to connect to
--eval arg
evaluate javascript
-h [ --help ]
show this usage information
show version information
increase verbosity
enable IPv6 support (disabled by default)
--disableJavaScriptJIT
disable the Javascript Just In Time
--enableJavaScriptProtection
disable automatic JavaScript function
marshalling
use SSL for all connections
--sslCAFile arg
Certificate Authority file for SSL
--sslPEMKeyFile arg
PEM certificate/key file for SSL
--sslPEMKeyPassword arg
password for key in PEM file for SSL
--sslCRLFile arg
Certificate Revocation List file for SSL
--sslAllowInvalidHostnames
allow connections to servers with
non-matching hostnames
--sslAllowInvalidCertificates
allow connections to servers with invalid
certificates
--sslFIPSMode
activate FIPS 140-2 mode at startup
Authentication Options:
-u [ --username ] arg
username for authentication
-p [ --password ] arg
password for authentication
--authenticationDatabase arg
user source (defaults to dbname)
--authenticationMechanism arg
authentication mechanism
--gssapiServiceName arg (=mongodb)
Service name to use when authenticating
using GSSAPI/Kerberos
--gssapiHostName arg
Remote host name to use for purpose of
GSSAPI/Kerberos authentication
同步到新浪微博
分享到微博?
你好!看起来你挺喜欢这个内容,但是你还没有注册帐号。 当你创建了帐号,我们能准确地追踪你关注的问题,在有新答案或内容的时候收到网页和邮件通知。还能直接向作者咨询更多细节。如果上面的内容有帮助,记得点赞 (????)? 表示感谢。
明天提醒我
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:
扫扫下载 App

我要回帖

更多关于 饥荒蜘蛛陷阱 的文章

 

随机推荐