Skip to content

Commit

Permalink
add couchDB
Browse files Browse the repository at this point in the history
  • Loading branch information
qufei committed Apr 13, 2019
1 parent 697c269 commit c2908fa
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 4 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
* [MongoDB](https://www.mongodb.com/)
* [Redis](https://redis.io/)
* [RocksDB](https://github.com/facebook/rocksdb/)[RocksDB中文网](https://rocksdb.org.cn/)
* [CouchDB](http://couchdb.apache.org/)
- **Search Engines**
* [ElasticSearch](https://www.elastic.co/)
* [Solr](http://lucene.apache.org/solr/)
Expand Down Expand Up @@ -189,7 +190,6 @@
* `[Nginx]` [实现http2协议](#实现http2协议)

## DevOps

- **Node.js生产环境完整部署指南** [[more]](/docs/devops/node-deploy.md)
- ```[Node.js]``` [用户权限管理及登陆服务器](/docs/devops/node-deploy.md#用户权限管理及登陆服务器)
- ```[Node.js]``` [增强服务器安全等级](/docs/devops/node-deploy.md#增强服务器安全等级)
Expand All @@ -202,20 +202,18 @@
- ```[NPM]``` [nnpm注册登录](/docs/devops/npm-deploy.md#npm注册登录)
- ```[NPM]``` [npm module 发布](/docs/devops/npm-deploy.md#npm-module-发布)
- ```[NPM]``` [可能遇到的问题](/docs/devops/npm-deploy.md#可能遇到的问题)

- **Linux系统问题汇总** [[more]](/docs/devops/linux-question.md)

## 工具

- **Git** [[more]](/docs/tools/git.md)
- ```[Git]``` [Git常用命令及日常问题集锦](/docs/tools/git.md)
- **SEO** [[more]](/docs/tools/seo.md)
- ```[SEO实战]``` [SEO网站优化title设置与快速排名](/docs/tools/seo.md)

## 资料

- **书籍推荐** [[more]](/docs/materials/book.md)
- **Blog推荐** [[more]](/docs/materials/blog.md)
- **文章推荐** [[more]](/docs/materials/article.md)

<hr/>

Expand Down
Binary file added docs/devops/img/couchdb_futon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions docs/devops/lan-npm-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# NPM局域网搭建

## 基础环境搭建

#### **Erlang安装**

- **获取Erlang安装包**

```
sudo wget http://www.rabbitmq.com/releases/erlang/erlang-18.3-1.el6.x86_64.rpm
```

- **Centos rpm一键安装**

这里采用rpm一键安装,centos 执行命令 ```rpm -ivh erlang-18.3-1.el6.x86_64.rpm```,在```ubuntu```中不支持此命令```rpm```,使用```rpm```提示如下信息:

```bash
rpm: RPM should not be used directly install RPM packages, use Alien instead!
rpm: However assuming you know what you are doing...
error: Failed dependencies:
```

- **```ubuntu```系统rpm一键安装解决方案**
1. 安装```alien```,执行命令```sudo apt-get install alien```
2. 转换```rpm```包为```.deb```格式,执行命令```sudo alien package.rpm```其中```package.rpm```为你的包名
3. 通过dpkg安装,```sudo dpkg -i package.deb```

- **检查是否安装成功**
```
$ erl
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V7.3 (abort with ^G)
1>
```

#### **CouchDB安装**

执行以下命令将在您的服务器上安装CouchDB和Futon

```
mkdir /data
cd /data
sudo wget http://mirrors.tuna.tsinghua.edu.cn/apache/couchdb/source/2.3.1/apache-couchdb-2.3.1.tar.gz
$ sudo tar xfv apache-couchdb-2.3.1.tar.gz
$ sudo apache-couchdb-2.3.1
$ sudo ./configure
```

```
$ sudo apt-get install couchdb -y
```

CouchDB默认端口为5984,运行以下命令检索安装信息

```
$ curl localhost:5984
{"couchdb":"Welcome","uuid":"8d11c599b6487b117e21b8d7b5f79bed","version":"1.6.0","vendor":{"version":"15.10","name":"Ubuntu"}}
```

####

```
$ wget http://mirrors.tuna.tsinghua.edu.cn/apache/couchdb/source/2.3.1/apache-couchdb-2.3.1.tar.gz
```

#### **访问Futon**

> ```Futon``````CouchDB```提供的一个```WebUI```界面,为了更安全的链接到```CouchDB```,可以从本地访问,创建一个本地到服务的```SSH```链接隧道。
如下所示:建立```本地端口5984```到远程```服务器端口5984```的链接隧道。

```shell
ssh -L5984:127.0.0.1:5984 [email protected]
```

建立链接隧道之后浏览器输入URL:```http://localhost:5984/_utils/```访问,结果如下所示:

![](./img/couchdb_futon.png)

> CouchDB的更多安装姿势可参考[官网](http://docs.couchdb.org/en/latest/install/unix.html#user-registration-and-security)
#### **搭建NPM仓库**

> 在搭建NPM仓库之前确保CouchDB数据库安装成功且运行中。
1. **创建数据库**

> 用于保存模块和文件信息。
```
curl -X PUT http://localhost:5984/registry
{"ok":true}
```

3. **设置用于名密码**

```
$ curl -X PUT http://localhost:5984/_config/admins/admin -d '"123456"'
```

2. **克隆NPM远程仓库地址到本地**

```
$ git clone git://github.com/npm/npm-registry-couchapp
$ cd npm-registry-couchapp
$ npm install
$ npm start \
--npm-registry-couchapp:couch=http://localhost:5984/registry
npm start \
--npm-registry-couchapp:couch=http://admin:123456@localhost:5984/registry
$ npm run load \
--npm-registry-couchapp:couch=http://localhost:5984/registry
$ npm run copy \
--npm-registry-couchapp:couch=http://localhost:5984/registry
```

3. **客户端设置NPM镜像**

```
$ npm config set \
registry=http://localhost:5984/registry/_design/app/_rewrite
```
6 changes: 6 additions & 0 deletions docs/materials/article.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 文章推荐

* [从头实现一个koa框架](https://zhuanlan.zhihu.com/p/35040744),作者:```@马龄阳```
* [前后端分离的思考与实践](https://frontenddev.org/link/full-stack-development-with-nodejs-1.html),作者:```@云淡然```
* [面试官问我,Redis分布式锁如何续期?懵了](https://mp.weixin.qq.com/s/y-8W6H9JriUv557Nhudpow),作者:```@肥朝```
* [百万级别长连接,并发测试指南](https://blog.51cto.com/youerning/2089930?lb),作者:```@youerning```

0 comments on commit c2908fa

Please sign in to comment.