云服务器Centos7系统部署mongodb和redis并远程链接及图形化界面推荐

云服务器Centos7系统部署mongodb和redis并远程链接

云服务器双十一买了一年的腾讯云的 真便宜啊,50硬盘1核2G才80好像(腾讯打钱)

mongodb

创建yum源文件:
vim /etc/yum.repos.d/mongodb-org-3.4.repo
添加以下内容:
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
然后

yum -y install mongodb-org

安装完毕后的mongodb的配置文件一般在/etc/mongod.conf
你也可以输

whereis mongod

进入配置文件修改配置

vim /etc/mongod.conf

mangodb默认是没有账户密码的,如果你开启远程链接当然要创账户设密码

https://blog.csdn.net/qq_32502511/article/details/80619277网上随便找了个

然后继续修改配置文件

打开这个 按照我的格式缩进,不然会无法重启mongo
security:
  authorization: enabled 

这个改成0.0.0.0 原来的应该是127.0.0.1 改全0即可允许任何ip登陆,也可以改成你想指定的IP地址
net:
  port: 27017
  bindIp: 0.0.0.0  # Listen to local interface only, comment to listen on all interfaces.

然后esc :wq,保存后输入systemctl restart mongod.service

chkconfig mongod on 检测是否开启成功

成功后就大功告成了,可视化图形界面推荐navicat,最新版支持mongodb,是真的好用,不过改新版界面看不习惯,筛选不如以前好用了。链接后选择云服务器的IP地址,你的账户密码端口号就链接成功了
别忘了systemctl enable mongod.service 开机自启动服务
plus:我没开防火墙,如果开的可以去打开端口号,芒果的是27017

redis

这个步骤很相似,从简来了
下载fedora的epel仓库
yum install epel-release
(这个据说很有用 但我还是小白 不知道有啥用哈哈)
安装 redis
yum install redis
安装完毕后
vim /etc/redis.conf
(这个里面很多东西 仔细找)
network里, bind 127.0.0.1 改成0.0.0.0
在security里 有个requirepass xxxx 改成你要登陆的密码,redis没有帐户名只有密码,记得取消掉#
esc :wq保存,
然后systemctl restart redis.service
system enable redis.service
完成,图形化界面推荐another redis desktop manager,之所以是another是因为这个是学习版嘿嘿,正版的你懂的。

https://github.com/qishibo/AnotherRedisDesktopManager/releases

这里下载,链接与mongo一样
下一章写python创分布式scrapy_redis 链接redis和mongo的教程! 有兴趣的兄嘚可以点去看哦(今天肯定应该可能不一定也许会能写出来)

author:Jay
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是分别针对CentOS系统下的源码一键部署安装配置Redis持久化存储、MongoDB和Nginx的脚本,以及CentOS系统下源码一键部署安装配置Redis数据库的脚本。请注意,这些脚本仅供参考,使用前请仔细检查并根据自己的需要进行相应的修改。 1. CentOS系统下源码一键部署安装配置Redis持久化存储脚本 ``` #!/bin/bash # 安装Redis相关依赖 yum install -y gcc make wget # 下载Redis源码 wget http://download.redis.io/releases/redis-6.2.5.tar.gz # 解压Redis源码 tar -zxvf redis-6.2.5.tar.gz # 进入Redis源码目录 cd redis-6.2.5 # 编译Redis源码 make # 安装Redis make install # 创建Redis配置文件 cp redis.conf /etc/redis.conf # 修改Redis配置文件 sed -i 's/daemonize no/daemonize yes/g' /etc/redis.conf sed -i 's/# requirepass foobared/requirepass yourpassword/g' /etc/redis.conf sed -i 's/# appendonly no/appendonly yes/g' /etc/redis.conf # 启动Redis服务 redis-server /etc/redis.conf ``` 2. CentOS系统下源码一键部署安装配置MongoDB脚本 ``` #!/bin/bash # 安装MongoDB相关依赖 yum install -y gcc make wget # 下载MongoDB源码 wget https://fastdl.mongodb.org/src/mongodb-src-r4.4.6.tar.gz # 解压MongoDB源码 tar -zxvf mongodb-src-r4.4.6.tar.gz # 进入MongoDB源码目录 cd mongodb-src-r4.4.6 # 编译MongoDB源码 scons # 安装MongoDB scons --prefix=/usr/local/mongodb install # 创建MongoDB配置文件 mkdir /usr/local/mongodb/conf cp ./mongod.conf /usr/local/mongodb/conf/mongod.conf # 修改MongoDB配置文件 sed -i 's/#auth = true/auth = true/g' /usr/local/mongodb/conf/mongod.conf # 启动MongoDB服务 /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/conf/mongod.conf ``` 3. CentOS系统下源码一键部署安装配置Nginx脚本 ``` #!/bin/bash # 安装Nginx相关依赖 yum install -y gcc make wget zlib-devel openssl-devel pcre-devel # 下载Nginx源码 wget http://nginx.org/download/nginx-1.21.0.tar.gz # 解压Nginx源码 tar -zxvf nginx-1.21.0.tar.gz # 进入Nginx源码目录 cd nginx-1.21.0 # 编译Nginx源码 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre make && make install # 创建Nginx配置文件 cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak cat > /usr/local/nginx/conf/nginx.conf <<EOF user www www; worker_processes auto; error_log /usr/local/nginx/logs/error.log; pid /usr/local/nginx/logs/nginx.pid; worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" ' '\$status \$body_bytes_sent "\$http_referer" ' '"\$http_user_agent" "\$http_x_forwarded_for"'; access_log /usr/local/nginx/logs/access.log main; sendfile on; tcp_nopush on; keepalive_timeout 60s; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } } server { listen 443 ssl; server_name localhost; ssl_certificate /usr/local/nginx/conf/server.crt; ssl_certificate_key /usr/local/nginx/conf/server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root html; index index.html index.htm; } } } EOF # 启动Nginx服务 /usr/local/nginx/sbin/nginx ``` 4. CentOS系统下源码一键部署安装配置Redis数据库一键自己部署安装脚本 ``` #!/bin/bash # 安装Redis相关依赖 yum install -y gcc make wget # 下载Redis源码 wget http://download.redis.io/releases/redis-6.2.5.tar.gz # 解压Redis源码 tar -zxvf redis-6.2.5.tar.gz # 进入Redis源码目录 cd redis-6.2.5 # 编译Redis源码 make # 安装Redis make install # 创建Redis目录 mkdir /usr/local/redis # 将Redis配置文件复制到Redis目录下 cp redis.conf /usr/local/redis/redis.conf # 设置Redis为后台运行模式 sed -i 's/daemonize no/daemonize yes/g' /usr/local/redis/redis.conf # 设置Redis密码 sed -i 's/# requirepass foobared/requirepass yourpassword/g' /usr/local/redis/redis.conf # 设置Redis持久化 sed -i 's/# appendonly no/appendonly yes/g' /usr/local/redis/redis.conf # 启动Redis服务 redis-server /usr/local/redis/redis.conf ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值