- 浏览: 3515908 次
- 性别:
- 来自: 大连
博客专栏
-
使用Titanium Mo...
浏览量:37529
-
Cordova 3.x入门...
浏览量:604459
-
常用Java开源Libra...
浏览量:678291
-
搭建 CentOS 6 服...
浏览量:87390
-
Spring Boot 入...
浏览量:399927
-
基于Spring Secu...
浏览量:69098
-
MQTT入门
浏览量:90561
文章分类
最新评论
-
afateg:
阿里云的图是怎么画出来的?用什么工具?
各云服务平台的架构图 -
cbn_1992:
博主,采用jdbctoken也就是数据库形式之后,反复点击获取 ...
Spring Security OAuth2 Provider 之 数据库存储 -
ipodao:
写的很是清楚了,我找到一份中文协议:https://mcxia ...
MQTT入门(6)- 主题Topics -
Cavani_cc:
还行
MQTT入门(6)- 主题Topics -
fexiong:
博主,能否提供完整源码用于学习?邮箱:2199611997@q ...
TensorFlow 之 构建人物识别系统
(一)MySQL
(1)安装
(2)基本设置
(3)主从设置
①设置Master
②设置Slave
③确认主从
主
从
(二)PostgreSQL
(1)下载安装
只安装Client:
(2)确认版本
(3)设置
数据库操作的历史记录文件
通过pgAdmin测试是否连接成功。
(4)启动设置
(5)创建登录用户
(6)创建数据库
(7)主从设置
①设置Master
②设置Slave
③确认主从
主
从
卸载PostgreSQL:
(1)安装
# yum -y install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm # yum info mysql-community-server # yum -y install mysql-community-server # vi /etc/my.cnf character-set-server=utf8 # /etc/init.d/mysqld restart # mysqld --version mysqld Ver 5.6.23 for Linux on x86_64 (MySQL Community Server (GPL))
(2)基本设置
# mysql_secure_installation Enter current password for root (enter for none): ← 回车 Set root password? [Y/n] ← 回车 New password: ← 123456 Re-enter new password: ← 123456 Remove anonymous users? [Y/n] ← 回车(删除匿名用户) Disallow root login remotely? [Y/n] ← 回车(禁止远程root登录) Remove test database and access to it? [Y/n] ← 回车(删除test库) Reload privilege tables now? [Y/n] ← 回车 Thanks for using MySQL! # mysql -u root -p Enter password:123456 mysql> create database mydb; mysql> grant all privileges on mydb.* to testuser@localhost identified by '123456'; mysql> select user, host from mysql.user; mysql> quit
(3)主从设置
①设置Master
# vi /etc/my.cnf [mysqld] server-id=10 log-bin=mysqld-bin binlog-ignore-db=test,performance_schema,information_schema # service mysqld restart # mysql -u root -p mysql> grant replication slave on *.* to 'repl_user'@'slave_host' identified by 'repl_pwd'; mysql> flush privileges; mysql> flush tables with read lock; mysql> quit # mysqldump -u root -p --all-databases --lock-all-tables > /root/dump.sql # gzip dump.sql # mysql -u root -p mysql> unlock tables; mysql> show master status\G ←确认File和Position,后边Slave会用到 mysql> quit
②设置Slave
# vi /etc/my.cnf [mysqld] server-id=11 relay-log=mysqld-relay-bin read_only=1 # service mysqld restart # scp root@slave_host:/root/dump.sql.gz /root # cd /root # gzip -d dump.sql.gz # mysql -uroot -p < /root/dump.sql # mysql -u root -p mysql> reset slave; mysql> change master to master_host='master_host', master_user='repl_user', master_password='repl_pwd', master_log_file='mysqld-bin.xxxxxx', master_log_pos=xxxx; ←这里的值和上边'show master status'的结果相同 mysql> start slave; mysql> show slave status\G mysql> quit
③确认主从
主
# mysql -u root -p mysql> show databases; mysql> create database test_db; mysql> quit
从
# mysql -u root -p mysql> show databases; ←test_db同时被做成 mysql> quit
(二)PostgreSQL
(1)下载安装
# cd /usr/local/src # wget http://sourceforge.net/projects/postgresql.mirror/files/PostgreSQL%209.3.4/postgresql-9.3.4-1-linux-x64.run/download # chmod 755 postgresql-9.3.4-1-linux-x64.run # ./postgresql-9.3.4-1-linux-x64.run Installation Directory [/opt/PostgreSQL/9.2]:/usr/local/pgsql Data Directory [/usr/local/pgsql/data]: Password :postgres Retype password :postgres Port [5432]: Please choose an option [1] : 430 ←选择对应的语言(430代表日语) Do you want to continue? [Y/n]: y Setup has finished installing PostgreSQL on your computer.
只安装Client:
# yum install readline-devel zlib-devel # cd /usr/local/src/ # wget https://ftp.postgresql.org/pub/source/v9.3.4/postgresql-9.3.4.tar.gz # tar xzvf postgresql-9.3.4.tar.gz # cd postgresql-9.3.4 # ./configure --prefix /usr/local/pgsql # make # gmake -C src/bin install # gmake -C src/include install # gmake -C src/interfaces install # gmake -C doc install
(2)确认版本
# id postgres # su - postgres # cd /usr/local/pgsql/bin # ./psql --version
(3)设置
# cd /usr/local/pgsql/data # cp postgresql.conf postgresql.conf.default # vi postgresql.conf max_connections=100 shared_buffers=128MB work_mem=16MB # cp pg_hba.conf pg_hba.conf.default # vi pg_hba.conf host all all 192.168.21.0/24 trust # /etc/init.d/postgresql-9.3 restart
数据库操作的历史记录文件
# touch /usr/local/pgsql/.psql_history # chown postgres:postgres /usr/local/pgsql/.psql_history
通过pgAdmin测试是否连接成功。
(4)启动设置
# chkconfig postgresql-9.3 on # chkconfig --list postgresql-9.3
(5)创建登录用户
# su - postgres # cd /usr/local/pgsql/bin # ./createuser -s -d -r -l -P pguser Enter password for new role: 123456 Enter it again: 123456 Password :postgres ./psql Password :postgres postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------+----------- pguser | Superuser, Create role, Create DB | {} postgres | Superuser, Create role, Create DB, Replication | {} postgres=# \q
(6)创建数据库
# ./createdb -E UTF8 -O pguser -U pguser pgdb Password :postgres # ./psql -l Password :postgres # ./psql -U pguser -d pgdb postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+------------+------------+---- pgdb | pguser | UTF8 | ja_JP.utf8 | ja_JP.utf8 | postgres=# CREATE TABLE test_users(id integer NOT NULL, name character varying(10) NOT NULL, CONSTRAINT test_users_pkc PRIMARY KEY (id)); postgres=# INSERT INTO test_users(id,name) VALUES (1, 'rensanning'); postgres=# SELECT * FROM test_users; id | name ----+------ 1 | rensanning (1 row) postgres=# \q
(7)主从设置
①设置Master
# vi /usr/local/pgsql/data/postgresql.conf wal_level = hot_standby synchronous_commit = on max_wal_senders = 2 synchronous_standby_names = 'slave1' wal_keep_segments = 100 # vi /usr/local/pgsql/data/pg_hba.conf local replication postgres trust host replication postgres 127.0.0.1/32 trust # /etc/init.d/postgresql-9.3 restart
②设置Slave
# /etc/init.d/postgresql-9.3 stop # /usr/local/pgsql/bin/pg_basebackup -U postgres -h master_host -p 5432 -D /usr/local/pg_slave --xlog --progress --verbose # cp /usr/local/pgsql/data/postmaster.opts /usr/local/pg_slave/ # mv /usr/local/pgsql/data/ /usr/local/pgsql/data_bak/ # cp /usr/local/pg_slave/ /usr/local/pgsql/data/ # chown -R postgres:postgres /usr/local/pgsql/data/ # vi /usr/local/pgsql/data/postgresql.conf hot_standby = on # cp /usr/local/pgsql/share/postgresql/recovery.conf.sample /usr/local/pgsql/data/recovery.conf # vi /usr/local/pgsql/data/recovery.conf standby_mode = on primary_conninfo = 'host=master_host port=5432 application_name=slave1' # /etc/init.d/postgresql-9.3 restart
③确认主从
主
# su - postgres # cd /usr/local/pgsql/bin # ./psql -U pguser -d pgdb -c "INSERT INTO test_users VALUES (2,'slave')" OK # ./psql -U pguser -d pgdb -c "select * from test_users" id | name ----+------- 1 | rensanning 2 | slave (2 rows) # ./psql -U pguser -d pgdb -c "SELECT application_name,state,sync_priority,sync_state FROM pg_stat_replication;" application_name | state | sync_priority | sync_state ------------------+-----------+---------------+------------ slave1 | streaming | 1 | sync slave1 | streaming | 1 | potential
从
# su - postgres # cd /usr/local/pgsql/bin # ./psql -U pguser -d pgdb -c "INSERT INTO test_users VALUES (3,'slave')" ERROR: cannot execute INSERT in a read-only transaction # ./psql -U pguser -d pgdb -c "select * from test_users" id | name ----+------- 1 | rensanning 2 | slave (2 rows)
卸载PostgreSQL:
# /etc/init.d/postgresql stop # rm -f /etc/postgres-reg.ini # rm -rf /usr/local/pgsql/ # rm -f /etc/init.d/postgresql # vi /etc/ld.so.conf remove /usr/local/pgsql/lib # rm /etc/ld.so.conf.d/postgresql.conf # userdel -r postgres # groupdel postgres
发表评论
-
logrotate入门
2018-02-07 08:36 1148日志文件对于开发运维是非常有用的,通过日志可以跟踪系统的使用以 ... -
Bash简要入门
2018-01-19 16:03 1044(一)Shell 和 Bash Bash ... -
搭建独立图像处理服务(Thumbor)
2017-08-16 10:26 7196Thumbor是基于Python的开源 ... -
搭建分布式文件存储服务(FastDFS)
2017-03-17 16:04 3189服务器规划如下: 引用-跟踪服务器 192.168. ... -
CentOS 安装 OpenAM
2017-01-23 15:59 3462官网:https://forgerock.org/openam ... -
CentOS 安装 Nexus
2016-12-08 15:21 1516前提:Java 1)下载 # cd /usr/local/s ... -
CentOS 安装 KVM
2016-09-07 15:55 1399KVM:Kernel-based Virtual Machin ... -
CentOS 安装 Android
2016-09-02 09:58 1786前提 # java -version # gradle -v ... -
CentOS 安装 Jenkins
2016-09-01 09:03 1977(1)安装Jenkins # java -version ... -
CentOS 安装 ELK
2016-07-19 10:02 2570ELK(Elasticsearch, Logstash, Ki ... -
CentOS 7 vs CentOS 6的不同
2015-07-20 14:36 6563升级 CentOS 6 到 CentOS 7 1)备份你的系 ... -
搭建 CentOS 6 服务器(15) - Cacti、Nagios
2015-07-20 13:17 2409(一)Cacti *** 需要先安装Apache + MySQ ... -
搭建VirtualBox + Vagrant + CoreOS + Docker环境
2015-05-08 14:26 10985构成图 引用 Container | Container | ... -
搭建 CentOS 6 服务器(13) - Keepalived、HAProxy、LVS
2015-04-15 15:47 3408(一)Keepalived (1)安装 # cd /usr/ ... -
搭建 CentOS 6 服务器(4) - TigerVNC
2015-04-15 09:34 2556安装GNOME桌面环境 # yum groupinstall ... -
搭建 CentOS 6 服务器(12) - squid、Varnish
2015-04-13 14:07 2336(一)squid 安装 # yum -y install e ... -
搭建 CentOS 6 服务器(11) - rsync、Amanda
2015-04-13 14:06 2408(一)rsync Server端 # yum install ... -
搭建 CentOS 6 服务器(10) - Samba
2015-04-13 14:04 2004(1)安装 # yum -y install samba ... -
搭建 CentOS 6 服务器(14) - CVS、SVN、Git
2015-04-08 10:29 2326(一)CVS 安装xinetd # rpm -q xinetd ... -
搭建 CentOS 6 服务器(9) - vsftpd、ProFTPD
2015-03-18 15:09 3177(一)vsftpd 安装 # yum -y install ...
相关推荐
Centos7版本搭建Linux-Apache-PHP-Mysql环境
CentOS6-Mysql-5.7.28-离线安装包(含依赖安装包)CentOS6-Mysql-5.7.28-离线安装包(含依赖安装包)CentOS6-Mysql-5.7.28-离线安装包(含依赖安装包)
Txt文件中包含 CentOS-6.3-i386-bin-DVD1.iso 和 CentOS-6.3-i386-bin-DVD2.iso 的官网下载地址 和百度网盘下载地址
centos-release-7-6.1810.2.el7.centos.x86_64.rpm包 命令主要是针对将 centos7.9版本降级到centos7.6,其他版本也可以参考降底版本到7.6,包含操作命令
Linux环境mysql5.5.59安装包系列6:perl-DBD-MySQL-4.014-1.el6.rfx.x86_64.rpm
CentOS-6.3-i386-bin-DVD1.iso 镜像文件 用于虚拟机系统安装。
因安装环境不能连接外网,配置lnmp环境时整理一些centos7离线部署nginx-mysql-php时需要用到的一些依赖包
CentOS-Nginx-Apache-PHP-MySQL 镜像使用帮助文档 1.镜像环境说明 2.musql以及phpmyadmin的密码 3.软件目录及配置列表 4.软件操作命令汇总 5.关于卸载 6.升级内容介绍 7.升级后的操作说明 8.附录 教程一 :部署网站 ...
Centos-6-Vault-Aliyun.repo
CentOS-7.0-1406-x86_64-DVD.iso 百度网盘下载地址 an
CentOS-7.2-x86_64-DVD-1511 CentOS-7.3-x86_64-DVD-1611 CentOS-7.4-x86_64-DVD-1708 CentOS-7.5-x86_64-DVD-1804 CentOS-7.6-aarch64-Everything-1810 CentOS-7.6-x86_64-DVD-1810 CentOS-7.7-x86_64-DVD-1908 ...
centos-indexhtml-6-1.el6.centos.noarch.rpm是centos工具包。
# CentOS-7-x86_64-DVD-1810.iso CentOS 7.6 DVD 版 4G http://mirrors.163.com/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-DVD-1810.iso # CentOS-7-x86_64-Everything-1810.iso CentOS 7.6 Everything版 10G ...
CentOS 团员已经发布了 CentOS 6 系列的第三个版本,CentOS 6.3 基于上游的红帽 RHEL 6.3。CentOS 是一个企业级的 Linux 发行版本,CentOS 是 RHEL(Red Hat ...CentOS-6.3-i386-bin-DVD1to2.torrent(包含第1、2张ISO)
centos7的postgresql的rpm安装文件,postgresql11-11.8-centos7-x64-rpm包括postgresql11-11.8-1PGDG.rhel7.x86_64.rpm,postgresql11-contrib-11.8-1PGDG.rhel7.x86_64.rpm,postgresql11-libs-11.8-1PGDG.rhel7.x86_...
CentOS-5.6-i386-bin-DVD这个是迅雷的下载地址希望对你有帮助
centos 8.4 镜像种子文件
zabbix5安装文档-centos7.8-mysql5.7-nginx;zabbix5安装文档-centos7.8-mysql5.7-nginx
centos-yumconf-4-4.5.noarch.rpm
centos6 下安装MySQL-python.docx