当前位置: 首页 > news >正文

校园二手交易网站建设方案汕头市网站建设分站公司

校园二手交易网站建设方案,汕头市网站建设分站公司,企业宣传片文案范文,手机网站开发ios实验目的 配置一个最简的主从环境,了解基本的主从配置。 环境参数 操作系统CentOS Linux release 7.9.2009 (Core)数据库版本PostgreSQL 10.23主库端口15431备库端口15432 因为只是做实验,所以主备库放在同一台机器上,仅通过端口区分主备…

实验目的

配置一个最简的主从环境,了解基本的主从配置。

环境参数

操作系统CentOS Linux release 7.9.2009 (Core)
数据库版本PostgreSQL 10.23
主库端口15431
备库端口15432
  • 因为只是做实验,所以主备库放在同一台机器上,仅通过端口区分主备
  • 操作的系统用户为pg,没有特殊说明的情况下操作命令都由pg用户执行

搭个环境

初始化主库

[pg@localhost ~]$ pg_ctl -D /data/db1 init
The files belonging to this database system will be owned by user "pg".
This user must also own the server process.The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".Data page checksums are disabled.creating directory /data/db1 ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Asia/Shanghai
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... okWARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.Success. You can now start the database server using:/usr/pgsql-10/bin/pg_ctl -D /data/db1 -l logfile start

配置主库参数

[pg@localhost ~]$ vi /data/db1/postgresql.conf
修改如下参数:
---------------------------------------
port = 15431	#主库端口
unix_socket_directories = '/tmp'  #本地连接socket文件目录pg访问/var/run/postgresql会有权限制问题,反正不打算用本地socket方式连接所以直接改成/tmp
[pg@localhost ~]$ vi /data/db1/pg_hba.conf
确认已开启本地复制的权限,本地连接的所有用户都有备机的复制权限
---------------------------------------
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

初始化备库

备库的基准文件必须来自于主库,直接复制主库文件到备库位置即可。

[pg@localhost ~]$ rsync -avz /data/db1/* /data/db2#修改主备库目录的权限为0700,否则会导致数据库启动异常
[pg@localhost ~]$ chmod 0700 /data/db[1,2]

配置备库参数

备库需求配置一个特定的参数文件recovery.conf,可以从安装目录中复制文件模板过来修改。

[pg@localhost ~]$ cp /usr/pgsql-10/share/recovery.conf.sample /data/db2/recovery.conf[pg@localhost ~]$ vi /data/db2/recovery.conf
开启备库模式
---------------------------------------
standby_mode = on
[pg@localhost ~]$ vi /data/db2/postgresql.conf
修改如下参数:
---------------------------------------
port = 15432
unix_socket_directories = '/tmp'

验证主备功能

#启动主库
[pg@localhost ~]$ pg_ctl -D /data/db1/ -l /data/db1/server.log start
waiting for server to start.... done
server started#启动备库
[pg@localhost ~]$ pg_ctl -D /data/db2/ -l /data/db2/server.log start
waiting for server to start.... done
server started#查看可用账号和库
[pg@localhost ~]$ psql -l -h localhost -p 15431List of databasesName    | Owner | Encoding |   Collate   |    Ctype    | Access privileges
-----------+-------+----------+-------------+-------------+-------------------postgres  | pg    | UTF8     | en_US.UTF-8 | en_US.UTF-8 |template0 | pg    | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/pg            +|       |          |             |             | pg=CTc/pgtemplate1 | pg    | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/pg            +|       |          |             |             | pg=CTc/pg
(3 rows)[pg@localhost ~]$ psql -l -h localhost -p 15432List of databasesName    | Owner | Encoding |   Collate   |    Ctype    | Access privileges
-----------+-------+----------+-------------+-------------+-------------------postgres  | pg    | UTF8     | en_US.UTF-8 | en_US.UTF-8 |template0 | pg    | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/pg            +|       |          |             |             | pg=CTc/pgtemplate1 | pg    | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/pg            +|       |          |             |             | pg=CTc/pg
(3 rows)#连接主库,建表
[pg@localhost ~]$ psql -h localhost -p 15431 -U pg postgres
psql (10.23)
Type "help" for help.postgres=# create table t3(a int);
CREATE TABLE
postgres=# insert into t3(a) values (1),(2),(3);
INSERT 0 3#连接备库查看看同步情况
[pg@localhost ~]$ psql -h localhost -p 15432 -U pg postgres
psql (10.23)
Type "help" for help.postgres=# \dtList of relationsSchema | Name | Type  | Owner
--------+------+-------+-------public | t3   | table | pg
(1 row)postgres=# select * from t3;a
---123
(3 rows)postgres=#
http://www.yayakq.cn/news/740691/

相关文章:

  • 周口 网站建设展馆设计的主题有哪些
  • 东莞技术网站建设济南公司注册网站
  • 网页制作网站图片石家庄网站设计公司排名
  • 将网站的字体设计成百分比的形式要怎样定义外贸seo关键词
  • 桥的设计网站建设技术培训机构
  • 九江网络营销seo技术分类
  • 正规的网站制作服务商wordpress添加下载地址
  • 合肥网站建帮人代做静态网站多少钱
  • 郑州网站建设中国建设建设银行wordpress 接口
  • 电子商务网站设计的原则Wordpress页面图片设计
  • 做一组静态页面网站多少钱网页设计制作页面
  • 挂甲寺网站建设wordpress整站无刷新
  • 苗木企业网站源码惠州seo按天付费
  • 绥德网站建设国外设交网站开发客户的重要性
  • 电商网站开发常用代码家具设计网站推荐
  • 怎么做倒计时网站专业俄语网站设计
  • 合肥正规的seo公司长沙谷歌seo
  • 商务网站建设心得体会普洱建设单位网站
  • 猎头公司网站建设方案微信小程序定制开发需要多少钱
  • 长网址转短网址网站网站开发者常见问题
  • 小型企业建设网站logofree制作网站
  • 云南固恒建设集团有限公司网站网站备案需要多长时间
  • 网站升级每天自动更新网上怎么发布广告
  • 太原免费静态网站制作网站快慢由什么决定
  • 网站3d特效源码商丘网站推广
  • 360网站建设的目标是什么校园门户网站系统建设关键技术
  • 杭州网站建设价格搭建wordpress服务器
  • 网站未备案会怎么样科技政策要聚焦自立自强
  • 网站优化分析百度登录页
  • 嘉兴云建站模板响水做网站的